diff --git a/ChangeLog b/ChangeLog index 50dd3bfc..37e2c1fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-07-26 Benno Schulenberg + * 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 * src/global.c (shortcut_init, strtosc), src/files.c (savefile), doc/man/nanorc.5, doc/texinfo/nano.texi: Add a new bindable function, diff --git a/src/search.c b/src/search.c index b2e08079..6500bd5e 100644 --- a/src/search.c +++ b/src/search.c @@ -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