]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - opts.c
Arithmetic exception flag and a plethora of tests.
[xonotic/gmqcc.git] / opts.c
diff --git a/opts.c b/opts.c
index e009d4e2cf52f8100e5139127043c5b46a525f59..ddb48f7d00e6f6b27bad2341c4e13fb6594a3506 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2013
+ * Copyright (C) 2012, 2013, 2014
  *     Wolfgang Bumiller
  *     Dale Weiler
  *
@@ -33,21 +33,21 @@ const unsigned int opts_opt_oflag[COUNT_OPTIMIZATIONS+1] = {
     0
 };
 
-const opts_flag_def opts_opt_list[COUNT_OPTIMIZATIONS+1] = {
+const opts_flag_def_t opts_opt_list[COUNT_OPTIMIZATIONS+1] = {
 # define GMQCC_TYPE_OPTIMIZATIONS
 # define GMQCC_DEFINE_FLAG(NAME, MIN_O) { #NAME, LONGBIT(OPTIM_##NAME) },
 #  include "opts.def"
     { NULL, LONGBIT(0) }
 };
 
-const opts_flag_def opts_warn_list[COUNT_WARNINGS+1] = {
+const opts_flag_def_t opts_warn_list[COUNT_WARNINGS+1] = {
 # define GMQCC_TYPE_WARNS
 # define GMQCC_DEFINE_FLAG(X) { #X, LONGBIT(WARN_##X) },
 #  include "opts.def"
     { NULL, LONGBIT(0) }
 };
 
-const opts_flag_def opts_flag_list[COUNT_FLAGS+1] = {
+const opts_flag_def_t opts_flag_list[COUNT_FLAGS+1] = {
 # define GMQCC_TYPE_FLAGS
 # define GMQCC_DEFINE_FLAG(X) { #X, LONGBIT(X) },
 #  include "opts.def"
@@ -55,11 +55,12 @@ const opts_flag_def opts_flag_list[COUNT_FLAGS+1] = {
 };
 
 unsigned int opts_optimizationcount[COUNT_OPTIMIZATIONS];
-opts_cmd_t   opts; /* command lien options */
+opts_cmd_t   opts; /* command line options */
 
 static void opts_setdefault(void) {
     memset(&opts, 0, sizeof(opts_cmd_t));
     OPTS_OPTION_BOOL(OPTION_CORRECTION) = true;
+    OPTS_OPTION_STR(OPTION_PROGSRC)     = "progs.src";
 
     /* warnings */
     opts_set(opts.warn,  WARN_UNUSED_VARIABLE,           true);
@@ -89,6 +90,10 @@ static void opts_setdefault(void) {
     opts_set(opts.warn,  WARN_UNINITIALIZED_CONSTANT,    true);
     opts_set(opts.warn,  WARN_DEPRECATED,                true);
     opts_set(opts.warn,  WARN_PARENTHESIS,               true);
+    opts_set(opts.warn,  WARN_CONST_OVERWRITE,           true);
+    opts_set(opts.warn,  WARN_DIRECTIVE_INMACRO,         true);
+    opts_set(opts.warn,  WARN_BUILTINS,                  true);
+    opts_set(opts.warn,  WARN_INEXACT_COMPARES,          true);
 
     /* flags */
     opts_set(opts.flags, ADJUST_VECTOR_FIELDS,           true);
@@ -126,13 +131,13 @@ void opts_restore_non_Werror_all() {
 void opts_init(const char *output, int standard, size_t arraysize) {
     opts_setdefault();
 
-    OPTS_OPTION_STR(OPTION_OUTPUT)         = (char*)output;
+    OPTS_OPTION_STR(OPTION_OUTPUT)         = 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) {
+static bool opts_setflag_all(const char *name, bool on, uint32_t *flags, const opts_flag_def_t *list, size_t listsize) {
     size_t i;
 
     for (i = 0; i < listsize; ++i) {
@@ -210,7 +215,7 @@ static char *opts_ini_next(const char *s, char c) {
 }
 
 static size_t opts_ini_parse (
-    FILE   *filehandle,
+    fs_file_t *filehandle,
     char *(*loadhandle)(const char *, const char *, const char *),
     char **errorhandle
 ) {
@@ -227,7 +232,7 @@ static size_t opts_ini_parse (
     char *read_name;
     char *read_value;
 
-    while (fs_file_getline(&line, &linesize, filehandle) != EOF) {
+    while (fs_file_getline(&line, &linesize, filehandle) != FS_FILE_EOF) {
         parse_beg = line;
 
         /* handle BOM */
@@ -348,16 +353,16 @@ static char *opts_ini_load(const char *section, const char *name, const char *va
             strcmp(section, "warnings")      &&
             strcmp(section, "optimizations"))
         {
-            vec_upload(error, "invalid section `", 17);
-            vec_upload(error, section, strlen(section));
+            vec_append(error, 17,             "invalid section `");
+            vec_append(error, strlen(section), section);
             vec_push  (error, '`');
             vec_push  (error, '\0');
         } else {
-            vec_upload(error, "invalid variable `", 18);
-            vec_upload(error, name, strlen(name));
+            vec_append(error, 18,             "invalid variable `");
+            vec_append(error, strlen(name), name);
             vec_push  (error, '`');
-            vec_upload(error, " in section: `", 14);
-            vec_upload(error, section, strlen(section));
+            vec_append(error, 14,              " in section: `");
+            vec_append(error, strlen(section), section);
             vec_push  (error, '`');
             vec_push  (error, '\0');
         }
@@ -377,7 +382,7 @@ void opts_ini_init(const char *file) {
      */
     char       *error = NULL;
     size_t     line;
-    FILE       *ini;
+    fs_file_t  *ini;
 
     if (!file) {
         /* try ini */