diff --git a/lang/b/compiler/b0.c b/lang/b/compiler/b0.c index 7ae35239b..2bf936805 100644 --- a/lang/b/compiler/b0.c +++ b/lang/b/compiler/b0.c @@ -34,12 +34,19 @@ init(char *s, int val) np->offset = val; } +static void +usage(void) +{ + error("Usage: em_b [-w wordsize] [-B modulename] [-i inputfile] [-o outputfile]"); + exit(1); +} + int main(int argc, char *argv[]) { for (;;) { - int opt = getopt(argc, argv, "-w:B:i:o:"); + int opt = getopt(argc, argv, "w:B:i:o:"); if (opt == -1) break; @@ -66,11 +73,12 @@ main(int argc, char *argv[]) } break; - derfault: - error("Usage: em_b [-w wordsize] [-B modulename] [-i inputfile] [-o outputfile]"); - exit(1); + default: + usage(); } } + if (optind < argc) + usage(); init("auto", AUTO); init("extrn", EXTERN); diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 36d64561f..eb177116a 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -346,7 +346,7 @@ int main(int argc, char* argv[]) opterr = 0; for (;;) { - int opt = getopt(argc, argv, "-M:P:O:vt"); + int opt = getopt(argc, argv, "M:P:O:vt"); if (opt == -1) break; @@ -364,17 +364,14 @@ int main(int argc, char* argv[]) { int o = atoi(optarg); if (o <= 2) - break; - if (o <= 3) + Ophase = &O2phases[0]; + else if (o == 3) Ophase = &O3phases[0]; - Ophase = &O4phases[0]; + else + Ophase = &O4phases[0]; break; } - case 1: - add_file(optarg); - break; - case 't': keeptemps = 1; goto addopt; @@ -390,6 +387,9 @@ int main(int argc, char* argv[]) } } + for (i = optind; i < argc; i++) + add_file(argv[i]); + phase_args[nphase_args] = 0; if (nuphases) Ophase = uphases;