2025-09-17 Paul Eggert <eggert@cs.ucla.edu>
+ 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:
+ * lib/file-has-acl.c, lib/gen-uni-tables.c, lib/get_ppid_of.c:
+ * lib/get_progname_of.c, lib/getlogin_r.c, lib/getprogname.c:
+ * lib/getumask.c, lib/isnan.c, lib/mbchar.h, lib/mem-hash-map.c:
+ * lib/memcoll.c, lib/progname.c, lib/progreloc.c:
+ * lib/pthread_sigmask.c, lib/quotearg.c, lib/readutmp.c:
+ * lib/same.c, lib/signbitd.c, lib/signbitf.c, lib/signbitl.c:
+ * lib/string-desc.c, lib/string.c, lib/string.in.h:
+ * lib/unictype/3level.h, lib/unictype/3levelbit.h:
+ * lib/uniname/uniname.c, lib/vc-mtime.c:
+ Prefer memeq to memcmp 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 (memeq): New static function, in same style.
+ * modules/argmatch, modules/backupfile, modules/bcp47:
+ * modules/boot-time, modules/csharpcomp, modules/csharpexec:
+ * modules/file-has-acl:
+ * modules/get_ppid_of, modules/get_progname_of:
+ * modules/getlogin_r, modules/getprogname, modules/getumask:
+ * modules/isnan, modules/mbchar, modules/mem-hash-map:
+ * modules/memcoll, modules/progname, modules/pthread_sigmask:
+ * modules/quotearg, modules/readutmp, modules/relocatable-prog:
+ * modules/relocatable-prog-wrapper, modules/same, modules/signbit:
+ * modules/string-desc, modules/stringeq, modules/uniname/uniname:
+ * modules/vc-mtime:
+ (Depends-on): Add stringeq.
+
stringeq: new module
* MODULES.html.sh (func_all_modules): Add stringeq.
* lib/string.c, modules/stringeq: New files.
{
/* Second nonexact match found. */
if (vallist == NULL
- || memcmp ((char const *) vallist + valsize * matchind,
+ || !memeq ((char const *) vallist + valsize * matchind,
(char const *) vallist + valsize * i, valsize))
{
/* There is a real ambiguity, or we could not
fputs (_("Valid arguments are:"), stderr);
for (i = 0; arglist[i]; i++)
if ((i == 0)
- || memcmp (last_val, (char const *) vallist + valsize * i, valsize))
+ || !memeq (last_val, (char const *) vallist + valsize * i, valsize))
{
fprintf (stderr, "\n - %s", quote (arglist[i]));
last_val = (char const *) vallist + valsize * i;
size_t i;
for (i = 0; arglist[i]; i++)
- if (!memcmp (value, (char const *) vallist + valsize * i, valsize))
+ if (memeq (value, (char const *) vallist + valsize * i, valsize))
return arglist[i];
return NULL;
}
# include <limits.h>
# include <stddef.h>
# include <stdio.h>
-# include <string.h> /* memcmp */
+# include <string.h> /* memeq */
# include "gettext.h"
# include "quote.h"
else if (res == -1) \
/* First nonexact match found. */ \
res = i; \
- else if (memcmp (&g->args[res].val, &g->args[i].val, size)) \
+ else if (!memeq (&g->args[res].val, &g->args[i].val, size)) \
/* Second nonexact match found. */ \
/* There is a real ambiguity, or we could not \
disambiguate. */ \
const argmatch_##Name##_group_type *g = &argmatch_##Name##_group; \
size_t size = argmatch_##Name##_size; \
for (size_t i = 0; g->args[i].arg; i++) \
- if (!memcmp (val, &g->args[i].val, size)) \
+ if (memeq (val, &g->args[i].val, size)) \
return g->args[i].arg; \
return NULL; \
} \
fputs (dgettext (GNULIB_TEXT_DOMAIN, "Valid arguments are:"), out); \
for (int i = 0; g->args[i].arg; i++) \
if (i == 0 \
- || memcmp (&g->args[i-1].val, &g->args[i].val, size)) \
+ || !memeq (&g->args[i-1].val, &g->args[i].val, size)) \
fprintf (out, "\n - %s", quote (g->args[i].arg)); \
else \
fprintf (out, ", %s", quote (g->args[i].arg)); \
else \
/* Genuine argument, display it with its synonyms. */ \
for (int j = 0; g->args[j].arg; ++j) \
- if (! memcmp (&g->args[ival].val, &g->args[j].val, size)) \
+ if (memeq (&g->args[ival].val, &g->args[j].val, size)) \
col += (col == 4 ? 0 : 2) + strlen (g->args[j].arg); \
if (res <= col) \
res = col <= 20 ? col : 20; \
else \
/* Genuine argument, display it with its synonyms. */ \
for (int j = 0; g->args[j].arg; ++j) \
- if (! memcmp (&g->args[ival].val, &g->args[j].val, size)) \
+ if (memeq (&g->args[ival].val, &g->args[j].val, size)) \
{ \
if (!first \
&& screen_width < col + 2 + strlen (g->args[j].arg)) \
if (_D_EXACT_NAMLEN (dp) < baselen + 4)
continue;
- if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0)
+ if (!memeq (buf + base_offset, dp->d_name, baselen + 2))
continue;
char const *p = dp->d_name + baselen + 2;
static const struct script *
default_script_in_territory (const char language[2], const char territory[2])
{
- if (memcmp (language, "az", 2) == 0)
+ if (memeq (language, "az", 2))
{
- if (memcmp (territory, "AZ", 2) == 0)
+ if (memeq (territory, "AZ", 2))
return &scripts[SCRIPT_LATIN];
- else if (memcmp (territory, "IR", 2) == 0)
+ else if (memeq (territory, "IR", 2))
return &scripts[SCRIPT_ARABIC];
}
- else if (memcmp (language, "ku", 2) == 0)
+ else if (memeq (language, "ku", 2))
{
- if (memcmp (territory, "IQ", 2) == 0
- || memcmp (territory, "IR", 2) == 0)
+ if (memeq (territory, "IQ", 2)
+ || memeq (territory, "IR", 2))
return &scripts[SCRIPT_ARABIC];
- else if (memcmp (territory, "SY", 2) == 0
- || memcmp (territory, "TR", 2) == 0)
+ else if (memeq (territory, "SY", 2)
+ || memeq (territory, "TR", 2))
return &scripts[SCRIPT_LATIN];
}
- else if (memcmp (language, "pa", 2) == 0)
+ else if (memeq (language, "pa", 2))
{
- if (memcmp (territory, "PK", 2) == 0)
+ if (memeq (territory, "PK", 2))
return &scripts[SCRIPT_ARABIC];
- else if (memcmp (territory, "IN", 2) == 0)
+ else if (memeq (territory, "IN", 2))
return &scripts[SCRIPT_GURMUKHI];
}
return NULL;
static const struct script *
default_script_for_language2 (const char language[2])
{
- if (memcmp (language, "be", 2) == 0)
+ if (memeq (language, "be", 2))
return &scripts[SCRIPT_CYRILLIC];
- else if (memcmp (language, "bs", 2) == 0)
+ else if (memeq (language, "bs", 2))
return &scripts[SCRIPT_LATIN];
- else if (memcmp (language, "ha", 2) == 0)
+ else if (memeq (language, "ha", 2))
return &scripts[SCRIPT_LATIN];
- else if (memcmp (language, "kk", 2) == 0)
+ else if (memeq (language, "kk", 2))
return &scripts[SCRIPT_CYRILLIC];
- else if (memcmp (language, "ks", 2) == 0)
+ else if (memeq (language, "ks", 2))
return &scripts[SCRIPT_ARABIC];
- else if (memcmp (language, "mn", 2) == 0)
+ else if (memeq (language, "mn", 2))
return &scripts[SCRIPT_CYRILLIC];
- else if (memcmp (language, "sd", 2) == 0)
+ else if (memeq (language, "sd", 2))
return &scripts[SCRIPT_ARABIC];
- else if (memcmp (language, "sr", 2) == 0)
+ else if (memeq (language, "sr", 2))
return &scripts[SCRIPT_CYRILLIC];
- else if (memcmp (language, "uz", 2) == 0)
+ else if (memeq (language, "uz", 2))
return &scripts[SCRIPT_LATIN];
- else if (memcmp (language, "yi", 2) == 0)
+ else if (memeq (language, "yi", 2))
return &scripts[SCRIPT_HEBREW];
return NULL;
}
static const struct script *
default_script_for_language3 (const char language[3])
{
- if (memcmp (language, "ber", 3) == 0)
+ if (memeq (language, "ber", 3))
return &scripts[SCRIPT_LATIN];
return NULL;
}
/* Canonicalize the language. */
/* For Quechua, Microsoft uses the ISO 639-3 code "quz" instead of the
ISO 639-1 code "qu". */
- if (language_len == 3 && memcmp (language_start, "quz", 3) == 0)
+ if (language_len == 3 && memeq (language_start, "quz", 3))
{
language_start = "qu";
language_len = 2;
}
/* For Tamazight, Microsoft uses the ISO 639-3 code "tzm" instead of the
ISO 639-2 code "ber". */
- else if (language_len == 3 && memcmp (language_start, "tzm", 3) == 0)
+ else if (language_len == 3 && memeq (language_start, "tzm", 3))
{
language_start = "ber";
language_len = 3;
size_t i;
for (i = 0; i < NUM_SCRIPTS; i++)
if (strlen (scripts[i].name) == modifier_len
- && memcmp (scripts[i].name, modifier_start, modifier_len) == 0)
+ && memeq (scripts[i].name, modifier_start, modifier_len))
script_subtag = scripts[i].code;
if (script_subtag == NULL)
{
default_script_in_territory (language_start, territory_start);
if (sp != NULL)
script_subtag = sp->code;
- else if (memcmp (language_start, "zh", 2) == 0)
+ else if (memeq (language_start, "zh", 2))
{
- if (memcmp (territory_start, "CN", 2) == 0
- || memcmp (territory_start, "SG", 2) == 0)
+ if (memeq (territory_start, "CN", 2)
+ || memeq (territory_start, "SG", 2))
script_subtag = "Hans";
else
script_subtag = "Hant";
default_script_for_language2 (language_start);
if (sp != NULL)
script_subtag = sp->code;
- else if (memcmp (language_start, "iu", 2) == 0)
+ else if (memeq (language_start, "iu", 2))
script_subtag = "Cans";
}
else if (language_len == 3)
default_script_for_language3 (language_start);
if (sp != NULL)
script_subtag = sp->code;
- else if (memcmp (language_start, "nan", 3) == 0)
+ else if (memeq (language_start, "nan", 3))
script_subtag = "Hant";
}
}
/* Canonicalize the language. */
/* For Quechua, Microsoft uses the ISO 639-3 code "quz" instead of the
ISO 639-1 code "qu". */
- if (language_len == 3 && memcmp (xpg, "quz", 3) == 0)
+ if (language_len == 3 && memeq (xpg, "quz", 3))
{
language_len = 2;
memcpy (xpg, "qu", language_len);
}
/* For Tamazight, Microsoft uses the ISO 639-3 code "tzm" instead of the
ISO 639-2 code "ber". */
- else if (language_len == 3 && memcmp (xpg, "tzm", 3) == 0)
+ else if (language_len == 3 && memeq (xpg, "tzm", 3))
{
language_len = 3;
memcpy (xpg, "ber", language_len);
if (strcmp (script, sp->name) == 0)
script = NULL;
}
- else if (memcmp (xpg, "zh", 2) == 0)
+ else if (memeq (xpg, "zh", 2))
{
/* "Hans" and "Hant" are not present in the scripts[] table,
therefore nothing to do here. */
if (strcmp (script, sp->name) == 0)
script = NULL;
}
- else if (memcmp (xpg, "iu", 2) == 0)
+ else if (memeq (xpg, "iu", 2))
{
/* "Cans" is not present in the scripts[] table,
therefore nothing to do here. */
if (strcmp (script, sp->name) == 0)
script = NULL;
}
- else if (memcmp (xpg, "nan", 3) == 0)
+ else if (memeq (xpg, "nan", 3))
{
/* "Hant" is not present in the scripts[] table,
therefore nothing to do here. */
found_boot_time = ts;
# if defined __linux__ && !defined __ANDROID__
- if (memcmp (UT_USER (ut), "runlevel", strlen ("runlevel") + 1) == 0
- && memcmp (ut->ut_line, "~", strlen ("~") + 1) == 0)
+ if (memeq (UT_USER (ut), "runlevel", strlen ("runlevel") + 1)
+ && memeq (ut->ut_line, "~", strlen ("~") + 1))
runlevel_ts = ts;
# endif
# if defined __minix
if (UT_USER (ut)[0] == '\0'
- && memcmp (ut->ut_line, "run-level ", strlen ("run-level ")) == 0)
+ && memeq (ut->ut_line, "run-level ", strlen ("run-level ")))
runlevel_ts = ts;
# endif
}
if (d->d_name[0] != '.')
{
size_t d_name_len = strlen (d->d_name);
- if (d_name_len > 4 && memcmp (d->d_name + d_name_len - 4, ".dll", 4) == 0)
+ if (d_name_len > 4 && memeq (d->d_name + d_name_len - 4, ".dll", 4))
/* Filter out files that start with a lowercase letter and files that
contain the substring ".Native.", since on Windows these files
produce an error "PE image doesn't contain managed metadata". */
count++;
if (count == 4)
{
- if (memcmp (c, "Mono", 4) == 0)
+ if (memeq (c, "Mono", 4))
mcs_present = true;
c[0] = c[1]; c[1] = c[2]; c[2] = c[3];
count--;
{
const char *source_file = sources[i];
if (strlen (source_file) >= 10
- && memcmp (source_file + strlen (source_file) - 10, ".resources",
- 10) == 0)
+ && memeq (source_file + strlen (source_file) - 10,
+ ".resources", 10))
{
char *option = (char *) xmalloca (10 + strlen (source_file) + 1);
l = (l + 1) % 2;
if (line[l] != NULL
&& !(linelen[l] >= 21
- && memcmp (line[l], "Compilation succeeded", 21) == 0))
+ && memeq (line[l], "Compilation succeeded", 21)))
fwrite (line[l], 1, linelen[l], stderr);
if (line[0] != NULL)
free (line[0]);
/* The line has the structure
Microsoft.SUBSYSTEM VERSION [DIRECTORY] */
if (linelen > 22
- && memcmp (line, "Microsoft.NETCore.App ", 22) == 0)
+ && memeq (line, "Microsoft.NETCore.App ", 22))
{
char *version = line + 22;
char *version_end = strchr (version, ' ');
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
- && memcmp (source_file_converted
- + strlen (source_file_converted) - 10,
- ".resources",
- 10) == 0)
+ && memeq ((source_file_converted
+ + strlen (source_file_converted) - 10),
+ ".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
count++;
if (count >= 7)
{
- if (memcmp (c, "chicken", 7) == 0)
+ if (memeq (c, "chicken", 7))
seen_chicken = true;
}
if (count == 8)
{
- if (memcmp (c, "analyzer", 8) == 0)
+ if (memeq (c, "analyzer", 8))
seen_analyzer = true;
c[0] = c[1]; c[1] = c[2]; c[2] = c[3]; c[3] = c[4];
c[4] = c[5]; c[5] = c[6]; c[6] = c[7];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
- && memcmp (source_file_converted
- + strlen (source_file_converted) - 10,
- ".resources",
- 10) == 0)
+ && memeq ((source_file_converted
+ + strlen (source_file_converted) - 10),
+ ".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
count++;
if (count == 7)
{
- if (memcmp (c, "chicken", 7) == 0)
+ if (memeq (c, "chicken", 7))
csc_present = false;
c[0] = c[1]; c[1] = c[2]; c[2] = c[3];
c[3] = c[4]; c[4] = c[5]; c[5] = c[6];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
- && memcmp (source_file_converted
- + strlen (source_file_converted) - 10,
- ".resources",
- 10) == 0)
+ && memeq ((source_file_converted
+ + strlen (source_file_converted) - 10),
+ ".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
{
bool output_is_library =
(strlen (output_file) >= 4
- && memcmp (output_file + strlen (output_file) - 4, ".dll", 4) == 0);
+ && memeq (output_file + strlen (output_file) - 4, ".dll", 4));
int result;
/* First try the C# implementation specified through --enable-csharp. */
if (d->d_name[0] != '.')
{
size_t d_name_len = strlen (d->d_name);
- if (d_name_len > 4 && memcmp (d->d_name + d_name_len - 4, ".dll", 4) == 0)
+ if (d_name_len > 4 && memeq (d->d_name + d_name_len - 4, ".dll", 4))
return 1;
}
return 0;
{
size_t assembly_path_len = strlen (assembly_path);
if (assembly_path_len > 4
- && memcmp (assembly_path + (assembly_path_len - 4), ".exe", 4) == 0)
+ && memeq (assembly_path + (assembly_path_len - 4), ".exe", 4))
assembly_path_len -= 4;
char *p = runtimeconfig_filename;
memcpy (p, assembly_path, assembly_path_len);
/* The line has the structure
Microsoft.SUBSYSTEM VERSION [DIRECTORY] */
if (linelen > 22
- && memcmp (line, "Microsoft.NETCore.App ", 22) == 0)
+ && memeq (line, "Microsoft.NETCore.App ", 22))
{
char *version = line + 22;
char *version_end = strchr (version, ' ');
first case, and ENODATA in the latter. */
if (r == 0)
scontext_err = ENOTSUP;
- if (r == 10 && memcmp (ai->scontext, "unlabeled", 10) == 0)
+ if (r == 10 && memeq (ai->scontext, "unlabeled", 10))
{
freecon (ai->scontext);
scontext_err = ENODATA;
/* For a trivial ACL, max 6 (typically 3) ACEs, 3 allow, 3 deny.
Check that there is at most one ACE of each TYPE and WHO. */
int who2
- = (wholen == 6 && memcmp (xattr, "OWNER@", 6) == 0 ? 0
- : wholen == 6 && memcmp (xattr, "GROUP@", 6) == 0 ? 2
- : wholen == 9 && memcmp (xattr, "EVERYONE@", 9) == 0 ? 4
+ = (wholen == 6 && memeq (xattr, "OWNER@", 6) ? 0
+ : wholen == 6 && memeq (xattr, "GROUP@", 6) ? 2
+ : wholen == 9 && memeq (xattr, "EVERYONE@", 9) ? 4
: -1);
if (who2 < 0)
return 1;
return len >= n && strcmp (string + len - n, suffix) == 0;
}
+static bool
+memeq (void const *s1, void const *s2, size_t n)
+{
+ return !memcmp (s1, s2, n);
+}
+
/* ========================================================================= */
/* Reading UnicodeData.txt. */
assert (rangle != NULL);
typelen = rangle + 1 - decomposition;
#define TYPE(t1,t2) \
- if (typelen == (sizeof (t1) - 1) && memcmp (decomposition, t1, typelen) == 0) \
+ if (typelen == (sizeof (t1) - 1) && memeq (decomposition, t1, typelen)) \
type = t2; \
else
TYPE ("<font>", UC_DECOMP_FONT)
{
bool negate = false;
- if (word_end - word_begin >= 4 && memcmp (word_begin, "Not_", 4) == 0)
+ if (word_end - word_begin >= 4 && memeq (word_begin, "Not_", 4))
{
word_begin += 4;
negate = true;
}
- if (word_end - word_begin == 11 && memcmp (word_begin, "Final_Sigma", 11) == 0)
+ if (word_end - word_begin == 11 && memeq (word_begin, "Final_Sigma", 11))
context = SCC_FINAL_SIGMA;
- else if (word_end - word_begin == 17 && memcmp (word_begin, "After_Soft_Dotted", 17) == 0)
+ else if (word_end - word_begin == 17 && memeq (word_begin, "After_Soft_Dotted", 17))
context = SCC_AFTER_SOFT_DOTTED;
- else if (word_end - word_begin == 10 && memcmp (word_begin, "More_Above", 10) == 0)
+ else if (word_end - word_begin == 10 && memeq (word_begin, "More_Above", 10))
context = SCC_MORE_ABOVE;
- else if (word_end - word_begin == 10 && memcmp (word_begin, "Before_Dot", 10) == 0)
+ else if (word_end - word_begin == 10 && memeq (word_begin, "Before_Dot", 10))
context = SCC_BEFORE_DOT;
- else if (word_end - word_begin == 7 && memcmp (word_begin, "After_I", 7) == 0)
+ else if (word_end - word_begin == 7 && memeq (word_begin, "After_I", 7))
context = SCC_AFTER_I;
else
{
/* Search for a line that starts with "PPid:". */
for (p = buf;;)
{
- if (bufend - p >= 5 && memcmp (p, "PPid:", 5) == 0)
+ if (bufend - p >= 5 && memeq (p, "PPid:", 5))
{
unsigned int ppid = 0;
if (sscanf (p + 5, "%u", &ppid) > 0)
else
p = cmd;
if (strlen (p) > PST_UCOMMLEN - 1
- && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
+ && memeq (p, ucomm, PST_UCOMMLEN - 1))
/* p is less truncated than ucomm. */
;
else
else
p = cmd;
if (strlen (p) > PST_UCOMMLEN - 1
- && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
+ && memeq (p, ucomm, PST_UCOMMLEN - 1))
/* p is less truncated than ucomm. */
;
else
return ENOMEM;
ret = getlogin_r (room, size + 1);
/* The untruncated result should be the same as in the first call. */
- if (ret == 0 && memcmp (name, room, size) != 0)
+ if (ret == 0 && !memeq (name, room, size))
/* The untruncated result would have been different. */
ret = ERANGE;
freea (room);
else
p = cmd;
if (strlen (p) > PST_UCOMMLEN - 1
- && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
+ && memeq (p, ucomm, PST_UCOMMLEN - 1))
/* p is less truncated than ucomm. */
;
else
else
p = cmd;
if (strlen (p) > PST_UCOMMLEN - 1
- && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
+ && memeq (p, ucomm, PST_UCOMMLEN - 1))
/* p is less truncated than ucomm. */
;
else
for (;;)
{
/* Here we're at the beginning of a line. */
- if (p_end - p > 8 && memcmp (p, "Umask:\t0", 8) == 0)
+ if (p_end - p > 8 && memeq (p, "Umask:\t0", 8))
{
unsigned int value = 0;
p += 8;
if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD])
& (EXP_MASK << EXPBIT0_BIT))
== 0)
- return (memcmp (&m.value, &plus_inf, SIZE) != 0
- && memcmp (&m.value, &minus_inf, SIZE) != 0);
+ return (!memeq (&m.value, &plus_inf, SIZE)
+ && !memeq (&m.value, &minus_inf, SIZE));
else
return 0;
}
memset (&m2.value, 0, SIZE);
m1.value = x;
m2.value = x + (x ? 0.0L : -0.0L);
- if (memcmp (&m1.value, &m2.value, SIZE) != 0)
+ if (!memeq (&m1.value, &m2.value, SIZE))
return 1;
# endif
return 0;
((mbc1).wc_valid && (mbc2).wc_valid \
? (mbc1).wc == (mbc2).wc \
: (mbc1).bytes == (mbc2).bytes \
- && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0)
+ && memeq ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes))
#define mb_caseequal(mbc1, mbc2) \
((mbc1).wc_valid && (mbc2).wc_valid \
? c32tolower ((mbc1).wc) == c32tolower ((mbc2).wc) \
: (mbc1).bytes == (mbc2).bytes \
- && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0)
+ && memeq ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes))
/* <ctype.h>, <wctype.h> classification. */
#define mb_isascii(mbc) \
if (table[idx].used)
{
if (table[idx].used == hval && table[idx].keylen == keylen
- && memcmp (table[idx].key, key, keylen) == 0)
+ && memeq (table[idx].key, key, keylen))
return idx;
/* Second hash function as suggested in [Knuth]. */
/* If entry is found use it. */
if (table[idx].used == hval && table[idx].keylen == keylen
- && memcmp (table[idx].key, key, keylen) == 0)
+ && memeq (table[idx].key, key, keylen))
return idx;
}
while (table[idx].used);
where the arguments are bytewise equal. Otherwise, walk through
the buffers using strcoll on each substring. */
- if (s1len == s2len && memcmp (s1, s2, s1len) == 0)
+ if (s1len == s2len && memeq (s1, s2, s1len))
{
errno = 0;
diff = 0;
int
memcoll0 (char const *s1, size_t s1size, char const *s2, size_t s2size)
{
- if (s1size == s2size && memcmp (s1, s2, s1size) == 0)
+ if (s1size == s2size && memeq (s1, s2, s1size))
{
errno = 0;
return 0;
Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */
char const *slash = strrchr (argv0, '/');
char const *base = slash ? slash + 1 : argv0;
- if (7 <= base - argv0 && memcmp (base - 7, "/.libs/", 7) == 0)
+ if (7 <= base - argv0 && memeq (base - 7, "/.libs/", 7))
{
argv0 = base;
if (strncmp (base, "lt-", 3) == 0)
size_t argv0_len = strlen (argv0);
const size_t exeext_len = sizeof (EXEEXT) - sizeof ("");
if (argv0_len > 4 + exeext_len)
- if (memcmp (argv0 + argv0_len - exeext_len - 4, ".bin", 4) == 0)
+ if (memeq (argv0 + argv0_len - exeext_len - 4, ".bin", 4))
{
if (sizeof (EXEEXT) > sizeof (""))
{
Don't cache the information: libpthread.so could be dynamically
loaded after the program started and after pthread_sigmask was
called for the first time. */
- if (memcmp (&omask_copy, &omask, sizeof omask) == 0
+ if (memeq (&omask_copy, &omask, sizeof omask)
&& pthread_sigmask (1729, &omask_copy, NULL) == 0)
{
/* pthread_sigmask is currently ineffective. The program is not
and when the quote string is more than 1 byte long.
If we do call strlen, save the result. */
? (argsize = strlen (arg)) : argsize))
- && memcmp (arg + i, quote_string, quote_string_len) == 0)
+ && memeq (arg + i, quote_string, quote_string_len))
{
if (elide_outer_quotes)
goto force_outer_quoting_style;
);
# if defined __linux__ && !defined __ANDROID__
if (file_is_utmp
- && memcmp (UT_USER (ut), "runlevel", strlen ("runlevel") + 1) == 0
- && memcmp (ut->ut_line, "~", strlen ("~") + 1) == 0)
+ && memeq (UT_USER (ut), "runlevel", strlen ("runlevel") + 1)
+ && memeq (ut->ut_line, "~", strlen ("~") + 1))
runlevel_ts = ts;
# endif
# if defined __minix
if (file_is_utmp
&& UT_USER (ut)[0] == '\0'
- && memcmp (ut->ut_line, "run-level ", strlen ("run-level ")) == 0)
+ && memeq (ut->ut_line, "run-level ", strlen ("run-level ")))
runlevel_ts = ts;
# endif
}
size_t dest_baselen = base_len (dest_basename);
bool identical_basenames =
(source_baselen == dest_baselen
- && memcmp (source_basename, dest_basename, dest_baselen) == 0);
+ && memeq (source_basename, dest_basename, dest_baselen));
bool compare_dirs = identical_basenames;
bool same = false;
size_t slen_max = HAVE_LONG_FILE_NAMES ? 255 : _POSIX_NAME_MAX;
size_t min_baselen = MIN (source_baselen, dest_baselen);
if (slen_max <= min_baselen
- && memcmp (source_basename, dest_basename, slen_max) == 0)
+ && memeq (source_basename, dest_basename, slen_max))
compare_dirs = true;
#endif
destdir_errno = errno;
else
same = (name_max <= min_baselen
- && (memcmp (source_basename, dest_basename, name_max)
- == 0));
+ && memeq (source_basename, dest_basename, name_max));
}
}
close (destdir_fd);
/* Distinguish 0.0 and -0.0. */
static double plus_zero = 0.0;
double arg_mem = arg;
- return (memcmp (&plus_zero, &arg_mem, SIZEOF_DBL) != 0);
+ return !memeq (&plus_zero, &arg_mem, SIZEOF_DBL);
}
else
return 0;
/* Distinguish 0.0f and -0.0f. */
static float plus_zero = 0.0f;
float arg_mem = arg;
- return (memcmp (&plus_zero, &arg_mem, SIZEOF_FLT) != 0);
+ return !memeq (&plus_zero, &arg_mem, SIZEOF_FLT);
}
else
return 0;
/* Distinguish 0.0L and -0.0L. */
static long double plus_zero = 0.0L;
long double arg_mem = arg;
- return (memcmp (&plus_zero, &arg_mem, SIZEOF_LDBL) != 0);
+ return !memeq (&plus_zero, &arg_mem, SIZEOF_LDBL);
}
else
return 0;
idx_t b_nbytes, const char *b_data)
{
return (a_nbytes == b_nbytes
- && (a_nbytes == 0 || memcmp (a_data, b_data, a_nbytes) == 0));
+ && (a_nbytes == 0 || memeq (a_data, b_data, a_nbytes)));
}
bool
{
return (s_nbytes >= prefix_nbytes
&& (prefix_nbytes == 0
- || memcmp (s_data, prefix_data, prefix_nbytes) == 0));
+ || memeq (s_data, prefix_data, prefix_nbytes)));
}
bool
{
return (s_nbytes >= suffix_nbytes
&& (suffix_nbytes == 0
- || memcmp (s_data + (s_nbytes - suffix_nbytes), suffix_data,
- suffix_nbytes) == 0));
+ || memeq (s_data + (s_nbytes - suffix_nbytes), suffix_data,
+ suffix_nbytes)));
}
int
for (j = 0; j < t->level3_size; j++)
{
for (i = 0; i < k; i++)
- if (memcmp (&t->level3[i << t->p], &t->level3[j << t->p],
- (1 << t->p) * sizeof (ELEMENT)) == 0)
+ if (memeq (&t->level3[i << t->p], &t->level3[j << t->p],
+ (1 << t->p) * sizeof (ELEMENT)))
break;
/* Relocate block j to block i. */
reorder3[j] = i;
for (j = 0; j < t->level2_size; j++)
{
for (i = 0; i < k; i++)
- if (memcmp (&t->level2[i << t->q], &t->level2[j << t->q],
- (1 << t->q) * sizeof (uint32_t)) == 0)
+ if (memeq (&t->level2[i << t->q], &t->level2[j << t->q],
+ (1 << t->q) * sizeof (uint32_t)))
break;
/* Relocate block j to block i. */
reorder2[j] = i;
for (j = 0; j < t->level3_size; j++)
{
for (i = 0; i < k; i++)
- if (memcmp (&t->level3[i << t->p], &t->level3[j << t->p],
- (1 << t->p) * sizeof (uint32_t)) == 0)
+ if (memeq (&t->level3[i << t->p], &t->level3[j << t->p],
+ (1 << t->p) * sizeof (uint32_t)))
break;
/* Relocate block j to block i. */
reorder3[j] = i;
for (j = 0; j < t->level2_size; j++)
{
for (i = 0; i < k; i++)
- if (memcmp (&t->level2[i << t->q], &t->level2[j << t->q],
- (1 << t->q) * sizeof (uint32_t)) == 0)
+ if (memeq (&t->level2[i << t->q], &t->level2[j << t->q],
+ (1 << t->q) * sizeof (uint32_t)))
break;
/* Relocate block j to block i. */
reorder2[j] = i;
unsigned int index1;
for (index1 = 0; index1 < 19; index1++)
- if (memcmp (jamo_initial_short_name[index1], p1, n1) == 0
+ if (memeq (jamo_initial_short_name[index1], p1, n1)
&& jamo_initial_short_name[index1][n1] == '\0')
{
unsigned int index2;
for (index2 = 0; index2 < 21; index2++)
- if (memcmp (jamo_medial_short_name[index2], p2, n2) == 0
+ if (memeq (jamo_medial_short_name[index2], p2, n2)
&& jamo_medial_short_name[index2][n2] == '\0')
{
unsigned int index3;
for (index3 = 0; index3 < 28; index3++)
- if (memcmp (jamo_final_short_name[index3], p3, n3) == 0
+ if (memeq (jamo_final_short_name[index3], p3, n3)
&& jamo_final_short_name[index3][n3] == '\0')
{
return 0xAC00 + (index1 * 21 + index2) * 28 + index3;
&& words[1] == UNICODE_CHARNAME_WORD_COMPATIBILITY
&& p1 + 14 <= ptr
&& p1 + 15 >= ptr
- && memcmp (p1, "IDEOGRAPH-", 10) == 0)
+ && memeq (p1, "IDEOGRAPH-", 10))
{
const char *p2 = p1 + 10;
&& words[0] == UNICODE_CHARNAME_WORD_VARIATION
&& p1 + 10 <= ptr
&& p1 + 12 >= ptr
- && memcmp (p1, "SELECTOR-", 9) == 0)
+ && memeq (p1, "SELECTOR-", 9))
{
const char *p2 = p1 + 9;
break;
/* Did the components match? */
if (!(filename_s - filename == dir2_s - dir2
- && memcmp (filename, dir2, dir2_s - dir2) == 0))
+ && memeq (filename, dir2, dir2_s - dir2)))
break;
dir2 = dir2_s;
filename = filename_s;
quotearg
bool
stdlib-h
+stringeq
configure.ac:
bool
stdckdint-h
stdint-h
+stringeq
xalloc-die
configure.ac:
Depends-on:
bool
c-ctype
+stringeq
configure.ac:
Depends-on:
extensions
idx
+stringeq
stat-time
gettimeofday
bool
alphasort
sh-quote
safe-read
+stringeq
xmalloca
xvasprintf
gettext-h
scandir
alphasort
sh-quote
+stringeq
xalloc
xmalloca
copy-file
free-posix
limits-h
stdint-h
+stringeq
malloc-posix
ssize_t
stat
Depends-on:
extensions
+stringeq
sys_types-h
unistd-h
open
Depends-on:
extensions
+stringeq
unistd-h
open
extensions
malloca [test $HAVE_GETLOGIN_R = 0 || test $REPLACE_GETLOGIN_R = 1]
memchr [test $HAVE_GETLOGIN_R = 0 || test $REPLACE_GETLOGIN_R = 1]
+stringeq [test $HAVE_GETLOGIN_R = 0 || test $REPLACE_GETLOGIN_R = 1]
configure.ac:
gl_FUNC_GETLOGIN_R
basename-lgpl [test $HAVE_GETPROGNAME = 0]
extensions [test $HAVE_GETPROGNAME = 0]
open [test $HAVE_GETPROGNAME = 0 && case "$host_os" in sco* | unixware*) true;; *) false;; esac]
+stringeq [test $HAVE_GETPROGNAME = 0]
configure.ac:
AC_REQUIRE([AC_CANONICAL_HOST])
sys_stat-h
extensions
c99 [test $HAVE_GETUMASK = 0]
+stringeq [test $HAVE_GETUMASK = 0]
unistd-h [test $HAVE_GETUMASK = 0]
clean-temp [test $HAVE_GETUMASK = 0]
tempname [test $HAVE_GETUMASK = 0]
isnand
isnanl
math-h
+stringeq
extensions
configure.ac:
c32tolower
c32width
memcmp
+stringeq
configure.ac:
gl_MBCHAR
Depends-on:
next-prime
obstack
+stringeq
xalloc
configure.ac:
Depends-on:
memcmp
+stringeq
configure.ac:
gl_MEMCOLL
Depends-on:
snippet/arg-nonnull
+stringeq
configure.ac:
AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
signal-h
threadlib
sigprocmask [test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1]
+stringeq [test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1]
configure.ac:
gl_FUNC_PTHREAD_SIGMASK
quotearg-simple
bool
stdint-h
+stringeq
uchar-h
xalloc
gettimeofday
bool
stdint-h
+stringeq
strnlen
time-h
unlocked-io-internal
relocatable-prog-wrapper
progname
canonicalize-lgpl
+stringeq
xalloc
xreadlink
open
stdint-h
stdlib-h
string-h
+stringeq
sys_stat-h
unistd-h
xalloc-oversized
fstatat
openat
same-inode
+stringeq
bool
memcmp
isnanl-nolibm [test $REPLACE_SIGNBIT = 1]
fpieee [test $REPLACE_SIGNBIT = 1]
memcmp [test $REPLACE_SIGNBIT = 1]
+stringeq [test $REPLACE_SIGNBIT = 1]
configure.ac:
gl_SIGNBIT
memrchr
memmem
full-write
+stringeq
configure.ac:
uniname/base
attribute
memcmp
+stringeq
bool
c99
time-h
bool
spawn-pipe
+stringeq
wait-process
execute
safe-read