From: David Lawrence Ramsey Date: Mon, 29 Dec 2003 06:11:29 +0000 (+0000) Subject: DB's do_replace_loop fixes via DLR X-Git-Tag: v1.2.3~2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4ba2c2f2e048c03eeb16fe85e070d10a5713946a;p=nano.git DB's do_replace_loop fixes via DLR git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_2_branch/nano@1607 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 62051c62..04f58f0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -34,8 +34,11 @@ CVS code - certain zero-length regex replacements ("^", "$", and "^$"). Add a no_sameline parameter to findnextstr(), and set it in the calls in do_replace_loop() when such regexes are found, so - that such regexes are only found once per line. (DLR; found by - Mike Frysinger and DLR, match_len by David Benbennick) + that such regexes are only found once per line. Also change + length_change from a long to an int; size_t is unsuitable due + to its being unsigned. (DLR; found by Mike Frysinger and DLR, + match_len by David Benbennick) David Benbennick: Add a few + minor cleanups to do_replace_loop(). - winio.c: titlebar() - Fix problem with the available space for a filename on the diff --git a/search.c b/search.c index e73d741e..2abc4dcf 100644 --- a/search.c +++ b/search.c @@ -577,7 +577,6 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin, int beginline = 0, caretdollar = 0; #endif filestruct *fileptr = NULL; - char *copy; switch (*i) { case -1: /* Aborted enter. */ @@ -664,6 +663,9 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin, do_replace_highlight(FALSE, prevanswer); curs_set(1); + + if (*i == -1) /* We canceled the replace. */ + break; } #ifdef HAVE_REGEX_H @@ -674,8 +676,8 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin, #endif if (*i > 0 || replaceall) { /* Yes, replace it!!!! */ - long length_change; - size_t match_len; + char *copy; + int length_change; if (*i == 2) replaceall = 1; @@ -689,13 +691,6 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin, length_change = strlen(copy) - strlen(current->data); -#ifdef HAVE_REGEX_H - if (ISSET(USE_REGEXP)) - match_len = regmatches[0].rm_eo - regmatches[0].rm_so; - else -#endif - match_len = strlen(prevanswer); - #ifndef NANO_SMALL if (current == mark_beginbuf && mark_beginx > current_x) { if (mark_beginx < current_x + match_len) @@ -728,10 +723,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin, edit_refresh(); set_modified(); numreplaced++; - - } else if (*i == -1) /* Break out of the loop, else do - * nothing and continue loop. */ - break; + } } /* If text has been added to the magicline, make a new magicline. */