diff --git a/ChangeLog b/ChangeLog index 74a28bf1209638c254f81531a3ebe3034c09dda0..79df05305c3e0937eb5f13b05a5ea2106f8154e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-07-18 Benno Schulenberg <bensberg@justemail.net> + * src/winio.c (edit_draw): When looking for multiline-regex matches, + look for a new start only after an end, instead of right after the + last start. This fixes bug #45525 and bug #41313 on Savannah. + 2015-07-17 Benno Schulenberg <bensberg@justemail.net> * src/files.c (open_buffer): Verify that a named and existing file is a normal file, to avoid opening an empty buffer when the name of diff --git a/src/winio.c b/src/winio.c index 21e4e5f80aca5faafb1b8f89dbb99fe3a1e2134e..fed505c9b393f313c6441a9dac4ea8baff26f356 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2603,7 +2603,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int /* If the found start has been qualified as an end earlier, * believe it and skip to the next step. */ if (start_line != NULL && start_line->multidata != NULL && - start_line->multidata[tmpcolor->id] == CBEGINBEFORE) + (start_line->multidata[tmpcolor->id] == CBEGINBEFORE || + start_line->multidata[tmpcolor->id] == CSTARTENDHERE)) goto step_two; /* Skip over a zero-length regex match. */ @@ -2678,8 +2679,9 @@ void edit_draw(filestruct *fileptr, const char *converted, int if (paintlen < 0) goto end_of_loop; step_two: - /* Second step, we look for starts on this line. */ - start_col = 0; + /* Second step: look for starts on this line, but start + * looking only after an end match, if there is one. */ + start_col = (paintlen == 0) ? 0 : endmatch.rm_eo; while (start_col < endpos) { if (regexec(tmpcolor->start, fileptr->data + @@ -2728,6 +2730,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int #endif } } + start_col = endmatch.rm_eo; } else { /* There is no end on this line. But we * haven't yet looked for one on later @@ -2753,8 +2756,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int fileptr->multidata[tmpcolor->id] = CENDAFTER; break; } + start_col = startmatch.rm_so + 1; } - start_col = startmatch.rm_so + 1; } } }