* no_sameline is TRUE, skip over begin when looking for needle. begin
* is the line where we first started searching, at column beginx. If
* can_display_wrap is TRUE, we put messages on the statusbar, wrap
- * around the file boundaries, and set wrapped to TRUE if it isn't NULL.
- * The return value specifies whether we found anything. If we did, set
- * needle_len to the length of the string we found if it isn't NULL. */
+ * around the file boundaries. The return value specifies whether we
+ * found anything. If we did, set needle_len to the length of the
+ * string we found if it isn't NULL. */
bool findnextstr(bool can_display_wrap, bool wholeword, bool
no_sameline, const filestruct *begin, size_t beginx, const char
- *needle, bool *wrapped, size_t *needle_len)
+ *needle, size_t *needle_len)
{
filestruct *fileptr = current;
const char *rev_start = NULL, *found = NULL;
bool search_last_line = FALSE;
/* Have we gone past the last line while searching? */
- /* wrapped holds the value of search_last_line. */
- if (wrapped != NULL)
- *wrapped = FALSE;
-
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because strstrwrapper()
* will return immediately and say that no match was found, and
}
/* Original start line reached. */
- if (fileptr == begin) {
+ if (fileptr == begin)
search_last_line = TRUE;
- if (wrapped != NULL)
- *wrapped = TRUE;
- }
+
rev_start = fileptr->data;
#ifndef NANO_SMALL
if (ISSET(REVERSE_SEARCH))
#endif
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
- answer, NULL, NULL);
+ answer, NULL);
/* Check to see if there's only one occurrence of the string and
* we're on it now. */
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
last_search)) {
didfind = findnextstr(TRUE, FALSE, TRUE, current, current_x,
- answer, NULL, NULL);
+ answer, NULL);
if (fileptr == current && fileptr_x == current_x && !didfind)
statusbar(_("This is the only occurrence"));
} else {
#endif
didfind = findnextstr(TRUE, FALSE, FALSE, current, current_x,
- last_search, NULL, NULL);
+ last_search, NULL);
/* Check to see if there's only one occurrence of the string and
* we're on it now. */
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
last_search)) {
didfind = findnextstr(TRUE, FALSE, TRUE, current,
- current_x, answer, NULL, NULL);
+ current_x, answer, NULL);
if (fileptr == current && fileptr_x == current_x && !didfind)
statusbar(_("This is the only occurrence"));
} else {
bool begin_line = FALSE, bol_or_eol = FALSE;
#endif
#ifndef NANO_SMALL
- bool old_mark_set = ISSET(MARK_ISSET), wrapped;
- const filestruct *top, *bot;
- size_t top_x, bot_x;
- int wraps = 0;
+ bool old_mark_set = ISSET(MARK_ISSET);
if (old_mark_set) {
- /* Save the locations where the mark begins and ends. */
- filestruct *old_current = current;
- size_t old_current_x = current_x;
-
- current = real_current;
- current_x = *real_current_x;
- mark_order(&top, &top_x, &bot, &bot_x);
- current = old_current;
- current_x = old_current_x;
-
UNSET(MARK_ISSET);
edit_refresh();
}
#else
FALSE
#endif
- , current_save, current_x_save, needle,
-#ifndef NANO_SMALL
- /* If we're replacing marked text, we should take note of when
- * the search wraps. If the wrapped flag is set, it means that
- * we've wrapped since the last search. */
- &wrapped
-#else
- NULL
-#endif
- , &match_len)) {
+ , current_save, current_x_save, needle, &match_len)) {
int i = 0;
}
#endif
-#ifndef NANO_SMALL
- /* Keep track of how many times the search has wrapped. If it's
- * wrapped more than once, it means that the only matches left
- * are those outside the marked text, so we're done. */
- if (wrapped)
- wraps++;
- if (wraps > 1)
- break;
-
- /* Otherwise, if we've found a match outside the marked text,
- * skip over it and search for another one. */
- if (old_mark_set) {
- if (current->lineno < top->lineno || current->lineno >
- bot->lineno || (current == top && current_x < top_x) ||
- (current == bot && (current_x > bot_x || current_x +
- match_len > bot_x)))
- continue;
- }
-#endif
-
if (!replaceall) {
edit_redraw(current_save, pww_save);
pww_save = placewewant;
set_modified();
numreplaced++;
}
-
- /* Save the locations where the mark begins and ends again,
- * since they may have changed. */
- if (old_mark_set) {
- filestruct *old_current = current;
- size_t old_current_x = current_x;
-
- current = real_current;
- current_x = *real_current_x;
- mark_order(&top, &top_x, &bot, &bot_x);
- current = old_current;
- current_x = old_current_x;
- }
}
/* If text has been added to the magicline, make a new magicline. */
while (TRUE) {
if (findnextstr(FALSE, FALSE, FALSE, current, current_x,
- regexp_pat, NULL, NULL)) {
+ regexp_pat, NULL)) {
/* Found identical bracket. */
if (current->data[current_x] == ch_under_cursor)
count++;