]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - main.c
Fixing GMQCC_SUPPRESS_EMPTY_BODY typo
[xonotic/gmqcc.git] / main.c
diff --git a/main.c b/main.c
index 81afc79a15a74a80adaab6bdca45137e473f3d79..1ffcd998927a437459041cd79a53195b72a38465 100644 (file)
--- a/main.c
+++ b/main.c
 typedef struct { char *name, type; } argitem;
 VECTOR_MAKE(argitem, items);
 
-/* global options */
-bool opts_debug                     = false;
-bool opts_memchk                    = false;
-bool opts_darkplaces_stringtablebug = false;
-bool opts_omit_nullcode             = false;
-int  opts_compiler                  = COMPILER_GMQCC;
-
-static const int usage(const char *const app) {
+static int usage(const char *app) {
     printf("usage:\n"
            "    %s -c<file>          -oprog.dat -- compile file\n"
            "    %s -a<file>          -oprog.dat -- assemble file\n"
@@ -108,18 +101,17 @@ int main(int argc, char **argv) {
             case 'i': { param_argument(2); break; } /* includes */
             #undef parm_argument
             default:
-                if (!strncmp(&argv[1][1], "debug" , 5)) { opts_debug  = true; break; }
-                if (!strncmp(&argv[1][1], "memchk", 6)) { opts_memchk = true; break; }
-                if (!strncmp(&argv[1][1], "help",   4)) {
+                if (util_strncmpexact(&argv[1][1], "debug" , 5)) { opts_debug  = true; break; }
+                if (util_strncmpexact(&argv[1][1], "memchk", 6)) { opts_memchk = true; break; }
+                if (util_strncmpexact(&argv[1][1], "help",   4)) {
                     return usage(app);
-                    break;
                 }
                 /* compiler type selection */
-                if (!strncmp(&argv[1][1], "std=qcc"   , 7 )) { opts_compiler = COMPILER_QCC;    break; }
-                if (!strncmp(&argv[1][1], "std=fteqcc", 10)) { opts_compiler = COMPILER_FTEQCC; break; }
-                if (!strncmp(&argv[1][1], "std=qccx",   8 )) { opts_compiler = COMPILER_QCCX;   break; }
-                if (!strncmp(&argv[1][1], "std=gmqcc",  9 )) { opts_compiler = COMPILER_GMQCC;  break; }
-                if (!strncmp(&argv[1][1], "std=",       4 )) {
+                if (util_strncmpexact(&argv[1][1], "std=qcc"   , 7 )) { opts_compiler = COMPILER_QCC;    break; }
+                if (util_strncmpexact(&argv[1][1], "std=fteqcc", 10)) { opts_compiler = COMPILER_FTEQCC; break; }
+                if (util_strncmpexact(&argv[1][1], "std=qccx",   8 )) { opts_compiler = COMPILER_QCCX;   break; }
+                if (util_strncmpexact(&argv[1][1], "std=gmqcc",  9 )) { opts_compiler = COMPILER_GMQCC;  break; }
+                if (util_strncmpexact(&argv[1][1], "std=",       4 )) {
                     printf("invalid std selection, supported types:\n"
                            "    -std=qcc     -- original QuakeC\n"
                            "    -std=ftqecc  -- fteqcc QuakeC\n"
@@ -129,28 +121,27 @@ int main(int argc, char **argv) {
                 }
 
                 /* code specific switches */
-                if (!strcmp(&argv[1][1], "fdarkplaces-stringtablebug")) {
+                if (util_strncmpexact(&argv[1][1], "fdarkplaces-stringtablebug", 26)) {
                     opts_darkplaces_stringtablebug = true;
                     break;
                 }
-                if (!strcmp(&argv[1][1], "fomit-nullcode")) {
+                if (util_strncmpexact(&argv[1][1], "fomit-nullcode", 14)) {
                     opts_omit_nullcode = true;
                     break;
                 }
-                return usage(app);
+                return printf("invalid command line argument: %s\n",argv[1]);
 
         }
         ++argv;
         --argc;
     }
-
     /*
      * options could depend on another option, this is where option
      * validity checking like that would take place.
      */
     if (opts_memchk && !opts_debug)
         printf("Warning: cannot enable -memchk, without -debug.\n");
-
+    
     util_debug("COM", "starting ...\n");
     /* multi file multi path compilation system */
     for (; itr < items_elements; itr++) {