From: Paul Eggert Date: Sat, 9 Sep 2023 22:47:27 +0000 (-0700) Subject: mbslen: support GNULIB_MCEL_PREFER X-Git-Tag: v1.0~791 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=aab8f270731c977597a48cf7ec09376d56c7ae7a;p=gnulib.git mbslen: support GNULIB_MCEL_PREFER Support mcel API for apps that prefer it. The following changes are in effect only if GNULIB_MCEL_PREFER. * lib/mbslen.c: Include mcel.h instead of mbuiterf.h. (mbslen): Use mcel API. --- diff --git a/ChangeLog b/ChangeLog index 5929236789..fe2864b0ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2023-09-09 Paul Eggert + mbslen: support GNULIB_MCEL_PREFER + Support mcel API for apps that prefer it. + The following changes are in effect only if GNULIB_MCEL_PREFER. + * lib/mbslen.c: Include mcel.h instead of mbuiterf.h. + (mbslen): Use mcel API. + chown: work around symlink issues on odd platforms Problem reported by Jordi Sanfeliu in: https://lists.gnu.org/archive/html/bug-gnulib/2023-07/msg00116.html diff --git a/lib/mbslen.c b/lib/mbslen.c index 18642f55e9..db9fa70d63 100644 --- a/lib/mbslen.c +++ b/lib/mbslen.c @@ -22,7 +22,11 @@ #include -#include "mbuiterf.h" +#if GNULIB_MCEL_PREFER +# include "mcel.h" +#else +# include "mbuiterf.h" +#endif /* Return the number of multibyte characters in the character string STRING. */ size_t @@ -32,6 +36,10 @@ mbslen (const char *string) { size_t count = 0; +#if GNULIB_MCEL_PREFER + for (; *string; string += mcel_scanz (string).len) + count++; +#else mbuif_state_t state; const char *iter; for (mbuif_init (state), iter = string; mbuif_avail (state, iter); ) @@ -40,6 +48,7 @@ mbslen (const char *string) count++; iter += mb_len (cur); } +#endif return count; }