Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
ae8df00b
Commit
ae8df00b
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
search: rename a variable and a function, for clarity and contrast
parent
9f1a44d9
master
feature/match-parens
refactor/readbility
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/proto.h
+1
-1
src/proto.h
src/search.c
+12
-10
src/search.c
src/text.c
+1
-1
src/text.c
with
14 additions
and
12 deletions
+14
-12
src/proto.h
View file @
ae8df00b
...
...
@@ -587,7 +587,7 @@ int findnextstr(
#endif
const
filestruct
*
begin
,
size_t
begin_x
,
const
char
*
needle
,
size_t
*
match_len
);
void
findnextstr_wrap_reset
(
void
);
void
reset_full_circle_flag
(
void
);
void
do_search
(
void
);
#ifndef NANO_TINY
void
do_findprevious
(
void
);
...
...
This diff is collapsed.
Click to expand it.
src/search.c
View file @
ae8df00b
...
...
@@ -29,8 +29,8 @@
#include <errno.h>
#include <time.h>
static
bool
search_last_lin
e
=
FALSE
;
/* Have we
gone past the last line
while searching? */
static
bool
came_full_circl
e
=
FALSE
;
/* Have we
reached the starting line again
while searching? */
#ifndef DISABLE_HISTORIES
static
bool
history_changed
=
FALSE
;
/* Have any of the history lists changed? */
...
...
@@ -311,7 +311,7 @@ int findnextstr(
/* When we're spell-checking, don't search in the starting line
* again -- there is no need: we started at x = 0. */
if
(
whole_word_only
&&
search_last_lin
e
)
{
if
(
whole_word_only
&&
came_full_circl
e
)
{
disable_nodelay
();
return
0
;
}
...
...
@@ -343,7 +343,7 @@ int findnextstr(
}
/* If we're back at the beginning, then there is no needle. */
if
(
search_last_lin
e
)
{
if
(
came_full_circl
e
)
{
not_found_msg
(
needle
);
disable_nodelay
();
return
0
;
...
...
@@ -372,7 +372,7 @@ int findnextstr(
/* If we've reached the original starting line, take note. */
if
(
fileptr
==
begin
)
search_last_lin
e
=
TRUE
;
came_full_circl
e
=
TRUE
;
/* Set the starting x to the start or end of the line. */
rev_start
=
fileptr
->
data
;
...
...
@@ -385,7 +385,7 @@ int findnextstr(
found_x
=
found
-
fileptr
->
data
;
/* Ensure that the found occurrence is not beyond the starting x. */
if
(
search_last_lin
e
&&
if
(
came_full_circl
e
&&
#ifndef NANO_TINY
((
!
ISSET
(
BACKWARDS_SEARCH
)
&&
found_x
>
begin_x
)
||
(
ISSET
(
BACKWARDS_SEARCH
)
&&
found_x
<
begin_x
))
...
...
@@ -418,9 +418,9 @@ int findnextstr(
/* Clear the flag indicating that a search reached the last line of the
* file. We need to do this just before a new search. */
void
findnextstr_wrap_reset
(
void
)
void
reset_full_circle_flag
(
void
)
{
search_last_lin
e
=
FALSE
;
came_full_circl
e
=
FALSE
;
}
/* Ask what to search for and then go looking for it. */
...
...
@@ -504,7 +504,8 @@ void go_looking(void)
size_t
was_current_x
=
openfile
->
current_x
;
int
didfind
;
findnextstr_wrap_reset
();
reset_full_circle_flag
();
didfind
=
findnextstr
(
#ifndef DISABLE_SPELLER
FALSE
,
...
...
@@ -651,7 +652,8 @@ ssize_t do_replace_loop(
}
#endif
/* !NANO_TINY */
findnextstr_wrap_reset
();
reset_full_circle_flag
();
while
(
TRUE
)
{
int
i
=
0
;
int
result
=
findnextstr
(
...
...
This diff is collapsed.
Click to expand it.
src/text.c
View file @
ae8df00b
...
...
@@ -2417,7 +2417,7 @@ bool do_int_spell_fix(const char *word)
openfile
->
current
=
openfile
->
fileage
;
openfile
->
current_x
=
(
size_t
)
-
1
;
findnextstr_wrap_reset
();
reset_full_circle_flag
();
/* Find the first whole occurrence of word. */
result
=
findnextstr
(
TRUE
,
openfile
->
fileage
,
0
,
word
,
NULL
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help