+2015-04-25 Benno Schulenberg <bensberg@justemail.net>
+ * src/search.c (do_replace_loop): Remove the unintended special
+ case for replacing multiple occurrences of a literal ^ or $.
+
2015-04-21 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (findnextfile): Save the settings of the global
case-sens, direction, and regexp flags, and restore them on exit.
ssize_t numreplaced = -1;
size_t match_len;
bool replaceall = FALSE;
-#ifdef HAVE_REGEX_H
- /* The starting-line match and bol/eol regex flags. */
- bool begin_line = FALSE, bol_or_eol = FALSE;
-#endif
#ifndef NANO_TINY
bool old_mark_set = openfile->mark_set;
filestruct *top, *bot;
#ifndef DISABLE_SPELLER
whole_word,
#endif
-#ifdef HAVE_REGEX_H
- /* We should find a bol and/or eol regex only once per line. If
- * the bol_or_eol flag is set, it means that the last search
- * found one on the beginning line, so we should skip over the
- * beginning line when doing this search. */
- bol_or_eol
-#else
- FALSE
-#endif
- , real_current, *real_current_x, needle, &match_len)) {
+ FALSE, real_current, *real_current_x, needle, &match_len)) {
int i = 0;
#ifndef NANO_TINY
}
#endif
-#ifdef HAVE_REGEX_H
- /* If the bol_or_eol flag is set, we've found a match on the
- * beginning line already, and we're still on the beginning line
- * after the search, it means that we've wrapped around, so
- * we're done. */
- if (bol_or_eol && begin_line && openfile->current == real_current)
- break;
- /* Otherwise, set the begin_line flag if we've found a match on
- * the beginning line, reset the bol_or_eol flag, and continue. */
- else {
- if (openfile->current == real_current)
- begin_line = TRUE;
- bol_or_eol = FALSE;
- }
-#endif
-
/* Indicate that we found the search string. */
if (numreplaced == -1)
numreplaced = 0;
}
}
-#ifdef HAVE_REGEX_H
- /* Set the bol_or_eol flag if we're doing a bol and/or eol regex
- * replace ("^", "$", or "^$"). */
- if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp, needle))
- bol_or_eol = TRUE;
-#endif
-
if (i > 0 || replaceall) { /* Yes, replace it!!!! */
char *copy;
size_t length_change;
#endif /* !DISABLE_NANORC */
#ifdef HAVE_REGEX_H
-/* Do the compiled regex in preg and the regex in string match the
- * beginning or end of a line? */
-bool regexp_bol_or_eol(const regex_t *preg, const char *string)
-{
- return (regexec(preg, string, 0, NULL, 0) == 0 &&
- regexec(preg, string, 0, NULL, REG_NOTBOL | REG_NOTEOL) ==
- REG_NOMATCH);
-}
-
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)
fprintf(stderr, "fixbounds(): Ending string = \"%s\"\n", r3);
#endif
return (const char *) r3;
-#endif
+#endif /* !GNU_WORDBOUNDS */
return r;
}
-
-#endif
+#endif /* HAVE_REGEX_H */
#ifndef DISABLE_SPELLER
/* Is the word starting at position pos in buf a whole word? */