nano

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

commit 7e5524bb667674d0a8e6298a32f24c6398099276
parent e8c7cf207113d0a21485a2ba69fe872f3266cb51
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Fri, 20 Jan 2017 10:58:15 +0100

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.)

Diffstat:
Msrc/winio.c | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/winio.c b/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 * by an end on that line? */ while (TRUE) { - index += startmatch.rm_so; - startmatch.rm_eo -= startmatch.rm_so; - if (regexec(varnish->end, start_line->data + index + - startmatch.rm_eo, 0, NULL, - (index + startmatch.rm_eo == 0) ? - 0 : REG_NOTBOL) == REG_NOMATCH) + index += startmatch.rm_eo; + if (regexec(varnish->end, start_line->data + index, + 0, NULL, REG_NOTBOL) == REG_NOMATCH) /* No end found after this start. */ break; - index++; if (regexec(varnish->start, start_line->data + index, 1, &startmatch, REG_NOTBOL) == REG_NOMATCH) /* No later start on this line. */ goto step_two; + if (startmatch.rm_so == startmatch.rm_eo) + index++; } /* Indeed, there is a start without an end on that line. */