summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2017-10-08 14:34:06 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2017-10-08 15:36:21 +0200
commit8b4babb8f742a1a189df4c4569e68eda308df68f (patch)
tree1251ec94e762175d5f73c44c5519d496b4868901
parent43b6edbfafb73edd23f2040cfba119cd4a833f8f (diff)
downloadlibxslt-8b4babb8f742a1a189df4c4569e68eda308df68f.tar.gz
Rework locale feature tests
Support glibc 2.26 which removes xlocale.h. Fixes bug 788264. Thanks to Quentin Minster for the report. Drop support for ancient glibc 2.2.x. This allows to replace the test program in configure.ac with a simple check for strxfrm_l. Always use WinAPI locales on Windows. Define macros in xsltlocale.h and rename XSLT_LOCALE_XLOCALE to XSLT_LOCALE_POSIX.
-rw-r--r--configure.ac68
-rw-r--r--libxslt/xslt.c1
-rw-r--r--libxslt/xsltconfig.h.in13
-rw-r--r--libxslt/xsltlocale.c13
-rw-r--r--libxslt/xsltlocale.h29
-rw-r--r--win32/configure.js9
6 files changed, 24 insertions, 109 deletions
diff --git a/configure.ac b/configure.ac
index 59e9e69a..753b2d9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,74 +161,8 @@ dnl
dnl Detect supported locale
dnl
-XSLT_LOCALE_XLOCALE=0
-XSLT_LOCALE_WINAPI=0
-
AC_CHECK_HEADERS([locale.h xlocale.h])
-if test $ac_cv_header_xlocale_h = yes; then
-dnl
-dnl Check for generic locale_t declaration
-dnl
-AC_MSG_CHECKING([if xlocale program link])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
-#endif
-#ifdef HAVE_XLOCALE_H
-#include <xlocale.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef __GLIBC__
-typedef __locale_t xsltLocale;
-#else
-typedef locale_t xsltLocale;
-#endif
-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 2
-#define newlocale __newlocale
-#define freelocale __freelocale
-#define strxfrm_l __strxfrm_l
-#define LC_COLLATE_MASK (1 << LC_COLLATE)
-#endif
-]],[[
- xsltLocale locale;
- const char *src[2] = { "\xc3\x84rger", "Zeppelin" };
- char *dst[2];
- size_t len, r;
- int i;
-
- locale = newlocale(LC_COLLATE_MASK, "en_US.utf8", NULL);
- if (locale == NULL) exit(1);
- for (i=0; i<2; ++i) {
- len = strxfrm_l(NULL, src[i], 0, locale) + 1;
- dst[i] = malloc(len);
- if(dst[i] == NULL) exit(1);
- r = strxfrm_l(dst[i], src[i], len, locale);
- if(r >= len) exit(1);
- }
- if (strcmp(dst[0], dst[1]) >= 0) exit(1);
-
- exit(0);
- return(0);
-]])],
- [AC_MSG_RESULT(yes); XSLT_LOCALE_XLOCALE=1],
- [AC_MSG_RESULT(no)]
-)
-else
- case "$host" in
- *-*-mingw*)
- AC_MSG_NOTICE([using winapi locale])
- XSLT_LOCALE_WINAPI=1;;
- esac
-fi
-
-AC_SUBST(XSLT_LOCALE_XLOCALE)
-AC_SUBST(XSLT_LOCALE_WINAPI)
+AC_CHECK_FUNCS([strxfrm_l])
dnl
dnl Math detection
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index 7d9ddb66..54a39de9 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -42,6 +42,7 @@
#include "preproc.h"
#include "extra.h"
#include "security.h"
+#include "xsltlocale.h"
#ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_PARSING
diff --git a/libxslt/xsltconfig.h.in b/libxslt/xsltconfig.h.in
index 6e4e3285..5fa5e589 100644
--- a/libxslt/xsltconfig.h.in
+++ b/libxslt/xsltconfig.h.in
@@ -124,19 +124,6 @@ extern "C" {
#endif
/**
- * Locale support
- */
-#if @XSLT_LOCALE_XLOCALE@
-#ifndef XSLT_LOCALE_XLOCALE
-#define XSLT_LOCALE_XLOCALE
-#endif
-#elif @XSLT_LOCALE_WINAPI@
-#ifndef XSLT_LOCALE_WINAPI
-#define XSLT_LOCALE_WINAPI
-#endif
-#endif
-
-/**
* ATTRIBUTE_UNUSED:
*
* This macro is used to flag unused function parameters to GCC
diff --git a/libxslt/xsltlocale.c b/libxslt/xsltlocale.c
index b5fe9863..bc9774b5 100644
--- a/libxslt/xsltlocale.c
+++ b/libxslt/xsltlocale.c
@@ -19,13 +19,6 @@
#include "xsltlocale.h"
#include "xsltutils.h"
-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 2
-#define newlocale __newlocale
-#define freelocale __freelocale
-#define strxfrm_l __strxfrm_l
-#define LC_COLLATE_MASK (1 << LC_COLLATE)
-#endif
-
#define TOUPPER(c) (c & ~0x20)
#define TOLOWER(c) (c | 0x20)
#define ISALPHA(c) ((unsigned)(TOUPPER(c) - 'A') < 26)
@@ -92,7 +85,7 @@ xsltFreeLocales(void) {
*/
xsltLocale
xsltNewLocale(const xmlChar *languageTag) {
-#ifdef XSLT_LOCALE_XLOCALE
+#ifdef XSLT_LOCALE_POSIX
xsltLocale locale;
char localeName[XSLTMAX_LANGTAGLEN+6]; /* 6 chars for ".utf8\0" */
const xmlChar *p = languageTag;
@@ -352,7 +345,7 @@ xsltDefaultRegion(const xmlChar *localeName) {
*/
void
xsltFreeLocale(xsltLocale locale) {
-#ifdef XSLT_LOCALE_XLOCALE
+#ifdef XSLT_LOCALE_POSIX
freelocale(locale);
#endif
}
@@ -376,7 +369,7 @@ xsltStrxfrm(xsltLocale locale, const xmlChar *string)
size_t xstrlen, r;
xsltLocaleChar *xstr;
-#ifdef XSLT_LOCALE_XLOCALE
+#ifdef XSLT_LOCALE_POSIX
xstrlen = strxfrm_l(NULL, (const char *)string, 0, locale) + 1;
xstr = (xsltLocaleChar *) xmlMalloc(xstrlen);
if (xstr == NULL) {
diff --git a/libxslt/xsltlocale.h b/libxslt/xsltlocale.h
index 8a9ca152..f3b9d6e0 100644
--- a/libxslt/xsltlocale.h
+++ b/libxslt/xsltlocale.h
@@ -14,20 +14,31 @@
#include <libxml/xmlstring.h>
#include "xsltexports.h"
-#ifdef XSLT_LOCALE_XLOCALE
+#ifdef HAVE_STRXFRM_L
+/*
+ * XSLT_LOCALE_POSIX:
+ * Macro indicating to use POSIX locale extensions
+ */
+#define XSLT_LOCALE_POSIX
+
+#ifdef HAVE_LOCALE_H
#include <locale.h>
+#endif
+#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
+#endif
-#ifdef __GLIBC__
-/*locale_t is defined only if _GNU_SOURCE is defined*/
-typedef __locale_t xsltLocale;
-#else
typedef locale_t xsltLocale;
-#endif
typedef xmlChar xsltLocaleChar;
-#elif defined(XSLT_LOCALE_WINAPI)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+
+/*
+ * XSLT_LOCALE_WINAPI:
+ * Macro indicating to use WinAPI for extended locale support
+ */
+#define XSLT_LOCALE_WINAPI
#include <windows.h>
#include <winnls.h>
@@ -39,11 +50,9 @@ typedef wchar_t xsltLocaleChar;
/*
* XSLT_LOCALE_NONE:
- * Macro indicating that locale are not supported
+ * Macro indicating that there's no extended locale support
*/
-#ifndef XSLT_LOCALE_NONE
#define XSLT_LOCALE_NONE
-#endif
typedef void *xsltLocale;
typedef xmlChar xsltLocaleChar;
diff --git a/win32/configure.js b/win32/configure.js
index a8098132..56694cce 100644
--- a/win32/configure.js
+++ b/win32/configure.js
@@ -47,7 +47,6 @@ var withIconv = true;
var withZlib = false;
var withCrypto = true;
var withModules = false;
-var withLocale = true;
/* Win32 build options. */
var dirSep = "\\";
var compiler = "msvc";
@@ -107,7 +106,6 @@ function usage()
txt += " zlib: Use zlib library (" + (withZlib? "yes" : "no") + ")\n";
txt += " crypto: Enable Crypto support (" + (withCrypto? "yes" : "no") + ")\n";
txt += " modules: Enable Module support (" + (withModules? "yes" : "no") + ")\n";
- txt += " locale: Enable Locale support, requires unicode OS support (" + (withLocale? "yes" : "no") + ")\n";
txt += "\nWin32 build options, default value given in parentheses:\n\n";
txt += " compiler: Compiler to be used [msvc|mingw] (" + compiler + ")\n";
txt += " cruntime: C-runtime compiler option (only msvc) (" + cruntime + ")\n";
@@ -242,10 +240,6 @@ function configureXslt()
of.WriteLine(s.replace(/\@WITH_DEBUGGER\@/, withDebugger? "1" : "0"));
} else if (s.search(/\@WITH_MODULES\@/) != -1) {
of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
- } else if (s.search(/\@XSLT_LOCALE_XLOCALE\@/) != -1) {
- of.WriteLine(s.replace(/\@XSLT_LOCALE_XLOCALE\@/, "0"));
- } else if (s.search(/\@XSLT_LOCALE_WINAPI\@/) != -1) {
- of.WriteLine(s.replace(/\@XSLT_LOCALE_WINAPI\@/, withLocale? "1" : "0"));
} else if (s.search(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/) != -1) {
of.WriteLine(s.replace(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/, "NULL"));
} else
@@ -349,8 +343,6 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
withCrypto = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "modules")
withModules = strToBool(arg.substring(opt.length + 1, arg.length));
- else if (opt == "locale")
- withLocale = strToBool(arg.substring(opt.length + 1, arg.length));
else if (opt == "compiler")
compiler = arg.substring(opt.length + 1, arg.length);
else if (opt == "cruntime")
@@ -485,7 +477,6 @@ txtOut += " Use iconv: " + boolToStr(withIconv) + "\n";
txtOut += " With zlib: " + boolToStr(withZlib) + "\n";
txtOut += " Crypto: " + boolToStr(withCrypto) + "\n";
txtOut += " Modules: " + boolToStr(withModules) + "\n";
-txtOut += " Locale: " + boolToStr(withLocale) + "\n";
txtOut += "\n";
txtOut += "Win32 build configuration\n";
txtOut += "-------------------------\n";