diff options
Diffstat (limited to 'trek/getpar.c')
-rw-r--r-- | trek/getpar.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/trek/getpar.c b/trek/getpar.c index b51a209d..25dcdb61 100644 --- a/trek/getpar.c +++ b/trek/getpar.c @@ -1,4 +1,4 @@ -/* $NetBSD: getpar.c,v 1.13 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: getpar.c,v 1.14 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: getpar.c,v 1.13 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: getpar.c,v 1.14 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -56,8 +56,7 @@ getintpar(const char *s) int i; int n; - while (1) - { + while (1) { if (testnl() && s) printf("%s: ", s); i = scanf("%d", &n); @@ -80,8 +79,7 @@ getfltpar(const char *s) int i; double d; - while (1) - { + while (1) { if (testnl() && s) printf("%s: ", s); i = scanf("%lf", &d); @@ -98,8 +96,7 @@ getfltpar(const char *s) ** get yes/no parameter **/ -const struct cvntab Yntab[] = -{ +const struct cvntab Yntab[] = { { "y", "es", (cmdfun)1, 1 }, { "n", "o", (cmdfun)0, 0 }, { NULL, NULL, NULL, 0 } @@ -130,13 +127,14 @@ getcodpar(const char *s, const struct cvntab tab[]) int f; flag = 0; - while (1) - { + while (1) { flag |= (f = testnl()); if (flag) printf("%s: ", s); - if (f) - cgetc(0); /* throw out the newline */ + if (f) { + /* throw out the newline */ + cgetc(0); + } scanf("%*[ \t;]"); if ((c = scanf("%99[^ \t;\n]", input)) < 0) exit(1); @@ -145,11 +143,9 @@ getcodpar(const char *s, const struct cvntab tab[]) flag = 1; /* if command list, print four per line */ - if (input[0] == '?' && input[1] == 0) - { + if (input[0] == '?' && input[1] == 0) { c = 4; - for (r = tab; r->abrev; r++) - { + for (r = tab; r->abrev; r++) { strcpy(input, r->abrev); strcat(input, r->full); printf("%14.14s", input); @@ -164,14 +160,12 @@ getcodpar(const char *s, const struct cvntab tab[]) } /* search for in table */ - for (r = tab; r->abrev; r++) - { + for (r = tab; r->abrev; r++) { p = input; for (q = r->abrev; *q; q++) if (*p++ != *q) break; - if (!*q) - { + if (!*q) { for (q = r->full; *p && *q; q++, p++) if (*p != *q) break; @@ -181,12 +175,10 @@ getcodpar(const char *s, const struct cvntab tab[]) } /* check for not found */ - if (!r->abrev) - { + if (!r->abrev) { printf("invalid input; ? for valid inputs\n"); skiptonl(0); - } - else + } else return (r); } } @@ -206,8 +198,7 @@ getstrpar(const char *s, char *r, int l, const char *t) if (t == 0) t = " \t\n;"; (void)sprintf(format, "%%%d[^%s]", l, t); - while (1) - { + while (1) { if ((f = testnl()) && s) printf("%s: ", s); if (f) @@ -233,9 +224,8 @@ testnl(void) while ((c = cgetc(0)) != '\n') if ((c >= '0' && c <= '9') || c == '.' || c == '!' || - (c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || c == '-') - { + (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || c == '-') { ungetc(c, stdin); return(0); } @@ -291,8 +281,7 @@ readdelim(int d) { char c; - while ((c = cgetc(0)) != '\0') - { + while ((c = cgetc(0)) != '\0') { if (c == d) return (1); if (c == ' ') |