mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 23:33:03 +00:00
style: various fixes
Some reported by syntax-check. * po/POTFILES.in: Add fixits.cc. * src/muscle-tab.c: Don't cast for free. * src/files.c: Reduce scopes. * cfg.mk: We need the cast for free in muscle_percent_define_insert.
This commit is contained in:
1
cfg.mk
1
cfg.mk
@@ -160,6 +160,7 @@ exclude = \
|
|||||||
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
|
||||||
$(call exclude, \
|
$(call exclude, \
|
||||||
bindtextdomain=^lib/main.c$$ \
|
bindtextdomain=^lib/main.c$$ \
|
||||||
|
cast_of_argument_to_free=^src/muscle-tab.c$$ \
|
||||||
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
|
||||||
program_name=^lib/main.c$$ \
|
program_name=^lib/main.c$$ \
|
||||||
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
src/complain.c
|
src/complain.c
|
||||||
src/conflicts.c
|
src/conflicts.c
|
||||||
src/files.c
|
src/files.c
|
||||||
|
src/fixits.c
|
||||||
src/getargs.c
|
src/getargs.c
|
||||||
src/gram.c
|
src/gram.c
|
||||||
src/graphviz.c
|
src/graphviz.c
|
||||||
|
|||||||
51
src/files.c
51
src/files.c
@@ -45,7 +45,7 @@ char const *spec_outfile = NULL; /* for -o. */
|
|||||||
char const *spec_file_prefix = NULL; /* for -b. */
|
char const *spec_file_prefix = NULL; /* for -b. */
|
||||||
location spec_file_prefix_loc = EMPTY_LOCATION_INIT;
|
location spec_file_prefix_loc = EMPTY_LOCATION_INIT;
|
||||||
char const *spec_name_prefix = NULL; /* for -p. */
|
char const *spec_name_prefix = NULL; /* for -p. */
|
||||||
location spec_name_prefix_loc = EMPTY_LOCATION_INIT;;
|
location spec_name_prefix_loc = EMPTY_LOCATION_INIT;
|
||||||
char *spec_verbose_file = NULL; /* for --verbose. */
|
char *spec_verbose_file = NULL; /* for --verbose. */
|
||||||
char *spec_graph_file = NULL; /* for -g. */
|
char *spec_graph_file = NULL; /* for -g. */
|
||||||
char *spec_xml_file = NULL; /* for -x. */
|
char *spec_xml_file = NULL; /* for -x. */
|
||||||
@@ -117,14 +117,12 @@ concat2 (char const *str1, char const *str2)
|
|||||||
FILE *
|
FILE *
|
||||||
xfopen (const char *name, const char *mode)
|
xfopen (const char *name, const char *mode)
|
||||||
{
|
{
|
||||||
FILE *ptr;
|
FILE *res = fopen_safer (name, mode);
|
||||||
|
if (!res)
|
||||||
ptr = fopen_safer (name, mode);
|
|
||||||
if (!ptr)
|
|
||||||
error (EXIT_FAILURE, get_errno (),
|
error (EXIT_FAILURE, get_errno (),
|
||||||
_("%s: cannot open"), quotearg_colon (name));
|
_("%s: cannot open"), quotearg_colon (name));
|
||||||
|
|
||||||
return ptr;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------.
|
/*-------------------------------------------------------------.
|
||||||
@@ -245,19 +243,18 @@ file_name_split (const char *file_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE or
|
||||||
|
GRAMMAR_FILE.
|
||||||
|
|
||||||
|
The precise -o name will be used for FTABLE. For other output
|
||||||
|
files, remove the ".c" or ".tab.c" suffix. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
compute_file_name_parts (void)
|
compute_file_name_parts (void)
|
||||||
{
|
{
|
||||||
const char *base, *tab, *ext;
|
|
||||||
|
|
||||||
/* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE
|
|
||||||
or GRAMMAR_FILE.
|
|
||||||
|
|
||||||
The precise -o name will be used for FTABLE. For other output
|
|
||||||
files, remove the ".c" or ".tab.c" suffix. */
|
|
||||||
if (spec_outfile)
|
if (spec_outfile)
|
||||||
{
|
{
|
||||||
|
const char *base, *tab, *ext;
|
||||||
file_name_split (spec_outfile, &base, &tab, &ext);
|
file_name_split (spec_outfile, &base, &tab, &ext);
|
||||||
dir_prefix = xstrndup (spec_outfile, base - spec_outfile);
|
dir_prefix = xstrndup (spec_outfile, base - spec_outfile);
|
||||||
|
|
||||||
@@ -277,6 +274,7 @@ compute_file_name_parts (void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const char *base, *tab, *ext;
|
||||||
file_name_split (grammar_file, &base, &tab, &ext);
|
file_name_split (grammar_file, &base, &tab, &ext);
|
||||||
|
|
||||||
if (spec_file_prefix)
|
if (spec_file_prefix)
|
||||||
@@ -376,16 +374,13 @@ output_file_name_check (char **file_name, bool source)
|
|||||||
conflict = true;
|
conflict = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
for (int i = 0; i < generated_files_size; i++)
|
||||||
int i;
|
if (STREQ (generated_files[i].name, *file_name))
|
||||||
for (i = 0; i < generated_files_size; i++)
|
{
|
||||||
if (STREQ (generated_files[i].name, *file_name))
|
complain (NULL, Wother, _("conflicting outputs to file %s"),
|
||||||
{
|
quote (generated_files[i].name));
|
||||||
complain (NULL, Wother, _("conflicting outputs to file %s"),
|
conflict = true;
|
||||||
quote (generated_files[i].name));
|
}
|
||||||
conflict = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (conflict)
|
if (conflict)
|
||||||
{
|
{
|
||||||
free (*file_name);
|
free (*file_name);
|
||||||
@@ -403,8 +398,7 @@ output_file_name_check (char **file_name, bool source)
|
|||||||
void
|
void
|
||||||
unlink_generated_sources (void)
|
unlink_generated_sources (void)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < generated_files_size; i++)
|
||||||
for (i = 0; i < generated_files_size; i++)
|
|
||||||
if (generated_files[i].is_source)
|
if (generated_files[i].is_source)
|
||||||
/* Ignore errors. The file might not even exist. */
|
/* Ignore errors. The file might not even exist. */
|
||||||
unlink (generated_files[i].name);
|
unlink (generated_files[i].name);
|
||||||
@@ -420,10 +414,7 @@ output_file_names_free (void)
|
|||||||
free (spec_defines_file);
|
free (spec_defines_file);
|
||||||
free (parser_file_name);
|
free (parser_file_name);
|
||||||
free (dir_prefix);
|
free (dir_prefix);
|
||||||
{
|
for (int i = 0; i < generated_files_size; i++)
|
||||||
int i;
|
free (generated_files[i].name);
|
||||||
for (i = 0; i < generated_files_size; i++)
|
|
||||||
free (generated_files[i].name);
|
|
||||||
}
|
|
||||||
free (generated_files);
|
free (generated_files);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user