tweaks: make a skipping condition more precise

A step forward needs to be forced not when both start match and
end match have zero length, but when the "full match" (all text
from the start of the start match to the end of the end match)
covers zero bytes.  In other words: the start and end match are
both of zero length AND are at the same spot.
master
Benno Schulenberg 2021-02-16 16:11:02 +01:00
parent f0cc59bead
commit 764ab96bda
1 changed files with 6 additions and 4 deletions

View File

@ -326,15 +326,17 @@ void precalc_multicolorinfo(void)
if (regexec(ink->end, line->data + index, 1, if (regexec(ink->end, line->data + index, 1,
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) { &endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = JUSTONTHIS; line->multidata[ink->id] = JUSTONTHIS;
index += endmatch.rm_eo; index += endmatch.rm_eo;
/* If both start and end are mere anchors, step ahead. */
if (startmatch.rm_so == startmatch.rm_eo && /* If the total match has zero length, force an advance. */
endmatch.rm_so == endmatch.rm_eo) { if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) {
/* When at end-of-line, we're done. */ /* When at end-of-line, there is no other start. */
if (line->data[index] == '\0') if (line->data[index] == '\0')
break; break;
index = step_right(line->data, index); index = step_right(line->data, index);
} }
continue; continue;
} }