]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - main.c
unnamed globals in the trace output use [@addr] now instead of [#addr] since # is...
[xonotic/gmqcc.git] / main.c
diff --git a/main.c b/main.c
index ca404f9db25f68027fc986416719260efcc44e5f..6b751e3e03e7048788167dbd2bf4764c65e8505d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -68,36 +68,6 @@ static int usage() {
     return -1;
 }
 
-static void strtocmd(char *str)
-{
-    for(; *str; ++str) {
-        if (*str == '-') {
-            *str = '_';
-            continue;
-        }
-        if (isalpha(*str) && !isupper(*str)) {
-            *str += 'A' - 'a';
-            continue;
-        }
-    }
-}
-
-static void strtononcmd(char *buf, const char *str)
-{
-    for(; *str; ++buf, ++str) {
-        if (*str == '_') {
-            *buf = '-';
-            continue;
-        }
-        if (isalpha(*str) && isupper(*str)) {
-            *buf = *str + 'a' - 'A';
-            continue;
-        }
-        *buf = *str;
-    }
-    *buf = 0;
-}
-
 static bool options_setflag_all(const char *name, bool on, uint32_t *flags, const opts_flag_def *list, size_t listsize) {
     size_t i;
 
@@ -223,16 +193,16 @@ static bool options_parse(int argc, char **argv) {
 
                 /* handle all -fflags */
                 case 'f':
-                    strtocmd(argv[0]+2);
+                    util_strtocmd(argv[0]+2, argv[0]+2, strlen(argv[0]+2)+1);
                     if (!strcmp(argv[0]+2, "HELP")) {
                         printf("Possible flags:\n");
                         for (itr = 0; itr < COUNT_FLAGS; ++itr) {
-                            strtononcmd(buffer, opts_flag_list[itr].name);
+                            util_strtononcmd(opts_flag_list[itr].name, buffer, sizeof(buffer));
                             printf(" -f%s\n", buffer);
                         }
                         exit(0);
                     }
-                    else if (!strncmp(argv[0]+2, "NO-", 3)) {
+                    else if (!strncmp(argv[0]+2, "NO_", 3)) {
                         if (!options_setflag(argv[0]+5, false)) {
                             printf("unknown flag: %s\n", argv[0]+2);
                             return false;
@@ -244,21 +214,21 @@ static bool options_parse(int argc, char **argv) {
                     }
                     break;
                 case 'W':
-                    strtocmd(argv[0]+2);
+                    util_strtocmd(argv[0]+2, argv[0]+2, strlen(argv[0]+2)+1);
                     if (!strcmp(argv[0]+2, "HELP")) {
                         printf("Possible warnings:\n");
                         for (itr = 0; itr < COUNT_WARNINGS; ++itr) {
-                            strtononcmd(buffer, opts_warn_list[itr].name);
+                            util_strtononcmd(opts_warn_list[itr].name, buffer, sizeof(buffer));
                             printf(" -W%s\n", buffer);
                         }
                         exit(0);
                     }
-                    else if (!strcmp(argv[0]+2, "all")) {
+                    else if (!strcmp(argv[0]+2, "ALL")) {
                         for (itr = 0; itr < sizeof(opts_warn)/sizeof(opts_warn[0]); ++itr)
                             opts_warn[itr] = 0xFFFFFFFFL;
                         break;
                     }
-                    if (!strncmp(argv[0]+2, "no-", 3)) {
+                    if (!strncmp(argv[0]+2, "NO_", 3)) {
                         if (!options_setwarn(argv[0]+5, false)) {
                             printf("unknown warning: %s\n", argv[0]+2);
                             return false;