commit 41151ac50d8cf928ca2ff75fea328ef9869b44b7
parent 3e3fab5a0ff9140d9dafcaff9169a931da9f3502
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 15 Jan 2004 05:47:03 +0000
add DB's fix for a do_replace_loop() segfault
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1627 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
@@ -9,6 +9,11 @@ CVS code -
- Move the call to raw() on systems that don't define
_POSIX_VDISABLE outside the main input/output loop, as it
doesn't need to be called every time through the loop. (DLR)
+- search.c:
+ do_replace_loop()
+ - Fix segfault when doing a regex replace of a string that
+ matches inside a line (e.g. replace the "b" in "abc" with
+ anything). (David Benbennick)
- winio.c:
do_credits()
- Use nanosleep() instead of usleep(). The latter is only
diff --git a/src/search.c b/src/search.c
@@ -722,7 +722,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
#ifdef HAVE_REGEX_H
/* Set the bol_eol flag if we're doing a bol and/or eol regex
* replace ("^", "$", or "^$"). */
- if (ISSET(USE_REGEXP) && regexec(&search_regexp, prevanswer, 1, NULL, REG_NOTBOL | REG_NOTEOL) == REG_NOMATCH)
+ if (ISSET(USE_REGEXP) && regexec(&search_regexp, prevanswer, 0, NULL, REG_NOTBOL | REG_NOTEOL) == REG_NOMATCH)
bol_eol = 1;
#endif