+2023-07-19 Paul Eggert <eggert@cs.ucla.edu>
+
+ Don’t worry about Version 7 tolower
+ Some code ported back to pre-C89 libraries where tolower (C) had
+ undefined behavior if C is not an upper case character.
+ Nowadays that function is _tolower which is itself obsolete,
+ and much Gnulib code already assumes this part of C89 anyway.
+ Assume C89 or better tolower, which simplifies the code
+ and should improve performance slightly.
+ * lib/mbmemcasecmp.c, lib/mbmemcasecoll.c, lib/mbscasecmp.c:
+ * lib/mbscasestr.c, lib/mbsncasecmp.c, lib/mbspcasecmp.c:
+ * lib/strcasecmp.c, lib/strcasestr.c, lib/strncasecmp.c:
+ (TOLOWER): Remove. All uses replaced by tolower.
+
2023-07-19 Bruno Haible <bruno@clisp.org>
c32swidth, mbszero: Fix file list.
#include "mbiterf.h"
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
int
mbmemcasecmp (const char *s1, size_t n1, const char *s2, size_t n2)
{
while (p1 < s1_end && p2 < s2_end)
{
- unsigned char c1 = TOLOWER (*p1);
- unsigned char c2 = TOLOWER (*p2);
+ unsigned char c1 = tolower (*p1);
+ unsigned char c2 = tolower (*p2);
if (c1 != c2)
{
if (UCHAR_MAX <= INT_MAX)
#include "memcmp2.h"
#include "memcoll.h"
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Apply c32tolower() to the multibyte character sequence in INBUF, storing the
result as a multibyte character sequence in OUTBUF. */
static size_t
{
for (; bufsize > 0; bufsize--)
{
- *outbuf = TOLOWER ((unsigned char) *inbuf);
+ *outbuf = tolower ((unsigned char) *inbuf);
inbuf++;
outbuf++;
}
#include "mbuiterf.h"
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Compare the character strings S1 and S2, ignoring case, returning less than,
equal to or greater than zero if S1 is lexicographically less than, equal to
or greater than S2.
do
{
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
+ c1 = tolower (*p1);
+ c2 = tolower (*p2);
if (c1 == '\0')
break;
#include "malloca.h"
#include "mbuiter.h"
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Knuth-Morris-Pratt algorithm. */
#define UNIT unsigned char
-#define CANON_ELEMENT(c) TOLOWER (c)
+#define CANON_ELEMENT(c) tolower (c)
#include "str-kmp.h"
/* Knuth-Morris-Pratt algorithm.
/* Speed up the following searches of needle by caching its first
character. */
- unsigned char b = TOLOWER ((unsigned char) *needle);
+ unsigned char b = tolower ((unsigned char) *needle);
needle++;
for (;; haystack++)
outer_loop_count++;
comparison_count++;
- if (TOLOWER ((unsigned char) *haystack) == b)
+ if (tolower ((unsigned char) *haystack) == b)
/* The first character matches. */
{
const char *rhaystack = haystack + 1;
/* No match. */
return NULL;
comparison_count++;
- if (TOLOWER ((unsigned char) *rhaystack)
- != TOLOWER ((unsigned char) *rneedle))
+ if (tolower ((unsigned char) *rhaystack)
+ != tolower ((unsigned char) *rneedle))
/* Nothing in this round. */
break;
}
#include "mbuiterf.h"
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Compare the initial segment of the character string S1 consisting of at most
N characters with the initial segment of the character string S2 consisting
of at most N characters, ignoring case, returning less than, equal to or
for (; ; p1++, p2++)
{
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
+ c1 = tolower (*p1);
+ c2 = tolower (*p2);
if (--n == 0 || c1 == '\0' || c1 != c2)
break;
#include "mbuiterf.h"
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Compare the initial segment of the character string STRING consisting of
at most mbslen (PREFIX) characters with the character string PREFIX,
ignoring case. If the two match, return a pointer to the first byte
for (; ; p1++, p2++)
{
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
+ c1 = tolower (*p1);
+ c2 = tolower (*p2);
if (c2 == '\0' || c1 != c2)
break;
#include <ctype.h>
#include <limits.h>
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
greater than zero if S1 is lexicographically less than, equal to or greater
than S2.
do
{
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
+ c1 = tolower (*p1);
+ c2 = tolower (*p2);
if (c1 == '\0')
break;
#include <ctype.h>
#include <strings.h>
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Two-Way algorithm. */
#define RETURN_TYPE char *
#define AVAILABLE(h, h_l, j, n_l) \
(!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \
&& ((h_l) = (j) + (n_l)))
-#define CANON_ELEMENT(c) TOLOWER (c)
+#define CANON_ELEMENT(c) tolower (c)
#define CMP_FUNC(p1, p2, l) \
strncasecmp ((const char *) (p1), (const char *) (p2), l)
#include "str-two-way.h"
NEEDLE if HAYSTACK is too short). */
while (*haystack && *needle)
{
- ok &= (TOLOWER ((unsigned char) *haystack)
- == TOLOWER ((unsigned char) *needle));
+ ok &= (tolower ((unsigned char) *haystack)
+ == tolower ((unsigned char) *needle));
haystack++;
needle++;
}
#include <ctype.h>
#include <limits.h>
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
/* Compare no more than N bytes of strings S1 and S2, ignoring case,
returning less than, equal to or greater than zero if S1 is
lexicographically less than, equal to or greater than S2.
do
{
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
+ c1 = tolower (*p1);
+ c2 = tolower (*p2);
if (--n == 0 || c1 == '\0')
break;