mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 12:51:23 +03:00
clean up the search code a bit
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2809 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
e3df8788b7
commit
612b41615b
@ -13,6 +13,13 @@ CVS code -
|
||||
cursor position if there are no keys waiting in the buffer.
|
||||
(DLR)
|
||||
- search.c:
|
||||
search_init()
|
||||
- Don't blank out last_replace anymore when we get a new string,
|
||||
as it'll be blanked out in do_replace(). Also, consolidate
|
||||
the cases for blank and new search strings, as they now differ
|
||||
only in which string they pass to regexp_init(). (DLR)
|
||||
replace_abort()
|
||||
- Remove unnecessary update of placewewant. (DLR)
|
||||
do_replace()
|
||||
- Blank out last_replace properly again just before displaying
|
||||
the "Replace" prompt. (DLR, found by Mike Frysinger)
|
||||
|
22
src/search.c
22
src/search.c
@ -215,17 +215,14 @@ int search_init(bool replacing, bool use_answer)
|
||||
return -1;
|
||||
} else {
|
||||
switch (i) {
|
||||
case -2: /* It's the same string. */
|
||||
case -2: /* It's an empty string. */
|
||||
case 0: /* It's a new string. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Since answer is "", use last_search! */
|
||||
if (ISSET(USE_REGEXP) && regexp_init(last_search) == 0)
|
||||
return -1;
|
||||
#endif
|
||||
break;
|
||||
case 0: /* They entered something new. */
|
||||
last_replace[0] = '\0';
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP) && regexp_init(answer) == 0)
|
||||
/* Use last_search if answer is an empty string, or
|
||||
* answer if it isn't. */
|
||||
if (ISSET(USE_REGEXP) &&
|
||||
regexp_init((i == -2) ? last_search :
|
||||
answer) == 0)
|
||||
return -1;
|
||||
#endif
|
||||
break;
|
||||
@ -570,11 +567,8 @@ void do_research(void)
|
||||
|
||||
void replace_abort(void)
|
||||
{
|
||||
/* Identical to search_abort(), so we'll call it here. If it does
|
||||
* something different later, we can change it back. For now, it's
|
||||
* just a waste to duplicate code. */
|
||||
/* For now, we do the same thing as search_abort(). */
|
||||
search_abort();
|
||||
placewewant = xplustabs();
|
||||
}
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
|
Loading…
Reference in New Issue
Block a user