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
16d237ba
Commit
16d237ba
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rename two variables, to be more meaningful
parent
c3031b9b
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/search.c
+13
-12
src/search.c
with
13 additions
and
12 deletions
+13
-12
src/search.c
View file @
16d237ba
...
...
@@ -94,31 +94,32 @@ void search_replace_abort(void)
* when <Enter> is pressed or a non-toggle shortcut was executed. */
void
search_init
(
bool
replacing
,
bool
keep_the_answer
)
{
char
*
buf
;
static
char
*
backupstring
=
NULL
;
char
*
thedefault
;
/* What will be searched for when the user typed nothing. */
static
char
*
sofar
=
NULL
;
/* What the user has typed so far, before toggling something. */
if
(
keep_the_answer
)
backupstring
=
mallocstrcpy
(
backupstring
,
answer
);
sofar
=
mallocstrcpy
(
sofar
,
answer
);
/* If something was searched for earlier, include it in the prompt. */
if
(
*
last_search
!=
'\0'
)
{
char
*
disp
=
display_string
(
last_search
,
0
,
COLS
/
3
,
FALSE
);
buf
=
charalloc
(
strlen
(
disp
)
+
7
);
thedefault
=
charalloc
(
strlen
(
disp
)
+
7
);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf
(
buf
,
" [%s%s]"
,
disp
,
sprintf
(
thedefault
,
" [%s%s]"
,
disp
,
(
strlenpt
(
last_search
)
>
COLS
/
3
)
?
"..."
:
""
);
free
(
disp
);
}
else
buf
=
mallocstrcpy
(
NULL
,
""
);
thedefault
=
mallocstrcpy
(
NULL
,
""
);
while
(
TRUE
)
{
functionptrtype
func
;
/* Ask the user what to search for (or replace). */
int
i
=
do_prompt
(
FALSE
,
FALSE
,
inhelp
?
MFINDINHELP
:
(
replacing
?
MREPLACE
:
MWHEREIS
),
backupstring
,
&
search_history
,
sofar
,
&
search_history
,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh
,
"%s%s%s%s%s%s"
,
_
(
"Search"
),
/* TRANSLATORS: The next three modify the search prompt. */
...
...
@@ -129,14 +130,14 @@ void search_init(bool replacing, bool keep_the_answer)
/* TRANSLATORS: The next two modify the search prompt. */
openfile
->
mark
?
_
(
" (to replace) in selection"
)
:
#endif
_
(
" (to replace)"
)
:
""
,
buf
);
_
(
" (to replace)"
)
:
""
,
thedefault
);
/* If the search was cancelled, or we have a blank answer and
* nothing was searched for yet during this session, get out. */
if
(
i
==
-
1
||
(
i
==
-
2
&&
*
last_search
==
'\0'
))
{
statusbar
(
_
(
"Cancelled"
));
search_replace_abort
();
free
(
buf
);
free
(
thedefault
);
return
;
}
...
...
@@ -150,7 +151,7 @@ void search_init(bool replacing, bool keep_the_answer)
#endif
}
free
(
buf
);
free
(
thedefault
);
/* If doing a regular-expression search, compile the
* search string, and get out when it's invalid. */
...
...
@@ -168,7 +169,7 @@ void search_init(bool replacing, bool keep_the_answer)
return
;
}
backupstring
=
mallocstrcpy
(
backupstring
,
answer
);
sofar
=
mallocstrcpy
(
sofar
,
answer
);
func
=
func_from_key
(
&
i
);
...
...
@@ -187,7 +188,7 @@ void search_init(bool replacing, bool keep_the_answer)
do_gotolinecolumn
(
openfile
->
current
->
lineno
,
openfile
->
placewewant
+
1
,
TRUE
,
TRUE
);
search_replace_abort
();
free
(
buf
);
free
(
thedefault
);
return
;
}
}
...
...
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