* lib/mbscasecmp.c: Include stdlib.h, since we use MB_CUR_MAX.
Include uchar.h, for c32tolower.
(GNULIB_MCEL_PREFER): Include mcel.h instead of mbuiterf.h.
(mbscasecmp) [GNULIB_MCEL_PREFER]: Use mcel instead of mbuiterf.
* modules/mbscasecmp (Depends-on): Add c32tolower, stdlib, uchar.
Depend on mbuiterf only if not preferring mcel.
2023-09-07 Paul Eggert <eggert@cs.ucla.edu>
+ mbscasecmp: support GNULIB_MCEL_PREFER
+ * lib/mbscasecmp.c: Include stdlib.h, since we use MB_CUR_MAX.
+ Include uchar.h, for c32tolower.
+ (GNULIB_MCEL_PREFER): Include mcel.h instead of mbuiterf.h.
+ (mbscasecmp) [GNULIB_MCEL_PREFER]: Use mcel instead of mbuiterf.
+ * modules/mbscasecmp (Depends-on): Add c32tolower, stdlib, uchar.
+ Depend on mbuiterf only if not preferring mcel.
+
exclude: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
#include <ctype.h>
#include <limits.h>
+#include <stdlib.h>
+#include <uchar.h>
-#include "mbuiterf.h"
+#if GNULIB_MCEL_PREFER
+# include "mcel.h"
+#else
+# include "mbuiterf.h"
+#endif
/* 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
most often already in the very few first characters. */
if (MB_CUR_MAX > 1)
{
+#if GNULIB_MCEL_PREFER
+ while (true)
+ {
+ mcel_t g1 = mcel_scanz (iter1); iter1 += g1.len;
+ mcel_t g2 = mcel_scanz (iter2); iter2 += g2.len;
+ int cmp = mcel_tocmp (c32tolower, g1, g2);
+ if (cmp | !g1.ch)
+ return cmp;
+ }
+#else
mbuif_state_t state1;
mbuif_init (state1);
/* s1 terminated before s2. */
return -1;
return 0;
+#endif
}
else
for (;;)
lib/mbscasecmp.c
Depends-on:
-mbuiterf
+c32tolower
+mbuiterf [test "$GNULIB_MCEL_PREFER" != yes]
+stdlib
string
+uchar
configure.ac:
gl_STRING_MODULE_INDICATOR([mbscasecmp])