From 82bb9c39dadb7550cce6bd8b541a55344f903bbb Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 31 Oct 2012 10:48:56 +0400 Subject: [PATCH] Define winch_flag as volatile sig_atomic_t. Signed-off-by: Andrew Borodin --- lib/global.c | 2 +- lib/global.h | 5 ++++- lib/tty/key.c | 4 ++-- lib/tty/tty-ncurses.c | 2 +- lib/tty/tty-slang.c | 2 +- lib/widget/dialog-switch.c | 4 ++-- lib/widget/dialog.c | 2 +- src/execute.c | 6 +++--- src/subshell.c | 6 +++--- 9 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/global.c b/lib/global.c index e47e38e86..8b18c7c3b 100644 --- a/lib/global.c +++ b/lib/global.c @@ -101,7 +101,7 @@ mc_global_t mc_global = { .ugly_line_drawing = FALSE, .old_mouse = FALSE, .alternate_plus_minus = FALSE, - .winch_flag = FALSE + .winch_flag = 0 }, .vfs = diff --git a/lib/global.h b/lib/global.h index 92a3c1d08..a4767b214 100644 --- a/lib/global.h +++ b/lib/global.h @@ -21,6 +21,9 @@ #include #endif +/* for sig_atomic_t */ +#include + /*** typedefs(not structures) and defined constants **********************************************/ /* The O_BINARY definition was taken from gettext */ @@ -262,7 +265,7 @@ typedef struct gboolean alternate_plus_minus; /* Set if the window has changed it's size */ - gboolean winch_flag; + volatile sig_atomic_t winch_flag; } tty; struct diff --git a/lib/tty/key.c b/lib/tty/key.c index 40a761727..63d181056 100644 --- a/lib/tty/key.c +++ b/lib/tty/key.c @@ -2108,7 +2108,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) } } - if (!block || mc_global.tty.winch_flag) + if (!block || mc_global.tty.winch_flag != 0) { time_addr = &time_out; time_out.tv_sec = 0; @@ -2128,7 +2128,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) { if (redo_event) return EV_MOUSE; - if (!block || mc_global.tty.winch_flag) + if (!block || mc_global.tty.winch_flag != 0) return EV_NONE; vfs_timeout_handler (); } diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c index 0c3887202..737e68ec3 100644 --- a/lib/tty/tty-ncurses.c +++ b/lib/tty/tty-ncurses.c @@ -109,7 +109,7 @@ sigwinch_handler (int dummy) { (void) dummy; - mc_global.tty.winch_flag = TRUE; + mc_global.tty.winch_flag = 1; } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/tty/tty-slang.c b/lib/tty/tty-slang.c index 1fc866400..c4026f961 100644 --- a/lib/tty/tty-slang.c +++ b/lib/tty/tty-slang.c @@ -147,7 +147,7 @@ sigwinch_handler (int dummy) { (void) dummy; - mc_global.tty.winch_flag = TRUE; + mc_global.tty.winch_flag = 1; (void) SLsignal (SIGWINCH, sigwinch_handler); } diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c index 945548087..becc9ebdf 100644 --- a/lib/widget/dialog-switch.c +++ b/lib/widget/dialog-switch.c @@ -351,7 +351,7 @@ mc_refresh (void) if (mc_global.we_are_background) return; #endif /* ENABLE_BACKGROUND */ - if (!mc_global.tty.winch_flag) + if (mc_global.tty.winch_flag == 0) tty_refresh (); else { @@ -366,7 +366,7 @@ mc_refresh (void) void dialog_change_screen_size (void) { - mc_global.tty.winch_flag = FALSE; + mc_global.tty.winch_flag = 0; tty_change_screen_size (); diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 6d51fef95..1b4d8e01b 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -544,7 +544,7 @@ frontend_run_dlg (Dlg_head * h) while (h->state == DLG_ACTIVE) { - if (mc_global.tty.winch_flag) + if (mc_global.tty.winch_flag != 0) dialog_change_screen_size (); if (is_idle ()) diff --git a/src/execute.c b/src/execute.c index e41d76ce6..ba1b0c6dd 100644 --- a/src/execute.c +++ b/src/execute.c @@ -319,7 +319,7 @@ toggle_panels (void) vfs_path_t **new_dir_p; #endif /* ENABLE_SUBSHELL */ - gboolean was_sigwinch = FALSE; + volatile sig_atomic_t was_sigwinch = 0; channels_down (); disable_mouse (); @@ -395,7 +395,7 @@ toggle_panels (void) * There is some problem with screen redraw in ncurses-based mc in this situation. */ was_sigwinch = mc_global.tty.winch_flag; - mc_global.tty.winch_flag = FALSE; + mc_global.tty.winch_flag = 0; #ifdef ENABLE_SUBSHELL if (mc_global.tty.use_subshell) @@ -418,7 +418,7 @@ toggle_panels (void) update_xterm_title_path (); } - if (was_sigwinch || mc_global.tty.winch_flag) + if (was_sigwinch != 0 || mc_global.tty.winch_flag != 0) dialog_change_screen_size (); else repaint_screen (); diff --git a/src/subshell.c b/src/subshell.c index ebab09f91..510cf4d27 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -194,7 +194,7 @@ write_all (int fd, const void *buf, size_t count) { if (errno == EINTR) { - if (mc_global.tty.winch_flag) + if (mc_global.tty.winch_flag != 0) tty_change_screen_size (); continue; @@ -505,7 +505,7 @@ feed_subshell (int how, int fail_on_error) /* Despite using SA_RESTART, we still have to check for this */ if (errno == EINTR) { - if (mc_global.tty.winch_flag) + if (mc_global.tty.winch_flag != 0) tty_change_screen_size (); continue; /* try all over again */ @@ -1007,7 +1007,7 @@ read_subshell_prompt (void) { if (errno == EINTR) { - if (mc_global.tty.winch_flag) + if (mc_global.tty.winch_flag != 0) tty_change_screen_size (); continue; -- 2.11.4.GIT