From: David Lawrence Ramsey Date: Tue, 19 Oct 2004 21:09:37 +0000 (+0000) Subject: yet more search code cleanups X-Git-Tag: v1.3.5~117 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=27fbc69ec4d42ddb16e5a4f875fb20adced5a01e;p=nano.git yet more search code cleanups git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2003 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index ad8659d1..273e6b53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -74,6 +74,12 @@ CVS code - - Add support for reading in UTF-8 sequences to the low-level input routines. Changes to get_kbinput() and get_translated_kbinput(). (DLR) + - Reduce search_last_line to a local variable in findnextstr(), + since it's always set to FALSE just before and after + findnextstr() is called and isn't used anywhere except in + findnextstr(). Changes to do_int_spell_fix(), findnextstr(), + do_search(), do_research(), do_replace(), and + do_find_bracket(). (DLR) - files.c: do_insertfile() - Readd the NANO_SMALL #ifdef around the start_again: label to @@ -133,8 +139,6 @@ CVS code - NANO_SMALL is defined and DISABLE_SPELLER isn't. Also, turn the USE_REGEXP flag off during spell checking in order to avoid a potential segfault. (DLR) - - Fully save the position in the file, using edittop, current, - current_x, and placewewant. (DLR) do_alt_speller() - Call terminal_init() unconditionally after running the alternate spell checker, so that the terminal state is diff --git a/src/nano.c b/src/nano.c index babcddee..0567c2f3 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1420,7 +1420,7 @@ bool do_int_spell_fix(const char *word) { char *save_search; char *save_replace; - size_t current_x_save = current_x, pww_save = placewewant; + size_t current_x_save = current_x; filestruct *edittop_save = edittop; filestruct *current_save = current; /* Save where we are. */ @@ -1466,9 +1466,6 @@ bool do_int_spell_fix(const char *word) edittop = fileage; current = fileage; current_x = -1; - placewewant = 0; - - search_last_line = FALSE; /* Find the first whole-word occurrence of word. */ while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, NULL)) { @@ -1487,7 +1484,6 @@ bool do_int_spell_fix(const char *word) do_replace_highlight(FALSE, word); if (accepted && strcmp(word, answer) != 0) { - search_last_line = FALSE; current_x--; do_replace_loop(word, current_save, ¤t_x_save, TRUE); } @@ -1506,7 +1502,6 @@ bool do_int_spell_fix(const char *word) edittop = edittop_save; current = current_save; current_x = current_x_save; - placewewant = pww_save; /* Restore case sensitivity setting. */ if (!case_sens_set) diff --git a/src/proto.h b/src/proto.h index 82d2ebb7..3c28bc95 100644 --- a/src/proto.h +++ b/src/proto.h @@ -40,7 +40,6 @@ extern int mark_beginx; extern long totsize; extern long flags; extern ssize_t tabsize; -extern int search_last_line; extern int currslen; #if !defined(NANO_SMALL) && defined(ENABLE_NANORC) diff --git a/src/search.c b/src/search.c index 860d14dc..627d9069 100644 --- a/src/search.c +++ b/src/search.c @@ -32,7 +32,8 @@ #include "nano.h" #ifdef HAVE_REGEX_H -static int regexp_compiled = FALSE; +static bool regexp_compiled = FALSE; + /* Have we compiled any regular expressions? */ /* Regular expression helper functions. */ @@ -280,6 +281,8 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool size_t current_x_find = 0; /* The location of the match we found. */ int current_y_find = current_y; + bool search_last_line = FALSE; + /* Have we gone past the last line while searching? */ /* rev_start might end up 1 character before the start or after the * end of the line. This won't be a problem because strstrwrapper() @@ -448,7 +451,6 @@ void do_search(void) update_history(&search_history, answer); #endif - search_last_line = FALSE; didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x, answer, NULL); @@ -502,7 +504,6 @@ void do_research(void) return; #endif - search_last_line = FALSE; didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x, last_search, NULL); @@ -904,10 +905,9 @@ void do_replace(void) last_replace = mallocstrcpy(last_replace, answer); /* Save where we are. */ + edittop_save = edittop; begin = current; beginx = current_x; - edittop_save = edittop; - search_last_line = FALSE; numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE); @@ -915,6 +915,7 @@ void do_replace(void) edittop = edittop_save; current = begin; current_x = beginx; + renumber_all(); edit_refresh(); @@ -1053,7 +1054,6 @@ void do_find_bracket(void) /* We constructed regexp_pat to be a valid expression. */ assert(regexp_compiled); - search_last_line = FALSE; while (TRUE) { if (findnextstr(FALSE, FALSE, FALSE, current, current_x, regexp_pat, NULL)) {