From 790ce3791a71574945e066a2356a089d841e4269 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 6 Apr 2019 20:34:56 +0200 Subject: [PATCH] tweaks: reshuffle some lines, condense a comment and drop another Also, find_bracket_match() is only called when there is a bracket under the cursor, so stepping forward will never go beyond the end-of-line, so the central loop does not need to check for that. --- src/search.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/search.c b/src/search.c index 417f5dd5..2cda8344 100644 --- a/src/search.c +++ b/src/search.c @@ -868,23 +868,18 @@ void do_gotolinecolumn_void(void) bool find_bracket_match(bool reverse, const char *bracket_set) { linestruct *line = openfile->current; - const char *pointer = NULL, *found = NULL; + const char *pointer = line->data + openfile->current_x; + const char *found = NULL; - /* pointer might end up 1 character before the start or after the - * end of the line. This won't be a problem because we'll skip over - * it below in that case, and pointer will be properly set when - * the search continues on the previous or next line. */ + /* The pointer might end up one character before the start of the line. + * This is not a problem: it will be skipped over below in the loop. */ if (reverse) - pointer = line->data + (openfile->current_x - 1); + --pointer; else - pointer = line->data + (openfile->current_x + 1); + ++pointer; - /* Look for either of the two characters in bracket_set. pointer - * 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) { - if ((pointer > line->data && *(pointer - 1) == '\0') || - pointer < line->data) + if (pointer < line->data) found = NULL; else if (reverse) found = mbrevstrpbrk(line->data, bracket_set, pointer);