maint: use STREQ/STRNEQ.

* doc/bison.texinfo: Space change.
	* src/system.h (STREQ, STRNEQ): New.
	* src/files.c, src/ielr.c, src/lalr.c, src/muscle-tab.c,
	* src/output.c, src/print.c, src/print_graph.c,
	* src/reader.c, src/scan-skel.l, src/tables.c,
	* src/uniqstr.c:
	Use them.
	* src/scan-gram.l: Do not use streq.h, use system.h's STREQ.
	* cfg.mk: The documentation is an exception.
This commit is contained in:
Akim Demaille
2012-02-23 18:51:51 +01:00
parent 71b52b1342
commit f518dbaf46
15 changed files with 34 additions and 34 deletions

5
cfg.mk
View File

@@ -35,9 +35,7 @@ url_dir_list = \
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
sc_immutable_NEWS \
sc_prohibit_always_true_header_tests \
sc_prohibit_atoi_atof \
sc_prohibit_strcmp
sc_prohibit_atoi_atof
# The local directory containing the checked-out copy of gnulib used in
# this release. Used solely to get a date for the "announcement" target.
@@ -61,6 +59,7 @@ $(call exclude, \
prohibit_always-defined_macros+=?|^src/(parse-gram.c|system.h)$$ \
prohibit_always-defined_macros+=?|^tests/regression.at$$ \
prohibit_empty_lines_at_EOF=^src/parse-gram.h$$ \
prohibit_strcmp=^doc/bison\.texinfo$$ \
require_config_h_first=^(lib/yyerror|data/(glr|yacc))\.c$$ \
space_tab=^tests/(input|c\+\+)\.at$$ \
unmarked_diagnostics=^djgpp/ \

View File

@@ -2569,7 +2569,7 @@ getsym (char const *sym_name)
symrec *ptr;
for (ptr = sym_table; ptr != (symrec *) 0;
ptr = (symrec *)ptr->next)
if (strcmp (ptr->name,sym_name) == 0)
if (strcmp (ptr->name, sym_name) == 0)
return ptr;
return 0;
@}

View File

@@ -142,7 +142,7 @@ xfclose (FILE *ptr)
static void
compute_exts_from_gf (const char *ext)
{
if (strcmp (ext, ".y") == 0)
if (STREQ (ext, ".y"))
{
src_extension = xstrdup (language->src_extension);
header_extension = xstrdup (language->header_extension);
@@ -347,7 +347,7 @@ void
output_file_name_check (char **file_name)
{
bool conflict = false;
if (0 == strcmp (*file_name, grammar_file))
if (STREQ (*file_name, grammar_file))
{
complain (_("refusing to overwrite the input file %s"),
quote (*file_name));
@@ -357,7 +357,7 @@ output_file_name_check (char **file_name)
{
int i;
for (i = 0; i < file_names_count; i++)
if (0 == strcmp (file_names[i], *file_name))
if (STREQ (file_names[i], *file_name))
{
warn (_("conflicting outputs to file %s"),
quote (*file_name));

View File

@@ -1095,11 +1095,11 @@ ielr (void)
/* Examine user options. */
{
char *type = muscle_percent_define_get ("lr.type");
if (0 == strcmp (type, "lalr"))
if (STREQ (type, "lalr"))
lr_type = LR_TYPE__LALR;
else if (0 == strcmp (type, "ielr"))
else if (STREQ (type, "ielr"))
lr_type = LR_TYPE__IELR;
else if (0 == strcmp (type, "canonical-lr"))
else if (STREQ (type, "canonical-lr"))
lr_type = LR_TYPE__CANONICAL_LR;
else
aver (false);

View File

@@ -372,8 +372,7 @@ initialize_LA (void)
{
char *default_reductions =
muscle_percent_define_get ("lr.default-reductions");
default_reduction_only_for_accept =
0 == strcmp (default_reductions, "accepting");
default_reduction_only_for_accept = STREQ (default_reductions, "accepting");
free (default_reductions);
}

View File

@@ -50,7 +50,7 @@ hash_compare_muscles (void const *x, void const *y)
{
muscle_entry const *m1 = x;
muscle_entry const *m2 = y;
return strcmp (m1->key, m2->key) == 0;
return STREQ (m1->key, m2->key);
}
static size_t
@@ -407,7 +407,7 @@ muscle_percent_variable_update (char const *variable)
};
int i;
for (i = 0; i < sizeof conversion / sizeof *conversion; ++i)
if (!strcmp (conversion[i].obsolete, variable))
if (STREQ (conversion[i].obsolete, variable))
return conversion[i].updated;
return variable;
}
@@ -555,9 +555,9 @@ muscle_percent_define_flag_if (char const *variable)
if (muscle_percent_define_ifdef (variable))
{
char *value = muscle_percent_define_get (variable);
if (value[0] == '\0' || 0 == strcmp (value, "true"))
if (value[0] == '\0' || STREQ (value, "true"))
result = true;
else if (0 == strcmp (value, "false"))
else if (STREQ (value, "false"))
result = false;
else if (!muscle_find_const (invalid_boolean_name))
{
@@ -614,7 +614,7 @@ muscle_percent_define_check_values (char const * const *values)
{
for (++values; *values; ++values)
{
if (0 == strcmp (value, *values))
if (STREQ (value, *values))
break;
}
if (!*values)

View File

@@ -689,7 +689,7 @@ prepare (void)
bool use_push_for_pull_flag = false;
if (use_push_for_pull_env != NULL
&& use_push_for_pull_env[0] != '\0'
&& 0 != strcmp (use_push_for_pull_env, "0"))
&& STRNEQ (use_push_for_pull_env, "0"))
use_push_for_pull_flag = true;
/* Flags. */

View File

@@ -336,8 +336,8 @@ print_reductions (FILE *out, state *s)
char *default_reductions =
muscle_percent_define_get ("lr.default-reductions");
print_reduction (out, width, _("$default"), default_reduction, true);
aver (0 == strcmp (default_reductions, "most")
|| (0 == strcmp (default_reductions, "consistent")
aver (STREQ (default_reductions, "most")
|| (STREQ (default_reductions, "consistent")
&& default_reduction_only)
|| (reds->num == 1 && reds->rules[0]->number == 0));
free (default_reductions);

View File

@@ -133,7 +133,7 @@ print_actions (state const *s, FILE *fgraph)
: "dashed");
if (TRANSITION_IS_ERROR (trans, i)
&& strcmp (symbols[sym]->tag, "error") != 0)
&& STRNEQ (symbols[sym]->tag, "error"))
abort ();
output_edge (s->number, s1->number,
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,

View File

@@ -638,7 +638,7 @@ prepare_percent_define_front_end_variables (void)
default. */
muscle_percent_define_default ("lr.type", "lalr");
lr_type = muscle_percent_define_get ("lr.type");
if (0 != strcmp (lr_type, "canonical-lr"))
if (STRNEQ (lr_type, "canonical-lr"))
muscle_percent_define_default ("lr.default-reductions", "most");
else
muscle_percent_define_default ("lr.default-reductions", "accepting");

View File

@@ -39,7 +39,6 @@
#include <ctype.h>
#include <mbswidth.h>
#include <quote.h>
#include <streq.h>
#include <src/scan-gram.h>
@@ -968,7 +967,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end)
loc.end = scanner_cursor;
token_end = quote (token_end);
// Instead of '\'', display "'".
if (STREQ (token_end, "'\\''", '\'', '\\', '\'', '\'', 0,0,0,0,0))
if (STREQ (token_end, "'\\''"))
token_end = "\"'\"";
complain_at (loc, _(msgid), token_end);
}

View File

@@ -179,15 +179,15 @@ at_directive_perform (int at_directive_argc,
char *at_directive_argv[],
char **outnamep, int *out_linenop)
{
if (0 == strcmp (at_directive_argv[0], "@basename"))
if (STREQ (at_directive_argv[0], "@basename"))
{
if (at_directive_argc > 2)
fail_for_at_directive_too_many_args (at_directive_argv[0]);
fputs (last_component (at_directive_argv[1]), yyout);
}
else if (0 == strcmp (at_directive_argv[0], "@warn")
|| 0 == strcmp (at_directive_argv[0], "@complain")
|| 0 == strcmp (at_directive_argv[0], "@fatal"))
else if (STREQ (at_directive_argv[0], "@warn")
|| STREQ (at_directive_argv[0], "@complain")
|| STREQ (at_directive_argv[0], "@fatal"))
{
void (*func)(char const *, ...);
switch (at_directive_argv[0][1])
@@ -223,9 +223,9 @@ at_directive_perform (int at_directive_argc,
break;
}
}
else if (0 == strcmp (at_directive_argv[0], "@warn_at")
|| 0 == strcmp (at_directive_argv[0], "@complain_at")
|| 0 == strcmp (at_directive_argv[0], "@fatal_at"))
else if (STREQ (at_directive_argv[0], "@warn_at")
|| STREQ (at_directive_argv[0], "@complain_at")
|| STREQ (at_directive_argv[0], "@fatal_at"))
{
void (*func)(location, char const *, ...);
location loc;
@@ -266,7 +266,7 @@ at_directive_perform (int at_directive_argc,
break;
}
}
else if (0 == strcmp (at_directive_argv[0], "@output"))
else if (STREQ (at_directive_argv[0], "@output"))
{
if (at_directive_argc > 2)
fail_for_at_directive_too_many_args (at_directive_argv[0]);

View File

@@ -39,6 +39,9 @@
#include <stdlib.h>
#include <string.h>
#define STREQ(L, R) (strcmp(L, R) == 0)
#define STRNEQ(L, R) (!STREQ(L, R))
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

View File

@@ -309,7 +309,7 @@ action_row (state *s)
{
char *default_reductions =
muscle_percent_define_get ("lr.default-reductions");
if (0 != strcmp (default_reductions, "most") && !s->consistent)
if (STRNEQ (default_reductions, "most") && !s->consistent)
nodefault = true;
free (default_reductions);
}

View File

@@ -111,7 +111,7 @@ uniqstr_print_processor (void *ustr, void *null ATTRIBUTE_UNUSED)
static bool
hash_compare_uniqstr (void const *m1, void const *m2)
{
return strcmp (m1, m2) == 0;
return STREQ (m1, m2);
}
static size_t