mirror of git://git.sv.gnu.org/nano.git
yet more search code cleanups
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2003 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
53752e8f9a
commit
27fbc69ec4
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
12
src/search.c
12
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)) {
|
||||
|
|
Loading…
Reference in New Issue