Support mcel API for apps that prefer it.
The following changes are in effect only if GNULIB_MCEL_PREFER.
* lib/trim.c: Include mcel.h, not mbchar.h and mbuiterf.h.
(trim2): Use mcel API.
* modules/trim (Depends-on): Add c32isspace.
2023-09-09 Paul Eggert <eggert@cs.ucla.edu>
+ trim: support GNULIB_MCEL_PREFER
+ Support mcel API for apps that prefer it.
+ The following changes are in effect only if GNULIB_MCEL_PREFER.
+ * lib/trim.c: Include mcel.h, not mbchar.h and mbuiterf.h.
+ (trim2): Use mcel API.
+ * modules/trim (Depends-on): Add c32isspace.
+
mbsstr: support GNULIB_MCEL_PREFER
Support mcel API for apps that prefer it.
* lib/mbsstr.c [GNULIB_MCEL_PREFER]: Include mcel.h not mbuiter.h.
#include <stddef.h>
#include <stdlib.h>
-#include "mbchar.h"
-#include "mbuiterf.h"
+#if GNULIB_MCEL_PREFER
+# include "mcel.h"
+#else
+# include "mbchar.h"
+# include "mbuiterf.h"
+#endif
#include "xalloc.h"
char *
if (MB_CUR_MAX > 1)
{
+#if GNULIB_MCEL_PREFER
+ /* Skip leading whitespace. */
+ if (how != TRIM_TRAILING)
+ for (mcel_t g; *start; start += g.len)
+ {
+ g = mcel_scanz (start);
+ if (!c32isspace (g.ch))
+ break;
+ }
+
+ /* Find start of any trailing whitespace. */
+ if (how != TRIM_LEADING)
+ for (const char *p = end = start; *p; )
+ {
+ mcel_t g = mcel_scanz (p);
+ p += g.len;
+ if (!c32isspace (g.ch))
+ end = p;
+ }
+#else
mbuif_state_t state;
mbuif_init (state);
if (!mb_isspace (cur))
end = p;
}
+#endif
}
else
{
lib/trim.c
Depends-on:
+c32isspace
mbchar
mbuiterf
mempcpy