nano

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

commit 17f5c056ca73bb0617db807a28d8d0d8d31c2473
parent 914af36546bc5105e41ae263a837d2bfa51d1952
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Thu,  9 Feb 2017 16:00:07 -0600

tweaks: reduce duplicate code in new_magicline() and move_to_filestruct()

These two functions unnecessarily copy make_new_node(); use that instead.

Diffstat:
Msrc/nano.c | 6+-----
Msrc/utils.c | 8+-------
2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -353,14 +353,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot, } /* Since the text has now been saved, remove it from the filestruct. */ - openfile->fileage = (filestruct *)nmalloc(sizeof(filestruct)); + openfile->fileage = make_new_node(NULL); openfile->fileage->data = mallocstrcpy(NULL, ""); openfile->filebot = openfile->fileage; -#ifndef DISABLE_COLOR - openfile->fileage->multidata = NULL; -#endif - /* Restore the current line and cursor position. If the mark begins * inside the partition, set the beginning of the mark to where the * saved text used to start. */ diff --git a/src/utils.c b/src/utils.c @@ -530,14 +530,8 @@ size_t strlenpt(const char *text) /* Append a new magicline to filebot. */ void new_magicline(void) { - openfile->filebot->next = (filestruct *)nmalloc(sizeof(filestruct)); + openfile->filebot->next = make_new_node(openfile->filebot); openfile->filebot->next->data = mallocstrcpy(NULL, ""); - openfile->filebot->next->prev = openfile->filebot; - openfile->filebot->next->next = NULL; - openfile->filebot->next->lineno = openfile->filebot->lineno + 1; -#ifndef DISABLE_COLOR - openfile->filebot->next->multidata = NULL; -#endif openfile->filebot = openfile->filebot->next; openfile->totsize++; }