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:
David Lawrence Ramsey 2005-07-02 17:56:29 +00:00
parent e3df8788b7
commit 612b41615b
2 changed files with 15 additions and 14 deletions

View File

@ -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)

View File

@ -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