From 1c5af644b5584b09fb86f9b2b41d28189d8998c9 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 10 May 2006 15:15:06 +0000 Subject: [PATCH] avoid unnecessary state saving for when we resize git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3496 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/global.c | 5 ++++- src/nano.c | 15 +++++++++++---- src/proto.h | 3 ++- src/text.c | 6 +++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/global.c b/src/global.c index 969218d8..6e140060 100644 --- a/src/global.c +++ b/src/global.c @@ -25,9 +25,12 @@ /* Global variables. */ #ifndef NANO_TINY -sigjmp_buf jmpbuf; +sigjmp_buf jump_buf; /* Used to return to main() or the unjustify routine in * do_justify() after a SIGWINCH. */ +bool jump_buf_main = FALSE; + /* Have we set jump_buf so that we return to main() after a + * SIGWINCH? */ #endif #ifndef DISABLE_WRAPJUSTIFY diff --git a/src/nano.c b/src/nano.c index 0dcdcba6..bf666173 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1081,8 +1081,9 @@ RETSIGTYPE handle_sigwinch(int signal) currshortcut = main_list; total_refresh(); - /* Jump back to the main loop. */ - siglongjmp(jmpbuf, 1); + /* Jump back to either main() or the unjustify routine in + * do_justify(). */ + siglongjmp(jump_buf, 1); } /* If allow is TRUE, block any SIGWINCH signals that we get, so that we @@ -2134,8 +2135,14 @@ int main(int argc, char **argv) reset_cursor(); #ifndef NANO_TINY - /* Return here after a SIGWINCH. */ - sigsetjmp(jmpbuf, 1); + if (!jump_buf_main) { + /* If we haven't already, we're going to set jump_buf so + * that we return here after a SIGWINCH. Indicate this. */ + jump_buf_main = TRUE; + + /* Return here after a SIGWINCH. */ + sigsetjmp(jump_buf, 1); + } #endif /* If constant cursor position display is on, and there are no diff --git a/src/proto.h b/src/proto.h index 0552a3ab..c8054a5b 100644 --- a/src/proto.h +++ b/src/proto.h @@ -28,7 +28,8 @@ /* Public externs. See global.c for descriptions of them. */ #ifndef NANO_TINY -extern sigjmp_buf jmpbuf; +extern sigjmp_buf jump_buf; +extern bool jump_buf_main; #endif #ifndef DISABLE_WRAPJUSTIFY diff --git a/src/text.c b/src/text.c index 4b6fa325..1c1727ec 100644 --- a/src/text.c +++ b/src/text.c @@ -1656,8 +1656,12 @@ void do_justify(bool full_justify) edit_refresh(); #ifndef NANO_TINY + /* We're going to set jump_buf so that we return here after a + * SIGWINCH instead of to main(). Indicate this. */ + jump_buf_main = FALSE; + /* Return here after a SIGWINCH. */ - sigsetjmp(jmpbuf, 1); + sigsetjmp(jump_buf, 1); #endif statusbar(_("Can now UnJustify!")); -- 2.39.5