From 9ee573aeee7b5ed71e0b13b75d54c599acd89974 Mon Sep 17 00:00:00 2001 From: John Brandwood Date: Sun, 14 Apr 2024 13:34:39 -0400 Subject: [PATCH] PCEAS: Use xgetopt on all target platforms to avoid annoying differences in behavior. Display "--" for the long options in the help message, even though a single "-" works in order to maintain backwards compatibility. --- src/mkit/as/Makefile | 2 +- src/mkit/as/main.c | 52 ++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/mkit/as/Makefile b/src/mkit/as/Makefile index 87083123..51902674 100644 --- a/src/mkit/as/Makefile +++ b/src/mkit/as/Makefile @@ -9,7 +9,7 @@ include ../../Make_src.inc OBJS = main.o input.o assemble.o expr.o code.o command.o\ macro.o func.o proc.o symbol.o pcx.o output.o crc.o\ - pce.o map.o mml.o nes.o atari.o + pce.o map.o mml.o nes.o atari.o xgetopt.o LIBS = pngread/pngread.a diff --git a/src/mkit/as/main.c b/src/mkit/as/main.c index 7727285c..86627f2b 100644 --- a/src/mkit/as/main.c +++ b/src/mkit/as/main.c @@ -27,11 +27,6 @@ #include #include #include -#ifdef _MSC_VER -#include "xgetopt.h" -#else -#include -#endif #include #include "defs.h" #include "externs.h" @@ -39,6 +34,7 @@ #include "vars.h" #include "inst.h" #include "overlay.h" +#include "xgetopt.h" /* defines */ #define STANDARD_CD 1 @@ -361,6 +357,9 @@ main(int argc, char **argv) switch(opt) { case 'I': +// /* GNU optarg can add a leading space on linux */ +// while (*optarg == ' ') { ++optarg; } + if (*optarg == '-') { fprintf(stderr, "%s: include path missing after \"-I\"!\n", argv[0]); return (1); @@ -384,6 +383,9 @@ main(int argc, char **argv) return (0); case 'l': +// /* GNU optarg can add a leading space on linux */ +// while (*optarg == ' ') { ++optarg; } + if ((isdigit(*optarg) == 0) || (optarg[1] != '\0')) { fprintf(stderr, "%s: \"-l\" option must be followed by a single digit\n", argv[0]); return (1); @@ -402,6 +404,9 @@ main(int argc, char **argv) break; case 'o': +// /* GNU optarg can add a leading space on linux */ +// while (*optarg == ' ') { ++optarg; } + if (*optarg == '-') { fprintf(stderr, "%s: output filename missing after \"-o\"\n", argv[0]); return (1); @@ -1082,29 +1087,30 @@ help(void) prg_name = machine->asm_name; /* display help */ - printf("%s [-options] [-h (for help)] [-o outfile] infiles\n\n", prg_name); - printf("-s/S : show segment usage\n"); - printf("-l # : listing file output level (0-3)\n"); + printf("%s [options] [-h (for help)] [-o outfile] infiles\n\n", prg_name); + printf("-s : show segment usage\n"); + printf("-S : show segment usage and contents\n"); + printf("-l <0..3> : listing file output level (0-3), default is 2\n"); printf("-m : force macro expansion in listing\n"); - printf("-raw : prevent adding a ROM header\n"); - printf("-pad : pad ROM size to power-of-two\n"); - printf("-trim : strip unused head and tail from ROM\n"); + printf("--raw : prevent adding a ROM header\n"); + printf("--pad : pad ROM size to power-of-two\n"); + printf("--trim : strip unused head and tail from ROM\n"); printf("-I : add include path\n"); if (machine->type == MACHINE_PCE) { - printf("-sf2 : create a StreetFighterII HuCARD\n"); - printf("-cd : create a CD-ROM track image\n"); - printf("-scd : create a Super CD-ROM track image\n"); - printf("-sgx : add a SuperGRAFX signature to the CD-ROM\n"); - printf("-overlay : create an executable 'overlay' program segment\n"); - printf("-ipl : create a custom CD-ROM IPL file\n"); - printf("-develo : assemble and run on the Develo Box\n"); - printf("-mx : create a Develo MX file\n"); + printf("--sf2 : create a StreetFighterII HuCARD\n"); + printf("--cd : create a CD-ROM track image\n"); + printf("--scd : create a Super CD-ROM track image\n"); + printf("--sgx : add a SuperGRAFX signature to the CD-ROM\n"); + printf("--overlay : create an executable 'overlay' program segment\n"); + printf("--ipl : create a custom CD-ROM IPL file\n"); + printf("--develo : assemble and run on the Develo Box\n"); + printf("--mx : create a Develo MX file\n"); printf("-O : optimize .proc packing (compared to HuC v3.21)\n"); - printf("-strip : strip unused .proc & .procgroup\n"); - printf("-newproc : run .proc code in MPR6, instead of MPR5\n"); + printf("--strip : strip unused .proc & .procgroup\n"); + printf("--newproc : run .proc code in MPR6, instead of MPR5\n"); } - printf("-kc : assemble code generated by the KickC compiler\n"); - printf("-srec : create a Motorola S-record file\n"); + printf("--kc : assemble code generated by the KickC compiler\n"); + printf("--srec : create a Motorola S-record file\n"); printf("infiles : one or more files to be assembled\n"); printf("\n"); }