From: Daniel Veillard Date: Thu, 12 Jun 2008 09:43:28 +0000 (+0000) Subject: patch from Nick Wellnhofer and Roumen Petrov to fix some portability X-Git-Tag: v1.1.28~141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80353190270f6b742aea1969cb1d1de899764fb1;p=platform%2Fupstream%2Flibxslt.git patch from Nick Wellnhofer and Roumen Petrov to fix some portability * libxslt/xsltconfig.h.in libxslt/xsltlocale.h configure.in config.h.in win32/configure.js: patch from Nick Wellnhofer and Roumen Petrov to fix some portability problems on the previous xsl:sort locale patch Daniel svn path=/trunk/; revision=1478 --- diff --git a/ChangeLog b/ChangeLog index 0573b46..e688067 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Jun 12 11:23:23 CEST 2008 Daniel Veillard + + * libxslt/xsltconfig.h.in libxslt/xsltlocale.h configure.in + config.h.in win32/configure.js: patch from Nick Wellnhofer and + Roumen Petrov to fix some portability problems on the previous + xsl:sort locale patch + Tue Jun 3 18:26:26 CEST 2008 Daniel Veillard * configure.in libxslt/extra.c libxslt/Makefile.am libxslt/preproc.c diff --git a/config.h.in b/config.h.in index 1eebe19..83448e3 100644 --- a/config.h.in +++ b/config.h.in @@ -123,7 +123,7 @@ /* Define to 1 if you have the `vsprintf' function. */ #undef HAVE_VSPRINTF -/* Have working xlocale.h */ +/* Define to 1 if you have the header file. */ #undef HAVE_XLOCALE_H /* Define to 1 if you have the `_stat' function. */ diff --git a/configure.in b/configure.in index 7ad6b89..36d9fd5 100644 --- a/configure.in +++ b/configure.in @@ -106,9 +106,18 @@ AC_PATH_PROG(TAR, tar, /bin/tar) AC_STDC_HEADERS AM_PROG_LIBTOOL -AC_MSG_CHECKING([for working xlocale.h]) -AC_TRY_RUN( -[ + +dnl +dnl Detect supported locale +dnl + +XSLT_LOCALE_XLOCALE=0 +XSLT_LOCALE_MSVCRT=0 + +AC_CHECK_HEADERS([xlocale.h]) +if test $ac_cv_header_xlocale_h = yes; then +AC_MSG_CHECKING([for working xlocale]) +AC_RUN_IFELSE(AC_LANG_PROGRAM([[ #include #include #include @@ -121,32 +130,40 @@ AC_TRY_RUN( #define strxfrm_l __strxfrm_l #define LC_COLLATE_MASK (1 << LC_COLLATE) #endif - -int main() -{ +]],[[ locale_t locale; - const char *src[2] = { "\xc3\x84rger", "Zeppelin" }; - char *dst[2]; + 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); + 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); - + if (strcmp(dst[[0]], dst[[1]]) >= 0) exit(1); + exit(0); -} -], - [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_XLOCALE_H, 1, [Have working xlocale.h])], - [AC_MSG_RESULT(no)] + return(0); +]]), + [AC_MSG_RESULT(yes); XSLT_LOCALE_XLOCALE=1], + [AC_MSG_RESULT(no)], + [AC_MSG_WARN([cross compiling: assuming no])] ) +else + dnl defined in msvcrt + AC_CHECK_FUNC(_create_locale, + [XSLT_LOCALE_MSVCRT=1] + ) +fi + +AC_SUBST(XSLT_LOCALE_XLOCALE) +AC_SUBST(XSLT_LOCALE_MSVCRT) dnl dnl Math detection diff --git a/libxslt/xsltconfig.h.in b/libxslt/xsltconfig.h.in index a8b5acf..e9a3c56 100644 --- a/libxslt/xsltconfig.h.in +++ b/libxslt/xsltconfig.h.in @@ -124,6 +124,19 @@ extern "C" { #endif /** + * Locale support + */ +#if @XSLT_LOCALE_XLOCALE@ +#ifndef XSLT_LOCALE_XLOCALE +#define XSLT_LOCALE_XLOCALE +#endif +#elif @XSLT_LOCALE_MSVCRT@ +#ifndef XSLT_LOCALE_MSVCRT +#define XSLT_LOCALE_MSVCRT +#endif +#endif + +/** * ATTRIBUTE_UNUSED: * * This macro is used to flag unused function parameters to GCC diff --git a/libxslt/xsltlocale.h b/libxslt/xsltlocale.h index de43031..c700df4 100644 --- a/libxslt/xsltlocale.h +++ b/libxslt/xsltlocale.h @@ -13,9 +13,7 @@ #include -#ifdef HAVE_XLOCALE_H - -#define XSLT_LOCALE_XLOCALE +#ifdef XSLT_LOCALE_XLOCALE #include #include @@ -27,10 +25,7 @@ typedef locale_t xsltLocale; #endif typedef xmlChar xsltLocaleChar; -#else -#if defined(_MSC_VER) || defined (__MINGW32__) && defined(__MSVCRT__) - -#define XSLT_LOCALE_MSVCRT +#elif defined(XSLT_LOCALE_MSVCRT) #include @@ -39,13 +34,14 @@ typedef wchar_t xsltLocaleChar; #else +#ifndef XSLT_LOCALE_NONE #define XSLT_LOCALE_NONE +#endif typedef void *xsltLocale; typedef xmlChar xsltLocaleChar; #endif -#endif xsltLocale xsltNewLocale(const xmlChar *langName); void xsltFreeLocale(xsltLocale locale); diff --git a/win32/configure.js b/win32/configure.js index f28e9da..4feb4b2 100644 --- a/win32/configure.js +++ b/win32/configure.js @@ -47,6 +47,7 @@ var withIconv = true; var withZlib = false; var withCrypto = true; var withModules = false; +var withLocale = true; /* Win32 build options. */ var dirSep = "\\"; var compiler = "msvc"; @@ -106,6 +107,7 @@ 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 msvcr80.dll (" + (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"; @@ -240,6 +242,10 @@ 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_MSVCRT\@/) != -1) { + of.WriteLine(s.replace(/\@XSLT_LOCALE_MSVCRT\@/, withLocale? "1" : "0")); } else if (s.search(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/) != -1) { of.WriteLine(s.replace(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/, "NULL")); } else @@ -343,6 +349,8 @@ 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") @@ -477,6 +485,7 @@ 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";