nano

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

commit 764ab96bdad7613436f19d969b8ae90a1a84fce9
parent f0cc59bead5c947bd937e13d8440bfe2b878c583
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 16 Feb 2021 16:11:02 +0100

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.

Diffstat:
Msrc/color.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git 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; }