From 5834638d53f8c0f400266618d5f195ed06b9589f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 8 Dec 2015 18:54:13 +0000 Subject: [PATCH] It shouldn't be necessary to doubly check for being at the end of file. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5492 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/move.c | 6 ++++-- src/search.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d514f9a8..9c9b04ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2015-12-08 Benno Schulenberg * src/nano.c (splice_node, unlink_node): Let these functions update 'filebot', instead of doing it in four different places each. + * src/search.c (goto_line_posx), src/move (do_down): It should not + be necessary to doubly check for being at the end of file. 2015-12-07 Benno Schulenberg * src/winio.c (edit_draw): Quit the loop when there is no end match. diff --git a/src/move.c b/src/move.c index 9735bf53..82d1e301 100644 --- a/src/move.c +++ b/src/move.c @@ -460,10 +460,12 @@ void do_down( #endif /* If we're at the bottom of the file, get out. */ - if (openfile->current == openfile->filebot || !openfile->current->next) + if (openfile->current == openfile->filebot) return; - assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno); + assert(ISSET(SOFTWRAP) || openfile->current_y == + openfile->current->lineno - openfile->edittop->lineno); + assert(openfile->current->next != NULL); /* Move the current line of the edit window down. */ openfile->current = openfile->current->next; diff --git a/src/search.c b/src/search.c index dea199da..f4769cde 100644 --- a/src/search.c +++ b/src/search.c @@ -936,8 +936,8 @@ void do_replace(void) /* Go to the specified line and x position. */ void goto_line_posx(ssize_t line, size_t pos_x) { - for (openfile->current = openfile->fileage; openfile->current != openfile->filebot && - openfile->current->next != NULL && line > 1; line--) + for (openfile->current = openfile->fileage; line > 1 && + openfile->current != openfile->filebot; line--) openfile->current = openfile->current->next; openfile->current_x = pos_x; -- 2.39.5