X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/23f2b007ecac94848616420b27f0819ea559507e..366cc6fc4c7bf1eed47cc9b52d0ef809b2e90174:/sbr/read_switch.c?ds=sidebyside diff --git a/sbr/read_switch.c b/sbr/read_switch.c index 4599a41c..1c3e851e 100644 --- a/sbr/read_switch.c +++ b/sbr/read_switch.c @@ -1,38 +1,38 @@ - -/* - * 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 * complete copyright information. */ -#include +#include "h/mh.h" +#include "read_switch.h" +#include "smatch.h" 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 (;;) { - 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]) { - i = (isalpha(i) && isupper(i)) ? tolower(i) : i; + i = tolower(i); *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;