mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-25 11:57:05 +03:00
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
This commit is contained in:
parent
85f8f46c40
commit
e5e88fd9f2
12
ChangeLog
12
ChangeLog
@ -80,12 +80,12 @@ CVS code -
|
|||||||
- Add support for reading in UTF-8 sequences to the low-level
|
- Add support for reading in UTF-8 sequences to the low-level
|
||||||
input routines. Changes to get_kbinput() and
|
input routines. Changes to get_kbinput() and
|
||||||
get_translated_kbinput(). (DLR)
|
get_translated_kbinput(). (DLR)
|
||||||
- Reduce search_last_line to a local variable in findnextstr(),
|
- Reduce search_last_line to a static variable in search.c, and
|
||||||
since it's always set to FALSE just before and after
|
allow it to be set to FALSE via a function. New function
|
||||||
findnextstr() is called and isn't used anywhere except in
|
findnextstr_wrap_reset(); changes to do_int_spell_fix(),
|
||||||
findnextstr(). Changes to do_int_spell_fix(), findnextstr(),
|
findnextstr(), do_search(), do_research(), do_replace_loop(),
|
||||||
do_search(), do_research(), do_replace(), and
|
do_replace(), and do_find_bracket(). (DLR, problem with making
|
||||||
do_find_bracket(). (DLR)
|
search_last_line local to findnextstr() found by Rocco)
|
||||||
- When saving or changing file positions, be sure not to ignore
|
- When saving or changing file positions, be sure not to ignore
|
||||||
placewewant. Changes to do_int_spell_fix(), findnextstr(),
|
placewewant. Changes to do_int_spell_fix(), findnextstr(),
|
||||||
do_replace_loop(), and do_replace(). (DLR)
|
do_replace_loop(), and do_replace(). (DLR)
|
||||||
|
@ -1471,6 +1471,7 @@ bool do_int_spell_fix(const char *word)
|
|||||||
placewewant = 0;
|
placewewant = 0;
|
||||||
|
|
||||||
/* Find the first whole-word occurrence of word. */
|
/* Find the first whole-word occurrence of word. */
|
||||||
|
findnextstr_wrap_reset();
|
||||||
while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, NULL)) {
|
while (findnextstr(TRUE, TRUE, FALSE, fileage, 0, word, NULL)) {
|
||||||
if (is_whole_word(current_x, current->data, word)) {
|
if (is_whole_word(current_x, current->data, word)) {
|
||||||
edit_refresh();
|
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
|
bool findnextstr(bool can_display_wrap, bool wholeword, bool
|
||||||
no_sameline, const filestruct *begin, size_t beginx, const char
|
no_sameline, const filestruct *begin, size_t beginx, const char
|
||||||
*needle, size_t *needle_len);
|
*needle, size_t *needle_len);
|
||||||
|
void findnextstr_wrap_reset(void);
|
||||||
void do_search(void);
|
void do_search(void);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void do_research(void);
|
void do_research(void);
|
||||||
|
13
src/search.c
13
src/search.c
@ -31,6 +31,8 @@
|
|||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "nano.h"
|
#include "nano.h"
|
||||||
|
|
||||||
|
static bool search_last_line = FALSE;
|
||||||
|
/* Have we gone past the last line while searching? */
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
static bool regexp_compiled = FALSE;
|
static bool regexp_compiled = FALSE;
|
||||||
/* Have we compiled any regular expressions? */
|
/* 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;
|
size_t current_x_find = 0;
|
||||||
/* The location of the match we found. */
|
/* The location of the match we found. */
|
||||||
int current_y_find = current_y;
|
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
|
/* 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()
|
* 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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void findnextstr_wrap_reset(void)
|
||||||
|
{
|
||||||
|
search_last_line = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Search for a string. */
|
/* Search for a string. */
|
||||||
void do_search(void)
|
void do_search(void)
|
||||||
{
|
{
|
||||||
@ -455,6 +460,7 @@ void do_search(void)
|
|||||||
update_history(&search_history, answer);
|
update_history(&search_history, answer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
findnextstr_wrap_reset();
|
||||||
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
|
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
|
||||||
answer, NULL);
|
answer, NULL);
|
||||||
|
|
||||||
@ -508,6 +514,7 @@ void do_research(void)
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
findnextstr_wrap_reset();
|
||||||
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
|
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
|
||||||
last_search, NULL);
|
last_search, NULL);
|
||||||
|
|
||||||
@ -672,6 +679,7 @@ ssize_t do_replace_loop(const char *needle, filestruct *real_current,
|
|||||||
if (canceled != NULL)
|
if (canceled != NULL)
|
||||||
*canceled = FALSE;
|
*canceled = FALSE;
|
||||||
|
|
||||||
|
findnextstr_wrap_reset();
|
||||||
while (findnextstr(TRUE, wholewords,
|
while (findnextstr(TRUE, wholewords,
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
/* We should find a bol and/or eol regex only once per line. If
|
/* 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. */
|
/* We constructed regexp_pat to be a valid expression. */
|
||||||
assert(regexp_compiled);
|
assert(regexp_compiled);
|
||||||
|
|
||||||
|
findnextstr_wrap_reset();
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (findnextstr(FALSE, FALSE, FALSE, current, current_x,
|
if (findnextstr(FALSE, FALSE, FALSE, current, current_x,
|
||||||
regexp_pat, NULL)) {
|
regexp_pat, NULL)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user