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:
Akim Demaille
2019-01-18 08:30:47 +01:00
parent 4a690d3d19
commit 54ed577da0
3 changed files with 23 additions and 30 deletions

1
cfg.mk
View File

@@ -160,6 +160,7 @@ exclude = \
$(foreach a,$(1),$(eval $(subst $$,$$$$,exclude_file_name_regexp--sc_$(a))))
$(call exclude, \
bindtextdomain=^lib/main.c$$ \
cast_of_argument_to_free=^src/muscle-tab.c$$ \
preprocessor_indentation=^data/|^lib/|^src/parse-gram.[ch]$$ \
program_name=^lib/main.c$$ \
prohibit_always-defined_macros=^data/skeletons/yacc.c$$ \

View File

@@ -1,6 +1,7 @@
src/complain.c
src/conflicts.c
src/files.c
src/fixits.c
src/getargs.c
src/gram.c
src/graphviz.c

View File

@@ -45,7 +45,7 @@ char const *spec_outfile = NULL; /* for -o. */
char const *spec_file_prefix = NULL; /* for -b. */
location spec_file_prefix_loc = EMPTY_LOCATION_INIT;
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_graph_file = NULL; /* for -g. */
char *spec_xml_file = NULL; /* for -x. */
@@ -117,14 +117,12 @@ concat2 (char const *str1, char const *str2)
FILE *
xfopen (const char *name, const char *mode)
{
FILE *ptr;
ptr = fopen_safer (name, mode);
if (!ptr)
FILE *res = fopen_safer (name, mode);
if (!res)
error (EXIT_FAILURE, get_errno (),
_("%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
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)
{
const char *base, *tab, *ext;
file_name_split (spec_outfile, &base, &tab, &ext);
dir_prefix = xstrndup (spec_outfile, base - spec_outfile);
@@ -277,6 +274,7 @@ compute_file_name_parts (void)
}
else
{
const char *base, *tab, *ext;
file_name_split (grammar_file, &base, &tab, &ext);
if (spec_file_prefix)
@@ -376,16 +374,13 @@ output_file_name_check (char **file_name, bool source)
conflict = true;
}
else
{
int i;
for (i = 0; i < generated_files_size; i++)
for (int 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));
conflict = true;
}
}
if (conflict)
{
free (*file_name);
@@ -403,8 +398,7 @@ output_file_name_check (char **file_name, bool source)
void
unlink_generated_sources (void)
{
int i;
for (i = 0; i < generated_files_size; i++)
for (int i = 0; i < generated_files_size; i++)
if (generated_files[i].is_source)
/* Ignore errors. The file might not even exist. */
unlink (generated_files[i].name);
@@ -420,10 +414,7 @@ output_file_names_free (void)
free (spec_defines_file);
free (parser_file_name);
free (dir_prefix);
{
int i;
for (i = 0; i < generated_files_size; i++)
for (int i = 0; i < generated_files_size; i++)
free (generated_files[i].name);
}
free (generated_files);
}