From fb7dc2e983fc457af74e6c460f84683389c26f7b Mon Sep 17 00:00:00 2001 From: tjr Date: Wed, 15 May 2002 03:02:17 +0000 Subject: [PATCH] style(9): remove space between function name and opening parentheses, sort variables, NULL is the null-pointer constant, remove unnecessary braces. PR: 36130 Approved by: mike --- usr.bin/asa/asa.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/usr.bin/asa/asa.c b/usr.bin/asa/asa.c index 8194193b5d04..e166116cfe39 100644 --- a/usr.bin/asa/asa.c +++ b/usr.bin/asa/asa.c @@ -38,15 +38,15 @@ __RCSID("$NetBSD: asa.c,v 1.11 1997/09/20 14:55:00 lukem Exp $"); #endif __FBSDID("$FreeBSD$"); +#include #include #include -#include static void asa __P((FILE *)); int main __P((int, char *[])); int -main (argc, argv) +main(argc, argv) int argc; char **argv; { @@ -57,43 +57,42 @@ main (argc, argv) fp = stdin; do { - if (*argv) { - if (!(fp = fopen(*argv, "r"))) { - warn ("%s", *argv); + if (*argv != NULL) { + if ((fp = fopen(*argv, "r")) == NULL) { + warn("%s", *argv); continue; } } - asa (fp); + asa(fp); if (fp != stdin) (void)fclose(fp); - } while (*argv++); + } while (*argv++ != NULL); - exit (0); + exit(0); } static void asa(f) FILE *f; { - char *buf; size_t len; + char *buf; - if ((buf = fgetln (f, &len)) != NULL) { + if ((buf = fgetln(f, &len)) != NULL) { if (buf[len - 1] == '\n') buf[--len] = '\0'; - /* special case the first line */ + /* special case the first line */ switch (buf[0]) { case '0': - putchar ('\n'); + putchar('\n'); break; case '1': - putchar ('\f'); + putchar('\f'); break; } - if (len > 1 && buf[0] && buf[1]) { + if (len > 1 && buf[0] && buf[1]) printf("%.*s", (int)(len - 1), buf + 1); - } while ((buf = fgetln(f, &len)) != NULL) { if (buf[len - 1] == '\n') @@ -101,25 +100,24 @@ asa(f) switch (buf[0]) { default: case ' ': - putchar ('\n'); + putchar('\n'); break; case '0': - putchar ('\n'); - putchar ('\n'); + putchar('\n'); + putchar('\n'); break; case '1': - putchar ('\f'); + putchar('\f'); break; case '+': - putchar ('\r'); + putchar('\r'); break; } - if (len > 1 && buf[0] && buf[1]) { + if (len > 1 && buf[0] && buf[1]) printf("%.*s", (int)(len - 1), buf + 1); - } } - putchar ('\n'); + putchar('\n'); } }