]> git.wh0rd.org Git - nano.git/commitdiff
Finding each zero-length match only once, when doing regex replacements.
authorBenno Schulenberg <bensberg@justemail.net>
Sun, 26 Jul 2015 08:20:28 +0000 (08:20 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Sun, 26 Jul 2015 08:20:28 +0000 (08:20 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5319 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/search.c

index 50dd3bfc886fa5225eb5904928d6ff6d0fe41bd4..37e2c1fbb3f91d6d05662b8d3bc2951c7f26eda8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-07-26  Benno Schulenberg  <bensberg@justemail.net>
+       * src/search.c (do_replace_loop): When doing regex replacements, find
+        each zero-length match only once.  This fixes Savannah bug #45626.
+
 2015-07-25  Benno Schulenberg  <bensberg@justemail.net>
        * src/global.c (shortcut_init, strtosc), src/files.c (savefile),
        doc/man/nanorc.5, doc/texinfo/nano.texi: Add a new bindable function,
index b2e0807940d8170c391e6b19c01e36ffa9643a32..6500bd5e0bccbe4cf434fdf3cb7ad0c5c97589e6 100644 (file)
@@ -757,6 +757,12 @@ ssize_t do_replace_loop(
 #endif
            }
 
+#ifdef HAVE_REGEX_H
+           /* Don't find the same zero-length match again. */
+           if (match_len == 0)
+               match_len++;
+#endif
+
            /* Set the cursor at the last character of the replacement
             * text, so searching will resume after the replacement
             * text.  Note that current_x might be set to (size_t)-1