nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 6bdcc8faa9f04e94a0b0003270b8acb52e82d00e
parent e68759bf1261c3490498b997fd05903a78ab7e5e
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Tue, 21 Apr 2015 17:27:33 +0000

Saving the settings of the global case-sens, direction, and regexp flags,
and restoring them on exit.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5210 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 6++++++
Msrc/browser.c | 17+++++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2015-04-21 Benno Schulenberg <bensberg@justemail.net> + * src/browser.c (findnextfile): Save the settings of the global + 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(). + 2015-04-20 Benno Schulenberg <bensberg@justemail.net> * src/winio.c (need_horizontal_update, need_vertical_update): Fuse two identical functions into one: need_screen_update(). diff --git a/src/browser.c b/src/browser.c @@ -755,6 +755,16 @@ void findnextfile(const char *needle) const char *filetail = tail(filelist[looking_at]); /* The filename we display, minus the path. */ const char *rev_start = filetail, *found = NULL; + unsigned stash[sizeof(flags) / sizeof(flags[0])]; + /* A storage place for the current flag settings. */ + + /* Save the settings of all flags. */ + memcpy(stash, flags, sizeof(flags)); + + /* Search forward, case insensitive and without regexes. */ + UNSET(BACKWARDS_SEARCH); + UNSET(CASE_SENSITIVE); + UNSET(USE_REGEXP); /* Step through each filename in the list until a match is found or * we've come back to the point where we started. */ @@ -797,6 +807,9 @@ void findnextfile(const char *needle) rev_start = filetail; } + /* Restore the settings of all flags. */ + memcpy(flags, stash, sizeof(flags)); + /* Select the one we've found. */ selected = looking_at; } @@ -804,10 +817,6 @@ void findnextfile(const char *needle) /* Search for a filename. */ void do_filesearch(void) { - UNSET(CASE_SENSITIVE); - UNSET(USE_REGEXP); - UNSET(BACKWARDS_SEARCH); - if (filesearch_init() != 0) { /* Cancelled, or a blank search string, or done something. */ bottombars(MBROWSER);