painting: do not let a match for 'end' overlap a match for 'start'
During precalculation and in step_two, we begin looking for an end match only after the full start match, not merely one byte beyond its starting point. So do that too when searching backward for an unpaired start match. Also, index can never be zero here, because if the match was of length zero, this piece of code will have been skipped by the preceding goto. So we can always use REG_NOTBOL here. (That goto is wrong, by the way: https://savannah.gnu.org/bugs/?50078, but that will follow later.)master
parent
e8c7cf2071
commit
7e5524bb66
12
src/winio.c
12
src/winio.c
|
@ -2481,19 +2481,17 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
||||||
* a start match. Is there a start on that line not followed
|
* a start match. Is there a start on that line not followed
|
||||||
* by an end on that line? */
|
* by an end on that line? */
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
index += startmatch.rm_so;
|
index += startmatch.rm_eo;
|
||||||
startmatch.rm_eo -= startmatch.rm_so;
|
if (regexec(varnish->end, start_line->data + index,
|
||||||
if (regexec(varnish->end, start_line->data + index +
|
0, NULL, REG_NOTBOL) == REG_NOMATCH)
|
||||||
startmatch.rm_eo, 0, NULL,
|
|
||||||
(index + startmatch.rm_eo == 0) ?
|
|
||||||
0 : REG_NOTBOL) == REG_NOMATCH)
|
|
||||||
/* No end found after this start. */
|
/* No end found after this start. */
|
||||||
break;
|
break;
|
||||||
index++;
|
|
||||||
if (regexec(varnish->start, start_line->data + index,
|
if (regexec(varnish->start, start_line->data + index,
|
||||||
1, &startmatch, REG_NOTBOL) == REG_NOMATCH)
|
1, &startmatch, REG_NOTBOL) == REG_NOMATCH)
|
||||||
/* No later start on this line. */
|
/* No later start on this line. */
|
||||||
goto step_two;
|
goto step_two;
|
||||||
|
if (startmatch.rm_so == startmatch.rm_eo)
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
/* Indeed, there is a start without an end on that line. */
|
/* Indeed, there is a start without an end on that line. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue