intcmp(1): formatting, fixes argv[0] ternary and usage function
This commit is contained in:
parent
d9dd4e6057
commit
0c530dffbf
13
src/intcmp.c
13
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,21 +43,22 @@ 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){
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user