From 338a3e715550c84d4049fb802bf000e1bf26a9ad Mon Sep 17 00:00:00 2001 From: emma Date: Sun, 28 Jul 2024 18:31:01 -0600 Subject: [PATCH] intcmp(1): move program_name ternary --- src/intcmp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/intcmp.c b/src/intcmp.c index 88356b4..3e329b9 100644 --- a/src/intcmp.c +++ b/src/intcmp.c @@ -46,20 +46,20 @@ int main(int argc, char *argv[]) { int r; /* reference integer */ mode = 0; - program_name = (argv[0] == NULL ? program_name : argv[0]); - - if (argc == 0) { return usage(program_name); } + if (argc < 3) { + return usage(argv[0] == NULL ? program_name : argv[0]); + } 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(program_name); + default: return usage(argv[0]); } } - if (optind + 2 /* ref cmp */ > argc) { return usage(program_name); } + if (optind + 2 /* ref cmp */ > argc) { return usage(argv[0]); } i = optind; @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) { fprintf( stderr, "%s: argument #%d: Invalid integer\n", - program_name, + argv[0], (int)i ); return EX_USAGE;