]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - main.c
Print off the documentation when -[f/W/O]help, also fixed some of the descriptions...
[xonotic/gmqcc.git] / main.c
diff --git a/main.c b/main.c
index f659e4776dd292a5af167644fc9262cd0bbf48c1..f6d9b3163907d2d5d05608e1dfb80a5c7e8c8038 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012
+ * Copyright (C) 2012, 2013
  *     Dale Weiler
  *     Wolfgang Bumiller
  *
@@ -51,6 +51,11 @@ static void version() {
         __DATE__,
         __TIME__
     );
+#ifdef GMQCC_GITINFO
+    con_out("git build: %s\n", GMQCC_GITINFO);
+#elif defined(GMQCC_VERION_TYPE_DEVEL)
+    con_out("development build\n");
+#endif
 }
 
 static int usage() {
@@ -163,6 +168,7 @@ static bool options_parse(int argc, char **argv) {
                     opts_set(opts.flags, FALSE_EMPTY_STRINGS,           false);
                     opts_set(opts.flags, TRUE_EMPTY_STRINGS,            true);
                     opts_set(opts.flags, LOOP_LABELS,                   true);
+                    opts_set(opts.flags, TRANSLATABLE_STRINGS,          true);
                     opts_set(opts.flags, INITIALIZED_NONCONSTANTS,      true);
                     opts_set(opts.werror, WARN_INVALID_PARAMETER_COUNT, true);
                     opts_set(opts.werror, WARN_MISSING_RETURN_VALUES,   true);
@@ -180,8 +186,8 @@ static bool options_parse(int argc, char **argv) {
                     opts_set(opts.flags, TRANSLATABLE_STRINGS,     true);
                     opts_set(opts.flags, ADJUST_VECTOR_FIELDS,     false);
                     opts_set(opts.flags, ASSIGN_FUNCTION_TYPES,    true);
-                    opts_set(opts.warn, WARN_TERNARY_PRECEDENCE,   true);
                     opts_set(opts.flags, CORRECT_TERNARY,          false);
+                    opts_set(opts.warn, WARN_TERNARY_PRECEDENCE,   true);
                     opts.standard = COMPILER_FTEQCC;
 
                 } else if (!strcmp(argarg, "qccx")) {
@@ -304,10 +310,10 @@ static bool options_parse(int argc, char **argv) {
                 case 'f':
                     util_strtocmd(argv[0]+2, argv[0]+2, strlen(argv[0]+2)+1);
                     if (!strcmp(argv[0]+2, "HELP") || *(argv[0]+2) == '?') {
-                        con_out("Possible flags:\n");
+                        con_out("Possible flags:\n\n");
                         for (itr = 0; itr < COUNT_FLAGS; ++itr) {
                             util_strtononcmd(opts_flag_list[itr].name, buffer, sizeof(buffer));
-                            con_out(" -f%s\n", buffer);
+                            con_out(" -f%s:\n%s\n\n", buffer, opts_flag_list[itr].description);
                         }
                         exit(0);
                     }
@@ -328,7 +334,7 @@ static bool options_parse(int argc, char **argv) {
                         con_out("Possible warnings:\n");
                         for (itr = 0; itr < COUNT_WARNINGS; ++itr) {
                             util_strtononcmd(opts_warn_list[itr].name, buffer, sizeof(buffer));
-                            con_out(" -W%s\n", buffer);
+                            con_out(" -W%s:\n%s\n\n\n", buffer, opts_warn_list[itr].description);
                         }
                         exit(0);
                     }
@@ -342,8 +348,10 @@ static bool options_parse(int argc, char **argv) {
                     else if (!strcmp(argv[0]+2, "ERROR") ||
                              !strcmp(argv[0]+2, "ERROR_ALL"))
                     {
+                        opts_backup_non_Werror_all();
                         for (itr = 0; itr < sizeof(opts.werror)/sizeof(opts.werror[0]); ++itr)
                             opts.werror[itr] = 0xFFFFFFFFL;
+                        opts_restore_non_Werror_all();
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "NONE")) {
@@ -352,8 +360,10 @@ static bool options_parse(int argc, char **argv) {
                         break;
                     }
                     else if (!strcmp(argv[0]+2, "ALL")) {
+                        opts_backup_non_Wall();
                         for (itr = 0; itr < sizeof(opts.warn)/sizeof(opts.warn[0]); ++itr)
                             opts.warn[itr] = 0xFFFFFFFFL;
+                        opts_restore_non_Wall();
                         break;
                     }
                     else if (!strncmp(argv[0]+2, "ERROR_", 6)) {
@@ -394,7 +404,7 @@ static bool options_parse(int argc, char **argv) {
                             con_out("Possible optimizations:\n");
                             for (itr = 0; itr < COUNT_OPTIMIZATIONS; ++itr) {
                                 util_strtononcmd(opts_opt_list[itr].name, buffer, sizeof(buffer));
-                                con_out(" -O%-20s (-O%u)\n", buffer, opts_opt_oflag[itr]);
+                                con_out(" -O%-20s (-O%u):\n%s\n\n", buffer, opts_opt_oflag[itr], opts_opt_list[itr].description);
                             }
                             exit(0);
                         }
@@ -455,6 +465,18 @@ static bool options_parse(int argc, char **argv) {
                         opts.quiet = true;
                         break;
                     }
+                    else if (!strcmp(argv[0]+2, "correct")) {
+                        opts.correction = true;
+                        break;
+                    }
+                    else if (!strcmp(argv[0]+2, "no-correct")) {
+                        opts.correction = false;
+                        break;
+                    }
+                    else if (!strcmp(argv[0]+2, "add-info")) {
+                        opts.add_info = true;
+                        break;
+                    }
                     else {
             /* All long options with arguments */
                         if (options_long_witharg("output", &argc, &argv, &argarg)) {
@@ -570,7 +592,7 @@ int main(int argc, char **argv) {
             con_out("Flag %s = %i\n",    opts_flag_list[itr].name, OPTS_FLAG(itr));
         for (itr = 0; itr < COUNT_WARNINGS; ++itr)
             con_out("Warning %s = %i\n", opts_warn_list[itr].name, OPTS_WARN(itr));
-        
+
         con_out("output             = %s\n", opts.output);
         con_out("optimization level = %d\n", opts.O);
         con_out("standard           = %i\n", opts.standard);