Loading...
--- Libc/Libc-1725.40.4/tests/collate.c
+++ Libc/Libc-1669.0.4/tests/collate.c
@@ -1,13 +1,8 @@
-#include <sys/param.h>
-
#include <TargetConditionals.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
-#include <regex.h>
-#include <stdbool.h>
#include <stdlib.h>
-#include <unistd.h>
#include <xlocale.h>
#include <darwintest.h>
@@ -277,108 +272,3 @@
T_EXPECT_NE(sec, sec2, "Different secondary weight");
#endif
}
-
-static void
-try_one(regex_t *preg, unsigned char ch, bool expected, const char *type)
-{
- unsigned char str[2] = { ch, 0x00 };
- regmatch_t match;
- int error;
-
- error = regexec(preg, (const char *)&str[0], 1, &match, 0);
- T_ASSERT_EQ(error == 0, expected, "Character 0x%x should %s %s",
- ch, expected ? "match" : "not match", type);
-}
-
-T_DECL(collate_equivalence, "Test __collate_lookup() behavior",
- T_META_ENABLED(TARGET_OS_OSX)) {
- regex_t ireg, reg;
- const char *cpatterns[] = { "[[=a=]]", "[[=A=]]", NULL };
- const char *isopatterns[] = { "[[=\xe5=]]", "[[=a=]]", NULL };
- const char *loc;
- int error;
- bool lower, exp, iexp;
-
- loc = setlocale(LC_ALL, "en_US.ISO8859-1");
- T_ASSERT_EQ_STR(loc, "en_US.ISO8859-1", "setlocale en_US.ISO8859-1");
-
- for (const char **pat = isopatterns; *pat != NULL; pat++) {
- T_LOG("Trying pattern '%s', ISO8859-1 locale", *pat);
- error = regcomp(®, *pat, REG_BASIC);
- T_ASSERT_EQ_INT(error, 0, "Regex compilation");
-
- error = regcomp(&ireg, *pat, REG_BASIC | REG_ICASE);
- T_ASSERT_EQ_INT(error, 0, "Case-insensitive regex compilation");
-
- for (unsigned char ch = 0x00; ch < 0xff; ch++) {
- exp = (ch >= 0xe0 && ch < 0xe6) || ch == 'a';
- iexp = exp || (ch >= 0xc0 && ch < 0xc6) || ch == 'A' ||
- ch == 0xaa /* FEMININE_ORDINAL_INDICATOR */;
-
- try_one(®, ch, exp, "sensitively");
- try_one(&ireg, ch, iexp, "insensitively");
- }
-
- regfree(®);
- regfree(&ireg);
- }
-
- loc = setlocale(LC_ALL, "C");
- T_ASSERT_EQ_STR(loc, "C", "setlocale C");
-
- lower = true;
- for (const char **pat = cpatterns; *pat != NULL; pat++) {
- T_LOG("Trying pattern '%s', C locale", *pat);
- error = regcomp(®, *pat, REG_BASIC);
- T_ASSERT_EQ_INT(error, 0, "Regex compilation");
-
- error = regcomp(&ireg, *pat, REG_BASIC | REG_ICASE);
- T_ASSERT_EQ_INT(error, 0, "Case-insensitive regex compilation");
-
- for (unsigned char ch = 0x00; ch < 0xff; ch++) {
- if (lower) {
- exp = ch == 'a';
- iexp = exp || ch == 'A';
- } else {
- exp = ch == 'A';
- iexp = exp || ch == 'a';
- }
-
- try_one(®, ch, exp, "sensitively");
- try_one(&ireg, ch, iexp, "insensitively");
- }
-
- regfree(®);
- regfree(&ireg);
-
- lower = false;
- }
-}
-
-T_DECL(collate_subst_legacy, "Test legacy substitution behavior") {
- char cwdbuf[MAXPATHLEN], *cwd, *localepath;
- const char *curloc;
- int ret;
-
- cwd = getcwd(cwdbuf, sizeof(cwdbuf));
- T_ASSERT_NE_PTR(cwd, NULL, NULL);
-
- ret = asprintf(&localepath, "%s/locales", cwd);
- T_ASSERT_GT(ret, 0, NULL);
-
- T_LOG("Setting PATH_LOCALE to %s", localepath);
- ret = setenv("PATH_LOCALE", localepath, 1);
- T_ASSERT_EQ(ret, 0, NULL);
-
- /* They should not be equivalent in the C locale. */
- setlocale(LC_COLLATE, "C");
- ret = strcoll("ss", "\xdf");
- T_ASSERT_NE(ret, 0, NULL);
-
- curloc = setlocale(LC_COLLATE, "legacy.subst");
- T_ASSERT_EQ_STR(curloc, "legacy.subst", "Set LC_COLLATE to a legacy definition");
-
- ret = strcoll("ss", "\xdf");
- T_ASSERT_EQ(ret, 0, "Compare with substitutions applied");
- free(localepath);
-}