From 3f1878d9a97b946276c8a0a86261e02c38460877 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 18 Jul 2015 07:34:27 +0000 Subject: [PATCH] Looking for a new start only after an end, instead of right after the last start. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5307 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/winio.c | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74a28bf1..79df0530 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-07-18 Benno Schulenberg + * 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 * 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 21e4e5f8..fed505c9 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; } } } -- 2.39.5