nano

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

commit fe9cf6f399bdd8366c1c456a018ea1aa6125d5b4
parent 21edf7bb90c7254caf9d71740b3f05fc95e12cf0
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sun,  8 May 2016 10:41:53 +0200

tweaks: make advancing and retreating more symmetrical

Diffstat:
Msrc/utils.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/utils.c b/src/utils.c @@ -611,20 +611,21 @@ size_t get_totsize(const filestruct *begin, const filestruct *end) return totsize; } -/* Get back a pointer given a line number in the current openfilestruct. */ +/* Given a line number, return a pointer to the corresponding struct. */ filestruct *fsfromline(ssize_t lineno) { filestruct *f = openfile->current; if (lineno <= openfile->current->lineno) - for (; f->lineno != lineno && f != openfile->fileage; f = f->prev) - ; + while (f->lineno != lineno && f->prev != NULL) + f = f->prev; else - for (; f->lineno != lineno && f->next != NULL; f = f->next) - ; + while (f->lineno != lineno && f->next != NULL) + f = f->next; if (f->lineno != lineno) - f = NULL; + return NULL; + return f; }