>From 1a7292e7262958edb0f022abce6623c4d842319f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 18 Jan 2018 21:32:34 +0100 Subject: [PATCH] color: look for an end match only after a start match, if any This fixes https://savannah.gnu.org/bugs/?52925. --- src/color.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/color.c b/src/color.c index f0e8328a..8a26cac5 100644 --- a/src/color.c +++ b/src/color.c @@ -289,6 +289,7 @@ void check_the_multis(filestruct *line) const colortype *ink; bool astart, anend; regmatch_t startmatch, endmatch; + char *afterstart; /* If there is no syntax or no multiline regex, there is nothing to do. */ if (openfile->syntax == NULL || openfile->syntax->nmultis == 0) @@ -302,7 +303,8 @@ void check_the_multis(filestruct *line) alloc_multidata_if_needed(line); astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0); - anend = (regexec(ink->end, line->data, 1, &endmatch, 0) == 0); + afterstart = line->data + (astart ? startmatch.rm_eo : 0); + anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0); /* Check whether the multidata still matches the current situation. */ if (line->multidata[ink->id] == CNONE || -- 2.14.3