]> git.saurik.com Git - bison.git/blobdiff - src/getargs.c
Don't let Bison leak memory except when it complains.
[bison.git] / src / getargs.c
index 52f97e17346a14aed2ca67026c96415832d1f6c3..9a2f5307ced06eb3aa01882e369e46a794614978 100644 (file)
@@ -91,15 +91,15 @@ flags_argmatch (const char *option,
   if (args)
     {
       args = strtok (args, ",");
-      do
+      while (args)
        {
          int value = XARGMATCH (option, args, keys, values);
          if (value == 0)
            *flags = 0;
          else
            *flags |= value;
+         args = strtok (NULL, ",");
        }
-      while ((args = strtok (NULL, ",")));
     }
   else
     *flags = ~0;
@@ -203,19 +203,21 @@ static const char * const warnings_args[] =
 {
   /* In a series of synonyms, present the most meaningful first, so
      that argmatch_valid be more readable.  */
-  "none       - no warnings",
-  "error      - warnings are errors",
-  "yacc       - incompatibilities with POSIX YACC",
-  "all        - all of the above",
+  "none            - no warnings",
+  "midrule-values  - unset or unused midrule values",
+  "yacc            - incompatibilities with POSIX YACC",
+  "all             - all of the above",
+  "error           - warnings are errors",
   0
 };
 
 static const int warnings_types[] =
 {
   warnings_none,
-  warnings_error,
+  warnings_midrule_values,
   warnings_yacc,
-  warnings_all
+  warnings_all,
+  warnings_error
 };
 
 ARGMATCH_VERIFY (warnings_args, warnings_types);
@@ -406,7 +408,7 @@ getargs (int argc, char *argv[])
        /* Here, the -g and --graph=FILE options are differentiated.  */
        graph_flag = true;
        if (optarg)
-         spec_graph_file = AS_FILE_NAME (optarg);
+         spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
        break;
 
       case 'h':
@@ -424,7 +426,7 @@ getargs (int argc, char *argv[])
        /* Here, the -d and --defines options are differentiated.  */
        defines_flag = true;
        if (optarg)
-         spec_defines_file = AS_FILE_NAME (optarg);
+         spec_defines_file = xstrdup (AS_FILE_NAME (optarg));
        break;
 
       case 'k':
@@ -472,7 +474,10 @@ getargs (int argc, char *argv[])
        break;
 
       case 'W':
-       FLAGS_ARGMATCH (warnings, optarg);
+       if (optarg)
+         FLAGS_ARGMATCH (warnings, optarg);
+       else
+         warnings_flag |= warnings_all;
        break;
 
       case LOCATIONS_OPTION: