--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.
This commit is contained in:
Akim Demaille
2019-07-07 15:43:23 +02:00
parent 44a56b20ac
commit e29ac453d0
2 changed files with 22 additions and 12 deletions

View File

@@ -561,6 +561,7 @@ static char const short_options[] =
enum enum
{ {
COLOR_OPTION = CHAR_MAX + 1, COLOR_OPTION = CHAR_MAX + 1,
FIXED_OUTPUT_FILES_OPTION,
LOCATIONS_OPTION, LOCATIONS_OPTION,
PRINT_DATADIR_OPTION, PRINT_DATADIR_OPTION,
PRINT_LOCALEDIR_OPTION, PRINT_LOCALEDIR_OPTION,
@@ -607,9 +608,9 @@ static struct option const long_options[] =
{ "xml", optional_argument, 0, 'x' }, { "xml", optional_argument, 0, 'x' },
/* Hidden. */ /* Hidden. */
{ "fixed-output-files", no_argument, 0, 'y' }, { "fixed-output-files", no_argument, 0, FIXED_OUTPUT_FILES_OPTION },
{ "output-file", required_argument, 0, 'o' }, { "output-file", required_argument, 0, 'o' },
{ "trace", optional_argument, 0, 'T' }, { "trace", optional_argument, 0, 'T' },
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@@ -665,6 +666,8 @@ getargs (int argc, char *argv[])
int c; int c;
while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
!= -1) != -1)
{
location loc = command_line_location ();
switch (c) switch (c)
{ {
/* ASCII Sorting for short options (i.e., upper case then /* ASCII Sorting for short options (i.e., upper case then
@@ -697,7 +700,7 @@ getargs (int argc, char *argv[])
*end = 0; *end = 0;
} }
} }
muscle_percent_define_insert (name, command_line_location (), muscle_percent_define_insert (name, loc,
kind, value ? value : "", kind, value ? value : "",
c == 'D' ? MUSCLE_PERCENT_DEFINE_D c == 'D' ? MUSCLE_PERCENT_DEFINE_D
: MUSCLE_PERCENT_DEFINE_F); : MUSCLE_PERCENT_DEFINE_F);
@@ -705,13 +708,11 @@ getargs (int argc, char *argv[])
break; break;
case 'L': case 'L':
language_argmatch (optarg, command_line_prio, language_argmatch (optarg, command_line_prio, loc);
command_line_location ());
break; break;
case 'S': case 'S':
skeleton_arg (optarg, command_line_prio, skeleton_arg (optarg, command_line_prio, loc);
command_line_location ());
break; break;
case 'T': case 'T':
@@ -778,7 +779,7 @@ getargs (int argc, char *argv[])
case 't': case 't':
muscle_percent_define_insert ("parse.trace", muscle_percent_define_insert ("parse.trace",
command_line_location (), loc,
muscle_keyword, "", muscle_keyword, "",
MUSCLE_PERCENT_DEFINE_D); MUSCLE_PERCENT_DEFINE_D);
break; break;
@@ -803,16 +804,22 @@ getargs (int argc, char *argv[])
case 'y': case 'y':
warning_argmatch ("yacc", 0, 0); warning_argmatch ("yacc", 0, 0);
yacc_loc = command_line_location (); yacc_loc = loc;
break; break;
case COLOR_OPTION: case COLOR_OPTION:
/* Handled in getargs_colors. */ /* Handled in getargs_colors. */
break; 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: case LOCATIONS_OPTION:
muscle_percent_define_ensure ("locations", muscle_percent_define_ensure ("locations", loc, true);
command_line_location (), true);
break; break;
case PRINT_LOCALEDIR_OPTION: case PRINT_LOCALEDIR_OPTION:
@@ -835,6 +842,7 @@ getargs (int argc, char *argv[])
default: default:
usage (EXIT_FAILURE); usage (EXIT_FAILURE);
} }
}
if (argc - optind != 1) if (argc - optind != 1)
{ {

View File

@@ -74,6 +74,8 @@ AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c], AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
[foo.output foo.tab.c foo.tab.h]) [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], AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -y],
[y.dot y.output y.tab.c y.tab.h y.xml]) [y.dot y.output y.tab.c y.tab.h y.xml])
AT_CHECK_OUTPUT([foo.y], [%require "3.4"], [-dv -g --xml -y], AT_CHECK_OUTPUT([foo.y], [%require "3.4"], [-dv -g --xml -y],