clean up a bit of weirdness in do_replace_loop()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1606 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
32559294e8
commit
afb75f22b2
|
@ -83,8 +83,11 @@ CVS code -
|
||||||
certain zero-length regex replacements ("^", "$", and "^$").
|
certain zero-length regex replacements ("^", "$", and "^$").
|
||||||
Add a no_sameline parameter to findnextstr(), and set it in
|
Add a no_sameline parameter to findnextstr(), and set it in
|
||||||
the calls in do_replace_loop() when such regexes are found, so
|
the calls in do_replace_loop() when such regexes are found, so
|
||||||
that such regexes are only found once per line. (DLR; found by
|
that such regexes are only found once per line. Also change
|
||||||
Mike Frysinger and DLR)
|
length_change from a long to an int; size_t is unsuitable due
|
||||||
|
to its being unsigned. (DLR; found by Mike Frysinger and DLR)
|
||||||
|
David Benbennick: Add a few minor cleanups to
|
||||||
|
do_replace_loop().
|
||||||
- winio.c:
|
- winio.c:
|
||||||
get_kbinput(), get_accepted_kbinput()
|
get_kbinput(), get_accepted_kbinput()
|
||||||
- Don't pass in the value of the REBIND_DELETE flag anymore.
|
- Don't pass in the value of the REBIND_DELETE flag anymore.
|
||||||
|
|
20
src/search.c
20
src/search.c
|
@ -622,7 +622,6 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||||
int beginline = 0, caretdollar = 0;
|
int beginline = 0, caretdollar = 0;
|
||||||
#endif
|
#endif
|
||||||
filestruct *fileptr = NULL;
|
filestruct *fileptr = NULL;
|
||||||
char *copy;
|
|
||||||
|
|
||||||
switch (*i) {
|
switch (*i) {
|
||||||
case -1: /* Aborted enter. */
|
case -1: /* Aborted enter. */
|
||||||
|
@ -716,6 +715,9 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||||
do_replace_highlight(FALSE, exp_word);
|
do_replace_highlight(FALSE, exp_word);
|
||||||
free(exp_word);
|
free(exp_word);
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
|
if (*i == -1) /* We canceled the replace. */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
|
@ -726,8 +728,8 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*i > 0 || replaceall) { /* Yes, replace it!!!! */
|
if (*i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||||
long length_change;
|
char *copy;
|
||||||
size_t match_len;
|
int length_change;
|
||||||
|
|
||||||
if (*i == 2)
|
if (*i == 2)
|
||||||
replaceall = 1;
|
replaceall = 1;
|
||||||
|
@ -741,13 +743,6 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||||
|
|
||||||
length_change = strlen(copy) - strlen(current->data);
|
length_change = strlen(copy) - strlen(current->data);
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
if (ISSET(USE_REGEXP))
|
|
||||||
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
match_len = strlen(prevanswer);
|
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (current == mark_beginbuf && mark_beginx > current_x) {
|
if (current == mark_beginbuf && mark_beginx > current_x) {
|
||||||
if (mark_beginx < current_x + match_len)
|
if (mark_beginx < current_x + match_len)
|
||||||
|
@ -780,10 +775,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
set_modified();
|
set_modified();
|
||||||
numreplaced++;
|
numreplaced++;
|
||||||
|
}
|
||||||
} else if (*i == -1) /* Break out of the loop, else do
|
|
||||||
* nothing and continue loop. */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If text has been added to the magicline, make a new magicline. */
|
/* If text has been added to the magicline, make a new magicline. */
|
||||||
|
|
Loading…
Reference in New Issue