]> 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 6961ab3b3e6462d2dc4c27261bc2fed5377da07a..9a2f5307ced06eb3aa01882e369e46a794614978 100644 (file)
@@ -25,6 +25,7 @@
 #include "revision.h"
 
 #include <argmatch.h>
+#include <configmake.h>
 #include <error.h>
 
 /* Hack to get <getopt.h> to declare getopt with a prototype.  */
@@ -59,6 +60,7 @@ bool error_verbose = false;
 bool nondeterministic_parser = false;
 bool glr_parser = false;
 bool pure_parser = false;
+bool push_parser = false;
 
 int report_flag = report_none;
 int trace_flag = trace_none;
@@ -89,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;
@@ -201,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);
@@ -233,29 +237,25 @@ usage (int status)
             program_name);
   else
     {
-      /* Some efforts were made to ease the translators' task, please
-        continue.  */
+      printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
       fputs (_("\
-GNU bison generates LALR(1) and GLR parsers.\n"), stdout);
-      putc ('\n', stdout);
-
-      fprintf (stdout, _("\
-Usage: %s [OPTION]... FILE\n"), program_name);
-      putc ('\n', stdout);
+Generate LALR(1) and GLR parsers.\n\
+\n\
+"), stdout);
 
       fputs (_("\
-If a long option shows an argument as mandatory, then it is mandatory\n\
-for the equivalent short option also.  Similarly for optional arguments.\n"),
-            stdout);
-      putc ('\n', stdout);
+Mandatory arguments to long options are mandatory for short options too.\n\
+"), stdout);
 
       fputs (_("\
+\n\
 Operation modes:\n\
   -h, --help                 display this help and exit\n\
   -V, --version              output version information and exit\n\
       --print-localedir      output directory containing locale-dependent data\n\
-  -y, --yacc                 emulate POSIX Yacc\n"), stdout);
-      putc ('\n', stdout);
+  -y, --yacc                 emulate POSIX Yacc\n\
+\n\
+"), stdout);
 
       fputs (_("\
 Parser:\n\
@@ -266,8 +266,8 @@ Parser:\n\
   -l, --no-lines             don't generate `#line' directives\n\
   -n, --no-parser            generate the tables only\n\
   -k, --token-table          include a table of token names\n\
+\n\
 "), stdout);
-      putc ('\n', stdout);
 
       fputs (_("\
 Output:\n\
@@ -276,9 +276,9 @@ Output:\n\
   -v, --verbose              same as `--report=state'\n\
   -b, --file-prefix=PREFIX   specify a PREFIX for output files\n\
   -o, --output=FILE          leave output to FILE\n\
-  -g, --graph                also produce a VCG description of the automaton\n\
+  -g, --graph                also output a graph of the automaton\n\
+\n\
 "), stdout);
-      putc ('\n', stdout);
 
       fputs (_("\
 THINGS is a list of comma separated words that can include:\n\
@@ -289,10 +289,8 @@ THINGS is a list of comma separated words that can include:\n\
   `all'          include all the above information\n\
   `none'         disable the report\n\
 "), stdout);
-      putc ('\n', stdout);
 
-      fputs (_("\
-Report bugs to <" PACKAGE_BUGREPORT ">.\n"), stdout);
+      printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
     }
 
   exit (status);
@@ -410,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':
@@ -428,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':
@@ -476,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: