From: Paul Eggert Date: Wed, 17 Sep 2025 06:08:01 +0000 (-0700) Subject: stringeq: prefer streq to strcmp in other modules X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26fd35455dbff3506a960bb40a28a78db26a2517;p=thirdparty%2Fgnulib.git stringeq: prefer streq to strcmp in other modules * lib/acl-internal.c, lib/argmatch.c, lib/argp-help.c: * lib/argp-parse.c, lib/bcp47.c, lib/c32_get_mapping.c: * lib/c32_get_type_test.c, lib/concat-filename.c: * lib/cpu-supports.h, lib/dfa.c, lib/duplocale.c, lib/exclude.c: * lib/findprog-in.c, lib/findprog.c, lib/fopen.c, lib/freopen.c: * lib/fts.c, lib/gen-uni-tables.c, lib/getfilecon.c: * lib/getlogin.c, lib/getugroups.c, lib/hard-locale.c: * lib/hashcode-named-file.c, lib/hashkey-string.c: * lib/iconv_open.c, lib/idcache.c, lib/lc-charset-unicode.c: * lib/localcharset.c, lib/localename-environ.c: * lib/localename-unsafe.c, lib/mbs_endswith.c, lib/mountlist.c: * lib/newlocale.c, lib/nl_langinfo.c, lib/nproc.c, lib/open.c: * lib/os2-spawn.c, lib/parse-datetime.y, lib/popen.c: * lib/progreloc.c, lib/propername.c, lib/pt_chown.c, lib/putenv.c: * lib/qcopy-acl.c, lib/readutmp.c, lib/rpmatch.c: * lib/setlocale-fixes.c, lib/setlocale.c, lib/sig2str.c: * lib/spawni.c, lib/stat.c, lib/str_endswith.c, lib/streq.h: * lib/striconveha.c, lib/struniq.h, lib/supersede.c: * lib/time_rz.c, lib/unicodeio.c, lib/vasnprintf.c: * lib/vc-mtime.c, lib/wctrans-impl.h, lib/wctype-impl.h: Prefer streq to strcmp when either will do. Do not make this change to files shared with glibc. Do not make the change to test files, at least not for now. * lib/gen-uni-tables.c (streq): New static function, in same style. * modules/acl-permissions, modules/argp, modules/c32_get_mapping: * modules/c32_get_type_test, modules/concat-filename: * modules/cpu-supports, modules/dfa, modules/duplocale: * modules/exclude, modules/findprog, modules/findprog-in: * modules/fopen, modules/fopen-gnu, modules/freopen, modules/fts: * modules/getlocalename_l-simple, modules/getlocalename_l-unsafe: * modules/getlogin, modules/getugroups, modules/hard-locale: * modules/hashcode-named-file, modules/hashkey-string: * modules/iconv_open, modules/idcache, modules/localcharset: * modules/localename, modules/localename-unsafe: * modules/mbs_endswith, modules/mountlist, modules/newlocale: * modules/nl_langinfo, modules/nproc, modules/open: * modules/parse-datetime, modules/popen: * modules/posix_spawn-internal, modules/propername: * modules/pt_chown, modules/putenv-gnu, modules/qcopy-acl: * modules/rpmatch, modules/selinux-h, modules/setenv: * modules/setlocale, modules/setlocale-fixes, modules/sig2str: * modules/spawn-pipe, modules/stat, modules/str_endswith: * modules/streq, modules/striconveha, modules/supersede: * modules/time_rz, modules/uchar-h, modules/unicodeio: * modules/uniconv/base, modules/wctrans, modules/wctype: (Depends-on): Add stringeq. --- diff --git a/ChangeLog b/ChangeLog index e99039ed81..d0ed07e64f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,53 @@ 2025-09-17 Paul Eggert + stringeq: prefer streq to strcmp in other modules + * lib/acl-internal.c, lib/argmatch.c, lib/argp-help.c: + * lib/argp-parse.c, lib/bcp47.c, lib/c32_get_mapping.c: + * lib/c32_get_type_test.c, lib/concat-filename.c: + * lib/cpu-supports.h, lib/dfa.c, lib/duplocale.c, lib/exclude.c: + * lib/findprog-in.c, lib/findprog.c, lib/fopen.c, lib/freopen.c: + * lib/fts.c, lib/gen-uni-tables.c, lib/getfilecon.c: + * lib/getlogin.c, lib/getugroups.c, lib/hard-locale.c: + * lib/hashcode-named-file.c, lib/hashkey-string.c: + * lib/iconv_open.c, lib/idcache.c, lib/lc-charset-unicode.c: + * lib/localcharset.c, lib/localename-environ.c: + * lib/localename-unsafe.c, lib/mbs_endswith.c, lib/mountlist.c: + * lib/newlocale.c, lib/nl_langinfo.c, lib/nproc.c, lib/open.c: + * lib/os2-spawn.c, lib/parse-datetime.y, lib/popen.c: + * lib/progreloc.c, lib/propername.c, lib/pt_chown.c, lib/putenv.c: + * lib/qcopy-acl.c, lib/readutmp.c, lib/rpmatch.c: + * lib/setlocale-fixes.c, lib/setlocale.c, lib/sig2str.c: + * lib/spawni.c, lib/stat.c, lib/str_endswith.c, lib/streq.h: + * lib/striconveha.c, lib/struniq.h, lib/supersede.c: + * lib/time_rz.c, lib/unicodeio.c, lib/vasnprintf.c: + * lib/vc-mtime.c, lib/wctrans-impl.h, lib/wctype-impl.h: + Prefer streq to strcmp when either will do. + Do not make this change to files shared with glibc. + Do not make the change to test files, at least not for now. + * lib/gen-uni-tables.c (streq): New static function, in same style. + * modules/acl-permissions, modules/argp, modules/c32_get_mapping: + * modules/c32_get_type_test, modules/concat-filename: + * modules/cpu-supports, modules/dfa, modules/duplocale: + * modules/exclude, modules/findprog, modules/findprog-in: + * modules/fopen, modules/fopen-gnu, modules/freopen, modules/fts: + * modules/getlocalename_l-simple, modules/getlocalename_l-unsafe: + * modules/getlogin, modules/getugroups, modules/hard-locale: + * modules/hashcode-named-file, modules/hashkey-string: + * modules/iconv_open, modules/idcache, modules/localcharset: + * modules/localename, modules/localename-unsafe: + * modules/mbs_endswith, modules/mountlist, modules/newlocale: + * modules/nl_langinfo, modules/nproc, modules/open: + * modules/parse-datetime, modules/popen: + * modules/posix_spawn-internal, modules/propername: + * modules/pt_chown, modules/putenv-gnu, modules/qcopy-acl: + * modules/rpmatch, modules/selinux-h, modules/setenv: + * modules/setlocale, modules/setlocale-fixes, modules/sig2str: + * modules/spawn-pipe, modules/stat, modules/str_endswith: + * modules/streq, modules/striconveha, modules/supersede: + * modules/time_rz, modules/uchar-h, modules/unicodeio: + * modules/uniconv/base, modules/wctrans, modules/wctype: + (Depends-on): Add stringeq. + stringeq: prefer memeq to memcmp in other modules * lib/argmatch.c, lib/argmatch.h, lib/backupfile.c, lib/bcp47.c: * lib/boot-time.c, lib/csharpcomp.c, lib/csharpexec.c: diff --git a/lib/acl-internal.c b/lib/acl-internal.c index 11bd15c432..b8a6ed06c3 100644 --- a/lib/acl-internal.c +++ b/lib/acl-internal.c @@ -118,9 +118,9 @@ acl_access_nontrivial (acl_t acl) - S-1-5-32-545 (group "Users") Cf. and look at the output of the 'mkgroup' command. */ - ignorable = (strcmp (group_sid, "S-1-5-18") == 0 - || strcmp (group_sid, "S-1-5-32-544") == 0 - || strcmp (group_sid, "S-1-5-32-545") == 0); + ignorable = (streq (group_sid, "S-1-5-18") + || streq (group_sid, "S-1-5-32-544") + || streq (group_sid, "S-1-5-32-545")); } } if (!ignorable) diff --git a/lib/argmatch.c b/lib/argmatch.c index 4dcea99ccb..a1efc6fa22 100644 --- a/lib/argmatch.c +++ b/lib/argmatch.c @@ -126,7 +126,7 @@ argmatch_exact (const char *arg, const char *const *arglist) /* Test elements for exact match. */ for (i = 0; arglist[i]; i++) { - if (!strcmp (arglist[i], arg)) + if (streq (arglist[i], arg)) return i; } diff --git a/lib/argp-help.c b/lib/argp-help.c index fc6fcf456b..f742e1870f 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -654,7 +654,7 @@ hol_find_entry (struct hol *hol, const char *name) unsigned num_opts = entry->num; while (num_opts-- > 0) - if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0) + if (opt->name && ovisible (opt) && streq (opt->name, name)) return entry; else opt++; diff --git a/lib/argp-parse.c b/lib/argp-parse.c index 34ffd4f574..265dafa2d5 100644 --- a/lib/argp-parse.c +++ b/lib/argp-parse.c @@ -177,7 +177,7 @@ find_long_option (struct option *long_options, const char *name) { struct option *l = long_options; while (l->name != NULL) - if (name != NULL && strcmp (l->name, name) == 0) + if (name != NULL && streq (l->name, name)) return l - long_options; else l++; @@ -814,8 +814,7 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey) { parser->try_getopt = 0; if (parser->state.next > 1 - && strcmp (parser->state.argv[parser->state.next - 1], QUOTE) - == 0) + && streq (parser->state.argv[parser->state.next - 1], QUOTE)) /* Not only is this the end of the options, but it's a "quoted" region, which may have args that *look* like options, so we definitely shouldn't try to use getopt past diff --git a/lib/bcp47.c b/lib/bcp47.c index 33a078c8a2..dc7e06e28b 100644 --- a/lib/bcp47.c +++ b/lib/bcp47.c @@ -192,14 +192,14 @@ void xpg_to_bcp47 (char *bcp47, const char *xpg) { /* Special cases. */ - if (strcmp (xpg, "") == 0) + if (streq (xpg, "")) fail: { strcpy (bcp47, "und"); return; } if ((xpg[0] == 'C' && (xpg[1] == '\0' || xpg[1] == '.')) - || strcmp (xpg, "POSIX") == 0) + || streq (xpg, "POSIX")) { /* The "C" (or "C.UTF-8") and "POSIX" locales most closely resemble the "en_US" locale. */ @@ -367,7 +367,7 @@ void bcp47_to_xpg (char *xpg, const char *bcp47, const char *codeset) { /* Special cases. */ - if (strcmp (bcp47, "") == 0) + if (streq (bcp47, "")) fail: { strcpy (xpg, ""); @@ -514,7 +514,7 @@ bcp47_to_xpg (char *xpg, const char *bcp47, const char *codeset) default_script_in_territory (xpg, territory); if (sp != NULL) { - if (strcmp (script, sp->name) == 0) + if (streq (script, sp->name)) script = NULL; } else if (memeq (xpg, "zh", 2)) @@ -530,7 +530,7 @@ bcp47_to_xpg (char *xpg, const char *bcp47, const char *codeset) default_script_for_language2 (xpg); if (sp != NULL) { - if (strcmp (script, sp->name) == 0) + if (streq (script, sp->name)) script = NULL; } else if (memeq (xpg, "iu", 2)) @@ -545,7 +545,7 @@ bcp47_to_xpg (char *xpg, const char *bcp47, const char *codeset) default_script_for_language3 (xpg); if (sp != NULL) { - if (strcmp (script, sp->name) == 0) + if (streq (script, sp->name)) script = NULL; } else if (memeq (xpg, "nan", 3)) diff --git a/lib/c32_get_mapping.c b/lib/c32_get_mapping.c index 65775cd1fb..6766bbd981 100644 --- a/lib/c32_get_mapping.c +++ b/lib/c32_get_mapping.c @@ -39,11 +39,11 @@ c32_get_mapping (const char *name) switch (name[2]) { case 'l': - if (strcmp (name + 3, "ower") == 0) + if (streq (name + 3, "ower")) return c32tolower; break; case 'u': - if (strcmp (name + 3, "pper") == 0) + if (streq (name + 3, "pper")) return c32toupper; break; default: diff --git a/lib/c32_get_type_test.c b/lib/c32_get_type_test.c index 7bfa922d78..e682482872 100644 --- a/lib/c32_get_type_test.c +++ b/lib/c32_get_type_test.c @@ -43,11 +43,11 @@ c32_get_type_test (const char *name) switch (name[2]) { case 'n': - if (strcmp (name + 3, "um") == 0) + if (streq (name + 3, "um")) return c32isalnum; break; case 'p': - if (strcmp (name + 3, "ha") == 0) + if (streq (name + 3, "ha")) return c32isalpha; break; default: @@ -59,34 +59,34 @@ c32_get_type_test (const char *name) } break; case 'b': - if (strcmp (name + 1, "lank") == 0) + if (streq (name + 1, "lank")) return c32isblank; break; case 'c': - if (strcmp (name + 1, "ntrl") == 0) + if (streq (name + 1, "ntrl")) return c32iscntrl; break; case 'd': - if (strcmp (name + 1, "igit") == 0) + if (streq (name + 1, "igit")) return c32isdigit; break; case 'g': - if (strcmp (name + 1, "raph") == 0) + if (streq (name + 1, "raph")) return c32isgraph; break; case 'l': - if (strcmp (name + 1, "ower") == 0) + if (streq (name + 1, "ower")) return c32islower; break; case 'p': switch (name[1]) { case 'r': - if (strcmp (name + 2, "int") == 0) + if (streq (name + 2, "int")) return c32isprint; break; case 'u': - if (strcmp (name + 2, "nct") == 0) + if (streq (name + 2, "nct")) return c32ispunct; break; default: @@ -94,15 +94,15 @@ c32_get_type_test (const char *name) } break; case 's': - if (strcmp (name + 1, "pace") == 0) + if (streq (name + 1, "pace")) return c32isspace; break; case 'u': - if (strcmp (name + 1, "pper") == 0) + if (streq (name + 1, "pper")) return c32isupper; break; case 'x': - if (strcmp (name + 1, "digit") == 0) + if (streq (name + 1, "digit")) return c32isxdigit; break; default: diff --git a/lib/concat-filename.c b/lib/concat-filename.c index ccb55c0599..3524f4e419 100644 --- a/lib/concat-filename.c +++ b/lib/concat-filename.c @@ -39,7 +39,7 @@ concatenated_filename (const char *directory, const char *filename, char *result; char *p; - if (strcmp (directory, ".") == 0) + if (streq (directory, ".")) { /* No need to prepend the directory. */ result = (char *) malloc (strlen (filename) diff --git a/lib/cpu-supports.h b/lib/cpu-supports.h index 88fd4deaf0..8905680d09 100644 --- a/lib/cpu-supports.h +++ b/lib/cpu-supports.h @@ -50,10 +50,6 @@ -# ifndef STREQ -# define STREQ(a, b) (strcmp (a, b) == 0) -# endif - /* Return the glibc.cpu.hwcaps setting (prepended with "-"), corresponding to the passed gcc _builtin_cpu_supports(FEATURE). Supported hwcaps can be identified from the bit_cpu_* defines @@ -68,14 +64,14 @@ gcc_feature_to_glibc_hwcap (char const *feature) if (0) ; # if defined __x86_64__ - else if (STREQ (feature, "avx")) hwcap = "-AVX"; - else if (STREQ (feature, "avx2")) hwcap = "-AVX2"; - else if (STREQ (feature, "avx512bw")) hwcap = "-AVX512BW"; - else if (STREQ (feature, "avx512f")) hwcap = "-AVX512F"; - else if (STREQ (feature, "pclmul")) hwcap = "-PCLMULQDQ"; - else if (STREQ (feature, "vpclmulqdq")) hwcap = "-VPCLMULQDQ"; + else if (streq (feature, "avx")) hwcap = "-AVX"; + else if (streq (feature, "avx2")) hwcap = "-AVX2"; + else if (streq (feature, "avx512bw")) hwcap = "-AVX512BW"; + else if (streq (feature, "avx512f")) hwcap = "-AVX512F"; + else if (streq (feature, "pclmul")) hwcap = "-PCLMULQDQ"; + else if (streq (feature, "vpclmulqdq")) hwcap = "-VPCLMULQDQ"; # elif defined __aarch64__ - else if (STREQ (feature, "pmull")) hwcap = "-PMULL"; + else if (streq (feature, "pmull")) hwcap = "-PMULL"; # endif return hwcap; diff --git a/lib/dfa.c b/lib/dfa.c index d0011afc48..3720e6db94 100644 --- a/lib/dfa.c +++ b/lib/dfa.c @@ -51,6 +51,7 @@ # define c32isprint iswprint # define c32isspace iswspace # define mbszero(p) memset (p, 0, sizeof (mbstate_t)) +# define streq(a, b) (strcmp (a, b) == 0) #else /* Use ISO C 11 + gnulib API. */ # include @@ -63,12 +64,6 @@ MMU will check anyway. */ #define assume_nonnull(x) assume ((x) != NULL) -static bool -str_eq (char const *a, char const *b) -{ - return strcmp (a, b) == 0; -} - static bool c_isdigit (char c) { @@ -944,7 +939,7 @@ static const struct dfa_ctype *_GL_ATTRIBUTE_PURE find_pred (const char *str) { for (int i = 0; prednames[i].name; i++) - if (str_eq (str, prednames[i].name)) + if (streq (str, prednames[i].name)) return &prednames[i]; return NULL; } @@ -1023,8 +1018,8 @@ parse_bracket_exp (struct dfa *dfa) worry about that possibility. */ { char const *class - = (dfa->syntax.case_fold && (str_eq (str, "upper") - || str_eq (str, "lower")) + = (dfa->syntax.case_fold && (streq (str, "upper") + || streq (str, "lower")) ? "alpha" : str); const struct dfa_ctype *pred = find_pred (class); if (!pred) @@ -4207,7 +4202,7 @@ dfamust (struct dfa const *d) idx_t j, ln, rn, n; /* Guaranteed to be. Unlikely, but ... */ - if (str_eq (lmp->is, rmp->is)) + if (streq (lmp->is, rmp->is)) { lmp->begline &= rmp->begline; lmp->endline &= rmp->endline; @@ -4254,7 +4249,7 @@ dfamust (struct dfa const *d) for (idx_t i = 0; mp->in[i] != NULL; i++) if (strlen (mp->in[i]) > strlen (result)) result = mp->in[i]; - if (str_eq (result, mp->is)) + if (streq (result, mp->is)) { if ((!need_begline || mp->begline) && (!need_endline || mp->endline)) diff --git a/lib/duplocale.c b/lib/duplocale.c index d1ba3aa772..6be27459cd 100644 --- a/lib/duplocale.c +++ b/lib/duplocale.c @@ -95,7 +95,7 @@ duplocale (locale_t locale) errno = err; return NULL; } - if (strcmp (name, base_name) != 0) + if (!streq (name, base_name)) { locale_t copy = newlocale (category_mask, name, base_copy); if (copy == NULL) diff --git a/lib/exclude.c b/lib/exclude.c index cdc57d9df8..209f81130d 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -240,7 +240,7 @@ string_hasher_ci (void const *data, size_t n_buckets) static bool string_compare (void const *data1, void const *data2) { - return strcmp (data1, data2) == 0; + return streq (data1, data2); } /* compare two strings for equality, case-insensitive */ @@ -659,7 +659,7 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int), struct exclude *ex, char const *file_name, int options, char line_end) { - if (strcmp (file_name, "-") == 0) + if (streq (file_name, "-")) return add_exclude_fp (call_addfn, ex, stdin, options, line_end, &add_func); FILE *in = fopen (file_name, "re"); diff --git a/lib/findprog-in.c b/lib/findprog-in.c index a07dee534d..6d6ade672d 100644 --- a/lib/findprog-in.c +++ b/lib/findprog-in.c @@ -156,7 +156,7 @@ find_in_given_path (const char *progname, const char *path, if (! S_ISDIR (statbuf.st_mode)) { /* Found! */ - if (strcmp (progpathname, progname) == 0) + if (streq (progpathname, progname)) { free (progpathname); return progname; @@ -308,7 +308,7 @@ find_in_given_path (const char *progname, const char *path, if (! S_ISDIR (statbuf.st_mode)) { /* Found! */ - if (strcmp (progpathname, progname) == 0) + if (streq (progpathname, progname)) { free (progpathname); diff --git a/lib/findprog.c b/lib/findprog.c index d62a596d24..bf67452d0a 100644 --- a/lib/findprog.c +++ b/lib/findprog.c @@ -114,7 +114,7 @@ find_in_path (const char *progname) && ! S_ISDIR (statbuf.st_mode)) { /* Found! */ - if (strcmp (progpathname, progname) == 0) + if (streq (progpathname, progname)) { free (progpathname); diff --git a/lib/fopen.c b/lib/fopen.c index 586f651263..0b72a61cc8 100644 --- a/lib/fopen.c +++ b/lib/fopen.c @@ -54,7 +54,7 @@ rpl_fopen (const char *filename, const char *mode) #endif #if defined _WIN32 && ! defined __CYGWIN__ - if (strcmp (filename, "/dev/null") == 0) + if (streq (filename, "/dev/null")) filename = "NUL"; #endif diff --git a/lib/freopen.c b/lib/freopen.c index b0a26eaa17..14c94d989f 100644 --- a/lib/freopen.c +++ b/lib/freopen.c @@ -47,7 +47,7 @@ rpl_freopen (const char *filename, const char *mode, FILE *stream) FILE *result; #if defined _WIN32 && ! defined __CYGWIN__ char const *null_device = "NUL"; - if (filename && strcmp (filename, "/dev/null") == 0) + if (filename && streq (filename, "/dev/null")) filename = null_device; #else char const *null_device = "/dev/null"; diff --git a/lib/fts.c b/lib/fts.c index b611e997d4..4ab2a96a95 100644 --- a/lib/fts.c +++ b/lib/fts.c @@ -233,7 +233,6 @@ static int fts_safe_changedir (FTS *, FTSENT *, int, const char *) #endif #define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) -#define STREQ(a, b) (strcmp (a, b) == 0) #define CLR(opt) (sp->fts_options &= ~(opt)) #define ISSET(opt) ((sp->fts_options & (opt)) != 0) @@ -2048,7 +2047,7 @@ internal_function fts_safe_changedir (FTS *sp, FTSENT *p, int fd, char const *dir) { int ret; - bool is_dotdot = dir && STREQ (dir, ".."); + bool is_dotdot = dir && streq (dir, ".."); int newfd; /* This clause handles the unusual case in which FTS_NOCHDIR @@ -2094,7 +2093,7 @@ fts_safe_changedir (FTS *sp, FTSENT *p, int fd, char const *dir) not "..", diropen's use of O_NOFOLLOW ensures we don't mistakenly follow a symlink, so we can avoid the expense of this fstat. */ if (ISSET(FTS_LOGICAL) || ! HAVE_WORKING_O_NOFOLLOW - || (dir && STREQ (dir, ".."))) + || (dir && streq (dir, ".."))) { struct stat sb; if (fstat(newfd, &sb)) diff --git a/lib/gen-uni-tables.c b/lib/gen-uni-tables.c index 4dbe7f5f13..97f8ff4b0d 100644 --- a/lib/gen-uni-tables.c +++ b/lib/gen-uni-tables.c @@ -64,7 +64,7 @@ str_endswith (const char *string, const char *suffix) { size_t len = strlen (string); size_t n = strlen (suffix); - return len >= n && strcmp (string + len - n, suffix) == 0; + return len >= n && streq (string + len - n, suffix); } static bool @@ -73,6 +73,12 @@ memeq (void const *s1, void const *s2, size_t n) return !memcmp (s1, s2, n); } +static bool +streq (char const *s1, char const *s2) +{ + return !strcmp (s1, s2); +} + /* ========================================================================= */ /* Reading UnicodeData.txt. */ @@ -122,7 +128,7 @@ fill_attribute (unsigned int i, fprintf (stderr, "index too large\n"); exit (1); } - if (strcmp (field2, "Cs") == 0) + if (streq (field2, "Cs")) /* Surrogates are UTF-16 artifacts, not real characters. Ignore them. */ return; uni = &unicode_attributes[i]; @@ -799,9 +805,9 @@ output_predicate (const char *filename, bool (*predicate) (unsigned int), const fprintf (stream, "/* Copyright (C) 2000-2025 Free Software Foundation, Inc.\n"); fprintf (stream, "\n"); output_library_license (stream, - strcmp (filename, "unictype/categ_M.h") == 0 + streq (filename, "unictype/categ_M.h") || str_startswith (filename, "unictype/ctype_") - || strcmp (filename, "uniwidth/width2.h") == 0); + || streq (filename, "uniwidth/width2.h")); fprintf (stream, "\n"); t.p = 4; /* or: 5 */ @@ -2946,7 +2952,7 @@ fill_properties (const char *proplist_filename) i2 = i1; } #define PROP(name,code) \ - if (strcmp (propname, name) == 0) propcode = code; else + if (streq (propname, name)) propcode = code; else /* PropList.txt */ PROP ("White_Space", PROP_WHITE_SPACE) PROP ("Bidi_Control", PROP_BIDI_CONTROL) @@ -3015,7 +3021,7 @@ fill_properties (const char *proplist_filename) PROP ("Extended_Pictographic", PROP_EXTENDED_PICTOGRAPHIC) #undef PROP /* An enum-valued property from DerivedCoreProperties.txt */ - if (strcmp (propname, "InCB;") == 0) + if (streq (propname, "InCB;")) { char valuename[200+1]; unsigned int valuecode; @@ -3026,13 +3032,13 @@ fill_properties (const char *proplist_filename) exit (1); } - if (strcmp (valuename, "None") == 0) + if (streq (valuename, "None")) valuecode = UC_INDIC_CONJUNCT_BREAK_NONE; - else if (strcmp (valuename, "Consonant") == 0) + else if (streq (valuename, "Consonant")) valuecode = UC_INDIC_CONJUNCT_BREAK_CONSONANT; - else if (strcmp (valuename, "Linker") == 0) + else if (streq (valuename, "Linker")) valuecode = UC_INDIC_CONJUNCT_BREAK_LINKER; - else if (strcmp (valuename, "Extend") == 0) + else if (streq (valuename, "Extend")) valuecode = UC_INDIC_CONJUNCT_BREAK_EXTEND; else { @@ -3741,7 +3747,7 @@ is_property_iso_control (unsigned int ch) { bool result1 = (unicode_attributes[ch].name != NULL - && strcmp (unicode_attributes[ch].name, "") == 0); + && streq (unicode_attributes[ch].name, "")); bool result2 = is_category_Cc (ch); @@ -3871,7 +3877,7 @@ static bool is_property_combining (unsigned int ch) { return (unicode_attributes[ch].name != NULL - && (strcmp (unicode_attributes[ch].combining, "0") != 0 + && (!streq (unicode_attributes[ch].combining, "0") || is_category_Mc (ch) || is_category_Me (ch) || is_category_Mn (ch))); @@ -4497,7 +4503,7 @@ fill_arabicshaping (const char *arabicshaping_filename) } assert (i < 0x110000); -#define TRY(name) else if (strcmp (joining_type_name, #name + 16) == 0) joining_type = name; +#define TRY(name) else if (streq (joining_type_name, #name + 16)) joining_type = name; if (false) {} TRY(UC_JOINING_TYPE_U) TRY(UC_JOINING_TYPE_T) @@ -4518,7 +4524,7 @@ fill_arabicshaping (const char *arabicshaping_filename) && joining_group_name[strlen (joining_group_name) - 1] == ' ') joining_group_name[strlen (joining_group_name) - 1] = '\0'; -#define TRY(value,name) else if (strcmp (joining_group_name, name) == 0) joining_group = value; +#define TRY(value,name) else if (streq (joining_group_name, name)) joining_group = value; if (false) {} TRY(UC_JOINING_GROUP_NONE, "No_Joining_Group") TRY(UC_JOINING_GROUP_AIN, "AIN") @@ -5223,7 +5229,7 @@ fill_scripts (const char *scripts_filename) assert (i2 < 0x110000); for (script = numscripts - 1; script >= 0; script--) - if (strcmp (scripts[script], scriptname) == 0) + if (streq (scripts[script], scriptname)) break; if (script < 0) { @@ -6321,7 +6327,7 @@ static bool is_cntrl (unsigned int ch) { return (unicode_attributes[ch].name != NULL - && (strcmp (unicode_attributes[ch].name, "") == 0 + && (streq (unicode_attributes[ch].name, "") /* Categories Zl and Zp */ || (unicode_attributes[ch].category[0] == 'Z' && (unicode_attributes[ch].category[1] == 'l' @@ -6354,7 +6360,7 @@ static bool is_graph (unsigned int ch) { return (unicode_attributes[ch].name != NULL - && strcmp (unicode_attributes[ch].name, "") + && !streq (unicode_attributes[ch].name, "") && !is_space (ch)); } @@ -6362,7 +6368,7 @@ static bool is_print (unsigned int ch) { return (unicode_attributes[ch].name != NULL - && strcmp (unicode_attributes[ch].name, "") + && !streq (unicode_attributes[ch].name, "") /* Categories Zl and Zp */ && !(unicode_attributes[ch].name != NULL && unicode_attributes[ch].category[0] == 'Z' @@ -7119,12 +7125,12 @@ symbolic_width (unsigned int ch) return '0'; /* Test for double-width character. */ if (unicode_width[ch] != NULL - && (strcmp (unicode_width[ch], "W") == 0 - || strcmp (unicode_width[ch], "F") == 0)) + && (streq (unicode_width[ch], "W") + || streq (unicode_width[ch], "F"))) return '2'; /* Test for half-width character. */ if (unicode_width[ch] != NULL - && strcmp (unicode_width[ch], "H") == 0) + && streq (unicode_width[ch], "H")) return '1'; } /* In ancient CJK encodings, Cyrillic and most other characters are @@ -7266,9 +7272,9 @@ static int get_lbea (unsigned int ch) { return (unicode_width[ch] != NULL - && (strcmp (unicode_width[ch], "W") == 0 - || strcmp (unicode_width[ch], "F") == 0 - || strcmp (unicode_width[ch], "H") == 0)); + && (streq (unicode_width[ch], "W") + || streq (unicode_width[ch], "F") + || streq (unicode_width[ch], "H"))); } /* Returns the line breaking classification for ch, as a bit mask. */ @@ -8809,7 +8815,7 @@ fill_org_lbp (const char *linebreak_filename) /* Remove trailing spaces from field1. */ while (strlen (field1) > 0 && field1[strlen (field1) - 1] == ' ') field1[strlen (field1) - 1] = '\0'; -#define TRY(bit) else if (strcmp (field1, #bit + 4) == 0) value = bit; +#define TRY(bit) else if (streq (field1, #bit + 4)) value = bit; if (false) {} TRY(LBP_BK) TRY(LBP_CR) @@ -8857,9 +8863,9 @@ fill_org_lbp (const char *linebreak_filename) TRY(LBP_EM) TRY(LBP_XX) #undef TRY - else if (strcmp (field1, "NL") == 0) value = LBP_BK; - else if (strcmp (field1, "SG") == 0) value = LBP_XX; - else if (strcmp (field1, "CJ") == 0) value = LBP_NS; + else if (streq (field1, "NL")) value = LBP_BK; + else if (streq (field1, "SG")) value = LBP_XX; + else if (streq (field1, "CJ")) value = LBP_NS; else { fprintf (stderr, "unknown property value \"%s\" in '%s':%d\n", @@ -9651,12 +9657,12 @@ get_wbp (unsigned int ch) if (((unicode_properties[ch] >> PROP_GRAPHEME_EXTEND) & 1) != 0 || ((unicode_properties[ch] >> PROP_OTHER_GRAPHEME_EXTEND) & 1) != 0 || (unicode_attributes[ch].category != NULL - && strcmp (unicode_attributes[ch].category, "Mc") == 0) + && streq (unicode_attributes[ch].category, "Mc")) || ((unicode_properties[ch] >> PROP_EMOJI_MODIFIER) & 1) != 0 /* Emoji modifier */) attr |= 1 << WBP_EXTEND; if (unicode_attributes[ch].category != NULL - && strcmp (unicode_attributes[ch].category, "Cf") == 0 + && streq (unicode_attributes[ch].category, "Cf") && !(ch >= 0x0600 && ch <= 0x0605) && ch != 0x06DD && ch != 0x070F @@ -9667,15 +9673,15 @@ get_wbp (unsigned int ch) attr |= 1 << WBP_FORMAT; if ((unicode_scripts[ch] < numscripts - && strcmp (scripts[unicode_scripts[ch]], "Katakana") == 0) + && streq (scripts[unicode_scripts[ch]], "Katakana")) || (ch >= 0x3031 && ch <= 0x3035) || ch == 0x309B || ch == 0x309C || ch == 0x30A0 || ch == 0x30FC || ch == 0xFF70) attr |= 1 << WBP_KATAKANA; if ((unicode_scripts[ch] < numscripts - && strcmp (scripts[unicode_scripts[ch]], "Hebrew") == 0) - && strcmp (unicode_attributes[ch].category, "Lo") == 0) + && streq (scripts[unicode_scripts[ch]], "Hebrew")) + && streq (unicode_attributes[ch].category, "Lo")) attr |= 1 << WBP_HL; if ((((unicode_properties[ch] >> PROP_ALPHABETIC) & 1) != 0 @@ -9698,7 +9704,7 @@ get_wbp (unsigned int ch) && (attr & (1 << WBP_KATAKANA)) == 0 && ((get_lbp (ch) >> LBP_SA) & 1) == 0 && !(unicode_scripts[ch] < numscripts - && strcmp (scripts[unicode_scripts[ch]], "Hiragana") == 0) + && streq (scripts[unicode_scripts[ch]], "Hiragana")) && (attr & (1 << WBP_EXTEND)) == 0 && (attr & (1 << WBP_HL)) == 0) attr |= 1 << WBP_ALETTER; @@ -9728,7 +9734,7 @@ get_wbp (unsigned int ch) attr |= 1 << WBP_NUMERIC; if ((unicode_attributes[ch].category != NULL - && strcmp (unicode_attributes[ch].category, "Pc") == 0) + && streq (unicode_attributes[ch].category, "Pc")) || ch == 0x202F /* NARROW NO-BREAK SPACE */) attr |= 1 << WBP_EXTENDNUMLET; @@ -9875,7 +9881,7 @@ fill_org_wbp (const char *wordbreakproperty_filename) i2 = i1; } #define PROP(name,value) \ - if (strcmp (propname, name) == 0) propvalue = value; else + if (streq (propname, name)) propvalue = value; else PROP ("CR", WBP_CR) PROP ("LF", WBP_LF) PROP ("Newline", WBP_NEWLINE) @@ -10455,7 +10461,7 @@ fill_org_gbp (const char *graphemebreakproperty_filename) i2 = i1; } #define PROP(name,value) \ - if (strcmp (propname, name) == 0) propvalue = value; else + if (streq (propname, name)) propvalue = value; else PROP ("CR", GBP_CR) PROP ("LF", GBP_LF) PROP ("Control", GBP_CONTROL) @@ -10863,13 +10869,13 @@ debug_output_composition_tables (const char *filename) /* Exclude decompositions where the first part is not a starter, i.e. is not of canonical combining class 0. */ - if (strcmp (unicode_attributes[code1].combining, "0") == 0 + if (streq (unicode_attributes[code1].combining, "0") /* Exclude characters listed in CompositionExclusions.txt. */ && !unicode_composition_exclusions[combined]) { /* The combined character must now also be a starter. Verify this. */ - assert (strcmp (unicode_attributes[combined].combining, "0") == 0); + assert (streq (unicode_attributes[combined].combining, "0")); fprintf (stream, "0x%04X\t0x%04X\t0x%04X\t%s\n", code1, @@ -10965,13 +10971,13 @@ output_composition_tables (const char *filename, const char *filename2, /* Exclude decompositions where the first part is not a starter, i.e. is not of canonical combining class 0. */ - if (strcmp (unicode_attributes[code1].combining, "0") == 0 + if (streq (unicode_attributes[code1].combining, "0") /* Exclude characters listed in CompositionExclusions.txt. */ && !unicode_composition_exclusions[combined]) { /* The combined character must now also be a starter. Verify this. */ - assert (strcmp (unicode_attributes[combined].combining, "0") == 0); + assert (streq (unicode_attributes[combined].combining, "0")); if (max_code1 < code1) max_code1 = code1; @@ -11120,8 +11126,8 @@ output_simple_mapping (const char *filename, fprintf (stream, "/* Copyright (C) 2000-2025 Free Software Foundation, Inc.\n"); fprintf (stream, "\n"); output_library_license (stream, - strcmp (filename, "unicase/tolower.h") == 0 - || strcmp (filename, "unicase/toupper.h") == 0); + streq (filename, "unicase/tolower.h") + || streq (filename, "unicase/toupper.h")); fprintf (stream, "\n"); t.p = 7; @@ -11710,7 +11716,7 @@ redistribute_casefolding_rules (void) if (rule->code == cfrule->code && (cfrule->language == NULL || (rule->language != NULL - && strcmp (rule->language, cfrule->language) == 0))) + && streq (rule->language, cfrule->language)))) { memcpy (rule->casefold_mapping, cfrule->mapping, sizeof (rule->casefold_mapping)); @@ -11718,7 +11724,7 @@ redistribute_casefolding_rules (void) if ((cfrule->language == NULL ? rule->language == NULL : rule->language != NULL - && strcmp (rule->language, cfrule->language) == 0) + && streq (rule->language, cfrule->language)) && rule->context == SCC_ALWAYS) { /* Found it. */ diff --git a/lib/getfilecon.c b/lib/getfilecon.c index 4e1c3b45c4..6dd458e40c 100644 --- a/lib/getfilecon.c +++ b/lib/getfilecon.c @@ -60,7 +60,7 @@ map_to_failure (int ret, char **con) return -1; } - if (ret == 10 && strcmp (*con, "unlabeled") == 0) + if (ret == 10 && streq (*con, "unlabeled")) { freecon (*con); *con = NULL; diff --git a/lib/getlogin.c b/lib/getlogin.c index 4772111567..36965f1db5 100644 --- a/lib/getlogin.c +++ b/lib/getlogin.c @@ -94,7 +94,7 @@ getlogin (void) { idx_t i; for (i = 0; i < n; i++) - if (strcmp (entries[i].ut_line, tty + 5) == 0) + if (streq (entries[i].ut_line, tty + 5)) { if (strlen (entries[i].ut_user) < 64) { diff --git a/lib/getugroups.c b/lib/getugroups.c index 354cfa9976..5f48d56ec4 100644 --- a/lib/getugroups.c +++ b/lib/getugroups.c @@ -48,8 +48,6 @@ getugroups (_GL_UNUSED int maxcount, #else /* HAVE_GRP_H */ # include -# define STREQ(a, b) (strcmp (a, b) == 0) - /* Like 'getgroups', but for user USERNAME instead of for the current process. Store at most MAXCOUNT group IDs in the GROUPLIST array. If GID is not -1, store it first (if possible). GID should be the @@ -85,7 +83,7 @@ getugroups (int maxcount, gid_t *grouplist, char const *username, { int n; - if ( ! STREQ (username, *cp)) + if (!streq (username, *cp)) continue; /* See if this group number is already on the list. */ diff --git a/lib/hard-locale.c b/lib/hard-locale.c index 767906d11e..1e43088950 100644 --- a/lib/hard-locale.c +++ b/lib/hard-locale.c @@ -32,7 +32,7 @@ hard_locale (int category) if (setlocale_null_r (category, locale, sizeof (locale))) return false; - if (!(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)) + if (!(streq (locale, "C") || streq (locale, "POSIX"))) return true; #if defined __ANDROID__ diff --git a/lib/hashcode-named-file.c b/lib/hashcode-named-file.c index 1611cb5138..df5028f014 100644 --- a/lib/hashcode-named-file.c +++ b/lib/hashcode-named-file.c @@ -27,8 +27,6 @@ #include "hashcode-string2.h" #include "same-inode.h" -#define STREQ(a, b) (strcmp (a, b) == 0) - /* Hash an F_triple, and *do* consider the file name. */ size_t triple_hash (void const *x, size_t table_size) @@ -46,7 +44,7 @@ triple_compare_ino_str (void const *x, void const *y) { struct F_triple const *a = x; struct F_triple const *b = y; - return PSAME_INODE (a, b) && STREQ (a->name, b->name); + return PSAME_INODE (a, b) && streq (a->name, b->name); } /* Free an F_triple. */ diff --git a/lib/hashkey-string.c b/lib/hashkey-string.c index 7517780d5f..897e1bed41 100644 --- a/lib/hashkey-string.c +++ b/lib/hashkey-string.c @@ -27,7 +27,7 @@ hashkey_string_equals (const void *x1, const void *x2) { const char *s1 = (const char *) x1; const char *s2 = (const char *) x2; - return strcmp (s1, s2) == 0; + return streq (s1, s2); } #define SIZE_BITS (sizeof (size_t) * CHAR_BIT) diff --git a/lib/iconv_open.c b/lib/iconv_open.c index 544edbe3f9..c54b8ee603 100644 --- a/lib/iconv_open.c +++ b/lib/iconv_open.c @@ -67,7 +67,7 @@ rpl_iconv_open (const char *tocode, const char *fromcode) && c_toupper (tocode[2]) == 'F' && tocode[3] == '-') { - if (strcmp (fromcode + 4, "8") == 0) + if (streq (fromcode + 4, "8")) { if (c_strcasecmp (tocode + 4, "16BE") == 0) return _ICONV_UTF8_UTF16BE; @@ -78,7 +78,7 @@ rpl_iconv_open (const char *tocode, const char *fromcode) if (c_strcasecmp (tocode + 4, "32LE") == 0) return _ICONV_UTF8_UTF32LE; } - else if (strcmp (tocode + 4, "8") == 0) + else if (streq (tocode + 4, "8")) { if (c_strcasecmp (fromcode + 4, "16BE") == 0) return _ICONV_UTF16BE_UTF8; diff --git a/lib/idcache.c b/lib/idcache.c index 18c33fcf0e..5907838be4 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -109,12 +109,12 @@ getuidbyname (const char *user) for (tail = user_alist; tail; tail = tail->next) /* Avoid a function call for the most common case. */ - if (*tail->name == *user && !strcmp (tail->name, user)) + if (*tail->name == *user && streq (tail->name, user)) return &tail->id.u; for (tail = nouser_alist; tail; tail = tail->next) /* Avoid a function call for the most common case. */ - if (*tail->name == *user && !strcmp (tail->name, user)) + if (*tail->name == *user && streq (tail->name, user)) return NULL; pwent = getpwnam (user); @@ -191,12 +191,12 @@ getgidbyname (const char *group) for (tail = group_alist; tail; tail = tail->next) /* Avoid a function call for the most common case. */ - if (*tail->name == *group && !strcmp (tail->name, group)) + if (*tail->name == *group && streq (tail->name, group)) return &tail->id.g; for (tail = nogroup_alist; tail; tail = tail->next) /* Avoid a function call for the most common case. */ - if (*tail->name == *group && !strcmp (tail->name, group)) + if (*tail->name == *group && streq (tail->name, group)) return NULL; grent = getgrnam (group); diff --git a/lib/lc-charset-unicode.c b/lib/lc-charset-unicode.c index 448619b687..08369f546b 100644 --- a/lib/lc-charset-unicode.c +++ b/lib/lc-charset-unicode.c @@ -109,7 +109,7 @@ get_converters (const char *encoding) strcpy (conv->encoding, encoding); gl_tls_set (converters_key, conv); } - else if (strcmp (conv->encoding, encoding) != 0) + else if (!streq (conv->encoding, encoding)) { /* The locale encoding of this thread changed. */ iconv_t new_cd_locale_to_utf8 = iconv_open ("UTF-8", encoding); diff --git a/lib/localcharset.c b/lib/localcharset.c index 29dba9852a..57b9c9da4a 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -811,7 +811,7 @@ locale_charset (void) /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always returns "US-ASCII". Return the suffix of the locale name from the environment variables (if present) or the codepage as a number. */ - if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) + if (codeset != NULL && streq (codeset, "US-ASCII")) { const char *locale; static char resultbuf[2 + 10 + 1]; @@ -902,8 +902,7 @@ locale_charset (void) /* For a locale name such as "French_France.65001", in Windows 10, setlocale now returns "French_France.utf8" instead, or in the UTF-8 environment (with modern system settings) "fr_FR.UTF-8". */ - if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0 - || strcmp (buf + 2, "UTF-8") == 0) + if (streq (buf + 2, "65001") || streq (buf + 2, "utf8") || streq (buf + 2, "UTF-8")) codeset = "UTF-8"; else { @@ -953,7 +952,7 @@ locale_charset (void) } /* For the POSIX locale, don't use the system's codepage. */ - if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) + if (streq (locale, "C") || streq (locale, "POSIX")) codeset = ""; } @@ -985,7 +984,7 @@ locale_charset (void) Speed up the common case and slow down the less common cases by testing for this case first. */ # if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__ - if (strcmp (codeset, "UTF-8") == 0) + if (streq (codeset, "UTF-8")) goto done_table_lookup; else # endif @@ -1114,7 +1113,7 @@ locale_charset (void) #ifdef DARWIN7 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" (the default codeset) does not work when MB_CUR_MAX is 1. */ - if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1) + if (ostreq (codeset, "UTF-8") && MB_CUR_MAX_L (uselocale (NULL)) <= 1) codeset = "ASCII"; #endif diff --git a/lib/localename-environ.c b/lib/localename-environ.c index fea88fa88e..0d35d6bbde 100644 --- a/lib/localename-environ.c +++ b/lib/localename-environ.c @@ -44,12 +44,12 @@ gl_locale_name_environ (_GL_UNUSED int category, const char *categoryname) #if HAVE_CFPREFERENCESCOPYAPPVALUE /* Mac OS X 10.2 or newer. Ignore invalid LANG value set by the Terminal application. */ - if (strcmp (retval, "UTF-8") != 0) + if (!streq (retval, "UTF-8")) #endif #if defined __CYGWIN__ /* Cygwin. Ignore dummy LANG value set by ~/.profile. */ - if (strcmp (retval, "C.UTF-8") != 0) + if (!streq (retval, "C.UTF-8")) #endif return retval; } diff --git a/lib/localename-unsafe.c b/lib/localename-unsafe.c index 35fddfbfe9..708aa28569 100644 --- a/lib/localename-unsafe.c +++ b/lib/localename-unsafe.c @@ -1377,7 +1377,7 @@ gl_locale_name_canonicalize (char *name) else i1 = i; } - if (strcmp (name, legacy_table[i1].legacy) == 0) + if (streq (name, legacy_table[i1].legacy)) { strcpy (name, legacy_table[i1].unixy); return; @@ -1401,7 +1401,7 @@ gl_locale_name_canonicalize (char *name) else i1 = i; } - if (strcmp (name, langtag_table[i1].langtag) == 0) + if (streq (name, langtag_table[i1].langtag)) { strcpy (name, langtag_table[i1].unixy); return; @@ -1420,7 +1420,7 @@ gl_locale_name_canonicalize (char *name) else i1 = i; } - if (strcmp (name + 3, script_table[i1].script) == 0) + if (streq (name + 3, script_table[i1].script)) { name[2] = '@'; strcpy (name + 3, script_table[i1].unixy); @@ -2593,7 +2593,7 @@ get_lcid (const char *locale_name) /* Lock while looking for an LCID, to protect access to static variables: last_lcid, last_locale, found_lcid, and lname. */ glwthread_mutex_lock (&get_lcid_lock); - if (last_lcid > 0 && strcmp (locale_name, last_locale) == 0) + if (last_lcid > 0 && streq (locale_name, last_locale)) { glwthread_mutex_unlock (&get_lcid_lock); return last_lcid; diff --git a/lib/mbs_endswith.c b/lib/mbs_endswith.c index 5a7ff13ad6..d8faf772b0 100644 --- a/lib/mbs_endswith.c +++ b/lib/mbs_endswith.c @@ -67,7 +67,7 @@ mbs_endswith (const char *string, const char *suffix) if (!mbi_avail (iter)) /* We can get here due to incomplete multibyte characters. */ return false; - return strcmp (mbi_cur_ptr (iter), suffix) == 0; + return streq (mbi_cur_ptr (iter), suffix); } } return false; diff --git a/lib/mountlist.c b/lib/mountlist.c index 75e6c6590e..1a1e7fbf78 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -171,21 +171,21 @@ #endif #define ME_DUMMY_0(Fs_name, Fs_type) \ - (strcmp (Fs_type, "autofs") == 0 \ - || strcmp (Fs_type, "proc") == 0 \ - || strcmp (Fs_type, "subfs") == 0 \ + (streq (Fs_type, "autofs") \ + || streq (Fs_type, "proc") \ + || streq (Fs_type, "subfs") \ /* for Linux 2.6/3.x */ \ - || strcmp (Fs_type, "debugfs") == 0 \ - || strcmp (Fs_type, "devpts") == 0 \ - || strcmp (Fs_type, "fusectl") == 0 \ - || strcmp (Fs_type, "fuse.portal") == 0 \ - || strcmp (Fs_type, "mqueue") == 0 \ - || strcmp (Fs_type, "rpc_pipefs") == 0 \ - || strcmp (Fs_type, "sysfs") == 0 \ + || streq (Fs_type, "debugfs") \ + || streq (Fs_type, "devpts") \ + || streq (Fs_type, "fusectl") \ + || streq (Fs_type, "fuse.portal") \ + || streq (Fs_type, "mqueue") \ + || streq (Fs_type, "rpc_pipefs") \ + || streq (Fs_type, "sysfs") \ /* FreeBSD, Linux 2.4 */ \ - || strcmp (Fs_type, "devfs") == 0 \ + || streq (Fs_type, "devfs") \ /* for NetBSD 3.0 */ \ - || strcmp (Fs_type, "kernfs") == 0) + || streq (Fs_type, "kernfs")) /* Historically, we have marked as "dummy" any file system of type "none", but now that programs like du need to know about bind-mounted directories, @@ -194,10 +194,10 @@ #ifdef MOUNTED_GETMNTENT1 # define ME_DUMMY(Fs_name, Fs_type, Bind) \ (ME_DUMMY_0 (Fs_name, Fs_type) \ - || (strcmp (Fs_type, "none") == 0 && !Bind)) + || (streq (Fs_type, "none") && !Bind)) #else # define ME_DUMMY(Fs_name, Fs_type) \ - (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0) + (ME_DUMMY_0 (Fs_name, Fs_type) || streq (Fs_type, "none")) #endif #ifdef __CYGWIN__ @@ -238,19 +238,19 @@ me_remote (char const *fs_name, _GL_UNUSED char const *fs_type) (strchr (Fs_name, ':') != NULL \ || ((Fs_name)[0] == '/' \ && (Fs_name)[1] == '/' \ - && (strcmp (Fs_type, "smbfs") == 0 \ - || strcmp (Fs_type, "smb3") == 0 \ - || strcmp (Fs_type, "cifs") == 0)) \ - || strcmp (Fs_type, "acfs") == 0 \ - || strcmp (Fs_type, "afs") == 0 \ - || strcmp (Fs_type, "coda") == 0 \ - || strcmp (Fs_type, "auristorfs") == 0 \ - || strcmp (Fs_type, "fhgfs") == 0 \ - || strcmp (Fs_type, "gpfs") == 0 \ - || strcmp (Fs_type, "ibrix") == 0 \ - || strcmp (Fs_type, "ocfs2") == 0 \ - || strcmp (Fs_type, "vxfs") == 0 \ - || strcmp ("-hosts", Fs_name) == 0) + && (streq (Fs_type, "smbfs") \ + || streq (Fs_type, "smb3") \ + || streq (Fs_type, "cifs"))) \ + || streq (Fs_type, "acfs") \ + || streq (Fs_type, "afs") \ + || streq (Fs_type, "coda") \ + || streq (Fs_type, "auristorfs") \ + || streq (Fs_type, "fhgfs") \ + || streq (Fs_type, "gpfs") \ + || streq (Fs_type, "ibrix") \ + || streq (Fs_type, "ocfs2") \ + || streq (Fs_type, "vxfs") \ + || streq ("-hosts", Fs_name)) #endif #if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ @@ -695,10 +695,10 @@ read_file_system_list (bool need_fs_type) char *name; struct stat statbuf; - if (strcmp (d->d_name, "..") == 0) + if (streq (d->d_name, "..")) continue; - if (strcmp (d->d_name, ".") == 0) + if (streq (d->d_name, ".")) name = xstrdup ("/"); else { diff --git a/lib/newlocale.c b/lib/newlocale.c index 7635fb691f..7dfa0a9a42 100644 --- a/lib/newlocale.c +++ b/lib/newlocale.c @@ -48,7 +48,7 @@ newlocale (int category_mask, const char *name, locale_t base) if (category_mask != 0) { /* Test whether NAME is valid. */ - if (!(strcmp (name, "C") == 0 || strcmp (name, "POSIX") == 0)) + if (!(streq (name, "C") || streq (name, "POSIX"))) { char *filename = (char *) malloc (18 + strlen (name) + 9 + 1); if (filename == NULL) @@ -110,13 +110,13 @@ newlocale (int category_mask, const char *name, locale_t base) } /* Canonicalize the name. */ - if (strcmp (name, "POSIX") == 0) + if (streq (name, "POSIX")) name = "C"; # if !HAVE_WINDOWS_LOCALE_T /* In this case, the only NAMEs that we support are "C" and (equivalently) "POSIX". */ - if (category_mask != 0 && strcmp (name, "C") != 0) + if (category_mask != 0 && !streq (name, "C")) { errno = ENOENT; return NULL; @@ -164,7 +164,7 @@ newlocale (int category_mask, const char *name, locale_t base) err = ENOMEM; goto fail_with_err; } - if (strcmp (lcname, "C") == 0) + if (streq (lcname, "C")) { result->category[i].is_c_locale = true; # if HAVE_WINDOWS_LOCALE_T diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c index df824a61f8..e7a9334ec9 100644 --- a/lib/nl_langinfo.c +++ b/lib/nl_langinfo.c @@ -128,7 +128,7 @@ ctype_codeset (void) sprintf (buf + 2, "%u", GetACP ()); /* For a locale name such as "French_France.65001", in Windows 10, setlocale now returns "French_France.utf8" instead. */ - if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) + if (streq (buf + 2, "65001") || streq (buf + 2, "utf8")) return (char *) "UTF-8"; else { diff --git a/lib/nproc.c b/lib/nproc.c index f63d19a646..e899ff1762 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -392,7 +392,7 @@ cgroup2_mount (void) return NULL; while ((mnt = getmntent (fp)) != NULL) { - if (strcmp (mnt->mnt_type, "cgroup2") == 0) + if (streq (mnt->mnt_type, "cgroup2")) { ret = strdup (mnt->mnt_dir); break; diff --git a/lib/open.c b/lib/open.c index 7fae7d5ae9..fceacfcc00 100644 --- a/lib/open.c +++ b/lib/open.c @@ -94,7 +94,7 @@ open (const char *filename, int flags, ...) #endif #if defined _WIN32 && ! defined __CYGWIN__ - if (strcmp (filename, "/dev/null") == 0) + if (streq (filename, "/dev/null")) filename = "NUL"; #endif diff --git a/lib/os2-spawn.c b/lib/os2-spawn.c index 0bdf27162b..c532c07078 100644 --- a/lib/os2-spawn.c +++ b/lib/os2-spawn.c @@ -195,7 +195,7 @@ spawnpvech (int mode, #endif if (!(libcx_spawn2_loaded - || (currdir == NULL || strcmp (currdir, ".") == 0))) + || (currdir == NULL || streq (currdir, ".")))) { errno = EINVAL; return -1; @@ -219,7 +219,7 @@ spawnpvech (int mode, || dup2 (new_stderr, STDERR_FILENO) >= 0)) { if (!libcx_spawn2_loaded - || (currdir == NULL || strcmp (currdir, ".") == 0)) + || (currdir == NULL || streq (currdir, "."))) ret = spawnvpe (mode, progname, (char * const *) argv, (char * const *) envp); #if HAVE_LIBCX_SPAWN2_H diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y index a17b631d02..6c52cd2c4c 100644 --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -88,8 +88,6 @@ #define HOUR(x) (60 * 60 * (x)) -#define STREQ(a, b) (strcmp (a, b) == 0) - /* Verify that time_t is an integer as POSIX requires, and that every time_t value fits in intmax_t. Please file a bug report if these assumptions are false on your platform. */ @@ -1312,17 +1310,17 @@ lookup_zone (parser_control const *pc, char const *name) table const *tp; for (tp = universal_time_zone_table; tp->name; tp++) - if (strcmp (name, tp->name) == 0) + if (streq (name, tp->name)) return tp; /* Try local zone abbreviations before those in time_zone_table, as the local ones are more likely to be right. */ for (tp = pc->local_time_zone_table; tp->name; tp++) - if (strcmp (name, tp->name) == 0) + if (streq (name, tp->name)) return tp; for (tp = time_zone_table; tp->name; tp++) - if (strcmp (name, tp->name) == 0) + if (streq (name, tp->name)) return tp; return NULL; @@ -1370,7 +1368,7 @@ lookup_word (parser_control const *pc, char *word) *p = c_toupper (to_uchar (*p)); for (tp = meridian_table; tp->name; tp++) - if (strcmp (word, tp->name) == 0) + if (streq (word, tp->name)) return tp; /* See if we have an abbreviation for a month. */ @@ -1384,11 +1382,11 @@ lookup_word (parser_control const *pc, char *word) if ((tp = lookup_zone (pc, word))) return tp; - if (strcmp (word, dst_table[0].name) == 0) + if (streq (word, dst_table[0].name)) return dst_table; for (tp = time_units_table; tp->name; tp++) - if (strcmp (word, tp->name) == 0) + if (streq (word, tp->name)) return tp; /* Strip off any plural and try the units table again. */ @@ -1396,13 +1394,13 @@ lookup_word (parser_control const *pc, char *word) { word[wordlen - 1] = '\0'; for (tp = time_units_table; tp->name; tp++) - if (strcmp (word, tp->name) == 0) + if (streq (word, tp->name)) return tp; word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ } for (tp = relative_time_table; tp->name; tp++) - if (strcmp (word, tp->name) == 0) + if (streq (word, tp->name)) return tp; /* Military time zones. */ @@ -1879,8 +1877,8 @@ parse_datetime_body (struct timespec *result, char const *p, populate_local_time_zone_table (&pc, &probe_tm); if (pc.local_time_zone_table[1].name) { - if (! strcmp (pc.local_time_zone_table[0].name, - pc.local_time_zone_table[1].name)) + if (streq (pc.local_time_zone_table[0].name, + pc.local_time_zone_table[1].name)) { /* This locale uses the same abbreviation for standard and daylight times. So if we see that abbreviation, we don't @@ -1919,7 +1917,7 @@ parse_datetime_body (struct timespec *result, char const *p, { if (tz != tzdefault) fprintf (stderr, _("TZ=\"%s\" in date string"), tzstring); - else if (STREQ (tzstring, "UTC0")) + else if (streq (tzstring, "UTC0")) { /* Special case: 'date -u' sets TZ="UTC0". */ fputs (_("TZ=\"UTC0\" environment value or -u"), stderr); @@ -2324,7 +2322,7 @@ parse_datetime_body (struct timespec *result, char const *p, /* Special case: using 'date -u' simply set TZ=UTC0 */ if (! tzstring) dbg_fputs (_("timezone: system default\n")); - else if (STREQ (tzstring, "UTC0")) + else if (streq (tzstring, "UTC0")) dbg_fputs (_("timezone: Universal Time\n")); else dbg_printf (_("timezone: TZ=\"%s\" environment value\n"), tzstring); diff --git a/lib/popen.c b/lib/popen.c index d9d94a6cdc..a8ed25db1c 100644 --- a/lib/popen.c +++ b/lib/popen.c @@ -30,9 +30,9 @@ FILE * popen (const char *filename, const char *mode) { /* Use binary mode by default. */ - if (strcmp (mode, "r") == 0) + if (streq (mode, "r")) mode = "rb"; - else if (strcmp (mode, "w") == 0) + else if (streq (mode, "w")) mode = "wb"; return _popen (filename, mode); diff --git a/lib/progreloc.c b/lib/progreloc.c index 715e750e7a..71d8c34ae5 100644 --- a/lib/progreloc.c +++ b/lib/progreloc.c @@ -285,7 +285,7 @@ find_executable (const char *argv0) link = xreadlink ("/proc/curproc/file"); if (link != NULL) { - if (strcmp (link, "unknown") != 0) + if (!streq (link, "unknown")) return link; free (link); } diff --git a/lib/propername.c b/lib/propername.c index cb661348f2..e927df21b3 100644 --- a/lib/propername.c +++ b/lib/propername.c @@ -275,7 +275,7 @@ proper_name_utf8 (const char *name_ascii, const char *name_utf8) /* See whether we have a translation. Some translators have not understood that they should use the UTF-8 form of the name, if possible. So if the translator provided a no-op translation, we ignore it. */ - if (strcmp (translation, name_ascii) != 0) + if (!streq (translation, name_ascii)) { /* See whether the translation contains the original name. */ if (mbsstr_trimmed_wordbounded (translation, name_ascii) diff --git a/lib/pt_chown.c b/lib/pt_chown.c index 6e7b0c10d8..ec4ed905ae 100644 --- a/lib/pt_chown.c +++ b/lib/pt_chown.c @@ -85,7 +85,7 @@ main (int argc, char *argv[]) } /* It would be possible to drop setuid/setgid privileges here. But it is not - really needed, since the code below only calls strcmp and [f]printf. */ + really needed, since the code below only calls streq and [f]printf. */ { int do_help = 0; @@ -98,14 +98,14 @@ main (int argc, char *argv[]) if (arg[0] == '-') { - if (strcmp (arg, "--") == 0) + if (streq (arg, "--")) { remaining++; break; } - else if (strcmp (arg, "--help") == 0) + else if (streq (arg, "--help")) do_help = 1; - else if (strcmp (arg, "--version") == 0) + else if (streq (arg, "--version")) do_version = 1; else { diff --git a/lib/putenv.c b/lib/putenv.c index acd49f7c53..c310ebda65 100644 --- a/lib/putenv.c +++ b/lib/putenv.c @@ -106,7 +106,7 @@ putenv (char *string) name_x[name_end - string + 2] = 0; putenv_result = _putenv (name_x); for (ep = environ; *ep; ep++) - if (strcmp (*ep, name_x) == 0) + if (streq (*ep, name_x)) { *ep = string; break; diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c index 282f4b2d2a..e86e15544f 100644 --- a/lib/qcopy-acl.c +++ b/lib/qcopy-acl.c @@ -50,9 +50,9 @@ is_attr_permissions (const char *name, struct error_context *ctx) { /* We need to explicitly test for the known extended attribute names, because at least on CentOS 7, attr_copy_action does not do it. */ - return strcmp (name, XATTR_NAME_POSIX_ACL_ACCESS) == 0 - || strcmp (name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0 - || strcmp (name, XATTR_NAME_NFSV4_ACL) == 0 + return streq (name, XATTR_NAME_POSIX_ACL_ACCESS) + || streq (name, XATTR_NAME_POSIX_ACL_DEFAULT) + || streq (name, XATTR_NAME_NFSV4_ACL) || attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS; } diff --git a/lib/readutmp.c b/lib/readutmp.c index 1ddc4a5117..ce9aff9595 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -343,7 +343,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, SET_UTMP_ENT (); # if (defined __linux__ && !defined __ANDROID__) || defined __minix - bool file_is_utmp = (strcmp (file, UTMP_FILE) == 0); + bool file_is_utmp = streq (file, UTMP_FILE); /* Timestamp of the "runlevel" entry, if any. */ struct timespec runlevel_ts = {0}; # endif @@ -457,7 +457,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, it produces wrong values after the date has been bumped in the running system. */ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -556,7 +556,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, } else { - if (strcmp (file, UTMP_FILE) != 0) + if (!streq (file, UTMP_FILE)) { int saved_errno = errno; free (a.utmp); @@ -567,7 +567,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, # if defined __OpenBSD__ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -585,7 +585,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, # if defined __linux__ && !defined __ANDROID__ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -604,7 +604,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, && defined CTL_KERN && defined KERN_BOOTTIME \ && !defined __minix if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -620,7 +620,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, # if defined __HAIKU__ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -636,7 +636,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, # if HAVE_OS_H /* BeOS, Haiku */ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -654,7 +654,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, # if defined __CYGWIN__ || defined _WIN32 if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -670,7 +670,7 @@ read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, # if defined _WIN32 && ! defined __CYGWIN__ if ((options & (READ_UTMP_USER_PROCESS | READ_UTMP_NO_BOOT_TIME)) == 0 - && strcmp (file, UTMP_FILE) == 0 + && streq (file, UTMP_FILE) && !have_boot_time (a)) { struct timespec boot_time; @@ -841,7 +841,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) /* Try harder to get a sensible value for the tty. */ if (sd_session_get_type (session, &type) < 0) type = missing; - if (strcmp (type, "tty") == 0) + if (streq (type, "tty")) { char *service; if (sd_session_get_service (session, &service) < 0) @@ -863,7 +863,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) else if (pty != NULL) tty = pty; } - else if (strcmp (type, "web") == 0) + else if (streq (type, "web")) { char *service; if (sd_session_get_service (session, &service) < 0) @@ -901,7 +901,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) host field. */ if (!type && sd_session_get_type (session, &type) < 0) type = missing; - if (strcmp (type, "x11") == 0) + if (streq (type, "x11")) { char *display; if (sd_session_get_display (session, &display) < 0) @@ -978,7 +978,7 @@ read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { # if READUTMP_USE_SYSTEMD - if (strcmp (file, UTMP_FILE) == 0) + if (streq (file, UTMP_FILE)) /* Imitate reading UTMP_FILE, using systemd and Linux APIs. */ return read_utmp_from_systemd (n_entries, utmp_buf, options); # endif diff --git a/lib/rpmatch.c b/lib/rpmatch.c index febefb2a02..507707345e 100644 --- a/lib/rpmatch.c +++ b/lib/rpmatch.c @@ -90,7 +90,7 @@ localized_pattern (const char *english_pattern, nl_item nl_index, static int try (const char *response, const char *pattern, char **lastp, regex_t *re) { - if (*lastp == NULL || strcmp (pattern, *lastp) != 0) + if (*lastp == NULL || !streq (pattern, *lastp)) { char *safe_pattern; diff --git a/lib/setlocale-fixes.c b/lib/setlocale-fixes.c index 771ffe15cf..caa1863329 100644 --- a/lib/setlocale-fixes.c +++ b/lib/setlocale-fixes.c @@ -98,7 +98,7 @@ fill_lc_all_name (void) { bool all_same = true; for (size_t i = 1; i < 12; i++) - if (strcmp (lc_cat_name[i], lc_cat_name[0]) != 0) + if (!streq (lc_cat_name[i], lc_cat_name[0])) { all_same = false; break; diff --git a/lib/setlocale.c b/lib/setlocale.c index ea8b4ba89b..814a9bd8c7 100644 --- a/lib/setlocale.c +++ b/lib/setlocale.c @@ -686,7 +686,7 @@ setlocale_unixlike (int category, const char *locale) /* The native Windows implementation of setlocale understands the special locale name "C", but not "POSIX". Therefore map "POSIX" to "C". */ - if (locale != NULL && strcmp (locale, "POSIX") == 0) + if (locale != NULL && streq (locale, "POSIX")) locale = "C"; /* The native Windows implementation of setlocale, in the UTF-8 environment, @@ -694,8 +694,8 @@ setlocale_unixlike (int category, const char *locale) but it understands "English_United States.65001", which is functionally equivalent. */ if (locale != NULL - && ((is_utf8 && strcmp (locale, "C") == 0) - || strcmp (locale, "C.UTF-8") == 0)) + && ((is_utf8 && streq (locale, "C")) + || streq (locale, "C.UTF-8"))) locale = "English_United States.65001"; /* First, try setlocale with the original argument unchanged. */ @@ -728,7 +728,7 @@ setlocale_unixlike (int category, const char *locale) /* llCC_buf now contains language[_territory][@modifier] */ - if (strcmp (llCC_buf, locale) != 0) + if (!streq (llCC_buf, locale)) { if (is_utf8) { @@ -890,7 +890,7 @@ setlocale_unixlike (int category, const char *locale) case LC_TELEPHONE: case LC_MEASUREMENT: if (locale == NULL - || strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) + || streq (locale, "C") || streq (locale, "POSIX")) result = (char *) "C"; break; default: @@ -1501,7 +1501,7 @@ setlocale_improved (int category, const char *locale) LC_CTYPE category to an invalid value ("C") when it does not support the specified encoding. Report a failure instead. */ if (strchr (base_name, '.') != NULL - && strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + && streq (setlocale (LC_CTYPE, NULL), "C")) goto fail; # endif @@ -1516,7 +1516,7 @@ setlocale_improved (int category, const char *locale) /* If name is the same as base_name, it has already been set through the setlocale call before the loop. */ - if (strcmp (name, base_name) != 0 + if (!streq (name, base_name) # if LC_MESSAGES == 1729 || cat == LC_MESSAGES # endif @@ -1726,7 +1726,7 @@ setlocale_improved (int category, const char *locale) set the LC_CTYPE category to an invalid value ("C") when it does not support the specified encoding. Report a failure instead. */ - if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) + if (streq (setlocale (LC_CTYPE, NULL), "C")) { /* Don't risk an endless recursion. */ if (saved_locale[0] != '\0') @@ -1778,7 +1778,7 @@ setlocale_improved (int category, const char *locale) { char *name1 = setlocale (LC_ALL, NULL); char *name2 = setlocale_single (LC_MESSAGES, NULL); - if (strcmp (name1, name2) == 0) + if (streq (name1, name2)) /* Not a mixed locale. */ return name1; else diff --git a/lib/sig2str.c b/lib/sig2str.c index e8c830c6da..bf4d009578 100644 --- a/lib/sig2str.c +++ b/lib/sig2str.c @@ -288,7 +288,7 @@ str2signum (char const *signame) { unsigned int i; for (i = 0; i < NUMNAME_ENTRIES; i++) - if (strcmp (numname_table[i].name, signame) == 0) + if (streq (numname_table[i].name, signame)) return numname_table[i].num; { diff --git a/lib/spawni.c b/lib/spawni.c index f6558dfd16..34c16445fc 100644 --- a/lib/spawni.c +++ b/lib/spawni.c @@ -328,7 +328,7 @@ static HANDLE open_handle (const char *name, int flags, mode_t mode) { /* To ease portability. Like in open.c. */ - if (strcmp (name, "/dev/null") == 0) + if (streq (name, "/dev/null")) name = "NUL"; /* POSIX diff --git a/lib/stat.c b/lib/stat.c index 9c44ba43b4..f4cc02e9d7 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -112,7 +112,7 @@ rpl_stat (char const *name, struct stat *buf) ? */ /* To ease portability. Like in open.c. */ - if (strcmp (name, "/dev/null") == 0) + if (streq (name, "/dev/null")) name = "NUL"; /* POSIX diff --git a/lib/str_endswith.c b/lib/str_endswith.c index d79d710866..cd2cc9e146 100644 --- a/lib/str_endswith.c +++ b/lib/str_endswith.c @@ -27,5 +27,5 @@ str_endswith (const char *string, const char *suffix) { size_t len = strlen (string); size_t n = strlen (suffix); - return len >= n && strcmp (string + len - n, suffix) == 0; + return len >= n && streq (string + len - n, suffix); } diff --git a/lib/streq.h b/lib/streq.h index 1f1ff38f6b..eb0df460e5 100644 --- a/lib/streq.h +++ b/lib/streq.h @@ -39,7 +39,7 @@ extern "C" { static inline int streq9 (const char *s1, const char *s2) { - return strcmp (s1 + 9, s2 + 9) == 0; + return streq (s1 + 9, s2 + 9); } static inline int diff --git a/lib/striconveha.c b/lib/striconveha.c index 26448250c1..b7dec0178b 100644 --- a/lib/striconveha.c +++ b/lib/striconveha.c @@ -160,7 +160,7 @@ mem_iconveha_notranslit (const char *src, size_t srclen, /* Unsupported from_codeset or to_codeset. Check whether the caller requested autodetection. */ for (alias = autodetect_list; alias != NULL; alias = alias->next) - if (strcmp (from_codeset, alias->name) == 0) + if (streq (from_codeset, alias->name)) { const char * const *encodings; @@ -270,7 +270,7 @@ str_iconveha_notranslit (const char *src, /* Unsupported from_codeset or to_codeset. Check whether the caller requested autodetection. */ for (alias = autodetect_list; alias != NULL; alias = alias->next) - if (strcmp (from_codeset, alias->name) == 0) + if (streq (from_codeset, alias->name)) { const char * const *encodings; diff --git a/lib/struniq.h b/lib/struniq.h index 7bc77d1cc9..00446f6eb8 100644 --- a/lib/struniq.h +++ b/lib/struniq.h @@ -84,7 +84,7 @@ struniq (const char *string) struct struniq_hash_node *new_node; struct struniq_hash_node *p; for (p = struniq_hash_table[slot]; p != NULL; p = p->next) - if (strcmp (p->contents, string) == 0) + if (streq (p->contents, string)) return p->contents; size = strlen (string) + 1; new_node = @@ -101,7 +101,7 @@ struniq (const char *string) /* Check whether another thread already added the string while we were waiting on the lock. */ for (p = struniq_hash_table[slot]; p != NULL; p = p->next) - if (strcmp (p->contents, string) == 0) + if (streq (p->contents, string)) { free (new_node); new_node = p; diff --git a/lib/supersede.c b/lib/supersede.c index 10691eb183..49206d746b 100644 --- a/lib/supersede.c +++ b/lib/supersede.c @@ -97,7 +97,7 @@ open_supersede (const char *filename, int flags, mode_t mode, #endif #if defined _WIN32 && ! defined __CYGWIN__ - if (strcmp (filename, "/dev/null") == 0) + if (streq (filename, "/dev/null")) filename = "NUL"; #endif diff --git a/lib/time_rz.c b/lib/time_rz.c index 125f4e272d..3a4336636f 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -116,7 +116,7 @@ save_abbr (timezone_t tz, struct tm *tm) { zone_copy = tz->abbrs; - while (strcmp (zone_copy, zone) != 0) + while (!streq (zone_copy, zone)) { if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { @@ -202,7 +202,7 @@ set_tz (timezone_t tz) { char *env_tz = getenv_TZ (); if (env_tz - ? tz->tz_is_set && strcmp (tz->abbrs, env_tz) == 0 + ? tz->tz_is_set && streq (tz->abbrs, env_tz) : !tz->tz_is_set) return local_tz; else diff --git a/lib/unicodeio.c b/lib/unicodeio.c index 6305cbbc42..5c67283a27 100644 --- a/lib/unicodeio.c +++ b/lib/unicodeio.c @@ -81,7 +81,7 @@ unicode_to_mb (unsigned int code, { const char *charset = locale_charset (); - is_utf8 = !strcmp (charset, UTF8_NAME); + is_utf8 = streq (charset, UTF8_NAME); #if HAVE_ICONV if (!is_utf8) { diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 7219c741cd..614da3187c 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -439,7 +439,7 @@ thousands_separator_char (char stackbuf[10]) stackbuf[strlen (stackbuf) - 3] = '\0'; # if defined __sun /* Solaris specific hack: Replace wrong result (0xC2 means U+00A0). */ - if (strcmp (&stackbuf[1], "\302") == 0) + if (streq (&stackbuf[1], "\302")) strcpy (&stackbuf[1], MB_CUR_MAX > 1 ? "\302\240" : "\240"); # endif return &stackbuf[1]; @@ -524,7 +524,7 @@ thousands_separator_wchar (wchar_t stackbuf[10]) /* Now tmp = L"1000". */ tmp[strlen (tmp) - 3] = '\0'; /* Solaris specific hack: Replace wrong result (0xC2 means U+00A0). */ - if (strcmp (&tmp[1], "\302") == 0) + if (streq (&tmp[1], "\302")) strcpy (&tmp[1], MB_CUR_MAX > 1 ? "\302\240" : "\240"); if (tmp[1] != '\0') { diff --git a/lib/vc-mtime.c b/lib/vc-mtime.c index 1351fd7ec3..5db654fbcc 100644 --- a/lib/vc-mtime.c +++ b/lib/vc-mtime.c @@ -381,9 +381,9 @@ abs_git_checkout (void) static long ancestor_level (const char *dir1, const char *dir2) { - if (strcmp (dir1, "/") == 0) + if (streq (dir1, "/")) dir1 = ""; - if (strcmp (dir2, "/") == 0) + if (streq (dir2, "/")) dir2 = ""; size_t dir1_len = strlen (dir1); if (strncmp (dir1, dir2, dir1_len) == 0) @@ -415,14 +415,14 @@ static char * relativize (const char *filename, unsigned long n, const char *dir1, const char *dir2) { - if (strcmp (dir1, "/") == 0) + if (streq (dir1, "/")) dir1 = ""; size_t dir1_len = strlen (dir1); if (!(strncmp (filename, dir1, dir1_len) == 0 && (filename[dir1_len] == '\0' || ISSLASH (filename[dir1_len])))) /* Invalid argument. */ abort (); - if (strcmp (dir2, "/") == 0) + if (streq (dir2, "/")) dir2 = ""; dir2 += dir1_len; @@ -560,7 +560,7 @@ max_vc_mtime (struct timespec *max_of_mtimes, /* Test which of these absolute file names are outside of the git_checkout. */ char *git_checkout_slash = - (strcmp (git_checkout, "/") == 0 + (streq (git_checkout, "/") ? xstrdup (git_checkout) : xasprintf ("%s%c", git_checkout, SLASH)); @@ -1002,75 +1002,75 @@ test_ancestor_level (void) static void test_relativize (void) { - assert (strcmp (relativize ("/home/user/projects/gnulib", - 0, "/home/user/projects/gnulib", "/home/user/projects/gnulib"), - ".") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/NEWS", - 0, "/home/user/projects/gnulib", "/home/user/projects/gnulib"), - "NEWS") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/doc/Makefile", - 0, "/home/user/projects/gnulib", "/home/user/projects/gnulib"), - "doc/Makefile") == 0); - - assert (strcmp (relativize ("/", - 0, "/", "/"), - ".") == 0); - assert (strcmp (relativize ("/swapfile", - 0, "/", "/"), - "swapfile") == 0); - assert (strcmp (relativize ("/etc/passwd", - 0, "/", "/"), - "etc/passwd") == 0); - - assert (strcmp (relativize ("/home/user/projects/gnulib", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../../") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/lib", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/lib/crypto", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - ".") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/lib/malloc", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../malloc") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/lib/cr", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../cr") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/lib/cryptography", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../cryptography") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/doc", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../../doc") == 0); - assert (strcmp (relativize ("/home/user/projects/gnulib/doc/Makefile", - 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), - "../../doc/Makefile") == 0); - - assert (strcmp (relativize ("/", - 2, "/", "/home/user"), - "../../") == 0); - assert (strcmp (relativize ("/home", - 2, "/", "/home/user"), - "../") == 0); - assert (strcmp (relativize ("/home/user", - 2, "/", "/home/user"), - ".") == 0); - assert (strcmp (relativize ("/home/root", - 2, "/", "/home/user"), - "../root") == 0); - assert (strcmp (relativize ("/home/us", - 2, "/", "/home/user"), - "../us") == 0); - assert (strcmp (relativize ("/home/users", - 2, "/", "/home/user"), - "../users") == 0); - assert (strcmp (relativize ("/etc", - 2, "/", "/home/user"), - "../../etc") == 0); - assert (strcmp (relativize ("/etc/passwd", - 2, "/", "/home/user"), - "../../etc/passwd") == 0); + assert (streq (relativize ("/home/user/projects/gnulib", + 0, "/home/user/projects/gnulib", "/home/user/projects/gnulib"), + ".")); + assert (streq (relativize ("/home/user/projects/gnulib/NEWS", + 0, "/home/user/projects/gnulib", "/home/user/projects/gnulib"), + "NEWS")); + assert (streq (relativize ("/home/user/projects/gnulib/doc/Makefile", + 0, "/home/user/projects/gnulib", "/home/user/projects/gnulib"), + "doc/Makefile")); + + assert (streq (relativize ("/", + 0, "/", "/"), + ".")); + assert (streq (relativize ("/swapfile", + 0, "/", "/"), + "swapfile")); + assert (streq (relativize ("/etc/passwd", + 0, "/", "/"), + "etc/passwd")); + + assert (streq (relativize ("/home/user/projects/gnulib", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../../")); + assert (streq (relativize ("/home/user/projects/gnulib/lib", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../")); + assert (streq (relativize ("/home/user/projects/gnulib/lib/crypto", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + ".")); + assert (streq (relativize ("/home/user/projects/gnulib/lib/malloc", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../malloc")); + assert (streq (relativize ("/home/user/projects/gnulib/lib/cr", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../cr")); + assert (streq (relativize ("/home/user/projects/gnulib/lib/cryptography", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../cryptography")); + assert (streq (relativize ("/home/user/projects/gnulib/doc", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../../doc")); + assert (streq (relativize ("/home/user/projects/gnulib/doc/Makefile", + 2, "/home/user/projects/gnulib", "/home/user/projects/gnulib/lib/crypto"), + "../../doc/Makefile")); + + assert (streq (relativize ("/", + 2, "/", "/home/user"), + "../../")); + assert (streq (relativize ("/home", + 2, "/", "/home/user"), + "../")); + assert (streq (relativize ("/home/user", + 2, "/", "/home/user"), + ".")); + assert (streq (relativize ("/home/root", + 2, "/", "/home/user"), + "../root")); + assert (streq (relativize ("/home/us", + 2, "/", "/home/user"), + "../us")); + assert (streq (relativize ("/home/users", + 2, "/", "/home/user"), + "../users")); + assert (streq (relativize ("/etc", + 2, "/", "/home/user"), + "../../etc")); + assert (streq (relativize ("/etc/passwd", + 2, "/", "/home/user"), + "../../etc/passwd")); } /* Usage: ./a.out FILE[...] diff --git a/lib/wctrans-impl.h b/lib/wctrans-impl.h index 0d1bc5de99..0c45caad39 100644 --- a/lib/wctrans-impl.h +++ b/lib/wctrans-impl.h @@ -23,11 +23,11 @@ wctrans (const char *name) switch (name[2]) { case 'l': - if (strcmp (name + 3, "ower") == 0) + if (streq (name + 3, "ower")) return (wctrans_t) towlower; break; case 'u': - if (strcmp (name + 3, "pper") == 0) + if (streq (name + 3, "pper")) return (wctrans_t) towupper; break; default: diff --git a/lib/wctype-impl.h b/lib/wctype-impl.h index 8bb83be71b..dad3fa1106 100644 --- a/lib/wctype-impl.h +++ b/lib/wctype-impl.h @@ -27,11 +27,11 @@ wctype (const char* name) switch (name[2]) { case 'n': - if (strcmp (name + 3, "um") == 0) + if (streq (name + 3, "um")) return (wctype_t) iswalnum; break; case 'p': - if (strcmp (name + 3, "ha") == 0) + if (streq (name + 3, "ha")) return (wctype_t) iswalpha; break; default: @@ -43,34 +43,34 @@ wctype (const char* name) } break; case 'b': - if (strcmp (name + 1, "lank") == 0) + if (streq (name + 1, "lank")) return (wctype_t) iswblank; break; case 'c': - if (strcmp (name + 1, "ntrl") == 0) + if (streq (name + 1, "ntrl")) return (wctype_t) iswcntrl; break; case 'd': - if (strcmp (name + 1, "igit") == 0) + if (streq (name + 1, "igit")) return (wctype_t) iswdigit; break; case 'g': - if (strcmp (name + 1, "raph") == 0) + if (streq (name + 1, "raph")) return (wctype_t) iswgraph; break; case 'l': - if (strcmp (name + 1, "ower") == 0) + if (streq (name + 1, "ower")) return (wctype_t) iswlower; break; case 'p': switch (name[1]) { case 'r': - if (strcmp (name + 2, "int") == 0) + if (streq (name + 2, "int")) return (wctype_t) iswprint; break; case 'u': - if (strcmp (name + 2, "nct") == 0) + if (streq (name + 2, "nct")) return (wctype_t) iswpunct; break; default: @@ -78,15 +78,15 @@ wctype (const char* name) } break; case 's': - if (strcmp (name + 1, "pace") == 0) + if (streq (name + 1, "pace")) return (wctype_t) iswspace; break; case 'u': - if (strcmp (name + 1, "pper") == 0) + if (streq (name + 1, "pper")) return (wctype_t) iswupper; break; case 'x': - if (strcmp (name + 1, "digit") == 0) + if (streq (name + 1, "digit")) return (wctype_t) iswxdigit; break; default: diff --git a/modules/acl-permissions b/modules/acl-permissions index bcd1fc5e40..d86c50e91a 100644 --- a/modules/acl-permissions +++ b/modules/acl-permissions @@ -16,6 +16,7 @@ extern-inline fstat minmax stat +stringeq bool sys_stat-h stdint-h diff --git a/modules/argp b/modules/argp index d6122adcef..d435ae0cfd 100644 --- a/modules/argp +++ b/modules/argp @@ -24,6 +24,7 @@ basename-lgpl extern-inline getopt-gnu strchrnul +stringeq sysexits-h malloc-gnu mempcpy diff --git a/modules/c32_get_mapping b/modules/c32_get_mapping index de2a3b63de..1545c5e22d 100644 --- a/modules/c32_get_mapping +++ b/modules/c32_get_mapping @@ -10,6 +10,7 @@ uchar-h wctrans c32tolower c32toupper +stringeq configure.ac: gl_UCHAR_MODULE_INDICATOR([c32_get_mapping]) diff --git a/modules/c32_get_type_test b/modules/c32_get_type_test index e511bd51c7..e26a894df0 100644 --- a/modules/c32_get_type_test +++ b/modules/c32_get_type_test @@ -20,6 +20,7 @@ c32ispunct c32isspace c32isupper c32isxdigit +stringeq configure.ac: gl_UCHAR_MODULE_INDICATOR([c32_get_type_test]) diff --git a/modules/concat-filename b/modules/concat-filename index 9e86b793bf..51e55a7465 100644 --- a/modules/concat-filename +++ b/modules/concat-filename @@ -10,6 +10,7 @@ Depends-on: filename malloc-posix stpcpy +stringeq configure.ac: diff --git a/modules/cpu-supports b/modules/cpu-supports index 448eb2a902..8f5871d46f 100644 --- a/modules/cpu-supports +++ b/modules/cpu-supports @@ -9,6 +9,7 @@ Depends-on: attribute bool c99 +stringeq configure.ac: AC_REQUIRE([AC_C_INLINE]) diff --git a/modules/dfa b/modules/dfa index eed35091b8..8aa8465c5a 100644 --- a/modules/dfa +++ b/modules/dfa @@ -31,6 +31,7 @@ stdint-h stdio-h stdlib-h string-h +stringeq uchar-h # The lonesome_lower array requires ISO C 23 semantics for char32_t. # But uchar-h-c23 has a global effect, therefore leave it to each package diff --git a/modules/duplocale b/modules/duplocale index e4fce0ed04..46e1ab0d63 100644 --- a/modules/duplocale +++ b/modules/duplocale @@ -10,6 +10,7 @@ locale-h freelocale [test $HAVE_LOCALE_T = 0 || { test $HAVE_DUPLOCALE = 1 && test $REPLACE_DUPLOCALE = 1; }] newlocale [test $HAVE_LOCALE_T = 0 || { test $HAVE_DUPLOCALE = 1 && test $REPLACE_DUPLOCALE = 1; }] setlocale-null [test $HAVE_LOCALE_T = 0 || { test $HAVE_DUPLOCALE = 1 && test $REPLACE_DUPLOCALE = 1; }] +stringeq [test $HAVE_LOCALE_T = 0 || { test $HAVE_DUPLOCALE = 1 && test $REPLACE_DUPLOCALE = 1; }] configure.ac: gl_FUNC_DUPLOCALE diff --git a/modules/exclude b/modules/exclude index d3ccc5be51..a4701ebf12 100644 --- a/modules/exclude +++ b/modules/exclude @@ -17,6 +17,7 @@ mbscasecmp mbuiter [test "$GNULIB_MCEL_PREFER" != yes] nullptr regex +stringeq bool unlocked-io-internal xalloc diff --git a/modules/findprog b/modules/findprog index 619f089407..782ba981a6 100644 --- a/modules/findprog +++ b/modules/findprog @@ -14,6 +14,7 @@ xalloc xconcat-filename access stat +stringeq unistd-h configure.ac: diff --git a/modules/findprog-in b/modules/findprog-in index 6f279f0f50..c36295f8af 100644 --- a/modules/findprog-in +++ b/modules/findprog-in @@ -15,6 +15,7 @@ concat-filename access stat strdup-posix +stringeq malloc-posix unistd-h diff --git a/modules/fopen b/modules/fopen index 4580b374a0..422759e622 100644 --- a/modules/fopen +++ b/modules/fopen @@ -12,6 +12,7 @@ stdio-h largefile fcntl-h [test $REPLACE_FOPEN = 1] bool [test $REPLACE_FOPEN = 1] +stringeq [test $REPLACE_FOPEN = 1] unistd-h [test $REPLACE_FOPEN = 1] close [test $REPLACE_FOPEN = 1] fstat [test $REPLACE_FOPEN = 1] diff --git a/modules/fopen-gnu b/modules/fopen-gnu index e6d20ed57f..1433f514a0 100644 --- a/modules/fopen-gnu +++ b/modules/fopen-gnu @@ -9,6 +9,7 @@ fopen open [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] fcntl-h [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] bool [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] +stringeq [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] unistd-h [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] close [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] fstat [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1] diff --git a/modules/freopen b/modules/freopen index 6bf857bb9c..19d41a440b 100644 --- a/modules/freopen +++ b/modules/freopen @@ -7,6 +7,7 @@ m4/freopen.m4 Depends-on: fcntl-h [test $REPLACE_FREOPEN = 1] +stringeq [test $REPLACE_FREOPEN = 1] open [test $REPLACE_FREOPEN = 1] stdio-h largefile diff --git a/modules/fts b/modules/fts index ac6be2cb32..70e3c1bdc2 100644 --- a/modules/fts +++ b/modules/fts @@ -40,6 +40,7 @@ realloc-posix bool stddef-h stdint-h +stringeq configure.ac: gl_FUNC_FTS diff --git a/modules/getlocalename_l-simple b/modules/getlocalename_l-simple index 6b9cc9e9ba..febf2911da 100644 --- a/modules/getlocalename_l-simple +++ b/modules/getlocalename_l-simple @@ -12,6 +12,7 @@ extensions getlocalename_l-unsafe [test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1] flexmember [test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1] lock [test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1] +stringeq [test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1] bool [test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1] thread-optim [test $HAVE_GETLOCALENAME_L = 0 || test $REPLACE_GETLOCALENAME_L = 1] diff --git a/modules/getlocalename_l-unsafe b/modules/getlocalename_l-unsafe index c2392fc39d..82bff7746f 100644 --- a/modules/getlocalename_l-unsafe +++ b/modules/getlocalename_l-unsafe @@ -15,6 +15,7 @@ locale-h getlocalename_l-unsafe-limited flexmember lock +stringeq bool thread-optim setlocale-fixes diff --git a/modules/getlogin b/modules/getlogin index 64f3e4fd25..6781219afe 100644 --- a/modules/getlogin +++ b/modules/getlogin @@ -8,6 +8,7 @@ m4/getlogin.m4 Depends-on: unistd-h readutmp [test $HAVE_GETLOGIN = 0 || test $REPLACE_GETLOGIN = 1] +stringeq [test $HAVE_GETLOGIN = 0 || test $REPLACE_GETLOGIN = 1] configure.ac: gl_FUNC_GETLOGIN diff --git a/modules/getugroups b/modules/getugroups index ee27691bcb..756df53033 100644 --- a/modules/getugroups +++ b/modules/getugroups @@ -8,6 +8,7 @@ m4/getugroups.m4 Depends-on: errno-h +stringeq configure.ac: gl_GETUGROUPS diff --git a/modules/hard-locale b/modules/hard-locale index af94813fd2..11e0265b2e 100644 --- a/modules/hard-locale +++ b/modules/hard-locale @@ -8,6 +8,7 @@ lib/hard-locale.c Depends-on: bool setlocale-null +stringeq configure.ac: AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) diff --git a/modules/hashcode-named-file b/modules/hashcode-named-file index 7e5eebf763..bda7905659 100644 --- a/modules/hashcode-named-file +++ b/modules/hashcode-named-file @@ -9,6 +9,7 @@ lib/hash-triple.h Depends-on: hashcode-string2 same-inode +stringeq bool configure.ac: diff --git a/modules/hashkey-string b/modules/hashkey-string index 8391b4576b..aa32fc9a07 100644 --- a/modules/hashkey-string +++ b/modules/hashkey-string @@ -7,6 +7,7 @@ lib/hashkey-string.c Depends-on: bool +stringeq configure.ac: diff --git a/modules/iconv_open b/modules/iconv_open index 2ac5252a1c..eb7dfeef40 100644 --- a/modules/iconv_open +++ b/modules/iconv_open @@ -18,6 +18,7 @@ iconv c-ctype [test $REPLACE_ICONV_OPEN = 1] c-strcasecmp [test $REPLACE_ICONV_OPEN = 1] stdint-h [test $REPLACE_ICONV_UTF = 1] +stringeq [test $REPLACE_ICONV_UTF = 1] unistr/u8-mbtoucr [test $REPLACE_ICONV_UTF = 1] unistr/u8-uctomb [test $REPLACE_ICONV_UTF = 1] diff --git a/modules/idcache b/modules/idcache index 25cfb3fe8d..34c19e046f 100644 --- a/modules/idcache +++ b/modules/idcache @@ -8,6 +8,7 @@ m4/idcache.m4 Depends-on: flexmember +stringeq xalloc configure.ac: diff --git a/modules/localcharset b/modules/localcharset index 65ab529e95..0e5be1d035 100644 --- a/modules/localcharset +++ b/modules/localcharset @@ -9,6 +9,7 @@ m4/localcharset.m4 Depends-on: extensions +stringeq configure.ac: gl_LOCALCHARSET diff --git a/modules/localename b/modules/localename index 15d1dea162..9a10ce44ea 100644 --- a/modules/localename +++ b/modules/localename @@ -11,6 +11,7 @@ locale-h localename-unsafe flexmember lock +stringeq bool thread-optim diff --git a/modules/localename-unsafe b/modules/localename-unsafe index 01901ab1f6..37d225a74b 100644 --- a/modules/localename-unsafe +++ b/modules/localename-unsafe @@ -17,6 +17,7 @@ localename-environ extensions locale-h strdup +stringeq windows-mutex getlocalename_l-unsafe setlocale-null-unlocked diff --git a/modules/mbs_endswith b/modules/mbs_endswith index 73ef26c1f5..9aeecb2873 100644 --- a/modules/mbs_endswith +++ b/modules/mbs_endswith @@ -8,6 +8,7 @@ Depends-on: string-h bool str_endswith +stringeq mbslen mbiter diff --git a/modules/mountlist b/modules/mountlist index 9658435562..4cf5563608 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -16,6 +16,7 @@ open unlocked-io-internal bool stdint-h +stringeq strstr-simple xalloc diff --git a/modules/newlocale b/modules/newlocale index c48ff2b8cd..0bff3d3794 100644 --- a/modules/newlocale +++ b/modules/newlocale @@ -8,6 +8,7 @@ m4/newlocale.m4 Depends-on: locale-h localename-environ +stringeq configure.ac: gl_FUNC_NEWLOCALE diff --git a/modules/nl_langinfo b/modules/nl_langinfo index b553cfb99b..0d8e968821 100644 --- a/modules/nl_langinfo +++ b/modules/nl_langinfo @@ -13,6 +13,7 @@ Depends-on: langinfo-h localeconv [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1] setlocale-null [test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0] +stringeq [test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0] configure.ac: gl_FUNC_NL_LANGINFO diff --git a/modules/nproc b/modules/nproc index 1081f7b778..ac56d1dd0f 100644 --- a/modules/nproc +++ b/modules/nproc @@ -10,6 +10,7 @@ Depends-on: c-ctype extensions minmax +stringeq unistd-h configure.ac: diff --git a/modules/open b/modules/open index 62b711f681..6eec9e29f6 100644 --- a/modules/open +++ b/modules/open @@ -15,6 +15,7 @@ cloexec [test $REPLACE_OPEN = 1] fstat [test $REPLACE_OPEN = 1] lstat [test $REPLACE_OPEN = 1] stat [test $REPLACE_OPEN = 1] +stringeq [test $REPLACE_OPEN = 1] configure.ac: gl_FUNC_OPEN diff --git a/modules/parse-datetime b/modules/parse-datetime index b8b3e6d75b..f64d63007b 100644 --- a/modules/parse-datetime +++ b/modules/parse-datetime @@ -22,6 +22,7 @@ intprops inttypes-h mktime stdckdint-h +stringeq time-h time_r time_rz diff --git a/modules/popen b/modules/popen index 494081105e..903b9d8c0f 100644 --- a/modules/popen +++ b/modules/popen @@ -8,6 +8,7 @@ m4/popen.m4 Depends-on: stdio-h open [test $HAVE_POPEN = 0 || test $REPLACE_POPEN = 1] +stringeq [test $HAVE_POPEN = 0 || test $REPLACE_POPEN = 1] configure.ac: gl_FUNC_POPEN diff --git a/modules/posix_spawn-internal b/modules/posix_spawn-internal index 8b5439e87b..008d22c903 100644 --- a/modules/posix_spawn-internal +++ b/modules/posix_spawn-internal @@ -20,6 +20,7 @@ concat-filename [test $HAVE_POSIX_SPAWN = 0] findprog-in [test $HAVE_POSIX_SPAWN = 0] free-posix [test $HAVE_POSIX_SPAWN = 0] malloca [test $HAVE_POSIX_SPAWN = 0] +stringeq [test $HAVE_POSIX_SPAWN = 0] bool [test $HAVE_POSIX_SPAWN = 0] windows-spawn [test $HAVE_POSIX_SPAWN = 0] diff --git a/modules/propername b/modules/propername index 427eec7896..3f6aa0f9b8 100644 --- a/modules/propername +++ b/modules/propername @@ -14,6 +14,7 @@ mbchar mbuiter iconv localcharset +stringeq c-strcasecmp xstriconv xalloc diff --git a/modules/pt_chown b/modules/pt_chown index 57775b24d6..3cc4e21d76 100644 --- a/modules/pt_chown +++ b/modules/pt_chown @@ -11,6 +11,7 @@ root-uid stdlib-h configmake stat +stringeq configure.ac: diff --git a/modules/putenv-gnu b/modules/putenv-gnu index a6f425d252..108ac8b8ae 100644 --- a/modules/putenv-gnu +++ b/modules/putenv-gnu @@ -10,6 +10,7 @@ stdlib-h environ [test $REPLACE_PUTENV = 1] free-posix [test $REPLACE_PUTENV = 1] malloc-posix [test $REPLACE_PUTENV = 1] +stringeq [test $REPLACE_PUTENV = 1] unsetenv [test $REPLACE_PUTENV = 1] configure.ac: diff --git a/modules/qcopy-acl b/modules/qcopy-acl index 8adedf7ad9..857b45e85b 100644 --- a/modules/qcopy-acl +++ b/modules/qcopy-acl @@ -10,6 +10,7 @@ Depends-on: acl-permissions dirent-h [test "$use_xattr" = yes] file-has-acl [test "$use_xattr" = yes] +stringeq [test "$use_xattr" = yes] configure.ac: gl_QCOPY_ACL diff --git a/modules/rpmatch b/modules/rpmatch index 657047da1d..fb32389a09 100644 --- a/modules/rpmatch +++ b/modules/rpmatch @@ -13,6 +13,7 @@ gettext-h [test $HAVE_RPMATCH = 0] gnulib-i18n [test $HAVE_RPMATCH = 0] regex [test $HAVE_RPMATCH = 0] strdup [test $HAVE_RPMATCH = 0] +stringeq [test $HAVE_RPMATCH = 0] configure.ac: gl_FUNC_RPMATCH @@ -39,4 +40,3 @@ GPL Maintainer: Jim Meyering - diff --git a/modules/selinux-h b/modules/selinux-h index ae5841e0ef..8f85c8e744 100644 --- a/modules/selinux-h +++ b/modules/selinux-h @@ -18,6 +18,7 @@ errno-h sys_types-h extern-inline gen-header +stringeq configure.ac: gl_HEADERS_SELINUX_SELINUX_H diff --git a/modules/setenv b/modules/setenv index df5b9c014d..76c7dc13e7 100644 --- a/modules/setenv +++ b/modules/setenv @@ -10,6 +10,7 @@ stdlib-h malloca [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1] alloca-opt [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1] malloc-posix [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1] +stringeq [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1] unistd-h [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1] environ [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1] diff --git a/modules/setlocale b/modules/setlocale index 4cf9597ea8..5f71838011 100644 --- a/modules/setlocale +++ b/modules/setlocale @@ -7,6 +7,7 @@ m4/setlocale.m4 Depends-on: locale-h +stringeq setlocale-fixes [test $NEED_SETLOCALE_IMPROVED = 1] localename [test $NEED_SETLOCALE_IMPROVED = 1] localename-environ [test $NEED_SETLOCALE_IMPROVED = 1] diff --git a/modules/setlocale-fixes b/modules/setlocale-fixes index a397793da9..7ab3bd821c 100644 --- a/modules/setlocale-fixes +++ b/modules/setlocale-fixes @@ -6,6 +6,7 @@ lib/setlocale-fixes.h lib/setlocale-fixes.c Depends-on: +stringeq configure.ac: AC_REQUIRE([AC_CANONICAL_HOST]) diff --git a/modules/sig2str b/modules/sig2str index 8055a58ff1..11b03ab47b 100644 --- a/modules/sig2str +++ b/modules/sig2str @@ -8,6 +8,7 @@ m4/sig2str.m4 Depends-on: signal-h +stringeq configure.ac: gl_FUNC_SIG2STR diff --git a/modules/spawn-pipe b/modules/spawn-pipe index 494c01bc63..e1fe269da8 100644 --- a/modules/spawn-pipe +++ b/modules/spawn-pipe @@ -39,6 +39,7 @@ posix_spawnattr_setflags posix_spawnattr_destroy bool stdlib-h +stringeq unistd-h unistd-safer wait-process diff --git a/modules/stat b/modules/stat index dc91855049..79c2087fc1 100644 --- a/modules/stat +++ b/modules/stat @@ -15,6 +15,7 @@ filename [test $REPLACE_STAT = 1] malloca [test $REPLACE_STAT = 1] pathmax [test $REPLACE_STAT = 1] stat-time [test $REPLACE_STAT = 1] +stringeq [test $REPLACE_STAT = 1] bool [test $REPLACE_STAT = 1] configure.ac: diff --git a/modules/str_endswith b/modules/str_endswith index aceb295ca8..9281e00c2b 100644 --- a/modules/str_endswith +++ b/modules/str_endswith @@ -6,6 +6,7 @@ lib/str_endswith.c Depends-on: string-h +stringeq bool configure.ac: diff --git a/modules/streq b/modules/streq index de509ccb29..aadce69305 100644 --- a/modules/streq +++ b/modules/streq @@ -5,6 +5,7 @@ Files: lib/streq.h Depends-on: +stringeq configure.ac: diff --git a/modules/striconveha b/modules/striconveha index 090855ccc9..01d8c4d6e4 100644 --- a/modules/striconveha +++ b/modules/striconveha @@ -11,6 +11,7 @@ bool striconveh malloca strdup +stringeq c-strcasecmp configure.ac: diff --git a/modules/supersede b/modules/supersede index 36f7278c33..51c167b9aa 100644 --- a/modules/supersede +++ b/modules/supersede @@ -10,6 +10,7 @@ Depends-on: c99 fcntl-h bool +stringeq sys_stat-h clean-temp tempname diff --git a/modules/time_rz b/modules/time_rz index ac5a0e7a84..1981b81920 100644 --- a/modules/time_rz +++ b/modules/time_rz @@ -14,6 +14,7 @@ flexmember [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test idx [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] setenv [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] bool [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] +stringeq [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] time_r [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] timegm [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] tzset [test $HAVE_TZALLOC = 0 || test $REPLACE_LOCALTIME_RZ = 1 || test $REPLACE_MKTIME_Z = 1] diff --git a/modules/uchar-h b/modules/uchar-h index 6360859857..a9a905db0c 100644 --- a/modules/uchar-h +++ b/modules/uchar-h @@ -15,6 +15,7 @@ snippet/warn-on-use extern-inline assert-h stdint-h +stringeq wchar-h wctype-h diff --git a/modules/unicodeio b/modules/unicodeio index 0b84d992bf..379bbf5938 100644 --- a/modules/unicodeio +++ b/modules/unicodeio @@ -16,6 +16,7 @@ gnulib-i18n localcharset error stdio-h +stringeq configure.ac: gl_UNICODEIO diff --git a/modules/uniconv/base b/modules/uniconv/base index f60d1b468d..432348c863 100644 --- a/modules/uniconv/base +++ b/modules/uniconv/base @@ -11,6 +11,7 @@ m4/libunistring-base.m4 Depends-on: gen-header bool +stringeq unitypes-h configure.ac: diff --git a/modules/wctrans b/modules/wctrans index 3412903161..f70b7790d4 100644 --- a/modules/wctrans +++ b/modules/wctrans @@ -7,6 +7,7 @@ lib/wctrans-impl.h m4/wctrans.m4 Depends-on: +stringeq wctype-h # When we override wctrans_t, we also need to override towctrans(). towctrans [test $REPLACE_WCTRANS = 1] diff --git a/modules/wctype b/modules/wctype index 69f2deb608..b19b746753 100644 --- a/modules/wctype +++ b/modules/wctype @@ -12,6 +12,7 @@ iswblank [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] iswdigit [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] iswpunct [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] iswxdigit [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] +stringeq [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1] # When we override wctype_t, we also need to override iswctype(). iswctype [test $REPLACE_WCTYPE = 1]