diff --git a/src/intcmp.c b/src/intcmp.c index 961b8a9..132c230 100644 --- a/src/intcmp.c +++ b/src/intcmp.c @@ -33,10 +33,8 @@ static char *program_name = "intcmp"; int usage(char *s) { - fprintf( - stderr, "Usage: %s [-egl] integer integer...\n", - s == NULL ? program_name : s - ); + fprintf(stderr, "Usage: %s [-egl] integer integer...\n", s); + return EX_USAGE; } @@ -45,25 +43,26 @@ int main(int argc, char *argv[]) { size_t i; unsigned char mode; int r; /* reference integer */ + char *s = (argv[0] == NULL ? program_name : argv[0]); mode = 0; - if (argc == 0 | argc < 3) { return usage(argv[0]); } + if (argc == 0 | argc < 3) { return usage(s); } while ((c = getopt(argc, argv, "egl")) != -1) { - switch(c){ + switch (c){ case 'e': mode |= EQUAL; break; case 'g': mode |= GREATER; break; case 'l': mode |= LESSER; break; - default: return usage(argv[0]); + default: return usage(s); } } - if(optind + 2 /* ref cmp */ > argc){ return usage(argv[0]); } + if (optind + 2 /* ref cmp */ > argc) { return usage(s); } i = optind; - do{ + do { r = c; c = strtol(argv[i], &argv[i], 10); @@ -82,7 +81,7 @@ int main(int argc, char *argv[]) { || (!(mode & GREATER) && r > c) || (!(mode & LESSER) && r < c) ) { return 1; } - } while(++i < argc); + } while (++i < argc); return EX_OK; }