nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 7984ea4eb61ebeb0dfed6672c9003d7e458e09d6
parent f38bd5030d68e7890cac9b5496bb40e63f9ebd3c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 29 Jan 2020 10:47:09 +0100

tweaks: remove two superfluous assignments, and rename a variable

The 'prev' and 'next' links get assigned to immediately after the
call of copy_node().  And anyway, it does not make sense to link
a copied node to the predecessor and successor of its original.

Also slightly regroup some lines.

Diffstat:
Msrc/nano.c | 20+++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -101,10 +101,7 @@ linestruct *copy_node(const linestruct *src) linestruct *dst = nmalloc(sizeof(linestruct)); dst->data = copy_of(src->data); - dst->next = src->next; - dst->prev = src->prev; dst->lineno = src->lineno; - #ifdef ENABLE_COLOR dst->multidata = NULL; #endif @@ -159,22 +156,23 @@ void delete_node(linestruct *line) /* Duplicate an entire linked list of linestructs. */ linestruct *copy_buffer(const linestruct *src) { - linestruct *head, *copy; + linestruct *head, *item; + + head = copy_node(src); + head->prev = NULL; - copy = copy_node(src); - copy->prev = NULL; - head = copy; + item = head; src = src->next; while (src != NULL) { - copy->next = copy_node(src); - copy->next->prev = copy; - copy = copy->next; + item->next = copy_node(src); + item->next->prev = item; + item = item->next; src = src->next; } - copy->next = NULL; + item->next = NULL; return head; }