mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
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.
This commit is contained in:
parent
7cf845a9db
commit
168622740b
1 changed files with 4 additions and 18 deletions
22
ape/loader.c
22
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue