From: Peter Johnson Date: Sat, 30 Sep 2006 08:16:39 +0000 (-0000) Subject: Accept (but ignore) -O and -Onnn command line options, for compatibility X-Git-Tag: v0.6.0~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63dab9dab65b17a788a2550dc95d589f0e15d6be;p=yasm Accept (but ignore) -O and -Onnn command line options, for compatibility with NASM. svn path=/trunk/yasm/; revision=1636 --- diff --git a/frontends/yasm/yasm-options.c b/frontends/yasm/yasm-options.c index a314bafd..282d705e 100644 --- a/frontends/yasm/yasm-options.c +++ b/frontends/yasm/yasm-options.c @@ -85,6 +85,8 @@ parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, break; } } + if (!got_it && !other_option_handler(argv[0])) + got_it = 1; if (!got_it) { print_error(_("warning: unrecognized option `%s'"), argv[0]); @@ -119,6 +121,8 @@ parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts, break; } } + if (!got_it && !other_option_handler(argv[0])) + got_it = 1; if (!got_it) { print_error(_("warning: unrecognized option `%s'"), argv[0]); diff --git a/frontends/yasm/yasm-options.h b/frontends/yasm/yasm-options.h index 0a4cd003..04cf0434 100644 --- a/frontends/yasm/yasm-options.h +++ b/frontends/yasm/yasm-options.h @@ -55,6 +55,9 @@ typedef struct opt_option_s /* handle everything that is not an option */ int not_an_option_handler(char *param); +/* handle possibly other special-case options; no parameters allowed */ +int other_option_handler(char *option); + /* parse command line calling handlers when appropriate * argc, argv - pass directly from main(argc,argv) * options - array of options diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 16e6be99..396485b1 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -770,6 +770,23 @@ not_an_option_handler(char *param) return 0; } +int +other_option_handler(char *option) +{ + /* Accept, but ignore, -O and -Onnn, for compatibility with NASM. */ + if (option[0] == '-' && option[1] == 'O') { + int n = 2; + for (;;) { + if (option[n] == '\0') + return 0; + if (!isdigit(option[n])) + return 1; + n++; + } + } + return 1; +} + static int opt_special_handler(/*@unused@*/ char *cmd, /*@unused@*/ char *param, int extra) {