From 4a59b12ed4e507e3bb225b7f317260d5661f62cd Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 26 Nov 2015 09:31:33 +0000 Subject: [PATCH] Warning about an impossible condition, instead of blithely continuing. And eliding an unneeded variable. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5445 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/text.c | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d847df1..d34219b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2015-11-26 Benno Schulenberg * src/text.c (do_redo): Not just the undoing, also the redoing of a Backspace at EOF is a special case. This fixes Savannah bug #46532. + * src/text.c (do_redo): Warn about an impossible condition, instead + of blithely continuing. And elide an unneeded variable. 2015-11-25 Benno Schulenberg * src/nano.c (do_output): Refreshing the whole edit window (instead diff --git a/src/text.c b/src/text.c index 20c98287..c0bcc35b 100644 --- a/src/text.c +++ b/src/text.c @@ -699,6 +699,10 @@ void do_redo(void) break; #endif case JOIN: + if (f->next == NULL) { + statusbar(_("Internal error: line is missing. Please save your work.")); + break; + } redidmsg = _("line join"); /* When the join was done by a Backspace at the tail of the file, * and the nonewlines flag isn't set, do not join anything, as @@ -709,12 +713,9 @@ void do_redo(void) } f->data = charealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1); strcat(f->data, u->strdata); - if (f->next != NULL) { - filestruct *tmp = f->next; - if (tmp == openfile->filebot) - openfile->filebot = f; - unlink_node(tmp); - } + if (f->next == openfile->filebot) + openfile->filebot = f; + unlink_node(f->next); renumber(f); goto_line_posx(u->mark_begin_lineno, u->mark_begin_x); break; -- 2.39.5