Merge db42efbdd13a1678eb7cae15bfd15205ab26f78c into f1139494d18a2053630c5ed3384a42bb70db3c53

This commit is contained in:
shynur 2026-01-05 16:44:59 +08:00 committed by GitHub
commit d24f51046b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

4
qjs.c

@ -308,7 +308,6 @@ void help(void)
"-s strip all the debug info\n"
" --strip-source strip the source code\n"
"-q --quit just instantiate the interpreter and quit\n");
exit(1);
}
int main(int argc, char **argv)
@ -355,7 +354,7 @@ int main(int argc, char **argv)
arg++;
if (opt == 'h' || opt == '?' || !strcmp(longopt, "help")) {
help();
continue;
exit(0);
}
if (opt == 'e' || !strcmp(longopt, "eval")) {
if (*arg) {
@ -447,6 +446,7 @@ int main(int argc, char **argv)
fprintf(stderr, "qjs: unknown option '--%s'\n", longopt);
}
help();
exit(2);
}
}

9
qjsc.c

@ -396,6 +396,7 @@ void help(void)
"usage: " PROG_NAME " [options] [files]\n"
"\n"
"options are:\n"
"-h list options\n"
"-c only output bytecode to a C file\n"
"-e output main() and bytecode to a C file (default = executable output)\n"
"-o output set the output filename\n"
@ -423,7 +424,6 @@ void help(void)
" disable selected language features (smaller code size)\n");
}
#endif
exit(1);
}
#if defined(CONFIG_CC) && !defined(_WIN32)
@ -625,7 +625,7 @@ int main(int argc, char **argv)
arg++;
if (opt == 'h' || opt == '?' || !strcmp(longopt, "help")) {
help();
continue;
exit(0);
}
if (opt == 'o') {
out_filename = get_short_optarg(&optind, opt, arg, argc, argv);
@ -723,11 +723,14 @@ int main(int argc, char **argv)
fprintf(stderr, "qjsc: unknown option '--%s'\n", longopt);
}
help();
exit(2);
}
}
if (optind >= argc)
if (optind >= argc) {
help();
exit(2);
}
if (!out_filename) {
if (output_type == OUTPUT_EXECUTABLE) {

@ -2056,7 +2056,6 @@ void help(void)
"-f file execute single test from 'file'\n"
"-r file set the report file name (default=none)\n"
"-x file exclude tests listed in 'file'\n");
exit(1);
}
char *get_opt_arg(const char *option, char *arg)
@ -2108,6 +2107,7 @@ int main(int argc, char **argv)
optind++;
if (str_equal(arg, "-h")) {
help();
exit(0);
} else if (str_equal(arg, "-m")) {
dump_memory++;
} else if (str_equal(arg, "-n")) {
@ -2152,8 +2152,10 @@ int main(int argc, char **argv)
}
}
if (optind >= argc && !test_list.count)
if (optind >= argc && !test_list.count) {
help();
exit(2);
}
if (is_test262_harness) {
return run_test262_harness_test(argv[optind], is_module);