mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Warn about output files that are generated by the skeletons and that
conflict with other output files. * data/glr.c: Don't generate the header file here when glr.cc does. * src/files.c (file_names, file_names_count): New static globals. (compute_output_file_names): Invoke output_file_name_check for files not generated by the skeletons and remove existing checks. (output_file_name_check): New function that warns about conflicting output file names. (output_file_names_free): Free file_names. * src/files.h (output_file_name_check): Declare. * src/scan-skel.l: Invoke output_file_name_check for files generated by the skeletons. * tests/output.at (AT_CHECK_CONFLICTING_OUTPUT): New. (Conflicting output files): New tests.
This commit is contained in:
40
src/files.c
40
src/files.c
@@ -53,6 +53,10 @@ char *spec_graph_file = NULL; /* for -g. */
|
||||
char *spec_defines_file = NULL; /* for --defines. */
|
||||
char *parser_file_name;
|
||||
|
||||
/* All computed output file names. */
|
||||
static char **file_names = NULL;
|
||||
static int file_names_count = 0;
|
||||
|
||||
uniqstr grammar_file = NULL;
|
||||
uniqstr current_file = NULL;
|
||||
|
||||
@@ -292,11 +296,6 @@ compute_file_name_parts (void)
|
||||
void
|
||||
compute_output_file_names (void)
|
||||
{
|
||||
char const *name[4];
|
||||
int i;
|
||||
int j;
|
||||
int names = 0;
|
||||
|
||||
compute_file_name_parts ();
|
||||
|
||||
/* If not yet done. */
|
||||
@@ -305,7 +304,7 @@ compute_output_file_names (void)
|
||||
if (!header_extension)
|
||||
header_extension = xstrdup (".h");
|
||||
|
||||
name[names++] = parser_file_name =
|
||||
parser_file_name =
|
||||
(spec_outfile
|
||||
? xstrdup (spec_outfile)
|
||||
: concat2 (all_but_ext, src_extension));
|
||||
@@ -314,33 +313,40 @@ compute_output_file_names (void)
|
||||
{
|
||||
if (! spec_defines_file)
|
||||
spec_defines_file = concat2 (all_but_ext, header_extension);
|
||||
name[names++] = spec_defines_file;
|
||||
}
|
||||
|
||||
if (graph_flag)
|
||||
{
|
||||
if (! spec_graph_file)
|
||||
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
||||
name[names++] = spec_graph_file;
|
||||
output_file_name_check (spec_graph_file);
|
||||
}
|
||||
|
||||
if (report_flag)
|
||||
{
|
||||
spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT);
|
||||
name[names++] = spec_verbose_file;
|
||||
output_file_name_check (spec_verbose_file);
|
||||
}
|
||||
|
||||
for (j = 0; j < names; j++)
|
||||
for (i = 0; i < j; i++)
|
||||
if (strcmp (name[i], name[j]) == 0)
|
||||
warn (_("conflicting outputs to file %s"), quote (name[i]));
|
||||
|
||||
free (all_but_ext);
|
||||
free (all_but_tab_ext);
|
||||
free (src_extension);
|
||||
free (header_extension);
|
||||
}
|
||||
|
||||
void
|
||||
output_file_name_check (char const *file_name)
|
||||
{
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < file_names_count; i++)
|
||||
if (0 == strcmp (file_names[i], file_name))
|
||||
warn (_("conflicting outputs to file %s"), quote (file_name));
|
||||
}
|
||||
file_names = xnrealloc (file_names, ++file_names_count, sizeof *file_names);
|
||||
file_names[file_names_count-1] = xstrdup (file_name);
|
||||
}
|
||||
|
||||
void
|
||||
output_file_names_free (void)
|
||||
{
|
||||
@@ -349,4 +355,10 @@ output_file_names_free (void)
|
||||
free (spec_defines_file);
|
||||
free (parser_file_name);
|
||||
free (dir_prefix);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < file_names_count; i++)
|
||||
free (file_names[i]);
|
||||
}
|
||||
free (file_names);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ extern uniqstr current_file;
|
||||
|
||||
void compute_output_file_names (void);
|
||||
void output_file_names_free (void);
|
||||
void output_file_name_check (char const *file_name);
|
||||
|
||||
FILE *xfopen (const char *name, const char *mode);
|
||||
void xfclose (FILE *ptr);
|
||||
|
||||
@@ -81,6 +81,7 @@ int skel_lex (void);
|
||||
xfclose (yyout);
|
||||
}
|
||||
outname = xstrdup (file_name);
|
||||
output_file_name_check (file_name);
|
||||
yyout = xfopen (outname, "w");
|
||||
lineno = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user