The mbs_startswith function, that I added in January 2025, lacks handling
of incomplete characters at the end of the PREFIX argument. This becomes
apparent when I add unit tests: They fail like this.

test-mbs_startswith2.c:58: assertion '!mbs_startswith 
("\303\244\306\200\303\247", "\303")' failed
test-mbs_startswith3.c:57: assertion '!mbs_startswith 
("\201\060\212\061\201\060\227\070\201\060\212\064", "\201\060\212")' failed

This set of patches fixes it.


2026-02-27  Bruno Haible  <[email protected]>

        mbs_startswith: Add tests.
        * tests/test-mbs_startswith1.c: New file, based on
        tests/test-mbs_endswith1.c.
        * tests/test-mbs_startswith2.c: New file, based on
        tests/test-mbs_endswith2.c.
        * tests/test-mbs_startswith2.sh: New file, based on
        tests/test-mbs_endswith2.sh.
        * tests/test-mbs_startswith3.c: New file, based on
        tests/test-mbs_endswith3.c.
        * tests/test-mbs_startswith3.sh: New file, based on
        tests/test-mbs_endswith3.sh.
        * modules/mbs_startswith-tests: New file.

        mbs_startswith: Fix handling of incomplete characters.
        * lib/string.in.h (mbs_startswith): Remove macro definition.
        * lib/mbs_startswith.c: New file.
        * modules/mbs_startswith (Files): Add it.
        (Depends-on): Add strnlen, mbiter.
        (Makefile.am): Arrange to compile mbs_startswith.c.

>From cdc6f6a03e8c67a5e192eb875e15fc7c5f1f7a61 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Fri, 27 Feb 2026 06:37:55 +0100
Subject: [PATCH 1/2] mbs_startswith: Fix handling of incomplete characters.

* lib/string.in.h (mbs_startswith): Remove macro definition.
* lib/mbs_startswith.c: New file.
* modules/mbs_startswith (Files): Add it.
(Depends-on): Add strnlen, mbiter.
(Makefile.am): Arrange to compile mbs_startswith.c.
---
 ChangeLog              |  9 +++++++
 lib/mbs_startswith.c   | 59 ++++++++++++++++++++++++++++++++++++++++++
 lib/string.in.h        |  2 --
 modules/mbs_startswith |  4 +++
 4 files changed, 72 insertions(+), 2 deletions(-)
 create mode 100644 lib/mbs_startswith.c

diff --git a/ChangeLog b/ChangeLog
index 766682bec3..6b2d4d01cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-02-27  Bruno Haible  <[email protected]>
+
+	mbs_startswith: Fix handling of incomplete characters.
+	* lib/string.in.h (mbs_startswith): Remove macro definition.
+	* lib/mbs_startswith.c: New file.
+	* modules/mbs_startswith (Files): Add it.
+	(Depends-on): Add strnlen, mbiter.
+	(Makefile.am): Arrange to compile mbs_startswith.c.
+
 2026-02-23  Collin Funk  <[email protected]>
 
 	crypto/sha3: Silence -Wzero-as-null-pointer-constant warning.
diff --git a/lib/mbs_startswith.c b/lib/mbs_startswith.c
new file mode 100644
index 0000000000..b481f3d072
--- /dev/null
+++ b/lib/mbs_startswith.c
@@ -0,0 +1,59 @@
+/* mbs_startswith function.
+   Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation, either version 3 of the
+   License, or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2025.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <string.h>
+
+#include "mbiter.h"
+
+#include <stdlib.h>
+
+bool
+mbs_startswith (const char *string, const char *prefix)
+{
+  /* First, test whether STRING starts with PREFIX as a byte sequence.
+     This is a necessary condition.  */
+  if (str_startswith (string, prefix))
+    {
+      /* It could be that PREFIX ends in an incomplete character and STRING
+         continues with a valid character or a longer incomplete character
+         instead.  In this case, mbs_startswith needs to return false.  */
+      size_t mb_max = MB_CUR_MAX;
+      if (mb_max == 1)
+        /* In unibyte locales, there are no incomplete characters.  */
+        return true;
+      /* Determine where we can stop the comparison.  */
+      size_t p_len = strlen (prefix);
+      size_t s_len = p_len + strnlen (string + p_len, mb_max);
+      mbi_iterator_t s_iter;
+      mbi_init (s_iter, string, s_len);
+      mbi_iterator_t p_iter;
+      for (mbi_init (p_iter, prefix, p_len); mbi_avail (p_iter); mbi_advance (p_iter))
+        {
+          if (!mbi_avail (s_iter))
+            return false;
+          if (!mb_equal (mbi_cur (s_iter), mbi_cur (p_iter)))
+            return false;
+          mbi_advance (s_iter);
+        }
+      return true;
+    }
+  return false;
+}
diff --git a/lib/string.in.h b/lib/string.in.h
index 9997bd58e7..a98552b8f5 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1617,8 +1617,6 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
 _GL_EXTERN_C bool 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
 
 #if @GNULIB_MBS_ENDSWITH@
diff --git a/modules/mbs_startswith b/modules/mbs_startswith
index 2e909c67e6..472b21cdda 100644
--- a/modules/mbs_startswith
+++ b/modules/mbs_startswith
@@ -2,16 +2,20 @@ Description:
 mbs_startswith() function: test whether a multibyte string starts with a given prefix.
 
 Files:
+lib/mbs_startswith.c
 
 Depends-on:
 string-h
 bool
 str_startswith
+strnlen
+mbiter
 
 configure.ac:
 gl_STRING_MODULE_INDICATOR([mbs_startswith])
 
 Makefile.am:
+lib_SOURCES += mbs_startswith.c
 
 Include:
 <string.h>
-- 
2.52.0

From 3574d0a5262e59fa63547b0b29eb7b02b2ff145f Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Fri, 27 Feb 2026 06:41:31 +0100
Subject: [PATCH 2/2] mbs_startswith: Add tests.

* tests/test-mbs_startswith1.c: New file, based on
tests/test-mbs_endswith1.c.
* tests/test-mbs_startswith2.c: New file, based on
tests/test-mbs_endswith2.c.
* tests/test-mbs_startswith2.sh: New file, based on
tests/test-mbs_endswith2.sh.
* tests/test-mbs_startswith3.c: New file, based on
tests/test-mbs_endswith3.c.
* tests/test-mbs_startswith3.sh: New file, based on
tests/test-mbs_endswith3.sh.
* modules/mbs_startswith-tests: New file.
---
 ChangeLog                     | 13 +++++
 modules/mbs_startswith-tests  | 30 +++++++++++
 tests/test-mbs_startswith1.c  | 48 ++++++++++++++++++
 tests/test-mbs_startswith2.c  | 95 +++++++++++++++++++++++++++++++++++
 tests/test-mbs_startswith2.sh | 23 +++++++++
 tests/test-mbs_startswith3.c  | 73 +++++++++++++++++++++++++++
 tests/test-mbs_startswith3.sh | 15 ++++++
 7 files changed, 297 insertions(+)
 create mode 100644 modules/mbs_startswith-tests
 create mode 100644 tests/test-mbs_startswith1.c
 create mode 100644 tests/test-mbs_startswith2.c
 create mode 100755 tests/test-mbs_startswith2.sh
 create mode 100644 tests/test-mbs_startswith3.c
 create mode 100755 tests/test-mbs_startswith3.sh

diff --git a/ChangeLog b/ChangeLog
index 6b2d4d01cf..f31e19cb4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2026-02-27  Bruno Haible  <[email protected]>
 
+	mbs_startswith: Add tests.
+	* tests/test-mbs_startswith1.c: New file, based on
+	tests/test-mbs_endswith1.c.
+	* tests/test-mbs_startswith2.c: New file, based on
+	tests/test-mbs_endswith2.c.
+	* tests/test-mbs_startswith2.sh: New file, based on
+	tests/test-mbs_endswith2.sh.
+	* tests/test-mbs_startswith3.c: New file, based on
+	tests/test-mbs_endswith3.c.
+	* tests/test-mbs_startswith3.sh: New file, based on
+	tests/test-mbs_endswith3.sh.
+	* modules/mbs_startswith-tests: New file.
+
 	mbs_startswith: Fix handling of incomplete characters.
 	* lib/string.in.h (mbs_startswith): Remove macro definition.
 	* lib/mbs_startswith.c: New file.
diff --git a/modules/mbs_startswith-tests b/modules/mbs_startswith-tests
new file mode 100644
index 0000000000..ac922ed450
--- /dev/null
+++ b/modules/mbs_startswith-tests
@@ -0,0 +1,30 @@
+Files:
+tests/test-mbs_startswith1.c
+tests/test-mbs_startswith2.sh
+tests/test-mbs_startswith2.c
+tests/test-mbs_startswith3.sh
+tests/test-mbs_startswith3.c
+tests/macros.h
+m4/locale-en.m4
+m4/locale-fr.m4
+m4/locale-zh.m4
+m4/codeset.m4
+
+Depends-on:
+setlocale
+
+configure.ac:
+gt_LOCALE_EN_UTF8
+gt_LOCALE_FR_UTF8
+gt_LOCALE_ZH_CN
+
+Makefile.am:
+TESTS += test-mbs_startswith1 test-mbs_startswith2.sh test-mbs_startswith3.sh
+TESTS_ENVIRONMENT += \
+  LOCALE_EN_UTF8='@LOCALE_EN_UTF8@' \
+  LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+  LOCALE_ZH_CN='@LOCALE_ZH_CN@'
+check_PROGRAMS += test-mbs_startswith1 test-mbs_startswith2 test-mbs_startswith3
+test_mbs_startswith1_LDADD = $(LDADD) $(LIBUNISTRING) $(MBRTOWC_LIB) $(LIBC32CONV)
+test_mbs_startswith2_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBC32CONV)
+test_mbs_startswith3_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBC32CONV)
diff --git a/tests/test-mbs_startswith1.c b/tests/test-mbs_startswith1.c
new file mode 100644
index 0000000000..a1b89fa4a5
--- /dev/null
+++ b/tests/test-mbs_startswith1.c
@@ -0,0 +1,48 @@
+/* Test of mbs_startswith() function.
+   Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2026.  */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <stdlib.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  /* This test is executed in the C locale.  */
+
+  ASSERT (mbs_startswith ("", ""));
+  ASSERT (mbs_startswith ("abc", ""));
+
+  ASSERT (!mbs_startswith ("", "a"));
+  ASSERT (!mbs_startswith ("x", "a"));
+  ASSERT (mbs_startswith ("a", "a"));
+  ASSERT (mbs_startswith ("abc", "a"));
+
+  ASSERT (!mbs_startswith ("", "xyz"));
+  ASSERT (!mbs_startswith ("x", "xyz"));
+  ASSERT (!mbs_startswith ("a", "xyz"));
+  ASSERT (!mbs_startswith ("abc", "xyz"));
+  ASSERT (mbs_startswith ("xyz", "xyz"));
+  ASSERT (mbs_startswith ("xyzzy", "xyz"));
+
+  return test_exit_status;
+}
diff --git a/tests/test-mbs_startswith2.c b/tests/test-mbs_startswith2.c
new file mode 100644
index 0000000000..38c53dd12b
--- /dev/null
+++ b/tests/test-mbs_startswith2.c
@@ -0,0 +1,95 @@
+/* Test of mbs_startswith() function.
+   Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2026.  */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <locale.h>
+#include <stdlib.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  ASSERT (mbs_startswith ("", ""));
+  ASSERT (mbs_startswith ("abc", ""));
+
+  ASSERT (!mbs_startswith ("", "a"));
+  ASSERT (!mbs_startswith ("x", "a"));
+  ASSERT (mbs_startswith ("a", "a"));
+  ASSERT (mbs_startswith ("abc", "a"));
+
+  ASSERT (!mbs_startswith ("", "xyz"));
+  ASSERT (!mbs_startswith ("x", "xyz"));
+  ASSERT (!mbs_startswith ("a", "xyz"));
+  ASSERT (!mbs_startswith ("abc", "xyz"));
+  ASSERT (mbs_startswith ("xyz", "xyz"));
+  ASSERT (mbs_startswith ("xyzzy", "xyz"));
+
+  ASSERT (mbs_startswith ("", ""));
+  ASSERT (mbs_startswith ("\303\244\306\200\303\247", "")); /* "??????" */
+
+  ASSERT (!mbs_startswith ("", "\303\244")); /* "??" */
+  ASSERT (!mbs_startswith ("\341\272\213", "\303\244")); /* "???" "??" */
+  ASSERT (mbs_startswith ("\303\244", "\303\244")); /* "??" "??" */
+  ASSERT (mbs_startswith ("\303\244\306\200\303\247", "\303\244")); /* "??????" "??" */
+  /* Test a prefix that ends in an incomplete character.  */
+  ASSERT (!mbs_startswith ("\303\244\306\200\303\247", "\303")); /* "??????" */
+
+  ASSERT (!mbs_startswith ("", "\341\272\213\303\277\341\272\221")); /* "????????" */
+  ASSERT (!mbs_startswith ("\341\272\213", "\341\272\213\303\277\341\272\221")); /* "???" "????????" */
+  ASSERT (!mbs_startswith ("\303\244", "\341\272\213\303\277\341\272\221")); /* "??" "????????" */
+  ASSERT (!mbs_startswith ("\303\244\306\200\303\247", "\341\272\213\303\277\341\272\221")); /* "??????" "????????" */
+  ASSERT (mbs_startswith ("\341\272\213\303\277\341\272\221", "\341\272\213\303\277\341\272\221")); /* "????????" "????????" */
+  ASSERT (mbs_startswith ("\341\272\213\303\277\341\272\221\341\272\221\303\277", "\341\272\213\303\277\341\272\221")); /* "?????????????" "????????" */
+  /* Test a prefix that ends in an incomplete character.  */
+  ASSERT (!mbs_startswith ("\341\272\213\303\277\341\272\221\341\272\221\303\277", "\341\272")); /* "?????????????" */
+  ASSERT (!mbs_startswith ("\341\272\213\303\277\341\272\221\341\272\221\303\277", "\341")); /* "?????????????" */
+
+  /* Test cases with invalid or incomplete characters.  */
+
+  /* A valid character should not match an invalid character.  */
+  ASSERT (!mbs_startswith ("\303\247", "\301\247"));
+  ASSERT (!mbs_startswith ("\301\247", "\303\247"));
+
+  /* A valid character should not match an incomplete character.  */
+  ASSERT (!mbs_startswith ("\303\247", "\343\247"));
+  ASSERT (!mbs_startswith ("\343\247", "\303\247"));
+
+  /* An invalid character should not match an incomplete character.  */
+  ASSERT (!mbs_startswith ("\301\247", "\343\247"));
+  ASSERT (!mbs_startswith ("\343\247", "\301\247"));
+
+  /* Two invalid characters should match only if they are identical.  */
+  ASSERT (!mbs_startswith ("\301\246", "\301\247"));
+  ASSERT (!mbs_startswith ("\301\247", "\301\246"));
+  ASSERT (mbs_startswith ("\301\247", "\301\247"));
+
+  /* Two incomplete characters should match only if they are identical.  */
+  ASSERT (!mbs_startswith ("\343\246", "\343\247"));
+  ASSERT (!mbs_startswith ("\343\247", "\343\246"));
+  ASSERT (mbs_startswith ("\343\247", "\343\247"));
+
+  return test_exit_status;
+}
diff --git a/tests/test-mbs_startswith2.sh b/tests/test-mbs_startswith2.sh
new file mode 100755
index 0000000000..8ff20abefb
--- /dev/null
+++ b/tests/test-mbs_startswith2.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: "${LOCALE_EN_UTF8=en_US.UTF-8}"
+: "${LOCALE_FR_UTF8=fr_FR.UTF-8}"
+if test "$LOCALE_EN_UTF8" = none && test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no english or french Unicode locale is installed"
+  else
+    echo "Skipping test: no english or french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+# It's sufficient to test in one of the two locales.
+if test $LOCALE_FR_UTF8 != none; then
+  testlocale=$LOCALE_FR_UTF8
+else
+  testlocale="$LOCALE_EN_UTF8"
+fi
+
+LC_ALL="$testlocale" \
+${CHECKER} ./test-mbs_startswith2${EXEEXT}
diff --git a/tests/test-mbs_startswith3.c b/tests/test-mbs_startswith3.c
new file mode 100644
index 0000000000..1965070401
--- /dev/null
+++ b/tests/test-mbs_startswith3.c
@@ -0,0 +1,73 @@
+/* Test of mbs_startswith() function.
+   Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2026.  */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <locale.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  ASSERT (mbs_startswith ("", ""));
+  ASSERT (mbs_startswith ("abc", ""));
+
+  ASSERT (!mbs_startswith ("", "a"));
+  ASSERT (!mbs_startswith ("x", "a"));
+  ASSERT (mbs_startswith ("a", "a"));
+  ASSERT (mbs_startswith ("abc", "a"));
+
+  ASSERT (!mbs_startswith ("", "xyz"));
+  ASSERT (!mbs_startswith ("x", "xyz"));
+  ASSERT (!mbs_startswith ("a", "xyz"));
+  ASSERT (!mbs_startswith ("abc", "xyz"));
+  ASSERT (mbs_startswith ("xyz", "xyz"));
+  ASSERT (mbs_startswith ("xyzzy", "xyz"));
+
+  ASSERT (mbs_startswith ("", ""));
+  ASSERT (mbs_startswith ("\201\060\212\061\201\060\227\070\201\060\212\064", "")); /* "??????" */
+
+  ASSERT (!mbs_startswith ("", "\201\060\212\061")); /* "??" */
+  ASSERT (!mbs_startswith ("\201\065\374\063", "\201\060\212\061")); /* "???" "??" */
+  ASSERT (mbs_startswith ("\201\060\212\061", "\201\060\212\061")); /* "??" "??" */
+  ASSERT (mbs_startswith ("\201\060\212\061\201\060\227\070\201\060\212\064", "\201\060\212\061")); /* "??????" "??" */
+  /* Test a prefix that ends in an incomplete character.  */
+  ASSERT (!mbs_startswith ("\201\060\212\061\201\060\227\070\201\060\212\064", "\201\060\212")); /* "??????" */
+  ASSERT (!mbs_startswith ("\201\060\212\061\201\060\227\070\201\060\212\064", "\201\060")); /* "??????" */
+  ASSERT (!mbs_startswith ("\201\060\212\061\201\060\227\070\201\060\212\064", "\201")); /* "??????" */
+
+  ASSERT (!mbs_startswith ("", "\201\065\374\063\201\060\213\067\201\065\374\071")); /* "????????" */
+  ASSERT (!mbs_startswith ("\201\065\374\063", "\201\065\374\063\201\060\213\067\201\065\374\071")); /* "???" "????????" */
+  ASSERT (!mbs_startswith ("\201\060\212\061", "\201\065\374\063\201\060\213\067\201\065\374\071")); /* "??" "????????" */
+  ASSERT (!mbs_startswith ("\201\060\212\061\201\060\227\070\201\060\212\064", "\201\065\374\063\201\060\213\067\201\065\374\071")); /* "??????" "????????" */
+  ASSERT (mbs_startswith ("\201\065\374\063\201\060\213\067\201\065\374\071", "\201\065\374\063\201\060\213\067\201\065\374\071")); /* "????????" "????????" */
+  ASSERT (mbs_startswith ("\201\065\374\063\201\060\213\067\201\065\374\071\201\065\374\071\201\060\213\067", "\201\065\374\063\201\060\213\067\201\065\374\071")); /* "?????????????" "????????" */
+  /* Test a prefix that ends in an incomplete character.  */
+  ASSERT (!mbs_startswith ("\201\065\374\063\201\060\213\067\201\065\374\071", "\201\065\374")); /* "????????" */
+  ASSERT (!mbs_startswith ("\201\065\374\063\201\060\213\067\201\065\374\071", "\201\065")); /* "????????" */
+  ASSERT (!mbs_startswith ("\201\065\374\063\201\060\213\067\201\065\374\071", "\201")); /* "????????" */
+
+  return test_exit_status;
+}
diff --git a/tests/test-mbs_startswith3.sh b/tests/test-mbs_startswith3.sh
new file mode 100755
index 0000000000..80a39f32bc
--- /dev/null
+++ b/tests/test-mbs_startswith3.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific GB18030 locale is installed.
+: "${LOCALE_ZH_CN=zh_CN.GB18030}"
+if test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no chinese GB18030 locale is installed"
+  else
+    echo "Skipping test: no chinese GB18030 locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_ZH_CN \
+${CHECKER} ./test-mbs_startswith3${EXEEXT}
-- 
2.52.0

Reply via email to