Commit 5ebdd3fe authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: reduce the scope of three variables, and rename them besides

No related merge requests found
Showing with 13 additions and 13 deletions
+13 -13
...@@ -1100,10 +1100,6 @@ void do_cancel(void) ...@@ -1100,10 +1100,6 @@ void do_cancel(void)
; ;
} }
static struct sigaction pager_oldaction, pager_newaction;
/* Original and temporary handlers for SIGINT. */
static bool pager_sig_failed = FALSE;
/* Did sigaction() fail without changing the signal handlers? */
static bool pager_input_aborted = FALSE; static bool pager_input_aborted = FALSE;
/* Did someone invoke the pager and abort it via ^C? */ /* Did someone invoke the pager and abort it via ^C? */
...@@ -1116,13 +1112,17 @@ RETSIGTYPE cancel_stdin_pager(int signal) ...@@ -1116,13 +1112,17 @@ RETSIGTYPE cancel_stdin_pager(int signal)
/* Read whatever comes from standard input into a new buffer. */ /* Read whatever comes from standard input into a new buffer. */
bool scoop_stdin(void) bool scoop_stdin(void)
{ {
struct sigaction oldaction, newaction;
/* Original and temporary handlers for SIGINT. */
bool setup_failed = FALSE;
/* Whether setting up the SIGINT handler failed. */
FILE *stream; FILE *stream;
int thetty; int thetty;
/* Exit from curses mode and put the terminal into its original state. */
endwin(); endwin();
tcsetattr(0, TCSANOW, &oldterm);
if (!pager_input_aborted)
tcsetattr(0, TCSANOW, &oldterm);
fprintf(stderr, _("Reading from stdin, ^C to abort\n")); fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
#ifndef NANO_TINY #ifndef NANO_TINY
...@@ -1131,14 +1131,14 @@ bool scoop_stdin(void) ...@@ -1131,14 +1131,14 @@ bool scoop_stdin(void)
enable_signals(); enable_signals();
#endif #endif
/* Set things up so that SIGINT will cancel the new process. */ /* Set things up so that SIGINT will cancel the reading. */
if (sigaction(SIGINT, NULL, &pager_newaction) == -1) { if (sigaction(SIGINT, NULL, &newaction) == -1) {
pager_sig_failed = TRUE; setup_failed = TRUE;
nperror("sigaction"); nperror("sigaction");
} else { } else {
pager_newaction.sa_handler = cancel_stdin_pager; newaction.sa_handler = cancel_stdin_pager;
if (sigaction(SIGINT, &pager_newaction, &pager_oldaction) == -1) { if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
pager_sig_failed = TRUE; setup_failed = TRUE;
nperror("sigaction"); nperror("sigaction");
} }
} }
...@@ -1168,7 +1168,7 @@ bool scoop_stdin(void) ...@@ -1168,7 +1168,7 @@ bool scoop_stdin(void)
if (!pager_input_aborted) if (!pager_input_aborted)
tcgetattr(0, &oldterm); tcgetattr(0, &oldterm);
if (!pager_sig_failed && sigaction(SIGINT, &pager_oldaction, NULL) == -1) if (!setup_failed && sigaction(SIGINT, &oldaction, NULL) == -1)
nperror("sigaction"); nperror("sigaction");
terminal_init(); terminal_init();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment