From 168622740b344fad660e5681f2f5a138dc054cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sun, 24 Dec 2023 15:47:42 -0500 Subject: [PATCH] Shave off a few more bytes Removes `-h` and flags from usage. Keeps flag-parsing logic the same, i.e. still accepts `-h` / `--help`. Only difference is what fd and rc the usage uses. Still over 1k north of 8192. --- ape/loader.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/ape/loader.c b/ape/loader.c index a3f681399..abab7f030 100644 --- a/ape/loader.c +++ b/ape/loader.c @@ -936,24 +936,13 @@ __attribute__((__noreturn__)) static void ShowUsage(int os, int fd, int rc) { "\n" "USAGE\n" "\n" - " ape -h\n" " ape PROG [ARGV1,ARGV2,...]\n" " ape - PROG [ARGV0,ARGV1,...]\n" - "\n" - "FLAGS\n" - "\n" - " -h show this help\n" "\n", 0l); Exit(rc, os); } -__attribute__((__noreturn__)) static void ShowError(int os, const char *ape, - const char *s) { - Print(os, 2, ape, ": ", s, " (pass -h for help)\n", 0l); - Exit(1, os); -} - EXTERN_C __attribute__((__noreturn__)) void ApeLoader(long di, long *sp, char dl) { int rc, n; @@ -1033,15 +1022,12 @@ EXTERN_C __attribute__((__noreturn__)) void ApeLoader(long di, long *sp, argc = sp[3] = sp[0] - 3; argv = (char **)((sp += 3) + 1); } else if (argc < 2) { - ShowError(os, ape, "missing command name"); + ShowUsage(os, 2, 1); } else { if (argv[1][0] == '-') { - if ((argv[1][1] == 'h' && !argv[1][2]) || - !StrCmp(argv[1] + 1, "-help")) { - ShowUsage(os, 1, 0); - } else { - ShowError(os, ape, "invalid flag"); - } + rc = !(argv[1][1] == 'h' && !argv[1][2]) || !StrCmp(argv[1] + 1, + "-help"); + ShowUsage(os, 1 + rc, rc); } prog = (char *)sp[2]; argc = sp[1] = sp[0] - 1;