X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fgans.c;h=1f9e497fc25768d275357f9991f9bd18f61bab29;hp=270b72930315378c411cd3eeded36141e49c48ee;hb=5ba9c2f13fedf1d8d6ed907ef1f505616290efaa;hpb=a485ed478abbd599d8c9aab48934e7a26733ecb1 diff --git a/sbr/gans.c b/sbr/gans.c index 270b729..1f9e497 100644 --- a/sbr/gans.c +++ b/sbr/gans.c @@ -1,48 +1,43 @@ /* - * gans.c -- get an answer from the user - * - * 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. - */ +** gans.c -- get an answer from the user +** +** 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 int -gans (char *prompt, struct swit *ansp) +gans(char *prompt, struct swit *ansp) { - register int i; - register char *cp; - register struct swit *ap; + int i; + char *cp; + struct swit *ap; char ansbuf[BUFSIZ]; for (;;) { - printf ("%s", prompt); - fflush (stdout); + printf("%s", prompt); + fflush(stdout); cp = ansbuf; - while ((i = getchar ()) != '\n') { + while ((i = getchar()) != '\n') { if (i == EOF) return 0; if (cp < &ansbuf[sizeof ansbuf - 1]) { -#ifdef LOCALE - i = (isalpha(i) && isupper(i)) ? tolower(i) : i; -#else - if (i >= 'A' && i <= 'Z') - i += 'a' - 'A'; -#endif - *cp++ = i; + *cp++ = tolower(i); } } *cp = '\0'; if (ansbuf[0] == '?' || cp == ansbuf) { - printf ("Options are:\n"); + printf("Options are:\n"); for (ap = ansp; ap->sw; ap++) - printf (" %s\n", ap->sw); + printf(" %s\n", ap->sw); continue; } - if ((i = smatch (ansbuf, ansp)) < 0) { - printf ("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous"); + if ((i = smatch(ansbuf, ansp)) < 0) { + printf("%s: %s.\n", ansbuf, i == -1 ? "unknown" : "ambiguous"); continue; } return i;