* lib/string.in.h (mbs_startswith): New declaration.
* m4/string_h.m4 (gl_STRING_H_REQUIRE_DEFAULTS): Initialize
GNULIB_MBS_STARTSWITH.
* modules/string-h (Makefile.am): Substitute GNULIB_MBS_STARTSWITH.
* modules/mbs_startswith: New file.
+2025-01-03 Bruno Haible <bruno@clisp.org>
+
+ mbs_startswith: New module.
+ * lib/string.in.h (mbs_startswith): New declaration.
+ * m4/string_h.m4 (gl_STRING_H_REQUIRE_DEFAULTS): Initialize
+ GNULIB_MBS_STARTSWITH.
+ * modules/string-h (Makefile.am): Substitute GNULIB_MBS_STARTSWITH.
+ * modules/mbs_startswith: New file.
+
2025-01-03 Bruno Haible <bruno@clisp.org>
tests: Use str_endswith.
_GL_ARG_NONNULL ((2, 3));
#endif
+#if @GNULIB_MBS_STARTSWITH@
+/* Returns true if STRING starts with PREFIX.
+ Returns false otherwise. */
+_GL_EXTERN_C int mbs_startswith (const char *string, const char *prefix)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1, 2));
+/* No extra code is needed for multibyte locales for this function. */
+# define mbs_startswith str_startswith
+#endif
+
/* Map any int, typically from errno, into an error message. */
#if @GNULIB_STRERROR@
# if @REPLACE_STRERROR@
# string_h.m4
-# serial 41
+# serial 42
dnl Copyright (C) 2007-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBS_STARTSWITH])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP])
--- /dev/null
+Description:
+mbs_startswith() function: test whether a multibyte string starts with a given prefix.
+
+Files:
+
+Depends-on:
+string-h
+str_startswith
+
+configure.ac:
+gl_STRING_MODULE_INDICATOR([mbs_startswith])
+
+Makefile.am:
+
+Include:
+<string.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
-e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
-e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
-e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
+ -e 's/@''GNULIB_MBS_STARTSWITH''@/$(GNULIB_MBS_STARTSWITH)/g' \
-e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
-e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
-e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \