Saving and restoring the global flags the short and quick way.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5211 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
6bdcc8faa9
commit
583a30e971
|
@ -3,6 +3,8 @@
|
||||||
case-sens, direction, and regexp flags, and restore them on exit.
|
case-sens, direction, and regexp flags, and restore them on exit.
|
||||||
And do this not in do_filesearch() but in findnextfile(), so that
|
And do this not in do_filesearch() but in findnextfile(), so that
|
||||||
it will also work for do_fileresearch().
|
it will also work for do_fileresearch().
|
||||||
|
* src/text.c (do_int_spell_fix): Save and restore the global flags
|
||||||
|
in the same short and quick way as above.
|
||||||
|
|
||||||
2015-04-20 Benno Schulenberg <bensberg@justemail.net>
|
2015-04-20 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/winio.c (need_horizontal_update, need_vertical_update): Fuse
|
* src/winio.c (need_horizontal_update, need_vertical_update): Fuse
|
||||||
|
|
28
src/text.c
28
src/text.c
|
@ -2327,13 +2327,8 @@ bool do_int_spell_fix(const char *word)
|
||||||
/* Save where we are. */
|
/* Save where we are. */
|
||||||
bool canceled = FALSE;
|
bool canceled = FALSE;
|
||||||
/* The return value. */
|
/* The return value. */
|
||||||
bool case_sens_set = ISSET(CASE_SENSITIVE);
|
unsigned stash[sizeof(flags) / sizeof(flags[0])];
|
||||||
#ifndef NANO_TINY
|
/* A storage place for the current flag settings. */
|
||||||
bool backwards_search_set = ISSET(BACKWARDS_SEARCH);
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
bool regexp_set = ISSET(USE_REGEXP);
|
|
||||||
#endif
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
bool old_mark_set = openfile->mark_set;
|
bool old_mark_set = openfile->mark_set;
|
||||||
bool added_magicline = FALSE;
|
bool added_magicline = FALSE;
|
||||||
|
@ -2345,6 +2340,9 @@ bool do_int_spell_fix(const char *word)
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Save the settings of the global flags. */
|
||||||
|
memcpy(stash, flags, sizeof(flags));
|
||||||
|
|
||||||
/* Make sure spell-check is case sensitive. */
|
/* Make sure spell-check is case sensitive. */
|
||||||
SET(CASE_SENSITIVE);
|
SET(CASE_SENSITIVE);
|
||||||
|
|
||||||
|
@ -2466,20 +2464,8 @@ bool do_int_spell_fix(const char *word)
|
||||||
openfile->current_x = current_x_save;
|
openfile->current_x = current_x_save;
|
||||||
openfile->placewewant = pww_save;
|
openfile->placewewant = pww_save;
|
||||||
|
|
||||||
/* Restore case sensitivity setting. */
|
/* Restore the settings of the global flags. */
|
||||||
if (!case_sens_set)
|
memcpy(flags, stash, sizeof(flags));
|
||||||
UNSET(CASE_SENSITIVE);
|
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
/* Restore search/replace direction. */
|
|
||||||
if (backwards_search_set)
|
|
||||||
SET(BACKWARDS_SEARCH);
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_REGEX_H
|
|
||||||
/* Restore regular expression usage setting. */
|
|
||||||
if (regexp_set)
|
|
||||||
SET(USE_REGEXP);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return !canceled;
|
return !canceled;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue