]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - opts.c
Remove trailing whitespace
[xonotic/gmqcc.git] / opts.c
diff --git a/opts.c b/opts.c
index 5ea4f6e85ff2654cdfab6834d69bfcd4eff390e8..c2e019e28a9ff932bf060c93de7412de2050e832 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2012, 2013
  *     Wolfgang Bumiller
- *     Dale Weiler 
+ *     Dale Weiler
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
@@ -27,7 +27,7 @@ opts_cmd_t   opts; /* command lien options */
 
 static void opts_setdefault() {
     memset(&opts, 0, sizeof(opts_cmd_t));
-    OPTION_VALUE_BOOL(OPTION_CORRECTION) = true;
+    OPTS_OPTION_BOOL(OPTION_CORRECTION) = true;
 
     /* warnings */
     opts_set(opts.warn,  WARN_UNUSED_VARIABLE,           true);
@@ -63,6 +63,8 @@ static void opts_setdefault() {
     opts_set(opts.flags, CORRECT_TERNARY,                true);
     opts_set(opts.flags, BAIL_ON_WERROR,                 true);
     opts_set(opts.flags, LEGACY_VECTOR_MATHS,            true);
+    opts_set(opts.flags, DARKPLACES_STRING_TABLE_BUG,    true);
+
 }
 
 void opts_backup_non_Wall() {
@@ -92,9 +94,10 @@ void opts_restore_non_Werror_all() {
 void opts_init(const char *output, int standard, size_t arraysize) {
     opts_setdefault();
 
-    OPTION_VALUE_STR(OPTION_OUTPUT)         = (char*)output;
-    OPTION_VALUE_U32(OPTION_STANDARD)       = standard;
-    OPTION_VALUE_U32(OPTION_MAX_ARRAY_SIZE) = arraysize;
+    OPTS_OPTION_STR(OPTION_OUTPUT)         = (char*)output;
+    OPTS_OPTION_U32(OPTION_STANDARD)       = standard;
+    OPTS_OPTION_U32(OPTION_MAX_ARRAY_SIZE) = arraysize;
+    OPTS_OPTION_U16(OPTION_MEMDUMPCOLS)    = 16;
 }
 
 static bool opts_setflag_all(const char *name, bool on, uint32_t *flags, const opts_flag_def *list, size_t listsize) {
@@ -141,6 +144,9 @@ void opts_setoptimlevel(unsigned int level) {
     size_t i;
     for (i = 0; i < COUNT_OPTIMIZATIONS; ++i)
         opts_set(opts.optimization, i, level >= opts_opt_oflag[i]);
+
+    if (!level)
+        opts.optimizeoff = true;
 }
 
 /*
@@ -189,7 +195,7 @@ static size_t opts_ini_parse (
     char *read_name;
     char *read_value;
 
-    while (file_getline(&line, &linesize, filehandle) != EOF) {
+    while (fs_file_getline(&line, &linesize, filehandle) != EOF) {
         parse_beg = line;
 
         /* handle BOM */
@@ -253,7 +259,7 @@ static size_t opts_ini_parse (
 static bool opts_ini_bool(const char *value) {
     if (!strcmp(value, "true"))  return true;
     if (!strcmp(value, "false")) return false;
-    return !!atoi(value);
+    return !!strtol(value, NULL, 10);
 }
 
 static char *opts_ini_load(const char *section, const char *name, const char *value) {
@@ -263,14 +269,14 @@ static char *opts_ini_load(const char *section, const char *name, const char *va
     /*
      * undef all of these because they may still be defined like in my
      * case they where.
-     */  
+     */
     #undef GMQCC_TYPE_FLAGS
     #undef GMQCC_TYPE_OPTIMIZATIONS
     #undef GMQCC_TYPE_WARNS
 
     /* flags */
     #define GMQCC_TYPE_FLAGS
-    #define GMQCC_DEFINE_FLAG(X, Y)                                    \
+    #define GMQCC_DEFINE_FLAG(X)                                       \
     if (!strcmp(section, "flags") && !strcmp(name, #X)) {              \
         opts_set(opts.flags, X, opts_ini_bool(value));                 \
         found = true;                                                  \
@@ -279,7 +285,7 @@ static char *opts_ini_load(const char *section, const char *name, const char *va
 
     /* warnings */
     #define GMQCC_TYPE_WARNS
-    #define GMQCC_DEFINE_FLAG(X, Y)                                    \
+    #define GMQCC_DEFINE_FLAG(X)                                       \
     if (!strcmp(section, "warnings") && !strcmp(name, #X)) {           \
         opts_set(opts.warn, WARN_##X, opts_ini_bool(value));           \
         found = true;                                                  \
@@ -288,7 +294,7 @@ static char *opts_ini_load(const char *section, const char *name, const char *va
 
     /* Werror-individuals */
     #define GMQCC_TYPE_WARNS
-    #define GMQCC_DEFINE_FLAG(X, Y)                                    \
+    #define GMQCC_DEFINE_FLAG(X)                                       \
     if (!strcmp(section, "errors") && !strcmp(name, #X)) {             \
         opts_set(opts.werror, WARN_##X, opts_ini_bool(value));         \
         found = true;                                                  \
@@ -297,7 +303,7 @@ static char *opts_ini_load(const char *section, const char *name, const char *va
 
     /* optimizations */
     #define GMQCC_TYPE_OPTIMIZATIONS
-    #define GMQCC_DEFINE_FLAG(X,Y,Z)                                   \
+    #define GMQCC_DEFINE_FLAG(X,Y)                                     \
     if (!strcmp(section, "optimizations") && !strcmp(name, #X)) {      \
         opts_set(opts.optimization, OPTIM_##X, opts_ini_bool(value));  \
         found = true;                                                  \
@@ -341,14 +347,14 @@ void opts_ini_init(const char *file) {
     size_t     line;
     FILE       *ini;
 
-    
+
     if (!file) {
         /* try ini */
-        if (!(ini = file_open((file = "gmqcc.ini"), "r")))
+        if (!(ini = fs_file_open((file = "gmqcc.ini"), "r")))
             /* try cfg */
-            if (!(ini = file_open((file = "gmqcc.cfg"), "r")))
+            if (!(ini = fs_file_open((file = "gmqcc.cfg"), "r")))
                 return;
-    } else if (!(ini = file_open(file, "r")))
+    } else if (!(ini = fs_file_open(file, "r")))
         return;
 
     con_out("found ini file `%s`\n", file);
@@ -359,5 +365,5 @@ void opts_ini_init(const char *file) {
         vec_free(error);
     }
 
-    file_close(ini);
-}  
+    fs_file_close(ini);
+}