From 35a20dca7906eebc221af8672163130af2876aec Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 13 Jul 2024 17:03:41 -0600 Subject: [PATCH] npc(1): specifies sysexits imports, formatting --- src/npc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/npc.c b/src/npc.c index a6e3ce9..0892a72 100644 --- a/src/npc.c +++ b/src/npc.c @@ -19,9 +19,9 @@ #include /* fprintf(3), fputs(3), getc(3), putc(3), stdin, stdout, * EOF */ -#include /* EXIT_FAILURE, EXIT_SUCCESS */ +#include /* EXIT_FAILURE */ #include /* getopt(3) */ -#include +#include /* EX_OK, EX_USAGE */ int usage(char *s) { fprintf(stderr, "Usage: %s [-et]\n", s); @@ -36,17 +36,17 @@ int main(int argc, char *argv[]) { showend = 0; showtab = 0; - if(!argc > 0) { usage(argv[0]); } - - while ((c = getopt(argc, argv, "et")) != -1) { - switch(c){ - case 'e': showend = 1; break; - case 't': showtab = 1; break; - default: return usage(argv[0]); + if (argc > 0) { + while ((c = getopt(argc, argv, "et")) != -1) { + switch (c){ + case 'e': showend = 1; break; + case 't': showtab = 1; break; + default: return usage(argv[0]); + } } } - if(argc > optind) { return usage(argv[0]); } + if (argc > optind) { return usage(argv[0]); } while ((c = getc(stdin)) != EOF) { if ((c & 0x80) != 0) { fputs("M-", stdout); } @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) { case 0x7f: fputs("^?", stdout); break; case '\n': if (showend) { putc('$', stdout); } default: - if(c >= ' ' || c == '\n' || (!showtab && c == '\t')) { + if (c >= ' ' || c == '\n' || (!showtab && c == '\t')) { putc(c, stdout); } else { fprintf(stdout, "^%c", c + '@');