]> git.wh0rd.org Git - nano.git/commitdiff
Making sure to keep advancing also when regex matches are zero-length.
authorBenno Schulenberg <bensberg@justemail.net>
Sat, 9 Jan 2016 18:41:56 +0000 (18:41 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Sat, 9 Jan 2016 18:41:56 +0000 (18:41 +0000)
This fixes Savannah bug #26977 -- a hang on start="^" end="$".

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5538 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/color.c
src/winio.c

index 6ca2020836748226831335b1ab18cb4f32d877a4..17d9bbfafeffbb6531be53ad5a50138ef23e35fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-09  Benno Schulenberg  <bensberg@justemail.net>
+       * src/color.c (precalc_multicolorinfo), src/winio.c (edit_draw):
+       Make sure to keep advancing also when matches are zero-length.
+       This fixes Savannah bug #26977 reported by Tigrmesh.
+
 2016-01-07  Benno Schulenberg  <bensberg@justemail.net>
        * src/global.c (assign_keyinfo): Delete two unneeded #ifdefs: if
        they /could/ be false, the H and E keys would stop working.
index dd93bd7e6b1054611662a668ba317e211c87d478..849e26e469365b6b114af9b504d4803abf8612f3 100644 (file)
@@ -527,6 +527,10 @@ void precalc_multicolorinfo(void)
                if (regexec(tmpcolor->end, &fileptr->data[startx], 1,
                        &endmatch, (startx == 0) ? 0 : REG_NOTBOL) == 0) {
                    startx += endmatch.rm_eo;
+                   /* Step ahead when both start and end are mere anchors. */
+                   if (startmatch.rm_so == startmatch.rm_eo &&
+                               endmatch.rm_so == endmatch.rm_eo)
+                       startx += 1;
                    fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
 #ifdef DEBUG
                    fprintf(stderr, "end found on this line\n");
index eae0276d68e2300dd3eadd0bafa922a381f37cd0..06d8889fc37278d37b0eeae2113564308de0dbb8 100644 (file)
@@ -2611,6 +2611,9 @@ void edit_draw(filestruct *fileptr, const char *converted, int
                            }
                        }
                        start_col = endmatch.rm_eo;
+                       /* Skip over a zero-length match. */
+                       if (endmatch.rm_so == endmatch.rm_eo)
+                           start_col += 1;
                    } else {
                        /* There is no end on this line.  But we haven't yet
                         * looked for one on later lines. */