X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d42f7b865b7f765b14f05f2561ddb2a4f1e8cee9..fc5bc39368b0c7e05bb5c62a84c44e3bdcbbb1c2:/sbr/read_switch_multiword.c?ds=inline diff --git a/sbr/read_switch_multiword.c b/sbr/read_switch_multiword.c index 047d1474..9c123673 100644 --- a/sbr/read_switch_multiword.c +++ b/sbr/read_switch_multiword.c @@ -5,8 +5,13 @@ * complete copyright information. */ -#include -#include +#include "h/mh.h" +#include "read_switch_multiword.h" +#include "smatch.h" +#include "brkstring.h" +#include "ambigsw.h" +#include "print_sw.h" +#include "h/signals.h" #include static char ansbuf[BUFSIZ]; @@ -25,12 +30,11 @@ read_switch_multiword (const char *prompt, const struct swit *ansp) SIGNAL_HANDLER istat = NULL; char *cp, **cpp; - if (!(sigsetjmp(sigenv, 1))) { - istat = SIGNAL (SIGINT, intrser); - } else { + if (sigsetjmp(sigenv, 1)) { SIGNAL (SIGINT, istat); return NULL; } + istat = SIGNAL (SIGINT, intrser); for (;;) { fputs(prompt, stdout); @@ -38,7 +42,7 @@ read_switch_multiword (const char *prompt, const struct swit *ansp) cp = ansbuf; while ((i = getchar ()) != '\n') { if (i == EOF) { - /* + /* * If we get an EOF, return */ if (feof(stdin)) @@ -50,22 +54,19 @@ read_switch_multiword (const char *prompt, const struct swit *ansp) * then just return. */ - else if (ferror(stdin)) { + if (ferror(stdin)) { if (errno == EINTR) { - clearerr(stdin); + clearerr(stdin); continue; } fprintf(stderr, "\nError %s during read\n", - strerror(errno)); - siglongjmp (sigenv, 1); - } else { - /* - * Just for completeness's sake ... - */ - - fprintf(stderr, "\nUnknown problem in getchar()\n"); + strerror(errno)); siglongjmp (sigenv, 1); } + + /* Just for completeness's sake... */ + fprintf(stderr, "\nUnknown problem in getchar()\n"); + siglongjmp(sigenv, 1); } if (cp < &ansbuf[sizeof ansbuf - 1]) *cp++ = i;