]> diplodocus.org Git - nmh/blobdiff - sbr/read_switch.c
Replace some "FALLTHRU" comments with control flow.
[nmh] / sbr / read_switch.c
index 4599a41c03d2f091dfff0d2257b04d53d0715d89..8ca0be334dec1036b5233798e28f855c19a275a3 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * read_switch.c -- prompt the user for an answer from the list
+/* read_switch.c -- prompt the user for an answer from the list
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
 int
 read_switch (const char *prompt, const struct swit *ansp)
 {
 int
 read_switch (const char *prompt, const struct swit *ansp)
 {
-    register int i;
-    register char *cp;
-    register const struct swit *ap;
+    int i;
+    char *cp;
+    const struct swit *ap;
     char ansbuf[BUFSIZ];
 
     for (;;) {
     char ansbuf[BUFSIZ];
 
     for (;;) {
-       printf ("%s", prompt);
+       fputs(prompt, stdout);
        fflush (stdout);
        cp = ansbuf;
        while ((i = getchar ()) != '\n') {
            if (i == EOF)
                return 0;
            if (cp < &ansbuf[sizeof ansbuf - 1]) {
        fflush (stdout);
        cp = ansbuf;
        while ((i = getchar ()) != '\n') {
            if (i == EOF)
                return 0;
            if (cp < &ansbuf[sizeof ansbuf - 1]) {
-               i = (isalpha(i) && isupper(i)) ? tolower(i) : i;
+               i = tolower(i);
                *cp++ = i;
            }
        }
        *cp = '\0';
        if (ansbuf[0] == '?' || cp == ansbuf) {
                *cp++ = i;
            }
        }
        *cp = '\0';
        if (ansbuf[0] == '?' || cp == ansbuf) {
-           printf ("Options are:\n");
+           puts("Options are:");
            for (ap = ansp; ap->sw; ap++)
                printf ("  %s\n", ap->sw);
            continue;
            for (ap = ansp; ap->sw; ap++)
                printf ("  %s\n", ap->sw);
            continue;