diff --git a/ChangeLog b/ChangeLog index 3b7f5238..43c037aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ case-sens, direction, and regexp flags, and restore them on exit. And do this not in do_filesearch() but in findnextfile(), so that 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 * src/winio.c (need_horizontal_update, need_vertical_update): Fuse diff --git a/src/text.c b/src/text.c index 9310a317..31f3ed17 100644 --- a/src/text.c +++ b/src/text.c @@ -2327,13 +2327,8 @@ bool do_int_spell_fix(const char *word) /* Save where we are. */ bool canceled = FALSE; /* The return value. */ - bool case_sens_set = ISSET(CASE_SENSITIVE); -#ifndef NANO_TINY - bool backwards_search_set = ISSET(BACKWARDS_SEARCH); -#endif -#ifdef HAVE_REGEX_H - bool regexp_set = ISSET(USE_REGEXP); -#endif + unsigned stash[sizeof(flags) / sizeof(flags[0])]; + /* A storage place for the current flag settings. */ #ifndef NANO_TINY bool old_mark_set = openfile->mark_set; bool added_magicline = FALSE; @@ -2345,6 +2340,9 @@ bool do_int_spell_fix(const char *word) size_t top_x, bot_x; #endif + /* Save the settings of the global flags. */ + memcpy(stash, flags, sizeof(flags)); + /* Make sure spell-check is case sensitive. */ SET(CASE_SENSITIVE); @@ -2466,20 +2464,8 @@ bool do_int_spell_fix(const char *word) openfile->current_x = current_x_save; openfile->placewewant = pww_save; - /* Restore case sensitivity setting. */ - if (!case_sens_set) - 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 + /* Restore the settings of the global flags. */ + memcpy(flags, stash, sizeof(flags)); return !canceled; }