From 044a98e6d3c47f512c779b38bddb975c5de67577 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Thu, 25 Jan 2024 19:20:28 +0100 Subject: [PATCH] tests: Check whether C library supports collation with locales Fixes #104. --- tests/runtest.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/runtest.c b/tests/runtest.c index f61c66a5..9b024387 100644 --- a/tests/runtest.c +++ b/tests/runtest.c @@ -595,10 +595,28 @@ xsltTest(const char *filename, int options) { if (strcmp(filename, "./test-10-3.xsl") == 0) { void *locale = xsltNewLocale(BAD_CAST "de", 0); + xmlChar *str1, *str2; + /* Skip test requiring "de" locale */ if (locale == NULL) return(0); + + /* + * Some C libraries like musl or older macOS don't support + * collation with locales. + */ + str1 = xsltStrxfrm(locale, BAD_CAST "\xC3\xA4"); + str2 = xsltStrxfrm(locale, BAD_CAST "b"); + res = xmlStrcmp(str1, str2); + xmlFree(str1); + xmlFree(str2); xsltFreeLocale(locale); + + if (res >= 0) { + fprintf(stderr, "Warning: Your C library doesn't seem to support " + "collation with locales"); + return(0); + } } styleDoc = xmlReadFile(filename, NULL, XSLT_PARSE_OPTIONS | options); -- GitLab