mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-08-07 10:42:55 +03:00
patch from Nick Wellnhofer adding xsl:sort lang support using the locale
* configure.in libxslt/extra.c libxslt/Makefile.am libxslt/preproc.c libxslt/xsltInternals.h libxslt/xsltlocale.c libxslt/xsltlocale.h libxslt/xsltutils.c win32/Makefile.mingw win32/Makefile.msvc: patch from Nick Wellnhofer adding xsl:sort lang support using the locale support from the C library. Daniel svn path=/trunk/; revision=1476
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
Tue Jun 3 18:26:26 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* configure.in libxslt/extra.c libxslt/Makefile.am libxslt/preproc.c
|
||||||
|
libxslt/xsltInternals.h libxslt/xsltlocale.c libxslt/xsltlocale.h
|
||||||
|
libxslt/xsltutils.c win32/Makefile.mingw win32/Makefile.msvc: patch
|
||||||
|
from Nick Wellnhofer adding xsl:sort lang support using the locale
|
||||||
|
support from the C library.
|
||||||
|
|
||||||
Tue Jun 3 18:14:55 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
Tue Jun 3 18:14:55 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* libxslt/extensions.h: as Ralf Junker pointed out
|
* libxslt/extensions.h: as Ralf Junker pointed out
|
||||||
|
@@ -123,6 +123,9 @@
|
|||||||
/* Define to 1 if you have the `vsprintf' function. */
|
/* Define to 1 if you have the `vsprintf' function. */
|
||||||
#undef HAVE_VSPRINTF
|
#undef HAVE_VSPRINTF
|
||||||
|
|
||||||
|
/* Have working xlocale.h */
|
||||||
|
#undef HAVE_XLOCALE_H
|
||||||
|
|
||||||
/* Define to 1 if you have the `_stat' function. */
|
/* Define to 1 if you have the `_stat' function. */
|
||||||
#undef HAVE__STAT
|
#undef HAVE__STAT
|
||||||
|
|
||||||
@@ -150,6 +153,11 @@
|
|||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
|
|
||||||
|
/* Enable GNU extensions on systems that have them. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# undef _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Using the Win32 Socket implementation */
|
/* Using the Win32 Socket implementation */
|
||||||
#undef _WINSOCKAPI_
|
#undef _WINSOCKAPI_
|
||||||
|
|
||||||
|
43
configure.in
43
configure.in
@@ -3,6 +3,7 @@ AC_PREREQ(2.2)
|
|||||||
AC_INIT(libxslt/xslt.c)
|
AC_INIT(libxslt/xslt.c)
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
|
AC_GNU_SOURCE
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl libxslt is the main part of the package
|
dnl libxslt is the main part of the package
|
||||||
@@ -105,6 +106,48 @@ AC_PATH_PROG(TAR, tar, /bin/tar)
|
|||||||
AC_STDC_HEADERS
|
AC_STDC_HEADERS
|
||||||
AM_PROG_LIBTOOL
|
AM_PROG_LIBTOOL
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([for working xlocale.h])
|
||||||
|
AC_TRY_RUN(
|
||||||
|
[
|
||||||
|
#include <locale.h>
|
||||||
|
#include <xlocale.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 2
|
||||||
|
#define locale_t __locale_t
|
||||||
|
#define newlocale __newlocale
|
||||||
|
#define freelocale __freelocale
|
||||||
|
#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];
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_XLOCALE_H, 1, [Have working xlocale.h])],
|
||||||
|
[AC_MSG_RESULT(no)]
|
||||||
|
)
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Math detection
|
dnl Math detection
|
||||||
dnl
|
dnl
|
||||||
|
@@ -24,11 +24,13 @@ xsltinc_HEADERS = \
|
|||||||
security.h \
|
security.h \
|
||||||
xsltInternals.h \
|
xsltInternals.h \
|
||||||
xsltconfig.h \
|
xsltconfig.h \
|
||||||
xsltexports.h
|
xsltexports.h \
|
||||||
|
xsltlocale.h
|
||||||
|
|
||||||
libxslt_la_SOURCES = \
|
libxslt_la_SOURCES = \
|
||||||
attrvt.c \
|
attrvt.c \
|
||||||
xslt.c \
|
xslt.c \
|
||||||
|
xsltlocale.c \
|
||||||
xsltutils.c \
|
xsltutils.c \
|
||||||
pattern.c \
|
pattern.c \
|
||||||
templates.c \
|
templates.c \
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef HAVE_TIME_H
|
#ifdef HAVE_TIME_H
|
||||||
#define __USE_XOPEN
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
|
@@ -391,6 +391,8 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
|
|||||||
break;
|
break;
|
||||||
case XSLT_FUNC_SORT: {
|
case XSLT_FUNC_SORT: {
|
||||||
xsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp;
|
xsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp;
|
||||||
|
if (item->locale != NULL)
|
||||||
|
xsltFreeLocale(item->locale);
|
||||||
if (item->comp != NULL)
|
if (item->comp != NULL)
|
||||||
xmlXPathFreeCompExpr(item->comp);
|
xmlXPathFreeCompExpr(item->comp);
|
||||||
}
|
}
|
||||||
@@ -487,6 +489,8 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
if (comp->locale != NULL)
|
||||||
|
xsltFreeLocale(comp->locale);
|
||||||
if (comp->comp != NULL)
|
if (comp->comp != NULL)
|
||||||
xmlXPathFreeCompExpr(comp->comp);
|
xmlXPathFreeCompExpr(comp->comp);
|
||||||
if (comp->nsList != NULL)
|
if (comp->nsList != NULL)
|
||||||
@@ -728,6 +732,12 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
|
|||||||
comp->lang = xsltEvalStaticAttrValueTemplate(style, inst,
|
comp->lang = xsltEvalStaticAttrValueTemplate(style, inst,
|
||||||
(const xmlChar *)"lang",
|
(const xmlChar *)"lang",
|
||||||
NULL, &comp->has_lang);
|
NULL, &comp->has_lang);
|
||||||
|
if (comp->lang != NULL) {
|
||||||
|
comp->locale = xsltNewLocale(comp->lang);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
comp->locale = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
comp->select = xsltGetCNsProp(style, inst,(const xmlChar *)"select", XSLT_NAMESPACE);
|
comp->select = xsltGetCNsProp(style, inst,(const xmlChar *)"select", XSLT_NAMESPACE);
|
||||||
if (comp->select == NULL) {
|
if (comp->select == NULL) {
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <libxml/xmlstring.h>
|
#include <libxml/xmlstring.h>
|
||||||
#include <libxslt/xslt.h>
|
#include <libxslt/xslt.h>
|
||||||
#include "xsltexports.h"
|
#include "xsltexports.h"
|
||||||
|
#include "xsltlocale.h"
|
||||||
#include "numbersInternals.h"
|
#include "numbersInternals.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -1045,6 +1046,7 @@ struct _xsltStyleItemSort {
|
|||||||
int descending; /* sort */
|
int descending; /* sort */
|
||||||
const xmlChar *lang; /* sort */
|
const xmlChar *lang; /* sort */
|
||||||
int has_lang; /* sort */
|
int has_lang; /* sort */
|
||||||
|
xsltLocale locale; /* sort */
|
||||||
const xmlChar *case_order; /* sort */
|
const xmlChar *case_order; /* sort */
|
||||||
int lower_first; /* sort */
|
int lower_first; /* sort */
|
||||||
|
|
||||||
@@ -1381,6 +1383,7 @@ struct _xsltStylePreComp {
|
|||||||
int descending; /* sort */
|
int descending; /* sort */
|
||||||
const xmlChar *lang; /* sort */
|
const xmlChar *lang; /* sort */
|
||||||
int has_lang; /* sort */
|
int has_lang; /* sort */
|
||||||
|
xsltLocale locale; /* sort */
|
||||||
const xmlChar *case_order; /* sort */
|
const xmlChar *case_order; /* sort */
|
||||||
int lower_first; /* sort */
|
int lower_first; /* sort */
|
||||||
|
|
||||||
|
@@ -1039,6 +1039,12 @@ xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (res->type == XPATH_STRING) {
|
if (res->type == XPATH_STRING) {
|
||||||
|
if (comp->locale != NULL) {
|
||||||
|
xmlChar *str = res->stringval;
|
||||||
|
res->stringval = (xmlChar *) xsltStrxfrm(comp->locale, str);
|
||||||
|
xmlFree(str);
|
||||||
|
}
|
||||||
|
|
||||||
results[i] = res;
|
results[i] = res;
|
||||||
} else {
|
} else {
|
||||||
#ifdef WITH_XSLT_DEBUG_PROCESS
|
#ifdef WITH_XSLT_DEBUG_PROCESS
|
||||||
@@ -1191,6 +1197,10 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
|||||||
results[j + incr]->floatval)
|
results[j + incr]->floatval)
|
||||||
tst = 1;
|
tst = 1;
|
||||||
else tst = -1;
|
else tst = -1;
|
||||||
|
} else if(comp->locale != NULL) {
|
||||||
|
tst = xsltLocaleStrcmp(
|
||||||
|
(xsltLocaleChar *) results[j]->stringval,
|
||||||
|
(xsltLocaleChar *) results[j + incr]->stringval);
|
||||||
} else {
|
} else {
|
||||||
tst = xmlStrcmp(results[j]->stringval,
|
tst = xmlStrcmp(results[j]->stringval,
|
||||||
results[j + incr]->stringval);
|
results[j + incr]->stringval);
|
||||||
@@ -1245,6 +1255,10 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
|||||||
res[j + incr]->floatval)
|
res[j + incr]->floatval)
|
||||||
tst = 1;
|
tst = 1;
|
||||||
else tst = -1;
|
else tst = -1;
|
||||||
|
} else if(comp->locale != NULL) {
|
||||||
|
tst = xsltLocaleStrcmp(
|
||||||
|
(xsltLocaleChar *) res[j]->stringval,
|
||||||
|
(xsltLocaleChar *) res[j + incr]->stringval);
|
||||||
} else {
|
} else {
|
||||||
tst = xmlStrcmp(res[j]->stringval,
|
tst = xmlStrcmp(res[j]->stringval,
|
||||||
res[j + incr]->stringval);
|
res[j + incr]->stringval);
|
||||||
|
@@ -87,6 +87,7 @@ XSLT_OBJS = $(XSLT_INTDIR)/attributes.o\
|
|||||||
$(XSLT_INTDIR)/transform.o\
|
$(XSLT_INTDIR)/transform.o\
|
||||||
$(XSLT_INTDIR)/variables.o\
|
$(XSLT_INTDIR)/variables.o\
|
||||||
$(XSLT_INTDIR)/xslt.o\
|
$(XSLT_INTDIR)/xslt.o\
|
||||||
|
$(XSLT_INTDIR)/xsltlocale.o\
|
||||||
$(XSLT_INTDIR)/xsltutils.o
|
$(XSLT_INTDIR)/xsltutils.o
|
||||||
XSLT_SRCS = $(subst .o,.c,$(subst $(XSLT_INTDIR),$(XSLT_SRCDIR),$(XSLT_OBJS)))
|
XSLT_SRCS = $(subst .o,.c,$(subst $(XSLT_INTDIR),$(XSLT_SRCDIR),$(XSLT_OBJS)))
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ XSLT_OBJS_A = $(XSLT_INTDIR_A)/attributes.o\
|
|||||||
$(XSLT_INTDIR_A)/transform.o\
|
$(XSLT_INTDIR_A)/transform.o\
|
||||||
$(XSLT_INTDIR_A)/variables.o\
|
$(XSLT_INTDIR_A)/variables.o\
|
||||||
$(XSLT_INTDIR_A)/xslt.o\
|
$(XSLT_INTDIR_A)/xslt.o\
|
||||||
|
$(XSLT_INTDIR_A)/xsltlocale.o\
|
||||||
$(XSLT_INTDIR_A)/xsltutils.o
|
$(XSLT_INTDIR_A)/xsltutils.o
|
||||||
|
|
||||||
# Libexslt object files.
|
# Libexslt object files.
|
||||||
|
@@ -53,6 +53,7 @@ CPPFLAGS = /nologo
|
|||||||
CC = cl.exe
|
CC = cl.exe
|
||||||
CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /W3 $(CRUNTIME) /D "_REENTRANT"
|
CFLAGS = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /W3 $(CRUNTIME) /D "_REENTRANT"
|
||||||
CFLAGS = $(CFLAGS) /I$(BASEDIR) /I$(XSLT_SRCDIR) /I$(INCPREFIX)
|
CFLAGS = $(CFLAGS) /I$(BASEDIR) /I$(XSLT_SRCDIR) /I$(INCPREFIX)
|
||||||
|
CFLAGS = $(CFLAGS) /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
|
||||||
# The linker and its options.
|
# The linker and its options.
|
||||||
LD = link.exe
|
LD = link.exe
|
||||||
@@ -90,6 +91,7 @@ XSLT_OBJS = $(XSLT_INTDIR)\attributes.obj\
|
|||||||
$(XSLT_INTDIR)\transform.obj\
|
$(XSLT_INTDIR)\transform.obj\
|
||||||
$(XSLT_INTDIR)\variables.obj\
|
$(XSLT_INTDIR)\variables.obj\
|
||||||
$(XSLT_INTDIR)\xslt.obj\
|
$(XSLT_INTDIR)\xslt.obj\
|
||||||
|
$(XSLT_INTDIR)\xsltlocale.obj\
|
||||||
$(XSLT_INTDIR)\xsltutils.obj\
|
$(XSLT_INTDIR)\xsltutils.obj\
|
||||||
$(XSLT_INTDIR)\attrvt.obj
|
$(XSLT_INTDIR)\attrvt.obj
|
||||||
|
|
||||||
@@ -110,6 +112,7 @@ XSLT_OBJS_A = $(XSLT_INTDIR_A)\attributes.obj\
|
|||||||
$(XSLT_INTDIR_A)\transform.obj\
|
$(XSLT_INTDIR_A)\transform.obj\
|
||||||
$(XSLT_INTDIR_A)\variables.obj\
|
$(XSLT_INTDIR_A)\variables.obj\
|
||||||
$(XSLT_INTDIR_A)\xslt.obj\
|
$(XSLT_INTDIR_A)\xslt.obj\
|
||||||
|
$(XSLT_INTDIR_A)\xsltlocale.obj\
|
||||||
$(XSLT_INTDIR_A)\xsltutils.obj\
|
$(XSLT_INTDIR_A)\xsltutils.obj\
|
||||||
$(XSLT_INTDIR_A)\attrvt.obj
|
$(XSLT_INTDIR_A)\attrvt.obj
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user