]> diplodocus.org Git - nmh/blobdiff - sbr/read_switch_multiword.c
Added tests of MMDF mailbox format to test-eom-align.
[nmh] / sbr / read_switch_multiword.c
index f653a7fe6b01ac5ae7c76ffd97c60079c6061f33..a5aedae35242cb811f389c2e40da3882472721c3 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * read_switch_multiword.c -- get an answer from the user and return a string array
+/* read_switch_multiword.c -- get an answer from the user and return a string array
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -27,15 +25,14 @@ 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 (;;) {
-       printf ("%s", prompt);
+       fputs(prompt, stdout);
        fflush (stdout);
        cp = ansbuf;
        while ((i = getchar ()) != '\n') {
@@ -52,7 +49,7 @@ 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);
                        continue;
@@ -60,21 +57,18 @@ read_switch_multiword (const char *prompt, const struct swit *ansp)
                    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");
-                   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;
        }
        *cp = '\0';
        if (ansbuf[0] == '?' || cp == ansbuf) {
-           printf ("Options are:\n");
+           puts("Options are:");
            print_sw (ALL, ansp, "", stdout);
            continue;
        }
@@ -99,8 +93,5 @@ intrser (int i)
 {
     NMH_UNUSED (i);
 
-    /*
-     * should this be siglongjmp?
-     */
     siglongjmp (sigenv, 1);
 }