nano

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

commit 04013fb7fa0a9cc21565abd3eed11e25692235af
parent a101b30fa81f91868db614ff10ea466da8292336
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sat, 16 Apr 2016 12:44:52 +0200

search: untangle two lines and tweak two comments

Diffstat:
Msrc/search.c | 24++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/search.c b/src/search.c @@ -976,20 +976,24 @@ bool find_bracket_match(bool reverse, const char *bracket_set) * end of the line. This won't be a problem because we'll skip over * it below in that case, and rev_start will be properly set when * the search continues on the previous or next line. */ - rev_start = reverse ? fileptr->data + (openfile->current_x - 1) : - fileptr->data + (openfile->current_x + 1); + if (reverse) + rev_start = fileptr->data + (openfile->current_x - 1); + else + rev_start = fileptr->data + (openfile->current_x + 1); /* Look for either of the two characters in bracket_set. rev_start * can be 1 character before the start or after the end of the line. * In either case, just act as though no match is found. */ while (TRUE) { - found = ((rev_start > fileptr->data && *(rev_start - 1) == - '\0') || rev_start < fileptr->data) ? NULL : (reverse ? - mbrevstrpbrk(fileptr->data, bracket_set, rev_start) : - mbstrpbrk(rev_start, bracket_set)); + if ((rev_start > fileptr->data && *(rev_start - 1) == '\0') || + rev_start < fileptr->data) + found = NULL; + else if (reverse) + found = mbrevstrpbrk(fileptr->data, bracket_set, rev_start); + else + found = mbstrpbrk(rev_start, bracket_set); - if (found != NULL) - /* We've found a potential match. */ + if (found) break; if (reverse) @@ -997,8 +1001,8 @@ bool find_bracket_match(bool reverse, const char *bracket_set) else fileptr = fileptr->next; + /* If we've reached the start or end of the buffer, get out. */ if (fileptr == NULL) - /* We've reached the start or end of the buffer, so get out. */ return FALSE; rev_start = fileptr->data; @@ -1006,7 +1010,7 @@ bool find_bracket_match(bool reverse, const char *bracket_set) rev_start += strlen(fileptr->data); } - /* We've definitely found something. */ + /* Set the current position to the found matching bracket. */ openfile->current = fileptr; openfile->current_x = found - fileptr->data; openfile->current_y = fileptr->lineno - openfile->edittop->lineno;