# HG changeset patch # User lost@l-w.ca # Date 1295714452 25200 # Node ID 917b608b8c6670e86bf08a37ac253a8eb65a0fe5 # Parent 1e5e8ec406fbe85d5555f37162a994c59eeaaeaf Switched lwasm to lw_cmdline from argp diff -r 1e5e8ec406fb -r 917b608b8c66 lwasm/main.c --- a/lwasm/main.c Sat Jan 22 09:31:43 2011 -0700 +++ b/lwasm/main.c Sat Jan 22 09:40:52 2011 -0700 @@ -19,7 +19,6 @@ this program. If not, see . */ -#include #include #include #include @@ -28,6 +27,7 @@ #include #include #include +#include #include "lwasm.h" #include "input.h" @@ -35,32 +35,31 @@ extern int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr); /* command line option handling */ -const char *argp_program_version = "lwasm from " PACKAGE_STRING; -const char *argp_program_bug_address = PACKAGE_BUGREPORT; +#define PROGVER "lwasm from " PACKAGE_STRING char *program_name; -static struct argp_option options[] = +static struct lw_cmdline_options options[] = { - { "output", 'o', "FILE", 0, "Output to FILE"}, - { "debug", 'd', "LEVEL", OPTION_ARG_OPTIONAL, "Set debug mode"}, - { "format", 'f', "TYPE", 0, "Select output format: decb, raw, obj, os9"}, - { "list", 'l', "FILE", OPTION_ARG_OPTIONAL, "Generate list [to FILE]"}, - { "symbols", 's', 0, OPTION_ARG_OPTIONAL, "Generate symbol list in listing, no effect without --list"}, - { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, - { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, - { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, - { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, - { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, - { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, - { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, - { "includedir", 'I', "PATH", 0, "Add entry to include path" }, + { "output", 'o', "FILE", 0, "Output to FILE"}, + { "debug", 'd', "LEVEL", lw_cmdline_opt_optional, "Set debug mode"}, + { "format", 'f', "TYPE", 0, "Select output format: decb, raw, obj, os9"}, + { "list", 'l', "FILE", lw_cmdline_opt_optional, "Generate list [to FILE]"}, + { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, + { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, + { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, + { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, + { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, + { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, + { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, + { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, + { "includedir", 'I', "PATH", 0, "Add entry to include path" }, { 0 } }; -static error_t parse_opts(int key, char *arg, struct argp_state *state) +static int parse_opts(int key, char *arg, void *state) { - asmstate_t *as = state -> input; + asmstate_t *as = state; switch (key) { @@ -146,25 +145,26 @@ as -> target = TARGET_6309; break; - case ARGP_KEY_END: + case lw_cmdline_key_end: break; - case ARGP_KEY_ARG: + case lw_cmdline_key_arg: lw_stringlist_addstring(as -> input_files, arg); break; default: - return ARGP_ERR_UNKNOWN; + return lw_cmdline_err_unknown; } return 0; } -static struct argp argp = +static struct lw_cmdline_parser cmdline_parser = { options, parse_opts, - "", - "LWASM, a HD6309 and MC6809 cross-assembler" + "INPUTFILE", + "lwasm, a HD6309 and MC6809 cross-assembler\vPlease report bugs to lost@l-w.ca.", + PROGVER }; /* @@ -219,7 +219,7 @@ asmstate.nextcontext = 1; /* parse command line arguments */ - argp_parse(&argp, argc, argv, 0, 0, &asmstate); + lw_cmdline_parse(&cmdline_parser, argc, argv, 0, 0, &asmstate); if (!asmstate.output_file) {