mirror of git://git.sv.gnu.org/nano.git
Deleting redundant reprises of a bol/eol regular-expression search.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5209 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
ec0e0235fa
commit
e68759bf12
|
@ -3,6 +3,9 @@
|
||||||
two identical functions into one: need_screen_update().
|
two identical functions into one: need_screen_update().
|
||||||
* src/prompt.c (need_statusbar_horizontal_update): Rename function
|
* src/prompt.c (need_statusbar_horizontal_update): Rename function
|
||||||
to need_statusbar_update() as there is no vertical counterpart.
|
to need_statusbar_update() as there is no vertical counterpart.
|
||||||
|
* src/search.c (do_search, do_research): Delete redundant reprises
|
||||||
|
of a regex search: finding an occurrence only at the very starting
|
||||||
|
point of the search necessarily means it is the only occurrence.
|
||||||
|
|
||||||
2015-04-18 Benno Schulenberg <bensberg@justemail.net>
|
2015-04-18 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/global.c, src/nano.c, doc/man/nanorc.5, doc/texinfo/nano.texi:
|
* src/global.c, src/nano.c, doc/man/nanorc.5, doc/texinfo/nano.texi:
|
||||||
|
|
52
src/search.c
52
src/search.c
|
@ -479,33 +479,11 @@ void do_search(void)
|
||||||
#endif
|
#endif
|
||||||
FALSE, openfile->current, openfile->current_x, answer, NULL);
|
FALSE, openfile->current, openfile->current_x, answer, NULL);
|
||||||
|
|
||||||
/* Check to see if there's only one occurrence of the string and
|
/* If we found something, and we're back at the exact same spot where
|
||||||
* we're on it now. */
|
* we started searching, then this is the only occurrence. */
|
||||||
if (fileptr == openfile->current && fileptr_x ==
|
if (fileptr == openfile->current && fileptr_x ==
|
||||||
openfile->current_x && didfind) {
|
openfile->current_x && didfind) {
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* Do the search again, skipping over the current line, if we're
|
|
||||||
* doing a bol and/or eol regex search ("^", "$", or "^$"), so
|
|
||||||
* that we find one only once per line. We should only end up
|
|
||||||
* back at the same position if the string isn't found again, in
|
|
||||||
* which case it's the only occurrence. */
|
|
||||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
|
||||||
answer)) {
|
|
||||||
didfind = findnextstr(
|
|
||||||
#ifndef DISABLE_SPELLER
|
|
||||||
FALSE,
|
|
||||||
#endif
|
|
||||||
TRUE, openfile->current,
|
|
||||||
openfile->current_x, answer, NULL);
|
|
||||||
if (fileptr == openfile->current && fileptr_x ==
|
|
||||||
openfile->current_x && !didfind)
|
|
||||||
statusbar(_("This is the only occurrence"));
|
statusbar(_("This is the only occurrence"));
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
statusbar(_("This is the only occurrence"));
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openfile->placewewant = xplustabs();
|
openfile->placewewant = xplustabs();
|
||||||
|
@ -539,33 +517,11 @@ void do_research(void)
|
||||||
FALSE, openfile->current, openfile->current_x,
|
FALSE, openfile->current, openfile->current_x,
|
||||||
last_search, NULL);
|
last_search, NULL);
|
||||||
|
|
||||||
/* Check to see if there's only one occurrence of the string and
|
/* If we found something, and we're back at the exact same spot
|
||||||
* we're on it now. */
|
* where we started searching, then this is the only occurrence. */
|
||||||
if (fileptr == openfile->current && fileptr_x ==
|
if (fileptr == openfile->current && fileptr_x ==
|
||||||
openfile->current_x && didfind) {
|
openfile->current_x && didfind) {
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* Do the search again, skipping over the current line, if
|
|
||||||
* we're doing a bol and/or eol regex search ("^", "$", or
|
|
||||||
* "^$"), so that we find one only once per line. We should
|
|
||||||
* only end up back at the same position if the string isn't
|
|
||||||
* found again, in which case it's the only occurrence. */
|
|
||||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
|
||||||
last_search)) {
|
|
||||||
didfind = findnextstr(
|
|
||||||
#ifndef DISABLE_SPELLER
|
|
||||||
FALSE,
|
|
||||||
#endif
|
|
||||||
TRUE, openfile->current, openfile->current_x,
|
|
||||||
last_search, NULL);
|
|
||||||
if (fileptr == openfile->current && fileptr_x ==
|
|
||||||
openfile->current_x && !didfind)
|
|
||||||
statusbar(_("This is the only occurrence"));
|
statusbar(_("This is the only occurrence"));
|
||||||
} else {
|
|
||||||
#endif /* HAVE_REGEX_H */
|
|
||||||
statusbar(_("This is the only occurrence"));
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
statusbar(_("No current search pattern"));
|
statusbar(_("No current search pattern"));
|
||||||
|
|
Loading…
Reference in New Issue