Commit b055a6b5 by Edward Thomson

tests: regex: add test with LC_COLLATE being set

While we already have a test for `p_regexec` with `LC_CTYPE` being
modified, `regexec` also alters behavior as soon as `LC_COLLATE` is
being modified. Most importantly, `LC_COLLATE` changes the way how
ranges are interpreted to just not handling them at all. Thus, ensure
that either we use `regcomp_l` to avoid this, or that we've fallen back
to our builtin regex functionality which also behaves properly.
parent ad4ede91
......@@ -177,6 +177,31 @@ void test_core_posix__p_regcomp_ignores_global_locale_ctype(void)
cl_must_pass(error);
}
void test_core_posix__p_regcomp_ignores_global_locale_collate(void)
{
regex_t preg;
int error = 0;
const char* oldlocale = setlocale(LC_COLLATE, NULL);
if (!setlocale(LC_COLLATE, "UTF-8") &&
!setlocale(LC_COLLATE, "c.utf8") &&
!setlocale(LC_COLLATE, "en_US.UTF-8"))
cl_skip();
if (MB_CUR_MAX == 1) {
setlocale(LC_COLLATE, oldlocale);
cl_fail("Expected locale to be switched to multibyte");
}
error = p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", REG_EXTENDED);
regfree(&preg);
setlocale(LC_COLLATE, oldlocale);
cl_must_pass(error);
}
void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
{
size_t idx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment