general: stop the spell checker from crashing after the changes in search

The spell fixer does not provide a beginning line, so the search routine
should then not try to refer to any data of this line.  Also, since the
changes to the search routine there is no need any more to retreat one
step before starting to search for a misspelled word.

This fixes https://savannah.gnu.org/bugs/?50159.
master
Benno Schulenberg 2017-01-26 20:05:21 +01:00
parent ef7a7c5360
commit 94e563232e
2 changed files with 5 additions and 6 deletions

View File

@ -283,7 +283,8 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
/* Ignore the initial match at the starting position: continue
* searching from the next character, or invalidate the match. */
if (skipone || (found == begin->data + begin_x && !came_full_circle)) {
if (skipone || (!whole_word_only && !came_full_circle &&
found == begin->data + begin_x)) {
skipone = FALSE;
if (ISSET(BACKWARDS_SEARCH) && from != line->data) {
from = line->data + move_mbleft(line->data, from - line->data);

View File

@ -2641,11 +2641,10 @@ bool do_int_spell_fix(const char *word)
* (current, current_x) (where searching starts) is at the top. */
if (right_side_up) {
openfile->current = top;
openfile->current_x = (size_t)(top_x - 1);
openfile->current_x = top_x;
openfile->mark_begin = bot;
openfile->mark_begin_x = bot_x;
} else
openfile->current_x = (size_t)(openfile->current_x - 1);
}
openfile->mark_set = FALSE;
} else
#endif
@ -2653,7 +2652,7 @@ bool do_int_spell_fix(const char *word)
{
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
openfile->current_x = (size_t)-1;
openfile->current_x = 0;
}
/* Find the first whole occurrence of word. */
@ -2685,7 +2684,6 @@ bool do_int_spell_fix(const char *word)
/* If a replacement was given, go through all occurrences. */
if (proceed && strcmp(word, answer) != 0) {
openfile->current_x--;
#ifndef NANO_TINY
/* Replacements should happen only in the marked region. */
openfile->mark_set = old_mark_set;