X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/4d699f44e65d29b4d49cf68d7a3b4bf856eb5d1b..b6403170609485abe21038a65255ae4d3825ec00:/src/getargs.c diff --git a/src/getargs.c b/src/getargs.c index 5e04ab0f..8596958c 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -61,8 +61,6 @@ bool glr_parser = false; int report_flag = report_none; int trace_flag = trace_none; -int warnings_flag = warnings_conflicts_sr | warnings_conflicts_rr - | warnings_other; static struct bison_language const valid_languages[] = { { "c", "c-skel.m4", ".c", ".h", true }, @@ -102,7 +100,7 @@ flags_argmatch (const char *option, args = strtok (args, ","); while (args) { - int no = strncmp (args, "no-", 3) == 0 ? 3 : 0; + int no = STRPREFIX_LIT ("no-", args) ? 3 : 0; int value = XARGMATCH (option, args + no, keys, values); if (value == 0) { @@ -129,15 +127,15 @@ flags_argmatch (const char *option, * * \param FlagName the flag familly to update. * \param Args the effective sub arguments to decode. + * \param All the "all" value. * * \arg FlagName_args the list of keys. * \arg FlagName_types the list of values. - * \arg FlagName_all the all value. * \arg FlagName_flag the flag to update. */ -#define FLAGS_ARGMATCH(FlagName, Args) \ +#define FLAGS_ARGMATCH(FlagName, Args, All) \ flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \ - FlagName ## _all, &FlagName ## _flag, Args) + All, &FlagName ## _flag, Args) /*----------------------. @@ -241,19 +239,18 @@ static const char * const warnings_args[] = static const int warnings_types[] = { - warnings_none, - warnings_midrule_values, - warnings_yacc, - warnings_conflicts_sr, - warnings_conflicts_rr, - warnings_other, - warnings_all, - warnings_error + Wnone, + Wmidrule_values, + Wyacc, + Wconflicts_sr, + Wconflicts_rr, + Wother, + Wall, + Werror }; ARGMATCH_VERIFY (warnings_args, warnings_types); - /*-------------------------------------------. | Display the help message and exit STATUS. | `-------------------------------------------*/ @@ -403,7 +400,8 @@ skeleton_arg (char const *arg, int prio, location loc) skeleton = arg; } else if (prio == skeleton_prio) - complain_at (loc, _("multiple skeleton declarations are invalid")); + complain_at (loc, complaint, + _("multiple skeleton declarations are invalid")); } void @@ -428,7 +426,7 @@ language_argmatch (char const *arg, int prio, location loc) else return; - complain_at (loc, msg, quotearg_colon (arg)); + complain_at (loc, complaint, msg, quotearg_colon (arg)); } /*----------------------. @@ -559,7 +557,7 @@ getargs (int argc, char *argv[]) case 'F': /* -FNAME[=VALUE]. */ { char* name = optarg; - char* value = mbschr (optarg, '='); + char* value = strchr (optarg, '='); if (value) *value++ = 0; muscle_percent_define_insert (name, command_line_location (), @@ -584,7 +582,7 @@ getargs (int argc, char *argv[]) break; case 'T': - FLAGS_ARGMATCH (trace, optarg); + FLAGS_ARGMATCH (trace, optarg, trace_all); break; case 'V': @@ -592,7 +590,7 @@ getargs (int argc, char *argv[]) exit (EXIT_SUCCESS); case 'W': - FLAGS_ARGMATCH (warnings, optarg); + FLAGS_ARGMATCH (warnings, optarg, Wall); break; case 'b': @@ -603,13 +601,19 @@ getargs (int argc, char *argv[]) /* Here, the -d and --defines options are differentiated. */ defines_flag = true; if (optarg) - spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_defines_file); + spec_defines_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'g': graph_flag = true; if (optarg) - spec_graph_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_graph_file); + spec_graph_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'h': @@ -632,7 +636,7 @@ getargs (int argc, char *argv[]) break; case 'r': - FLAGS_ARGMATCH (report, optarg); + FLAGS_ARGMATCH (report, optarg, report_all); break; case 't': @@ -648,7 +652,10 @@ getargs (int argc, char *argv[]) case 'x': xml_flag = true; if (optarg) - spec_xml_file = xstrdup (AS_FILE_NAME (optarg)); + { + free (spec_xml_file); + spec_xml_file = xstrdup (AS_FILE_NAME (optarg)); + } break; case 'y': @@ -665,10 +672,11 @@ getargs (int argc, char *argv[]) exit (EXIT_SUCCESS); case PRINT_DATADIR_OPTION: - printf ("%s\n", compute_pkgdatadir ()); + printf ("%s\n", pkgdatadir ()); exit (EXIT_SUCCESS); case REPORT_FILE_OPTION: + free (spec_verbose_file); spec_verbose_file = xstrdup (AS_FILE_NAME (optarg)); break;