1
1

fix problem found by Rocco: make search_last_line static to search.c

instead of local to findnextstr() so that search wrapping detection
works properly again


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2037 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2004-10-31 13:20:30 +00:00
родитель 85f8f46c40
Коммит e5e88fd9f2
4 изменённых файлов: 19 добавлений и 8 удалений

Просмотреть файл

@ -80,12 +80,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)
- Reduce search_last_line to a static variable in search.c, and
allow it to be set to FALSE via a function. New function
findnextstr_wrap_reset(); changes to do_int_spell_fix(),
findnextstr(), do_search(), do_research(), do_replace_loop(),
do_replace(), and do_find_bracket(). (DLR, problem with making
search_last_line local to findnextstr() found by Rocco)
- When saving or changing file positions, be sure not to ignore
placewewant. Changes to do_int_spell_fix(), findnextstr(),
do_replace_loop(), and do_replace(). (DLR)

Просмотреть файл

@ -1471,6 +1471,7 @@ bool do_int_spell_fix(const char *word)
placewewant = 0;
/* Find the first whole-word occurrence of word. */
findnextstr_wrap_reset();
while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, NULL)) {
if (is_whole_word(current_x, current->data, word)) {
edit_refresh();

Просмотреть файл

@ -408,6 +408,7 @@ bool is_whole_word(int curr_pos, const char *datastr, const char
bool findnextstr(bool can_display_wrap, bool wholeword, bool
no_sameline, const filestruct *begin, size_t beginx, const char
*needle, size_t *needle_len);
void findnextstr_wrap_reset(void);
void do_search(void);
#ifndef NANO_SMALL
void do_research(void);

Просмотреть файл

@ -31,6 +31,8 @@
#include "proto.h"
#include "nano.h"
static bool search_last_line = FALSE;
/* Have we gone past the last line while searching? */
#ifdef HAVE_REGEX_H
static bool regexp_compiled = FALSE;
/* Have we compiled any regular expressions? */
@ -281,8 +283,6 @@ 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()
@ -415,6 +415,11 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
return TRUE;
}
void findnextstr_wrap_reset(void)
{
search_last_line = FALSE;
}
/* Search for a string. */
void do_search(void)
{
@ -455,6 +460,7 @@ void do_search(void)
update_history(&search_history, answer);
#endif
findnextstr_wrap_reset();
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
answer, NULL);
@ -508,6 +514,7 @@ void do_research(void)
return;
#endif
findnextstr_wrap_reset();
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
last_search, NULL);
@ -672,6 +679,7 @@ ssize_t do_replace_loop(const char *needle, filestruct *real_current,
if (canceled != NULL)
*canceled = FALSE;
findnextstr_wrap_reset();
while (findnextstr(TRUE, wholewords,
#ifdef HAVE_REGEX_H
/* We should find a bol and/or eol regex only once per line. If
@ -1030,6 +1038,7 @@ void do_find_bracket(void)
/* We constructed regexp_pat to be a valid expression. */
assert(regexp_compiled);
findnextstr_wrap_reset();
while (TRUE) {
if (findnextstr(FALSE, FALSE, FALSE, current, current_x,
regexp_pat, NULL)) {