From e29ac453d06403d2b512731e79fcee98b7c786f0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 7 Jul 2019 15:43:23 +0200 Subject: [PATCH] --fixed-output-files: detach from --yacc See the previous commit. This option should be removed, -o suffices. * src/getargs.c (FIXED_OUTPUT_FILES): New. Add support for it. (getargs): Define loc, and use it. This is safer when we need to pass a pointer to a location. --- src/getargs.c | 32 ++++++++++++++++++++------------ tests/output.at | 2 ++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/getargs.c b/src/getargs.c index ea2a0fd6..68894633 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -561,6 +561,7 @@ static char const short_options[] = enum { COLOR_OPTION = CHAR_MAX + 1, + FIXED_OUTPUT_FILES_OPTION, LOCATIONS_OPTION, PRINT_DATADIR_OPTION, PRINT_LOCALEDIR_OPTION, @@ -607,9 +608,9 @@ static struct option const long_options[] = { "xml", optional_argument, 0, 'x' }, /* Hidden. */ - { "fixed-output-files", no_argument, 0, 'y' }, - { "output-file", required_argument, 0, 'o' }, - { "trace", optional_argument, 0, 'T' }, + { "fixed-output-files", no_argument, 0, FIXED_OUTPUT_FILES_OPTION }, + { "output-file", required_argument, 0, 'o' }, + { "trace", optional_argument, 0, 'T' }, {0, 0, 0, 0} }; @@ -665,6 +666,8 @@ getargs (int argc, char *argv[]) int c; while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) != -1) + { + location loc = command_line_location (); switch (c) { /* ASCII Sorting for short options (i.e., upper case then @@ -697,7 +700,7 @@ getargs (int argc, char *argv[]) *end = 0; } } - muscle_percent_define_insert (name, command_line_location (), + muscle_percent_define_insert (name, loc, kind, value ? value : "", c == 'D' ? MUSCLE_PERCENT_DEFINE_D : MUSCLE_PERCENT_DEFINE_F); @@ -705,13 +708,11 @@ getargs (int argc, char *argv[]) break; case 'L': - language_argmatch (optarg, command_line_prio, - command_line_location ()); + language_argmatch (optarg, command_line_prio, loc); break; case 'S': - skeleton_arg (optarg, command_line_prio, - command_line_location ()); + skeleton_arg (optarg, command_line_prio, loc); break; case 'T': @@ -778,7 +779,7 @@ getargs (int argc, char *argv[]) case 't': muscle_percent_define_insert ("parse.trace", - command_line_location (), + loc, muscle_keyword, "", MUSCLE_PERCENT_DEFINE_D); break; @@ -803,16 +804,22 @@ getargs (int argc, char *argv[]) case 'y': warning_argmatch ("yacc", 0, 0); - yacc_loc = command_line_location (); + yacc_loc = loc; break; case COLOR_OPTION: /* Handled in getargs_colors. */ break; + case FIXED_OUTPUT_FILES_OPTION: + complain (&loc, Wdeprecated, + _("deprecated option: %s, use %s"), + quote ("--fixed-output-files"), quote_n (1, "-o y.tab.c")); + spec_outfile = "y.tab.c"; + break; + case LOCATIONS_OPTION: - muscle_percent_define_ensure ("locations", - command_line_location (), true); + muscle_percent_define_ensure ("locations", loc, true); break; case PRINT_LOCALEDIR_OPTION: @@ -835,6 +842,7 @@ getargs (int argc, char *argv[]) default: usage (EXIT_FAILURE); } + } if (argc - optind != 1) { diff --git a/tests/output.at b/tests/output.at index 11ef8731..fd880f04 100644 --- a/tests/output.at +++ b/tests/output.at @@ -74,6 +74,8 @@ AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c], AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c], [foo.output foo.tab.c foo.tab.h]) +AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml --fixed-output-files], + [y.dot y.output y.tab.c y.tab.h y.xml]) AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -y], [y.dot y.output y.tab.c y.tab.h y.xml]) AT_CHECK_OUTPUT([foo.y], [%require "3.4"], [-dv -g --xml -y],