]> granicus.if.org Git - yasm/commitdiff
Accept (but ignore) -O and -Onnn command line options, for compatibility
authorPeter Johnson <peter@tortall.net>
Sat, 30 Sep 2006 08:16:39 +0000 (08:16 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 30 Sep 2006 08:16:39 +0000 (08:16 -0000)
with NASM.

svn path=/trunk/yasm/; revision=1636

frontends/yasm/yasm-options.c
frontends/yasm/yasm-options.h
frontends/yasm/yasm.c

index a314bafd1f7db6391913578f152793c87332c42c..282d705e09fe2da9ad12ae59424fb6a40b3e30c6 100644 (file)
@@ -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]);
index 0a4cd0033ae19acc7e672dc19aaf48af39c6b84a..04cf0434c1d418649cfbfe38f6ba3ec23aa339ff 100644 (file)
@@ -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
index 16e6be99a0a28c90e920363b5b1f65a3dc1d1626..396485b159bfe71c1612edf52874ba1ad1ebad01 100644 (file)
@@ -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)
 {