]> Savannah Git Hosting - gnulib.git/commitdiff
exclude: support GNULIB_MCEL_PREFER
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Sep 2023 21:51:58 +0000 (14:51 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Sep 2023 22:08:45 +0000 (15:08 -0700)
Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
* lib/exclude.c: Include mcel.h instead of mbuiter.h.
(string_hasher_ci): Use mcel_scanz instead of mbui_init,
mbui_avail, mbui_cur, and mbui_advance.
* modules/exclude: Do not depend on mbuiter.

ChangeLog
lib/exclude.c
modules/exclude

index 5c967214ed9a0f0b7d1711776532bd53856956a5..ba49a1177b8e3f0f0bed13e1d6fc2fed232761ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2023-09-07  Paul Eggert  <eggert@cs.ucla.edu>
 
+       exclude: support GNULIB_MCEL_PREFER
+       Support mcel API for apps that prefer it.
+       The following changes are in effect only if GNULIB_MCEL_PREFER.
+       * lib/exclude.c: Include mcel.h instead of mbuiter.h.
+       (string_hasher_ci): Use mcel_scanz instead of mbui_init,
+       mbui_avail, mbui_cur, and mbui_advance.
+       * modules/exclude: Do not depend on mbuiter.
+
        mcel-prefer: new module
        * modules/mcel-prefer: New file.
 
index d1ecaedfc6b6978e7dc7b519ee9d8af14e12b83a..a3479db8a637db2671d934b0d61eb7fc85fbf782 100644 (file)
 #include "filename.h"
 #include "fnmatch.h"
 #include "hash.h"
-#include "mbuiter.h"
+#if GNULIB_MCEL_PREFER
+# include "mcel.h"
+#else
+# include "mbuiter.h"
+#endif
 #include "xalloc.h"
 
 #if GNULIB_EXCLUDE_SINGLE_THREAD
@@ -204,7 +208,16 @@ string_hasher_ci (void const *data, size_t n_buckets)
   char const *p = data;
   size_t value = 0;
 
+#if GNULIB_MCEL_PREFER
+  while (*p)
+    {
+      mcel_t g = mcel_scanz (p);
+      value = value * 31 + (c32tolower (g.ch) - g.err);
+      p += g.len;
+    }
+#else
   mbui_iterator_t iter;
+
   for (mbui_init (iter, p); mbui_avail (iter); mbui_advance (iter))
     {
       mbchar_t m = mbui_cur (iter);
@@ -217,6 +230,7 @@ string_hasher_ci (void const *data, size_t n_buckets)
 
       value = value * 31 + wc;
     }
+#endif
 
   return value % n_buckets;
 }
index 8adae5400f21d9414db4df2644d46fe4d930c3d3..92f8d3c47258a77f2db2f54eea82c873fac5197b 100644 (file)
@@ -13,7 +13,7 @@ fnmatch
 fopen-gnu
 hash
 mbscasecmp
-mbuiter
+mbuiter               [test "$GNULIB_MCEL_PREFER" != yes]
 nullptr
 regex
 stdbool