- nano.c:do_int_spell_fix(), do_int_speller() - Fix crashes with mark position, current_x position and edit_update args (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
63d0b48d5b
commit
64fc78c0f1
|
@ -20,6 +20,9 @@ CVS Code -
|
||||||
- nano.c:
|
- nano.c:
|
||||||
do_preserve_msg():
|
do_preserve_msg():
|
||||||
- Unsplit error message into a single fprintf call (Jordi).
|
- Unsplit error message into a single fprintf call (Jordi).
|
||||||
|
do_int_spell_fix(), do_int_speller()
|
||||||
|
- Fix crashes with mark position, current_x position,
|
||||||
|
and edit_update args (David Benbennick).
|
||||||
main()
|
main()
|
||||||
- Call load_file with arg 0 for insert, as we aren't really
|
- Call load_file with arg 0 for insert, as we aren't really
|
||||||
doing an insert, allows new_file() to run if we open a
|
doing an insert, allows new_file() to run if we open a
|
||||||
|
|
74
nano.c
74
nano.c
|
@ -1605,32 +1605,29 @@ int do_wrap(filestruct *inptr)
|
||||||
#endif /* !DISABLE_WRAPPING */
|
#endif /* !DISABLE_WRAPPING */
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
|
/* word is misspelled in the file. Let the user replace it. We return
|
||||||
|
False if the user cancels. */
|
||||||
int do_int_spell_fix(const char *word)
|
int do_int_spell_fix(const char *word)
|
||||||
{
|
{
|
||||||
char *save_search;
|
char *save_search;
|
||||||
char *save_replace;
|
char *save_replace;
|
||||||
filestruct *begin;
|
filestruct *current_save = current;
|
||||||
int i = 0, j = 0, beginx, beginx_top, reverse_search_set, case_sens_set;
|
int current_x_save = current_x;
|
||||||
|
filestruct *edittop_save = edittop;
|
||||||
|
/* Save where we are. */
|
||||||
|
int i = 0;
|
||||||
|
/* The return value. */
|
||||||
|
int reverse_search_set = ISSET(REVERSE_SEARCH);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
int mark_set;
|
int case_sens_set = ISSET(CASE_SENSITIVE);
|
||||||
#endif
|
int mark_set = ISSET(MARK_ISSET);
|
||||||
|
|
||||||
/* save where we are */
|
|
||||||
begin = current;
|
|
||||||
beginx = current_x + 1;
|
|
||||||
|
|
||||||
/* Make sure Spell Check goes forward only */
|
|
||||||
reverse_search_set = ISSET(REVERSE_SEARCH);
|
|
||||||
UNSET(REVERSE_SEARCH);
|
|
||||||
|
|
||||||
case_sens_set = ISSET(CASE_SENSITIVE);
|
|
||||||
SET(CASE_SENSITIVE);
|
SET(CASE_SENSITIVE);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
|
||||||
/* Make sure the marking highlight is off during Spell Check */
|
/* Make sure the marking highlight is off during Spell Check */
|
||||||
mark_set = ISSET(MARK_ISSET);
|
|
||||||
UNSET(MARK_ISSET);
|
UNSET(MARK_ISSET);
|
||||||
#endif
|
#endif
|
||||||
|
/* Make sure Spell Check goes forward only */
|
||||||
|
UNSET(REVERSE_SEARCH);
|
||||||
|
|
||||||
/* save the current search/replace strings */
|
/* save the current search/replace strings */
|
||||||
search_init_globals();
|
search_init_globals();
|
||||||
|
@ -1643,41 +1640,34 @@ int do_int_spell_fix(const char *word)
|
||||||
|
|
||||||
/* start from the top of file */
|
/* start from the top of file */
|
||||||
current = fileage;
|
current = fileage;
|
||||||
current_x = beginx_top = -1;
|
current_x = -1;
|
||||||
|
|
||||||
search_last_line = FALSE;
|
search_last_line = FALSE;
|
||||||
|
|
||||||
while (1) {
|
/* We find the first whole-word occurrence of word. */
|
||||||
/* make sure word is still mis-spelt (i.e. when multi-errors) */
|
while (findnextstr(TRUE, TRUE, fileage, -1, word))
|
||||||
if (findnextstr(TRUE, FALSE, fileage, beginx_top, word)) {
|
if (is_whole_word(current_x, current->data, word)) {
|
||||||
|
edit_refresh();
|
||||||
|
|
||||||
/* find whole words only */
|
|
||||||
if (!is_whole_word(current_x, current->data, word))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
edit_update(current, current_x);
|
|
||||||
do_replace_highlight(TRUE, word);
|
do_replace_highlight(TRUE, word);
|
||||||
|
|
||||||
/* allow replace word to be corrected */
|
/* allow replace word to be corrected */
|
||||||
i = statusq(0, spell_list, last_replace,
|
i = statusq(0, spell_list, word,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
0,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
_("Edit a replacement"));
|
_("Edit a replacement"));
|
||||||
|
|
||||||
do_replace_highlight(FALSE, word);
|
do_replace_highlight(FALSE, word);
|
||||||
|
|
||||||
/* start from the start of this line again */
|
if (i != -1 && strcmp(word, answer)) {
|
||||||
current = fileage;
|
int j = 0;
|
||||||
current_x = beginx_top;
|
|
||||||
|
|
||||||
search_last_line = FALSE;
|
search_last_line = FALSE;
|
||||||
|
current_x--;
|
||||||
|
do_replace_loop(word, current_save, ¤t_x_save, TRUE, &j);
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(word, answer)) {
|
|
||||||
j = i;
|
|
||||||
do_replace_loop(word, fileage, &beginx_top, TRUE, &j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1686,26 +1676,24 @@ int do_int_spell_fix(const char *word)
|
||||||
free(last_replace); last_replace=save_replace;
|
free(last_replace); last_replace=save_replace;
|
||||||
|
|
||||||
/* restore where we were */
|
/* restore where we were */
|
||||||
current = begin;
|
current = current_save;
|
||||||
current_x = beginx - 1;
|
current_x = current_x_save;
|
||||||
|
edittop = edittop_save;
|
||||||
|
|
||||||
/* restore Search/Replace direction */
|
/* restore Search/Replace direction */
|
||||||
if (reverse_search_set)
|
if (reverse_search_set)
|
||||||
SET(REVERSE_SEARCH);
|
SET(REVERSE_SEARCH);
|
||||||
|
|
||||||
|
#ifndef NANO_SMALL
|
||||||
if (!case_sens_set)
|
if (!case_sens_set)
|
||||||
UNSET(CASE_SENSITIVE);
|
UNSET(CASE_SENSITIVE);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
|
||||||
/* restore marking highlight */
|
/* restore marking highlight */
|
||||||
if (mark_set)
|
if (mark_set)
|
||||||
SET(MARK_ISSET);
|
SET(MARK_ISSET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (i == -1)
|
return i != -1;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integrated spell checking using 'spell' program. Return value: NULL
|
/* Integrated spell checking using 'spell' program. Return value: NULL
|
||||||
|
@ -1862,7 +1850,7 @@ char *do_int_speller(char *tempfile_name)
|
||||||
|
|
||||||
free(read_buff);
|
free(read_buff);
|
||||||
replace_abort();
|
replace_abort();
|
||||||
edit_update(current, current_x);
|
edit_refresh();
|
||||||
|
|
||||||
/* Process end of spell process */
|
/* Process end of spell process */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue