From dbe39901b2ad297732bb474177ce37ce4b9b72e7 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Sun, 10 Apr 2016 17:42:01 +0200 Subject: [PATCH] utils: snip a superfluous check for NULL Nano doesn't start doing anything with the edit window or the keyboard until all files have been read in or a blank buffer has been opened, so the case of openfile->current == NULL will never occur. Also correct the comment -- because with multibyte characters, it is very well possible that the screen column corresponding to current_x is smaller than current_x itself. --- src/utils.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils.c b/src/utils.c index 5279d7c5..0814aa9f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -451,14 +451,12 @@ size_t get_page_start(size_t column) } /* Return the placewewant associated with current_x, i.e. the zero-based - * column position of the cursor. The value will be no smaller than - * current_x. */ + * column position of the cursor. */ size_t xplustabs(void) { - if (openfile->current) - return strnlenpt(openfile->current->data, openfile->current_x); - else - return 0; + assert(openfile->current != NULL); + + return strnlenpt(openfile->current->data, openfile->current_x); } /* Return the index in s of the character displayed at the given column, -- GitLab