tweaks: rename a function and a variable, to better match what they do

Also improve some comments.
master
Benno Schulenberg 2017-06-23 09:27:29 +02:00
parent 5ebdd3fe6e
commit 56ce5f2ba8
1 changed files with 11 additions and 8 deletions

View File

@ -59,6 +59,9 @@ static struct termios oldterm;
static struct sigaction act; static struct sigaction act;
/* Used to set up all our fun signal handlers. */ /* Used to set up all our fun signal handlers. */
static bool input_was_aborted = FALSE;
/* Whether reading from standard input was aborted via ^C. */
/* Create a new linestruct node. Note that we do not set prevnode->next /* Create a new linestruct node. Note that we do not set prevnode->next
* to the new line. */ * to the new line. */
filestruct *make_new_node(filestruct *prevnode) filestruct *make_new_node(filestruct *prevnode)
@ -1100,13 +1103,10 @@ void do_cancel(void)
; ;
} }
static bool pager_input_aborted = FALSE; /* Make a note that reading from stdin was concluded with ^C. */
/* Did someone invoke the pager and abort it via ^C? */ RETSIGTYPE make_a_note(int signal)
/* Cancel reading from stdin like a pager. */
RETSIGTYPE cancel_stdin_pager(int signal)
{ {
pager_input_aborted = TRUE; input_was_aborted = TRUE;
} }
/* Read whatever comes from standard input into a new buffer. */ /* Read whatever comes from standard input into a new buffer. */
@ -1136,7 +1136,7 @@ bool scoop_stdin(void)
setup_failed = TRUE; setup_failed = TRUE;
nperror("sigaction"); nperror("sigaction");
} else { } else {
newaction.sa_handler = cancel_stdin_pager; newaction.sa_handler = make_a_note;
if (sigaction(SIGINT, &newaction, &oldaction) == -1) { if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
setup_failed = TRUE; setup_failed = TRUE;
nperror("sigaction"); nperror("sigaction");
@ -1166,8 +1166,11 @@ bool scoop_stdin(void)
dup2(thetty, 0); dup2(thetty, 0);
close(thetty); close(thetty);
if (!pager_input_aborted) /* If things went well, store the current state of the terminal. */
if (!input_was_aborted)
tcgetattr(0, &oldterm); tcgetattr(0, &oldterm);
/* If it was changed, restore the handler for SIGINT. */
if (!setup_failed && sigaction(SIGINT, &oldaction, NULL) == -1) if (!setup_failed && sigaction(SIGINT, &oldaction, NULL) == -1)
nperror("sigaction"); nperror("sigaction");