]> diplodocus.org Git - nmh/blobdiff - sbr/read_switch_multiword.c
m_backup.c: Move interface to own file.
[nmh] / sbr / read_switch_multiword.c
index 047d147481154ff2fb6d608cfe88cfcc48e77d14..d13ae7a1df1432f83e4186c5f87638ca68d4e515 100644 (file)
@@ -5,8 +5,11 @@
  * complete copyright information.
  */
 
-#include <h/mh.h>
-#include <h/signals.h>
+#include "h/mh.h"
+#include "brkstring.h"
+#include "ambigsw.h"
+#include "print_sw.h"
+#include "h/signals.h"
 #include <setjmp.h>
 
 static char ansbuf[BUFSIZ];
@@ -25,12 +28,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);
@@ -50,7 +52,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;
@@ -58,14 +60,11 @@ 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;