From 491cad3e5dd41d2654db0d25c71e7fd9957ccfa3 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 8 Oct 2004 23:06:01 +0000 Subject: [PATCH] miscellaneous cleanups in do_replace_loop(): set current to real_current and current_x to current_x_save, only turn the mark off and call edit_refresh() if the mark was originally on, and make length_change a ssize_t git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1977 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/search.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60805692..12de2a77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -149,6 +149,11 @@ CVS code - the search prompt to the "Go To Line" prompt, since the toggling works both ways now and non-numeric text shouldn't be lost when going only one of those ways. (DLR) + do_replace_loop() + - Miscellaneous cleanups: set current to real_current and + current_x to current_x_save, only turn the mark off and call + edit_refresh() if the mark was originally on, and make + length_change a ssize_t. (DLR) findnextstr() - Take the no_sameline parameter after can_display_wrap and wholewords, not after all other parameters. (DLR) diff --git a/src/search.c b/src/search.c index a2ede844..57613f7c 100644 --- a/src/search.c +++ b/src/search.c @@ -604,9 +604,9 @@ char *replace_line(const char *needle) } /* Step through each replace word and prompt user before replacing. - * Parameters real_current and real_current_x are needed by the internal - * speller, to allow the cursor position to be updated when a word - * before the cursor is replaced by a shorter word. + * Parameters real_current and real_current_x are needed in order to + * allow the cursor position to be updated when a word before the cursor + * is replaced by a shorter word. * * needle is the string to seek. We replace it with answer. Return -1 * if needle isn't found, else the number of replacements performed. */ @@ -614,8 +614,8 @@ int do_replace_loop(const char *needle, const filestruct *real_current, size_t *real_current_x, bool wholewords) { int numreplaced = -1; - size_t old_pww = placewewant, current_x_save = current_x; - const filestruct *current_save = current; + size_t old_pww = placewewant, current_x_save = *real_current_x; + const filestruct *current_save = real_current; bool replaceall = FALSE; #ifdef HAVE_REGEX_H /* The starting-line match and bol/eol regex flags. */ @@ -624,8 +624,10 @@ int do_replace_loop(const char *needle, const filestruct *real_current, #ifndef NANO_SMALL bool old_mark_set = ISSET(MARK_ISSET); - UNSET(MARK_ISSET); - edit_refresh(); + if (old_mark_set) { + UNSET(MARK_ISSET); + edit_refresh(); + } #endif while (findnextstr(TRUE, wholewords, @@ -707,7 +709,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current, if (i > 0 || replaceall) { /* Yes, replace it!!!! */ char *copy; - int length_change; + ssize_t length_change; if (i == 2) replaceall = TRUE; -- 2.39.5