the spell checker will sometimes only correct the misspelled
word instances that appear before the cursor position and then
stop. (Rocco)
+ - Use do_replace_loop()'s canceled parameter in order to ensure
+ that the spell checking stops if we canceled at the replace
+ prompt. (DLR)
do_alt_speller()
- Call terminal_init() unconditionally after running the
alternate spell checker, so that the terminal state is
replacing only marked text when the mark is on. (DLR,
suggested by Joseph Birthisel)
- Return ssize_t instead of int. (DLR)
+ - Add new parameter canceled, set to TRUE if we canceled at the
+ prompt and FALSE otherwise. (DLR)
- utils.c:
regexp_bol_or_eol()
- Don't assume any longer that string will be found if
filestruct *edittop_save = edittop;
filestruct *current_save = current;
/* Save where we are. */
- bool accepted = TRUE;
+ bool canceled = FALSE;
/* The return value. */
bool case_sens_set = ISSET(CASE_SENSITIVE);
#ifndef NANO_SMALL
do_replace_highlight(TRUE, word);
/* Allow all instances of the word to be corrected. */
- accepted = (statusq(FALSE, spell_list, word,
+ canceled = (statusq(FALSE, spell_list, word,
#ifndef NANO_SMALL
NULL,
#endif
- _("Edit a replacement")) != -1);
+ _("Edit a replacement")) == -1);
do_replace_highlight(FALSE, word);
- if (accepted && strcmp(word, answer) != 0) {
+ if (!canceled && strcmp(word, answer) != 0) {
current_x--;
- do_replace_loop(word, current, ¤t_x, TRUE);
+ do_replace_loop(word, current, ¤t_x, TRUE,
+ &canceled);
}
break;
SET(MARK_ISSET);
#endif
- return accepted;
+ return !canceled;
}
/* Integrated spell checking using 'spell' program. Return value: NULL
#endif
char *replace_line(const char *needle);
ssize_t do_replace_loop(const char *needle, filestruct *real_current,
- size_t *real_current_x, bool wholewords);
+ size_t *real_current_x, bool wholewords, bool *canceled);
void do_replace(void);
void do_gotoline(int line, bool save_pos);
void do_gotoline_void(void);
* is replaced by a shorter word.
*
* needle is the string to seek. We replace it with answer. Return -1
- * if needle isn't found, else the number of replacements performed. */
+ * if needle isn't found, else the number of replacements performed. If
+ * canceled isn't NULL, set it to TRUE if we canceled. */
ssize_t do_replace_loop(const char *needle, filestruct *real_current,
- size_t *real_current_x, bool wholewords)
+ size_t *real_current_x, bool wholewords, bool *canceled)
{
ssize_t numreplaced = -1;
size_t match_len;
}
#endif
+ if (canceled != NULL)
+ *canceled = FALSE;
+
while (findnextstr(TRUE, wholewords,
#ifdef HAVE_REGEX_H
/* We should find a bol and/or eol regex only once per line. If
free(exp_word);
curs_set(1);
- if (i == -1) /* We canceled the replace. */
+ if (i == -1) { /* We canceled the replace. */
+ if (canceled != NULL)
+ *canceled = TRUE;
break;
+ }
}
#ifdef HAVE_REGEX_H
beginx = current_x;
pww_save = placewewant;
- numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE);
+ numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE,
+ NULL);
/* Restore where we were. */
edittop = edittop_save;