2026-05-07 Paul Eggert <eggert@cs.ucla.edu>
+ bench-tests: work with wchar-single
+ * modules/mbiter-bench-tests, modules/mbiterf-bench-tests:
+ * modules/mbswidth-bench-tests, modules/mbuiter-bench-tests:
+ * modules/mbuiterf-bench-tests, modules/mcel-bench-tests:
+ (Depends-on): Add streq.
+ * tests/bench-mbiter.c, tests/bench-mbiterf.c, tests/bench-mbswidth.c:
+ * tests/bench-mbuiter.c, tests/bench-mbuiterf.c, tests/bench-mcel.c:
+ If GNULIB_WCHAR_SINGLE_LOCALE, don’t call setlocale with different
+ locales.
+
regex-tests: fix usage of fastmap API
* tests/test-regex.c (main): Use documented fastmap API
rather than relying on undocumented behavior.
mbrtoc32-regular
mbiter
setlocale
+streq
striconv
getrusage
gettimeofday
mbrtoc32-regular
mbiterf
setlocale
+streq
striconv
getrusage
gettimeofday
mbrtoc32-regular
mbswidth
setlocale
+streq
striconv
getrusage
gettimeofday
mbrtoc32-regular
mbuiter
setlocale
+streq
striconv
getrusage
gettimeofday
mbrtoc32-regular
mbuiterf
setlocale
+streq
striconv
getrusage
gettimeofday
mbuiterf
mcel
setlocale
+streq
striconv
getrusage
gettimeofday
unsigned long long volatile result;
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
static void
do_test (char test, int repeat, const char *locale_name, const char *text)
{
printf ("Test %c\n", test);
- if (setlocale (LC_ALL, locale_name) != NULL)
+
+ static char const *current_locale_name;
+ if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+ && !streq (locale_name, current_locale_name))
+ printf ("Skipping test: earlier locale %s != test locale %s\n",
+ current_locale_name, locale_name);
+ else if (!setlocale (LC_ALL, locale_name))
+ printf ("Skipping test: locale %s not installed.\n", locale_name);
+ else
{
+ current_locale_name = locale_name;
+
struct timings_state ts;
timing_start (&ts);
timing_end (&ts);
timing_output (&ts);
}
- else
- {
- printf ("Skipping test: locale %s not installed.\n", locale_name);
- }
printf ("\n");
}
unsigned long long volatile result;
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
static void
do_test (char test, int repeat, const char *locale_name, const char *text)
{
printf ("Test %c\n", test);
- if (setlocale (LC_ALL, locale_name) != NULL)
+
+ static char const *current_locale_name;
+ if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+ && !streq (locale_name, current_locale_name))
+ printf ("Skipping test: earlier locale %s != test locale %s\n",
+ current_locale_name, locale_name);
+ else if (!setlocale (LC_ALL, locale_name))
+ printf ("Skipping test: locale %s not installed.\n", locale_name);
+ else
{
+ current_locale_name = locale_name;
+
struct timings_state ts;
timing_start (&ts);
timing_end (&ts);
timing_output (&ts);
}
- else
- {
- printf ("Skipping test: locale %s not installed.\n", locale_name);
- }
printf ("\n");
}
#include "bench-multibyte.h"
#include "mbswidth.h"
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
static void
do_test (char test, int repeat, const char *locale_name, const char *text)
{
printf ("Test %c\n", test);
- if (setlocale (LC_ALL, locale_name) != NULL)
+
+ static char const *current_locale_name;
+ if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+ && !streq (locale_name, current_locale_name))
+ printf ("Skipping test: earlier locale %s != test locale %s\n",
+ current_locale_name, locale_name);
+ else if (!setlocale (LC_ALL, locale_name))
+ printf ("Skipping test: locale %s not installed.\n", locale_name);
+ else
{
+ current_locale_name = locale_name;
+
struct timings_state ts;
timing_start (&ts);
timing_end (&ts);
timing_output (&ts);
}
- else
- {
- printf ("Skipping test: locale %s not installed.\n", locale_name);
- }
printf ("\n");
}
unsigned long long volatile result;
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
static void
do_test (char test, int repeat, const char *locale_name, const char *text)
{
printf ("Test %c\n", test);
- if (setlocale (LC_ALL, locale_name) != NULL)
+
+ static char const *current_locale_name;
+ if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+ && !streq (locale_name, current_locale_name))
+ printf ("Skipping test: earlier locale %s != test locale %s\n",
+ current_locale_name, locale_name);
+ else if (!setlocale (LC_ALL, locale_name))
+ printf ("Skipping test: locale %s not installed.\n", locale_name);
+ else
{
+ current_locale_name = locale_name;
+
struct timings_state ts;
timing_start (&ts);
timing_end (&ts);
timing_output (&ts);
}
- else
- {
- printf ("Skipping test: locale %s not installed.\n", locale_name);
- }
printf ("\n");
}
unsigned long long volatile result;
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
static void
do_test (char test, int repeat, const char *locale_name, const char *text)
{
printf ("Test %c\n", test);
- if (setlocale (LC_ALL, locale_name) != NULL)
+
+ static char const *current_locale_name;
+ if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+ && !streq (locale_name, current_locale_name))
+ printf ("Skipping test: earlier locale %s != test locale %s\n",
+ current_locale_name, locale_name);
+ else if (!setlocale (LC_ALL, locale_name))
+ printf ("Skipping test: locale %s not installed.\n", locale_name);
+ else
{
+ current_locale_name = locale_name;
+
struct timings_state ts;
timing_start (&ts);
timing_end (&ts);
timing_output (&ts);
}
- else
- {
- printf ("Skipping test: locale %s not installed.\n", locale_name);
- }
printf ("\n");
}
return sum;
}
+#ifndef GNULIB_WCHAR_SINGLE_LOCALE
+# define GNULIB_WCHAR_SINGLE_LOCALE 0
+#endif
+
static void
do_test (char test, int repeat, char const *locale_name,
char const *text, size_t text_len)
{
- if (setlocale (LC_ALL, locale_name) != NULL)
+ static char const *current_locale_name;
+ if (GNULIB_WCHAR_SINGLE_LOCALE && current_locale_name
+ && !streq (locale_name, current_locale_name))
+ printf ("Skipping test: earlier locale %s != test locale %s\n",
+ current_locale_name, locale_name);
+ else if (!setlocale (LC_ALL, locale_name))
+ printf ("Skipping test: locale %s not installed.\n", locale_name);
+ else
{
+ current_locale_name = locale_name;
+
char const *text_end = text + text_len;
static struct
testdesc[i].sum =
do_1_test (testdesc[i].fn, text, text_end, repeat, &testdesc[i].ts);
- setlocale (LC_ALL, "C");
-
static bool header_printed;
if (!header_printed)
{
}
printf ("\n");
}
- else
- {
- printf ("Skipping test: locale %s not installed.\n", locale_name);
- }
}
/* Performs some or all of the following tests: