From: Paul Eggert Date: Thu, 7 May 2026 18:24:22 +0000 (-0700) Subject: bench-tests: work with wchar-single X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d60036ddca99d4f682f6412a129d8aa8b51e1cc2;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index c2c49d0ca5..a3e37f6e93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2026-05-07 Paul Eggert + 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. diff --git a/modules/mbiter-bench-tests b/modules/mbiter-bench-tests index ec22673d1a..1648054e84 100644 --- a/modules/mbiter-bench-tests +++ b/modules/mbiter-bench-tests @@ -7,6 +7,7 @@ Depends-on: mbrtoc32-regular mbiter setlocale +streq striconv getrusage gettimeofday diff --git a/modules/mbiterf-bench-tests b/modules/mbiterf-bench-tests index b4b530dc5a..dc837a2304 100644 --- a/modules/mbiterf-bench-tests +++ b/modules/mbiterf-bench-tests @@ -7,6 +7,7 @@ Depends-on: mbrtoc32-regular mbiterf setlocale +streq striconv getrusage gettimeofday diff --git a/modules/mbswidth-bench-tests b/modules/mbswidth-bench-tests index f8edf91dfe..8ffc21db2e 100644 --- a/modules/mbswidth-bench-tests +++ b/modules/mbswidth-bench-tests @@ -7,6 +7,7 @@ Depends-on: mbrtoc32-regular mbswidth setlocale +streq striconv getrusage gettimeofday diff --git a/modules/mbuiter-bench-tests b/modules/mbuiter-bench-tests index de98778fd6..29b72b342e 100644 --- a/modules/mbuiter-bench-tests +++ b/modules/mbuiter-bench-tests @@ -7,6 +7,7 @@ Depends-on: mbrtoc32-regular mbuiter setlocale +streq striconv getrusage gettimeofday diff --git a/modules/mbuiterf-bench-tests b/modules/mbuiterf-bench-tests index cf806ecc49..c9551bff88 100644 --- a/modules/mbuiterf-bench-tests +++ b/modules/mbuiterf-bench-tests @@ -7,6 +7,7 @@ Depends-on: mbrtoc32-regular mbuiterf setlocale +streq striconv getrusage gettimeofday diff --git a/modules/mcel-bench-tests b/modules/mcel-bench-tests index 0c54aad819..1599505fdd 100644 --- a/modules/mcel-bench-tests +++ b/modules/mcel-bench-tests @@ -11,6 +11,7 @@ mbuiter mbuiterf mcel setlocale +streq striconv getrusage gettimeofday diff --git a/tests/bench-mbiter.c b/tests/bench-mbiter.c index b7bea54805..3593c164e6 100644 --- a/tests/bench-mbiter.c +++ b/tests/bench-mbiter.c @@ -27,12 +27,26 @@ 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); @@ -51,10 +65,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text) timing_end (&ts); timing_output (&ts); } - else - { - printf ("Skipping test: locale %s not installed.\n", locale_name); - } printf ("\n"); } diff --git a/tests/bench-mbiterf.c b/tests/bench-mbiterf.c index 505e5fbc6a..57564f5265 100644 --- a/tests/bench-mbiterf.c +++ b/tests/bench-mbiterf.c @@ -27,12 +27,26 @@ 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); @@ -55,10 +69,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text) timing_end (&ts); timing_output (&ts); } - else - { - printf ("Skipping test: locale %s not installed.\n", locale_name); - } printf ("\n"); } diff --git a/tests/bench-mbswidth.c b/tests/bench-mbswidth.c index 4facad04fc..bad0adcf5c 100644 --- a/tests/bench-mbswidth.c +++ b/tests/bench-mbswidth.c @@ -25,12 +25,26 @@ #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); @@ -42,10 +56,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text) timing_end (&ts); timing_output (&ts); } - else - { - printf ("Skipping test: locale %s not installed.\n", locale_name); - } printf ("\n"); } diff --git a/tests/bench-mbuiter.c b/tests/bench-mbuiter.c index 2fda0506c9..b1e4eccc6f 100644 --- a/tests/bench-mbuiter.c +++ b/tests/bench-mbuiter.c @@ -27,12 +27,26 @@ 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); @@ -50,10 +64,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text) timing_end (&ts); timing_output (&ts); } - else - { - printf ("Skipping test: locale %s not installed.\n", locale_name); - } printf ("\n"); } diff --git a/tests/bench-mbuiterf.c b/tests/bench-mbuiterf.c index 5f51c9b01a..92c3174599 100644 --- a/tests/bench-mbuiterf.c +++ b/tests/bench-mbuiterf.c @@ -27,12 +27,26 @@ 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); @@ -53,10 +67,6 @@ do_test (char test, int repeat, const char *locale_name, const char *text) timing_end (&ts); timing_output (&ts); } - else - { - printf ("Skipping test: locale %s not installed.\n", locale_name); - } printf ("\n"); } diff --git a/tests/bench-mcel.c b/tests/bench-mcel.c index d8f91a4b16..f100a366c1 100644 --- a/tests/bench-mcel.c +++ b/tests/bench-mcel.c @@ -191,12 +191,25 @@ do_1_test (test_function test, char const *text, 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 @@ -220,8 +233,6 @@ do_test (char test, int repeat, char const *locale_name, 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) { @@ -241,10 +252,6 @@ do_test (char test, int repeat, char const *locale_name, } printf ("\n"); } - else - { - printf ("Skipping test: locale %s not installed.\n", locale_name); - } } /* Performs some or all of the following tests: