From: Benno Schulenberg Date: Mon, 28 Mar 2016 19:14:33 +0000 (+0000) Subject: Removing the 'last_replace' variable that is never used. X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=51743233ed533d8a208179565f17a366df575de6;p=nano.git Removing the 'last_replace' variable that is never used. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5768 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 079c1312..3b6e5964 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ main loop. This prevents a segfault when trying to open a directory. * src/search.c (findnextstr): Provide feedback when searching takes longer than roughly half a second (on average). + * src/*.c: Remove the 'last_replace' variable that is never used. 2016-03-23 Benno Schulenberg * src/search.c (findnextstr): Prevent the internal spell checker from diff --git a/src/global.c b/src/global.c index fb0fc8c6..03a95483 100644 --- a/src/global.c +++ b/src/global.c @@ -57,8 +57,6 @@ ssize_t wrap_at = -CHARS_FROM_EOL; char *last_search = NULL; /* The last string we searched for. */ -char *last_replace = NULL; - /* The last replacement string we searched for. */ unsigned flags[4] = {0, 0, 0, 0}; /* Our flag containing the states of all global options. */ @@ -1650,7 +1648,6 @@ void thanks_for_all_the_fish(void) #endif free(answer); free(last_search); - free(last_replace); #ifndef DISABLE_SPELLER free(alt_speller); #endif diff --git a/src/nano.c b/src/nano.c index 78fbc8c8..f4ae87b7 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2479,9 +2479,8 @@ int main(int argc, char **argv) } #endif /* !NANO_TINY */ - /* Initialize the search and replace strings. */ + /* Initialize the search string. */ last_search = mallocstrcpy(NULL, ""); - last_replace = mallocstrcpy(NULL, ""); /* If tabsize wasn't specified, set its default value. */ if (tabsize == -1) diff --git a/src/proto.h b/src/proto.h index 860d3120..33972908 100644 --- a/src/proto.h +++ b/src/proto.h @@ -46,7 +46,6 @@ extern ssize_t wrap_at; #endif extern char *last_search; -extern char *last_replace; extern unsigned flags[4]; extern WINDOW *topwin; diff --git a/src/search.c b/src/search.c index c0afcc01..7c85da38 100644 --- a/src/search.c +++ b/src/search.c @@ -518,7 +518,7 @@ void go_looking(void) * text in the passed string only when create is TRUE. */ int replace_regexp(char *string, bool create) { - const char *c = last_replace; + const char *c = answer; size_t replacement_size = 0; /* Iterate through the replacement text to handle subexpression @@ -850,8 +850,6 @@ void do_replace(void) return; } - last_replace = mallocstrcpy(last_replace, answer); - /* Save where we are. */ edittop_save = openfile->edittop; begin = openfile->current; diff --git a/src/text.c b/src/text.c index 08c6e81f..07dd6853 100644 --- a/src/text.c +++ b/src/text.c @@ -2352,7 +2352,7 @@ void do_full_justify(void) * return FALSE if the user cancels. */ bool do_int_spell_fix(const char *word) { - char *save_search, *save_replace; + char *save_search; size_t match_len, current_x_save = openfile->current_x; size_t pww_save = openfile->placewewant; filestruct *edittop_save = openfile->edittop; @@ -2388,13 +2388,9 @@ bool do_int_spell_fix(const char *word) UNSET(USE_REGEXP); #endif - /* Save the current search/replace strings. */ + /* Save the current search string, then set it to the misspelled word. */ save_search = last_search; - save_replace = last_replace; - - /* Set the search/replace strings to the misspelled word. */ last_search = mallocstrcpy(NULL, word); - last_replace = mallocstrcpy(NULL, word); focusing = TRUE; @@ -2484,11 +2480,9 @@ bool do_int_spell_fix(const char *word) } #endif /* !NANO_TINY */ - /* Restore the search/replace strings. */ + /* Restore the string that was last searched for. */ free(last_search); last_search = save_search; - free(last_replace); - last_replace = save_replace; /* Restore where we were. */ openfile->edittop = edittop_save;