Commit ae8df00b authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

search: rename a variable and a function, for clarity and contrast

No related merge requests found
Showing with 14 additions and 12 deletions
+14 -12
...@@ -587,7 +587,7 @@ int findnextstr( ...@@ -587,7 +587,7 @@ int findnextstr(
#endif #endif
const filestruct *begin, size_t begin_x, const filestruct *begin, size_t begin_x,
const char *needle, size_t *match_len); const char *needle, size_t *match_len);
void findnextstr_wrap_reset(void); void reset_full_circle_flag(void);
void do_search(void); void do_search(void);
#ifndef NANO_TINY #ifndef NANO_TINY
void do_findprevious(void); void do_findprevious(void);
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>
static bool search_last_line = FALSE; static bool came_full_circle = FALSE;
/* Have we gone past the last line while searching? */ /* Have we reached the starting line again while searching? */
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
static bool history_changed = FALSE; static bool history_changed = FALSE;
/* Have any of the history lists changed? */ /* Have any of the history lists changed? */
...@@ -311,7 +311,7 @@ int findnextstr( ...@@ -311,7 +311,7 @@ int findnextstr(
/* When we're spell-checking, don't search in the starting line /* When we're spell-checking, don't search in the starting line
* again -- there is no need: we started at x = 0. */ * again -- there is no need: we started at x = 0. */
if (whole_word_only && search_last_line) { if (whole_word_only && came_full_circle) {
disable_nodelay(); disable_nodelay();
return 0; return 0;
} }
...@@ -343,7 +343,7 @@ int findnextstr( ...@@ -343,7 +343,7 @@ int findnextstr(
} }
/* If we're back at the beginning, then there is no needle. */ /* If we're back at the beginning, then there is no needle. */
if (search_last_line) { if (came_full_circle) {
not_found_msg(needle); not_found_msg(needle);
disable_nodelay(); disable_nodelay();
return 0; return 0;
...@@ -372,7 +372,7 @@ int findnextstr( ...@@ -372,7 +372,7 @@ int findnextstr(
/* If we've reached the original starting line, take note. */ /* If we've reached the original starting line, take note. */
if (fileptr == begin) if (fileptr == begin)
search_last_line = TRUE; came_full_circle = TRUE;
/* Set the starting x to the start or end of the line. */ /* Set the starting x to the start or end of the line. */
rev_start = fileptr->data; rev_start = fileptr->data;
...@@ -385,7 +385,7 @@ int findnextstr( ...@@ -385,7 +385,7 @@ int findnextstr(
found_x = found - fileptr->data; found_x = found - fileptr->data;
/* Ensure that the found occurrence is not beyond the starting x. */ /* Ensure that the found occurrence is not beyond the starting x. */
if (search_last_line && if (came_full_circle &&
#ifndef NANO_TINY #ifndef NANO_TINY
((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) || ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x)) (ISSET(BACKWARDS_SEARCH) && found_x < begin_x))
...@@ -418,9 +418,9 @@ int findnextstr( ...@@ -418,9 +418,9 @@ int findnextstr(
/* Clear the flag indicating that a search reached the last line of the /* Clear the flag indicating that a search reached the last line of the
* file. We need to do this just before a new search. */ * file. We need to do this just before a new search. */
void findnextstr_wrap_reset(void) void reset_full_circle_flag(void)
{ {
search_last_line = FALSE; came_full_circle = FALSE;
} }
/* Ask what to search for and then go looking for it. */ /* Ask what to search for and then go looking for it. */
...@@ -504,7 +504,8 @@ void go_looking(void) ...@@ -504,7 +504,8 @@ void go_looking(void)
size_t was_current_x = openfile->current_x; size_t was_current_x = openfile->current_x;
int didfind; int didfind;
findnextstr_wrap_reset(); reset_full_circle_flag();
didfind = findnextstr( didfind = findnextstr(
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
FALSE, FALSE,
...@@ -651,7 +652,8 @@ ssize_t do_replace_loop( ...@@ -651,7 +652,8 @@ ssize_t do_replace_loop(
} }
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
findnextstr_wrap_reset(); reset_full_circle_flag();
while (TRUE) { while (TRUE) {
int i = 0; int i = 0;
int result = findnextstr( int result = findnextstr(
......
...@@ -2417,7 +2417,7 @@ bool do_int_spell_fix(const char *word) ...@@ -2417,7 +2417,7 @@ bool do_int_spell_fix(const char *word)
openfile->current = openfile->fileage; openfile->current = openfile->fileage;
openfile->current_x = (size_t)-1; openfile->current_x = (size_t)-1;
findnextstr_wrap_reset(); reset_full_circle_flag();
/* Find the first whole occurrence of word. */ /* Find the first whole occurrence of word. */
result = findnextstr(TRUE, openfile->fileage, 0, word, NULL); result = findnextstr(TRUE, openfile->fileage, 0, word, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment