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.master
parent
97cd62a8fb
commit
790ce3791a
19
src/search.c
19
src/search.c
|
@ -868,23 +868,18 @@ void do_gotolinecolumn_void(void)
|
||||||
bool find_bracket_match(bool reverse, const char *bracket_set)
|
bool find_bracket_match(bool reverse, const char *bracket_set)
|
||||||
{
|
{
|
||||||
linestruct *line = openfile->current;
|
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
|
/* The pointer might end up one character before the start of the line.
|
||||||
* end of the line. This won't be a problem because we'll skip over
|
* This is not a problem: it will be skipped over below in the loop. */
|
||||||
* it below in that case, and pointer will be properly set when
|
|
||||||
* the search continues on the previous or next line. */
|
|
||||||
if (reverse)
|
if (reverse)
|
||||||
pointer = line->data + (openfile->current_x - 1);
|
--pointer;
|
||||||
else
|
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) {
|
while (TRUE) {
|
||||||
if ((pointer > line->data && *(pointer - 1) == '\0') ||
|
if (pointer < line->data)
|
||||||
pointer < line->data)
|
|
||||||
found = NULL;
|
found = NULL;
|
||||||
else if (reverse)
|
else if (reverse)
|
||||||
found = mbrevstrpbrk(line->data, bracket_set, pointer);
|
found = mbrevstrpbrk(line->data, bracket_set, pointer);
|
||||||
|
|
Loading…
Reference in New Issue