1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-09-01 02:34:55 +00:00

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.
This commit is contained in:
Paul Eggert
2023-09-09 15:47:27 -07:00
parent 17ca38df4f
commit aab8f27073
2 changed files with 16 additions and 1 deletions
+6
View File
@@ -1,5 +1,11 @@
2023-09-09 Paul Eggert <eggert@cs.ucla.edu>
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
+10 -1
View File
@@ -22,7 +22,11 @@
#include <stdlib.h>
#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;
}