mirror of git://git.sv.gnu.org/nano.git
Inserting a new node into a linked list by using just two parameters:
the insertion point and the new node. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
9c821dfe2e
commit
fbe4376822
|
@ -3,6 +3,8 @@
|
|||
.mk as Makefiles. Suggested by Emmanuel Bourg in Debian bug #804845.
|
||||
* src/color.c (color_update): Tell the user when a syntax name given
|
||||
on the command line does not exist. This fixes Savannah bug #46503.
|
||||
* src/nano.c (splice_node): Inserting a new node into a linked list
|
||||
requires just two parameters: the insertion point and the new node.
|
||||
|
||||
2015-11-23 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.c (main), src/winio.c (parse_kbinput): Make Ctrl+Left and
|
||||
|
|
|
@ -95,16 +95,15 @@ filestruct *copy_node(const filestruct *src)
|
|||
}
|
||||
|
||||
/* Splice a node into an existing filestruct. */
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct
|
||||
*end)
|
||||
void splice_node(filestruct *begin, filestruct *newnode)
|
||||
{
|
||||
assert(newnode != NULL && begin != NULL);
|
||||
|
||||
newnode->next = end;
|
||||
newnode->next = begin->next;
|
||||
newnode->prev = begin;
|
||||
if (begin->next != NULL)
|
||||
begin->next->prev = newnode;
|
||||
begin->next = newnode;
|
||||
if (end != NULL)
|
||||
end->prev = newnode;
|
||||
}
|
||||
|
||||
/* Unlink a node from the rest of the filestruct and delete it. */
|
||||
|
|
|
@ -432,8 +432,7 @@ void do_right(void);
|
|||
/* All functions in nano.c. */
|
||||
filestruct *make_new_node(filestruct *prevnode);
|
||||
filestruct *copy_node(const filestruct *src);
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct
|
||||
*end);
|
||||
void splice_node(filestruct *begin, filestruct *newnode);
|
||||
void unlink_node(filestruct *fileptr);
|
||||
void delete_node(filestruct *fileptr);
|
||||
filestruct *copy_filestruct(const filestruct *src);
|
||||
|
|
|
@ -1323,7 +1323,7 @@ void update_history(filestruct **h, const char *s)
|
|||
|
||||
/* Add the new entry to the end. */
|
||||
(*hbot)->data = mallocstrcpy((*hbot)->data, s);
|
||||
splice_node(*hbot, make_new_node(*hbot), (*hbot)->next);
|
||||
splice_node(*hbot, make_new_node(*hbot));
|
||||
*hbot = (*hbot)->next;
|
||||
(*hbot)->data = mallocstrcpy(NULL, "");
|
||||
|
||||
|
|
10
src/text.c
10
src/text.c
|
@ -546,7 +546,7 @@ void do_undo(void)
|
|||
data[u->mark_begin_x] = '\0';
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
splice_node(f, t, f->next);
|
||||
splice_node(f, t);
|
||||
if (f == openfile->filebot)
|
||||
openfile->filebot = t;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
|
@ -677,7 +677,7 @@ void do_redo(void)
|
|||
data[u->begin] = '\0';
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
splice_node(f, shoveline, f->next);
|
||||
splice_node(f, shoveline);
|
||||
if (f == openfile->filebot)
|
||||
openfile->filebot = shoveline;
|
||||
renumber(shoveline);
|
||||
|
@ -788,7 +788,7 @@ void do_enter()
|
|||
#endif
|
||||
openfile->current_x = extra;
|
||||
|
||||
splice_node(openfile->current, newnode, openfile->current->next);
|
||||
splice_node(openfile->current, newnode);
|
||||
|
||||
if (openfile->current == openfile->filebot)
|
||||
openfile->filebot = newnode;
|
||||
|
@ -2139,9 +2139,7 @@ void do_justify(bool full_justify)
|
|||
/* Make a new line, and copy the text after where we're
|
||||
* going to break this line to the beginning of the new
|
||||
* line. */
|
||||
splice_node(openfile->current,
|
||||
make_new_node(openfile->current),
|
||||
openfile->current->next);
|
||||
splice_node(openfile->current, make_new_node(openfile->current));
|
||||
|
||||
/* If this paragraph is non-quoted, and autoindent isn't
|
||||
* turned on, set the indentation length to zero so that the
|
||||
|
|
Loading…
Reference in New Issue