painting: look for an end match only after a start match, if any

This fixes https://savannah.gnu.org/bugs/?52925.

Reviewed-by: Brand Huntsman <alpha@qzx.com>
master
Benno Schulenberg 2018-01-18 21:32:34 +01:00
parent 4ad0490ce4
commit d5f9be7dc8
1 changed files with 3 additions and 1 deletions

View File

@ -289,6 +289,7 @@ void check_the_multis(filestruct *line)
const colortype *ink; const colortype *ink;
bool astart, anend; bool astart, anend;
regmatch_t startmatch, endmatch; regmatch_t startmatch, endmatch;
char *afterstart;
/* If there is no syntax or no multiline regex, there is nothing to do. */ /* If there is no syntax or no multiline regex, there is nothing to do. */
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0) if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
@ -302,7 +303,8 @@ void check_the_multis(filestruct *line)
alloc_multidata_if_needed(line); alloc_multidata_if_needed(line);
astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0); 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. */ /* Check whether the multidata still matches the current situation. */
if (line->multidata[ink->id] == CNONE || if (line->multidata[ink->id] == CNONE ||