From 764ab96bdad7613436f19d969b8ae90a1a84fce9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 16 Feb 2021 16:11:02 +0100 Subject: [PATCH] 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. --- src/color.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/color.c b/src/color.c index aefc7c37..24e61cda 100644 --- a/src/color.c +++ b/src/color.c @@ -326,15 +326,17 @@ void precalc_multicolorinfo(void) if (regexec(ink->end, line->data + index, 1, &endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) { line->multidata[ink->id] = JUSTONTHIS; + index += endmatch.rm_eo; - /* If both start and end are mere anchors, step ahead. */ - if (startmatch.rm_so == startmatch.rm_eo && - endmatch.rm_so == endmatch.rm_eo) { - /* When at end-of-line, we're done. */ + + /* If the total match has zero length, force an advance. */ + if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) { + /* When at end-of-line, there is no other start. */ if (line->data[index] == '\0') break; index = step_right(line->data, index); } + continue; }