mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[LIBXSLT] Update to release 1.1.42 (from Wine-10.0)
This commit is contained in:
Vendored
+6
-1
@@ -1,4 +1,6 @@
|
||||
|
||||
spec2def(libxslt.dll libxslt.spec ADD_IMPORTLIB)
|
||||
|
||||
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libxslt
|
||||
${REACTOS_SOURCE_DIR}/sdk/lib/3rdparty/libwin-iconv)
|
||||
|
||||
@@ -7,7 +9,6 @@ add_definitions(
|
||||
-DWIN32
|
||||
-D_WINDOWS
|
||||
-D_MBCS
|
||||
-DHAVE_STAT
|
||||
-DHAVE_WIN32_THREADS
|
||||
-D_REENTRANT
|
||||
-DLIBXML_STATIC)
|
||||
@@ -41,6 +42,10 @@ add_importlibs(libxslt msvcrt ws2_32 kernel32)
|
||||
|
||||
if(MSVC)
|
||||
add_importlibs(libxslt ntdll)
|
||||
if (ARCH STREQUAL "amd64" OR ARCH STREQUAL "arm64")
|
||||
# warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
|
||||
target_compile_options(libxslt PRIVATE /wd4267)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
|
||||
Vendored
-79
@@ -1,79 +0,0 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = libxslt libexslt xsltproc doc tests
|
||||
if WITH_PYTHON
|
||||
SUBDIRS += python
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = libxslt libexslt xsltproc python doc tests
|
||||
|
||||
confexecdir=$(libdir)
|
||||
confexec_DATA = xsltConf.sh
|
||||
|
||||
bin_SCRIPTS = xslt-config
|
||||
|
||||
dist-hook: cleanup
|
||||
touch $(distdir)/doc/*.xml
|
||||
touch $(distdir)/doc/EXSLT/*.xml
|
||||
touch $(distdir)/libxslt/*.syms
|
||||
(cd $(srcdir) ; tar -cf - win32 vms examples) | (cd $(distdir); tar xf -)
|
||||
|
||||
EXTRA_DIST = xsltConf.sh.in \
|
||||
FEATURES TODO Copyright \
|
||||
CMakeLists.txt config.h.cmake.in libxslt-config.cmake.in libxslt-config.cmake.cmake.in
|
||||
|
||||
## We create xsltConf.sh here and not from configure because we want
|
||||
## to get the paths expanded correctly. Macros like srcdir are given
|
||||
## the value NONE in configure if the user doesn't specify them (this
|
||||
## is an autoconf feature, not a bug).
|
||||
|
||||
xsltConf.sh: xsltConf.sh.in Makefile
|
||||
## Use sed and then mv to avoid problems if the user interrupts.
|
||||
sed -e 's?\@XSLT_LIBDIR\@?$(XSLT_LIBDIR)?g' \
|
||||
-e 's?\@XSLT_INCLUDEDIR\@?$(XSLT_INCLUDEDIR)?g' \
|
||||
-e 's?\@VERSION\@?$(VERSION)?g' \
|
||||
-e 's?\@XSLT_LIBS\@?$(XSLT_LIBS) $(EXTRA_LIBS)?g' \
|
||||
-e 's?\@XSLT_PRIVATE_LIBS\@?$(XSLT_PRIVATE_LIBS)?g' \
|
||||
< $(srcdir)/xsltConf.sh.in > xsltConf.tmp \
|
||||
&& mv xsltConf.tmp xsltConf.sh
|
||||
|
||||
CLEANFILES = xsltConf.sh
|
||||
|
||||
check-local: tests
|
||||
|
||||
dummy:
|
||||
|
||||
tests: dummy
|
||||
@echo '## Running the regression test suite'
|
||||
@(cd tests ; $(MAKE) -s tests)
|
||||
@(cd xsltproc ; $(MAKE) -s tests)
|
||||
if WITH_PYTHON
|
||||
@cd python && $(MAKE) tests
|
||||
endif
|
||||
|
||||
valgrind:
|
||||
@echo '## Running the regression tests under Valgrind'
|
||||
@echo '## Go get a cup of coffee it is gonna take a while ...'
|
||||
@(cd tests ; $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests)
|
||||
@(cd xsltproc ; $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests)
|
||||
|
||||
cleanup:
|
||||
-@(find . -name .\#\* -exec rm {} \;)
|
||||
|
||||
cleantar:
|
||||
@(rm -f libxslt*.tar.gz)
|
||||
|
||||
rpm: cleantar
|
||||
@(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
|
||||
|
||||
|
||||
pkgconfigdir=$(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libxslt.pc libexslt.pc
|
||||
|
||||
cmakedir = $(libdir)/cmake/libxslt
|
||||
dist_cmake_DATA = FindGcrypt.cmake
|
||||
cmake_DATA = libxslt-config.cmake
|
||||
|
||||
m4datadir = $(datadir)/aclocal
|
||||
dist_m4data_DATA = libxslt.m4
|
||||
|
||||
Vendored
-1454
File diff suppressed because it is too large
Load Diff
Vendored
+36
-4
@@ -9,7 +9,26 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "attributes.h"
|
||||
#include "namespaces.h"
|
||||
#include "templates.h"
|
||||
#include "imports.h"
|
||||
#include "transform.h"
|
||||
#include "preproc.h"
|
||||
|
||||
#define WITH_XSLT_DEBUG_ATTRIBUTES
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
@@ -68,6 +87,7 @@ typedef xsltAttrSetContext *xsltAttrSetContextPtr;
|
||||
struct _xsltAttrSetContext {
|
||||
xsltStylesheetPtr topStyle;
|
||||
xsltStylesheetPtr style;
|
||||
int error;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -255,7 +275,7 @@ xsltAddUseAttrSetList(xsltUseAttrSetPtr list, const xmlChar *ncname,
|
||||
* Returns the newly allocated xsltAttrSetPtr or NULL in case of error.
|
||||
*/
|
||||
static xsltAttrSetPtr
|
||||
xsltNewAttrSet() {
|
||||
xsltNewAttrSet(void) {
|
||||
xsltAttrSetPtr cur;
|
||||
|
||||
cur = (xsltAttrSetPtr) xmlMalloc(sizeof(xsltAttrSet));
|
||||
@@ -402,9 +422,12 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
set = xmlHashLookup2(style->attributeSets, ncname, nsUri);
|
||||
if (set == NULL) {
|
||||
set = xsltNewAttrSet();
|
||||
if (set == NULL)
|
||||
if ((set == NULL) ||
|
||||
(xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set) < 0)) {
|
||||
xsltGenericError(xsltGenericErrorContext, "memory error\n");
|
||||
xsltFreeAttrSet(set);
|
||||
return;
|
||||
xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -644,6 +667,12 @@ xsltResolveSASCallback(void *payload, void *data,
|
||||
xsltStylesheetPtr topStyle = asctx->topStyle;
|
||||
xsltStylesheetPtr style = asctx->style;
|
||||
|
||||
if (asctx->error) {
|
||||
if (style != topStyle)
|
||||
xsltFreeAttrSet(set);
|
||||
return;
|
||||
}
|
||||
|
||||
xsltResolveAttrSet(set, topStyle, style, name, ns, 1);
|
||||
|
||||
/* Move attribute sets to top stylesheet. */
|
||||
@@ -656,6 +685,8 @@ xsltResolveSASCallback(void *payload, void *data,
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"xsl:attribute-set : internal error, can't move imported "
|
||||
" attribute set %s\n", name);
|
||||
asctx->error = 1;
|
||||
xsltFreeAttrSet(set);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -676,6 +707,7 @@ xsltResolveStylesheetAttributeSet(xsltStylesheetPtr style) {
|
||||
"Resolving attribute sets references\n");
|
||||
#endif
|
||||
asctx.topStyle = style;
|
||||
asctx.error = 0;
|
||||
cur = style;
|
||||
while (cur != NULL) {
|
||||
if (cur->attributeSets != NULL) {
|
||||
|
||||
Vendored
+1
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include "xsltexports.h"
|
||||
#include "xsltInternals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
Vendored
+34
-13
@@ -13,7 +13,19 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltutils.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "templates.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_AVT
|
||||
@@ -142,12 +154,9 @@ xsltSetAttrVTsegment(xsltAttrVTPtr avt, void *val) {
|
||||
if (avt->nb_seg >= avt->max_seg) {
|
||||
size_t size = sizeof(xsltAttrVT) +
|
||||
(avt->max_seg + MAX_AVT_SEG) * sizeof(void *);
|
||||
xsltAttrVTPtr tmp = (xsltAttrVTPtr) xmlRealloc(avt, size);
|
||||
if (tmp == NULL) {
|
||||
xsltFreeAttrVT(avt);
|
||||
avt = (xsltAttrVTPtr) xmlRealloc(avt, size);
|
||||
if (avt == NULL)
|
||||
return NULL;
|
||||
}
|
||||
avt = tmp;
|
||||
memset(&avt->segments[avt->nb_seg], 0, MAX_AVT_SEG*sizeof(void *));
|
||||
avt->max_seg += MAX_AVT_SEG;
|
||||
}
|
||||
@@ -170,7 +179,8 @@ xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) {
|
||||
const xmlChar *cur;
|
||||
xmlChar *ret = NULL;
|
||||
xmlChar *expr = NULL;
|
||||
xsltAttrVTPtr avt;
|
||||
xmlXPathCompExprPtr comp = NULL;
|
||||
xsltAttrVTPtr avt, tmp;
|
||||
int i = 0, lastavt = 0;
|
||||
|
||||
if ((style == NULL) || (attr == NULL) || (attr->children == NULL))
|
||||
@@ -234,8 +244,9 @@ xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) {
|
||||
str = cur;
|
||||
if (avt->nb_seg == 0)
|
||||
avt->strstart = 1;
|
||||
if ((avt = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
|
||||
if ((tmp = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
|
||||
goto error;
|
||||
avt = tmp;
|
||||
ret = NULL;
|
||||
lastavt = 0;
|
||||
}
|
||||
@@ -268,8 +279,6 @@ xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) {
|
||||
XSLT_TODO
|
||||
goto error;
|
||||
} else {
|
||||
xmlXPathCompExprPtr comp;
|
||||
|
||||
comp = xsltXPathCompile(style, expr);
|
||||
if (comp == NULL) {
|
||||
xsltTransformError(NULL, style, attr->parent,
|
||||
@@ -281,14 +290,23 @@ xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) {
|
||||
if (avt->nb_seg == 0)
|
||||
avt->strstart = 0;
|
||||
if (lastavt == 1) {
|
||||
if ((avt = xsltSetAttrVTsegment(avt, NULL)) == NULL)
|
||||
if ((tmp = xsltSetAttrVTsegment(avt, NULL)) == NULL) {
|
||||
xsltTransformError(NULL, style, attr->parent,
|
||||
"out of memory\n");
|
||||
goto error;
|
||||
}
|
||||
avt = tmp;
|
||||
}
|
||||
if ((avt = xsltSetAttrVTsegment(avt, (void *) comp)) == NULL)
|
||||
if ((tmp = xsltSetAttrVTsegment(avt, (void *) comp)) == NULL) {
|
||||
xsltTransformError(NULL, style, attr->parent,
|
||||
"out of memory\n");
|
||||
goto error;
|
||||
}
|
||||
avt = tmp;
|
||||
lastavt = 1;
|
||||
xmlFree(expr);
|
||||
expr = NULL;
|
||||
comp = NULL;
|
||||
}
|
||||
cur++;
|
||||
str = cur;
|
||||
@@ -313,8 +331,9 @@ xsltCompileAttr(xsltStylesheetPtr style, xmlAttrPtr attr) {
|
||||
str = cur;
|
||||
if (avt->nb_seg == 0)
|
||||
avt->strstart = 1;
|
||||
if ((avt = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
|
||||
if ((tmp = xsltSetAttrVTsegment(avt, (void *) ret)) == NULL)
|
||||
goto error;
|
||||
avt = tmp;
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
@@ -338,6 +357,8 @@ error:
|
||||
xmlFree(ret);
|
||||
if (expr != NULL)
|
||||
xmlFree(expr);
|
||||
if (comp != NULL)
|
||||
xmlXPathFreeCompExpr(comp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <win32config.h>
|
||||
Vendored
+20
-4
@@ -6,7 +6,24 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "documents.h"
|
||||
#include "transform.h"
|
||||
#include "imports.h"
|
||||
#include "keys.h"
|
||||
#include "security.h"
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
@@ -71,8 +88,6 @@ xsltDocDefaultLoaderFunc(const xmlChar * URI, xmlDictPtr dict, int options,
|
||||
return(NULL);
|
||||
}
|
||||
inputPush(pctxt, inputStream);
|
||||
if (pctxt->directory == NULL)
|
||||
pctxt->directory = xmlParserGetDirectory((const char *) URI);
|
||||
|
||||
xmlParseDocument(pctxt);
|
||||
|
||||
@@ -382,6 +397,8 @@ xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
|
||||
return(NULL);
|
||||
|
||||
ret = xsltNewStyleDocument(style, doc);
|
||||
if (ret == NULL)
|
||||
xmlFreeDoc(doc);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -416,4 +433,3 @@ xsltFindDocument (xsltTransformContextPtr ctxt, xmlDocPtr doc) {
|
||||
return(ctxt->document);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+59
-32
@@ -9,14 +9,34 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#ifdef WITH_MODULES
|
||||
#include <libxml/xmlmodule.h>
|
||||
#endif
|
||||
#include <libxml/list.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include <libxml/threads.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltlocale.h"
|
||||
#include "xsltutils.h"
|
||||
#include "imports.h"
|
||||
#include "extensions.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stdlib.h> /* for _MAX_PATH */
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#endif
|
||||
@@ -395,6 +415,7 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
|
||||
module_filename, URI);
|
||||
#endif
|
||||
|
||||
#if LIBXML_VERSION < 21300
|
||||
if (1 != xmlCheckFilename(module_filename)) {
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG_EXTENSIONS
|
||||
@@ -405,6 +426,7 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
|
||||
xmlFree(ext_name);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* attempt to open the module */
|
||||
m = xmlModuleOpen(module_filename, 0);
|
||||
@@ -721,8 +743,11 @@ xsltStyleInitializeStylesheetModule(xsltStylesheetPtr style,
|
||||
* Store the user-data in the context of the given stylesheet.
|
||||
*/
|
||||
dataContainer = xsltNewExtData(module, userData);
|
||||
if (dataContainer == NULL)
|
||||
if (dataContainer == NULL) {
|
||||
if (module->styleShutdownFunc)
|
||||
module->styleShutdownFunc(style, URI, userData);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (xmlHashAddEntry(style->extInfos, URI,
|
||||
(void *) dataContainer) < 0)
|
||||
@@ -788,17 +813,13 @@ xsltStyleGetExtData(xsltStylesheetPtr style, const xmlChar * URI)
|
||||
* Old behaviour.
|
||||
*/
|
||||
tmpStyle = style;
|
||||
while (tmpStyle != NULL) {
|
||||
if (tmpStyle->extInfos != NULL) {
|
||||
dataContainer =
|
||||
(xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
|
||||
if (dataContainer != NULL) {
|
||||
return(dataContainer->extData);
|
||||
}
|
||||
}
|
||||
tmpStyle = xsltNextImport(tmpStyle);
|
||||
if (tmpStyle->extInfos != NULL) {
|
||||
dataContainer =
|
||||
(xsltExtDataPtr) xmlHashLookup(tmpStyle->extInfos, URI);
|
||||
if (dataContainer != NULL) {
|
||||
return(dataContainer->extData);
|
||||
}
|
||||
}
|
||||
tmpStyle = style;
|
||||
#endif
|
||||
|
||||
dataContainer =
|
||||
@@ -903,9 +924,8 @@ xsltGetExtData(xsltTransformContextPtr ctxt, const xmlChar * URI)
|
||||
return (NULL);
|
||||
|
||||
data = xsltNewExtData(module, extData);
|
||||
if (data == NULL)
|
||||
return (NULL);
|
||||
if (xmlHashAddEntry(ctxt->extInfos, URI, (void *) data) < 0) {
|
||||
if ((data == NULL) ||
|
||||
(xmlHashAddEntry(ctxt->extInfos, URI, (void *) data) < 0)) {
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"Failed to register module data: %s\n",
|
||||
URI);
|
||||
@@ -977,6 +997,8 @@ xsltInitCtxtExt(void *payload, void *data, const xmlChar * URI)
|
||||
}
|
||||
ctxtData = xsltNewExtData(module, extData);
|
||||
if (ctxtData == NULL) {
|
||||
if (module->shutdownFunc)
|
||||
module->shutdownFunc(ctxt->ctxt, URI, extData);
|
||||
ctxt->ret = -1;
|
||||
return;
|
||||
}
|
||||
@@ -984,6 +1006,9 @@ xsltInitCtxtExt(void *payload, void *data, const xmlChar * URI)
|
||||
if (ctxt->ctxt->extInfos == NULL)
|
||||
ctxt->ctxt->extInfos = xmlHashCreate(10);
|
||||
if (ctxt->ctxt->extInfos == NULL) {
|
||||
if (module->shutdownFunc)
|
||||
module->shutdownFunc(ctxt->ctxt, URI, extData);
|
||||
xsltFreeExtData(ctxtData);
|
||||
ctxt->ret = -1;
|
||||
return;
|
||||
}
|
||||
@@ -2326,32 +2351,34 @@ xsltDebugDumpExtensions(FILE * output)
|
||||
output = stdout;
|
||||
fprintf(output,
|
||||
"Registered XSLT Extensions\n--------------------------\n");
|
||||
if (!xsltFunctionsHash)
|
||||
xmlMutexLock(xsltExtMutex);
|
||||
if (!xsltFunctionsHash) {
|
||||
fprintf(output, "No registered extension functions\n");
|
||||
else {
|
||||
fprintf(output, "Registered Extension Functions:\n");
|
||||
xmlMutexLock(xsltExtMutex);
|
||||
} else {
|
||||
fprintf(output, "Registered extension functions:\n");
|
||||
xmlHashScanFull(xsltFunctionsHash, xsltDebugDumpExtensionsCallback,
|
||||
output);
|
||||
xmlMutexUnlock(xsltExtMutex);
|
||||
}
|
||||
if (!xsltElementsHash)
|
||||
fprintf(output, "\nNo registered extension elements\n");
|
||||
else {
|
||||
fprintf(output, "\nRegistered Extension Elements:\n");
|
||||
xmlMutexLock(xsltExtMutex);
|
||||
if (!xsltTopLevelsHash) {
|
||||
fprintf(output, "\nNo registered top-level extension elements\n");
|
||||
} else {
|
||||
fprintf(output, "\nRegistered top-level extension elements:\n");
|
||||
xmlHashScanFull(xsltTopLevelsHash, xsltDebugDumpExtensionsCallback,
|
||||
output);
|
||||
}
|
||||
if (!xsltElementsHash) {
|
||||
fprintf(output, "\nNo registered instruction extension elements\n");
|
||||
} else {
|
||||
fprintf(output, "\nRegistered instruction extension elements:\n");
|
||||
xmlHashScanFull(xsltElementsHash, xsltDebugDumpExtensionsCallback,
|
||||
output);
|
||||
xmlMutexUnlock(xsltExtMutex);
|
||||
}
|
||||
if (!xsltExtensionsHash)
|
||||
if (!xsltExtensionsHash) {
|
||||
fprintf(output, "\nNo registered extension modules\n");
|
||||
else {
|
||||
fprintf(output, "\nRegistered Extension Modules:\n");
|
||||
xmlMutexLock(xsltExtMutex);
|
||||
} else {
|
||||
fprintf(output, "\nRegistered extension modules:\n");
|
||||
xmlHashScanFull(xsltExtensionsHash, xsltDebugDumpExtModulesCallback,
|
||||
output);
|
||||
xmlMutexUnlock(xsltExtMutex);
|
||||
}
|
||||
|
||||
xmlMutexUnlock(xsltExtMutex);
|
||||
}
|
||||
|
||||
Vendored
+19
-1
@@ -10,7 +10,25 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "extensions.h"
|
||||
#include "variables.h"
|
||||
#include "transform.h"
|
||||
#include "extra.h"
|
||||
#include "preproc.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_EXTRA
|
||||
|
||||
Vendored
+182
-65
@@ -10,9 +10,30 @@
|
||||
* Bjorn Reese <[email protected]> for number formatting
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/xpointer.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "functions.h"
|
||||
#include "extensions.h"
|
||||
#include "numbersInternals.h"
|
||||
#include "keys.h"
|
||||
#include "documents.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_FUNCTION
|
||||
@@ -75,45 +96,25 @@ xsltXPathFunctionLookup (void *vctxt,
|
||||
************************************************************************/
|
||||
|
||||
static void
|
||||
xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
|
||||
xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt,
|
||||
const xmlChar* URI, const xmlChar *fragment)
|
||||
{
|
||||
xsltTransformContextPtr tctxt;
|
||||
xmlURIPtr uri;
|
||||
xmlChar *fragment;
|
||||
xsltDocumentPtr idoc; /* document info */
|
||||
xmlDocPtr doc;
|
||||
xmlXPathContextPtr xptrctxt = NULL;
|
||||
xmlXPathObjectPtr resObj = NULL;
|
||||
|
||||
(void) xptrctxt;
|
||||
|
||||
tctxt = xsltXPathGetTransformContext(ctxt);
|
||||
if (tctxt == NULL) {
|
||||
xsltTransformError(NULL, NULL, NULL,
|
||||
"document() : internal error tctxt == NULL\n");
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
return;
|
||||
goto out_fragment;
|
||||
}
|
||||
|
||||
uri = xmlParseURI((const char *) URI);
|
||||
if (uri == NULL) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"document() : failed to parse URI\n");
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* check for and remove fragment identifier
|
||||
*/
|
||||
fragment = (xmlChar *)uri->fragment;
|
||||
if (fragment != NULL) {
|
||||
xmlChar *newURI;
|
||||
uri->fragment = NULL;
|
||||
newURI = xmlSaveUri(uri);
|
||||
idoc = xsltLoadDocument(tctxt, newURI);
|
||||
xmlFree(newURI);
|
||||
} else
|
||||
idoc = xsltLoadDocument(tctxt, URI);
|
||||
xmlFreeURI(uri);
|
||||
idoc = xsltLoadDocument(tctxt, URI);
|
||||
|
||||
if (idoc == NULL) {
|
||||
if ((URI == NULL) ||
|
||||
@@ -126,12 +127,7 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
|
||||
*/
|
||||
doc = tctxt->style->doc;
|
||||
} else {
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
|
||||
if (fragment != NULL)
|
||||
xmlFree(fragment);
|
||||
|
||||
return;
|
||||
goto out_fragment;
|
||||
}
|
||||
} else
|
||||
doc = idoc->doc;
|
||||
@@ -143,7 +139,7 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
|
||||
|
||||
/* use XPointer of HTML location for fragment ID */
|
||||
#ifdef LIBXML_XPTR_ENABLED
|
||||
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
|
||||
xptrctxt = xmlXPathNewContext(doc);
|
||||
if (xptrctxt == NULL) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"document() : internal error xptrctxt == NULL\n");
|
||||
@@ -178,7 +174,6 @@ out_fragment:
|
||||
if (resObj == NULL)
|
||||
resObj = xmlXPathNewNodeSet(NULL);
|
||||
valuePush(ctxt, resObj);
|
||||
xmlFree(fragment);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +189,8 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
{
|
||||
xmlXPathObjectPtr obj, obj2 = NULL;
|
||||
xmlChar *base = NULL, *URI;
|
||||
|
||||
xmlChar *newURI = NULL;
|
||||
xmlChar *fragment = NULL;
|
||||
|
||||
if ((nargs < 1) || (nargs > 2)) {
|
||||
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
|
||||
@@ -221,14 +217,14 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
obj2 = valuePop(ctxt);
|
||||
}
|
||||
|
||||
if (ctxt->value->type == XPATH_NODESET) {
|
||||
if ((ctxt->value != NULL) && (ctxt->value->type == XPATH_NODESET)) {
|
||||
int i;
|
||||
xmlXPathObjectPtr newobj, ret;
|
||||
|
||||
obj = valuePop(ctxt);
|
||||
ret = xmlXPathNewNodeSet(NULL);
|
||||
|
||||
if ((obj != NULL) && obj->nodesetval) {
|
||||
if ((obj != NULL) && (obj->nodesetval != NULL) && (ret != NULL)) {
|
||||
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
|
||||
valuePush(ctxt,
|
||||
xmlXPathNewNodeSet(obj->nodesetval->nodeTab[i]));
|
||||
@@ -240,11 +236,15 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
xmlXPathNewNodeSet(obj->nodesetval->
|
||||
nodeTab[i]));
|
||||
}
|
||||
if (ctxt->error)
|
||||
break;
|
||||
xsltDocumentFunction(ctxt, 2);
|
||||
newobj = valuePop(ctxt);
|
||||
ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
|
||||
newobj->nodesetval);
|
||||
xmlXPathFreeObject(newobj);
|
||||
if (newobj != NULL) {
|
||||
ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
|
||||
newobj->nodesetval);
|
||||
xmlXPathFreeObject(newobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
* Make sure it's converted to a string
|
||||
*/
|
||||
xmlXPathStringFunction(ctxt, 1);
|
||||
if (ctxt->value->type != XPATH_STRING) {
|
||||
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
|
||||
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
|
||||
"document() : invalid arg expecting a string\n");
|
||||
ctxt->error = XPATH_INVALID_TYPE;
|
||||
@@ -272,7 +272,32 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
} else {
|
||||
xsltTransformContextPtr tctxt;
|
||||
xmlURIPtr uri;
|
||||
const xmlChar *url;
|
||||
|
||||
tctxt = xsltXPathGetTransformContext(ctxt);
|
||||
|
||||
url = obj->stringval;
|
||||
|
||||
uri = xmlParseURI((const char *) url);
|
||||
if (uri == NULL) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"document() : failed to parse URI '%s'\n", url);
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* check for and remove fragment identifier
|
||||
*/
|
||||
fragment = (xmlChar *)uri->fragment;
|
||||
if (fragment != NULL) {
|
||||
uri->fragment = NULL;
|
||||
newURI = xmlSaveUri(uri);
|
||||
url = newURI;
|
||||
}
|
||||
xmlFreeURI(uri);
|
||||
|
||||
if ((obj2 != NULL) && (obj2->nodesetval != NULL) &&
|
||||
(obj2->nodesetval->nodeNr > 0) &&
|
||||
IS_XSLT_REAL_NODE(obj2->nodesetval->nodeTab[0])) {
|
||||
@@ -293,7 +318,8 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
(xmlNodePtr) tctxt->style->doc);
|
||||
}
|
||||
}
|
||||
URI = xmlBuildURI(obj->stringval, base);
|
||||
|
||||
URI = xmlBuildURI(url, base);
|
||||
if (base != NULL)
|
||||
xmlFree(base);
|
||||
if (URI == NULL) {
|
||||
@@ -306,10 +332,14 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
}
|
||||
} else {
|
||||
xsltDocumentFunctionLoadDocument( ctxt, URI );
|
||||
xsltDocumentFunctionLoadDocument(ctxt, URI, fragment);
|
||||
xmlFree(URI);
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
xmlFree(newURI);
|
||||
xmlFree(fragment);
|
||||
xmlXPathFreeObject(obj);
|
||||
if (obj2 != NULL)
|
||||
xmlXPathFreeObject(obj2);
|
||||
@@ -358,6 +388,12 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
xmlXPathObjectPtr newobj, ret;
|
||||
|
||||
ret = xmlXPathNewNodeSet(NULL);
|
||||
if (ret == NULL) {
|
||||
ctxt->error = XPATH_MEMORY_ERROR;
|
||||
xmlXPathFreeObject(obj1);
|
||||
xmlXPathFreeObject(obj2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj2->nodesetval != NULL) {
|
||||
for (i = 0; i < obj2->nodesetval->nodeNr; i++) {
|
||||
@@ -367,8 +403,9 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
xmlXPathStringFunction(ctxt, 1);
|
||||
xsltKeyFunction(ctxt, 2);
|
||||
newobj = valuePop(ctxt);
|
||||
ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
|
||||
newobj->nodesetval);
|
||||
if (newobj != NULL)
|
||||
ret->nodesetval = xmlXPathNodeSetMerge(ret->nodesetval,
|
||||
newobj->nodesetval);
|
||||
xmlXPathFreeObject(newobj);
|
||||
}
|
||||
}
|
||||
@@ -425,13 +462,13 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
*/
|
||||
valuePush(ctxt, obj2);
|
||||
xmlXPathStringFunction(ctxt, 1);
|
||||
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
|
||||
obj2 = valuePop(ctxt);
|
||||
if ((obj2 == NULL) || (obj2->type != XPATH_STRING)) {
|
||||
xsltTransformError(tctxt, NULL, tctxt->inst,
|
||||
"key() : invalid arg expecting a string\n");
|
||||
ctxt->error = XPATH_INVALID_TYPE;
|
||||
goto error;
|
||||
}
|
||||
obj2 = valuePop(ctxt);
|
||||
value = obj2->stringval;
|
||||
|
||||
/*
|
||||
@@ -534,6 +571,10 @@ xsltUnparsedEntityURIFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
obj = valuePop(ctxt);
|
||||
if (obj->type != XPATH_STRING) {
|
||||
obj = xmlXPathConvertString(obj);
|
||||
if (obj == NULL) {
|
||||
xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
str = obj->stringval;
|
||||
@@ -626,7 +667,8 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
return;
|
||||
}
|
||||
|
||||
if (formatValues != NULL) {
|
||||
if ((ctxt->error == 0) &&
|
||||
(formatValues != NULL) && (formatObj != NULL) && (numberObj != NULL)) {
|
||||
if (xsltFormatNumberConversion(formatValues,
|
||||
formatObj->stringval,
|
||||
numberObj->floatval,
|
||||
@@ -651,11 +693,16 @@ xsltFormatNumberFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
*/
|
||||
void
|
||||
xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
static char base_address;
|
||||
xsltTransformContextPtr tctxt;
|
||||
xmlNodePtr cur = NULL;
|
||||
xmlXPathObjectPtr obj = NULL;
|
||||
long val;
|
||||
xmlChar str[30];
|
||||
char *str;
|
||||
const xmlChar *nsPrefix = NULL;
|
||||
void **psviPtr;
|
||||
unsigned long id;
|
||||
size_t size, nsPrefixSize = 0;
|
||||
|
||||
tctxt = xsltXPathGetTransformContext(ctxt);
|
||||
|
||||
if (nargs == 0) {
|
||||
cur = ctxt->context->node;
|
||||
@@ -665,16 +712,15 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
|
||||
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
|
||||
ctxt->error = XPATH_INVALID_TYPE;
|
||||
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"generate-id() : invalid arg expecting a node-set\n");
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
obj = valuePop(ctxt);
|
||||
nodelist = obj->nodesetval;
|
||||
if ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {
|
||||
xmlXPathFreeObject(obj);
|
||||
valuePush(ctxt, xmlXPathNewCString(""));
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
cur = nodelist->nodeTab[0];
|
||||
for (i = 1;i < nodelist->nodeNr;i++) {
|
||||
@@ -683,22 +729,93 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||
cur = nodelist->nodeTab[i];
|
||||
}
|
||||
} else {
|
||||
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"generate-id() : invalid number of args %d\n", nargs);
|
||||
ctxt->error = XPATH_INVALID_ARITY;
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (obj)
|
||||
xmlXPathFreeObject(obj);
|
||||
size = 30; /* for "id%lu" */
|
||||
|
||||
val = (long)((char *)cur - (char *)&base_address);
|
||||
if (val >= 0) {
|
||||
snprintf((char *)str, sizeof(str), "idp%ld", val);
|
||||
if (cur->type == XML_NAMESPACE_DECL) {
|
||||
xmlNsPtr ns = (xmlNsPtr) cur;
|
||||
|
||||
nsPrefix = ns->prefix;
|
||||
if (nsPrefix == NULL)
|
||||
nsPrefix = BAD_CAST "";
|
||||
nsPrefixSize = xmlStrlen(nsPrefix);
|
||||
/* For "ns" and hex-encoded string */
|
||||
size += nsPrefixSize * 2 + 2;
|
||||
|
||||
/* Parent is stored in 'next'. */
|
||||
cur = (xmlNodePtr) ns->next;
|
||||
}
|
||||
|
||||
psviPtr = xsltGetPSVIPtr(cur);
|
||||
if (psviPtr == NULL) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"generate-id(): invalid node type %d\n", cur->type);
|
||||
ctxt->error = XPATH_INVALID_TYPE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (xsltGetSourceNodeFlags(cur) & XSLT_SOURCE_NODE_HAS_ID) {
|
||||
id = (unsigned long) (size_t) *psviPtr;
|
||||
} else {
|
||||
snprintf((char *)str, sizeof(str), "idm%ld", -val);
|
||||
if (cur->type == XML_TEXT_NODE && cur->line == USHRT_MAX) {
|
||||
/* Text nodes store big line numbers in psvi. */
|
||||
cur->line = 0;
|
||||
} else if (*psviPtr != NULL) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"generate-id(): psvi already set\n");
|
||||
ctxt->error = XPATH_MEMORY_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (tctxt->currentId == ULONG_MAX) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"generate-id(): id overflow\n");
|
||||
ctxt->error = XPATH_MEMORY_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
id = ++tctxt->currentId;
|
||||
*psviPtr = (void *) (size_t) id;
|
||||
xsltSetSourceNodeFlags(tctxt, cur, XSLT_SOURCE_NODE_HAS_ID);
|
||||
}
|
||||
valuePush(ctxt, xmlXPathNewString(str));
|
||||
|
||||
str = xmlMalloc(size);
|
||||
if (str == NULL) {
|
||||
xsltTransformError(tctxt, NULL, NULL,
|
||||
"generate-id(): out of memory\n");
|
||||
ctxt->error = XPATH_MEMORY_ERROR;
|
||||
goto out;
|
||||
}
|
||||
if (nsPrefix == NULL) {
|
||||
snprintf(str, size, "id%lu", id);
|
||||
} else {
|
||||
size_t i, j;
|
||||
|
||||
snprintf(str, size, "id%luns", id);
|
||||
|
||||
/*
|
||||
* Only ASCII alphanumerics are allowed, so we hex-encode the prefix.
|
||||
*/
|
||||
j = strlen(str);
|
||||
for (i = 0; i < nsPrefixSize; i++) {
|
||||
int v;
|
||||
|
||||
v = nsPrefix[i] >> 4;
|
||||
str[j++] = v < 10 ? '0' + v : 'A' + (v - 10);
|
||||
v = nsPrefix[i] & 15;
|
||||
str[j++] = v < 10 ? '0' + v : 'A' + (v - 10);
|
||||
}
|
||||
str[j] = '\0';
|
||||
}
|
||||
valuePush(ctxt, xmlXPathWrapString(BAD_CAST str));
|
||||
|
||||
out:
|
||||
xmlXPathFreeObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+72
-27
@@ -9,7 +9,25 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/uri.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "preproc.h"
|
||||
#include "imports.h"
|
||||
#include "documents.h"
|
||||
#include "security.h"
|
||||
#include "pattern.h"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
@@ -35,6 +53,55 @@ static void xsltFixImportedCompSteps(xsltStylesheetPtr master,
|
||||
}
|
||||
}
|
||||
|
||||
#define XSLT_MAX_NESTING 40
|
||||
|
||||
static int
|
||||
xsltCheckCycle(xsltStylesheetPtr style, xmlNodePtr cur, const xmlChar *URI) {
|
||||
xsltStylesheetPtr ancestor;
|
||||
xsltDocumentPtr docptr;
|
||||
int depth;
|
||||
|
||||
/*
|
||||
* Check imported stylesheets.
|
||||
*/
|
||||
depth = 0;
|
||||
ancestor = style;
|
||||
while (ancestor != NULL) {
|
||||
if (++depth >= XSLT_MAX_NESTING) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
"maximum nesting depth exceeded: %s\n", URI);
|
||||
return(-1);
|
||||
}
|
||||
if (xmlStrEqual(ancestor->doc->URL, URI)) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
"recursion detected on imported URL %s\n", URI);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check included stylesheets.
|
||||
*/
|
||||
docptr = ancestor->includes;
|
||||
while (docptr != NULL) {
|
||||
if (++depth >= XSLT_MAX_NESTING) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
"maximum nesting depth exceeded: %s\n", URI);
|
||||
return(-1);
|
||||
}
|
||||
if (xmlStrEqual(docptr->doc->URL, URI)) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
"recursion detected on included URL %s\n", URI);
|
||||
return(-1);
|
||||
}
|
||||
docptr = docptr->includes;
|
||||
}
|
||||
|
||||
ancestor = ancestor->parent;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltParseStylesheetImport:
|
||||
* @style: the XSLT stylesheet
|
||||
@@ -73,17 +140,8 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
res = style;
|
||||
while (res != NULL) {
|
||||
if (res->doc == NULL)
|
||||
break;
|
||||
if (xmlStrEqual(res->doc->URL, URI)) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
"xsl:import : recursion detected on imported URL %s\n", URI);
|
||||
goto error;
|
||||
}
|
||||
res = res->parent;
|
||||
}
|
||||
if (xsltCheckCycle(style, cur, URI) < 0)
|
||||
goto error;
|
||||
|
||||
/*
|
||||
* Security framework check
|
||||
@@ -152,7 +210,6 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
xmlChar *URI = NULL;
|
||||
xsltStylesheetPtr result;
|
||||
xsltDocumentPtr include;
|
||||
xsltDocumentPtr docptr;
|
||||
int oldNopreproc;
|
||||
|
||||
if ((cur == NULL) || (style == NULL))
|
||||
@@ -173,19 +230,8 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* in order to detect recursion, we check all previously included
|
||||
* stylesheets.
|
||||
*/
|
||||
docptr = style->includes;
|
||||
while (docptr != NULL) {
|
||||
if (xmlStrEqual(docptr->doc->URL, URI)) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
"xsl:include : recursion detected on included URL %s\n", URI);
|
||||
goto error;
|
||||
}
|
||||
docptr = docptr->includes;
|
||||
}
|
||||
if (xsltCheckCycle(style, cur, URI) < 0)
|
||||
goto error;
|
||||
|
||||
include = xsltLoadStyleDocument(style, URI);
|
||||
if (include == NULL) {
|
||||
@@ -374,4 +420,3 @@ xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name,
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+26
-20
@@ -9,7 +9,25 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "imports.h"
|
||||
#include "templates.h"
|
||||
#include "keys.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_KEYS
|
||||
@@ -276,6 +294,8 @@ xsltAddKey(xsltStylesheetPtr style, const xmlChar *name,
|
||||
#endif
|
||||
|
||||
key = xsltNewKeyDef(name, nameURI);
|
||||
if (key == NULL)
|
||||
return(-1);
|
||||
key->match = xmlStrdup(match);
|
||||
key->use = xmlStrdup(use);
|
||||
key->inst = inst;
|
||||
@@ -809,31 +829,17 @@ fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
|
||||
keylist = xmlXPathNodeSetCreate(cur);
|
||||
if (keylist == NULL)
|
||||
goto error;
|
||||
xmlHashAddEntry(table->keys, str, keylist);
|
||||
if (xmlHashAddEntry(table->keys, str, keylist) < 0) {
|
||||
xmlXPathFreeNodeSet(keylist);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* TODO: How do we know if this function failed?
|
||||
*/
|
||||
xmlXPathNodeSetAdd(keylist, cur);
|
||||
}
|
||||
switch (cur->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
cur->psvi = keyDef;
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
((xmlAttrPtr) cur)->psvi = keyDef;
|
||||
break;
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
((xmlDocPtr) cur)->psvi = keyDef;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xsltSetSourceNodeFlags(ctxt, cur, XSLT_SOURCE_NODE_HAS_KEY);
|
||||
xmlFree(str);
|
||||
str = NULL;
|
||||
|
||||
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
.TH libxslt 3 "30 August 2001"
|
||||
.SH NAME
|
||||
libxslt \- library used to do XSL transformations on XML documents
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I libxslt
|
||||
library is used to do XSL transformations on XML documents that
|
||||
have been loaded into memory with functions from
|
||||
.I libxml.
|
||||
.LP
|
||||
.SH FILES
|
||||
.TP 2.2i
|
||||
.B /usr/lib/libxslt_1.0.0/libxslt.a
|
||||
static library
|
||||
.TP
|
||||
.B /usr/lib/libxslt_1.0.0/libxslt.so
|
||||
sharable library
|
||||
.TP
|
||||
.B /usr/package/libxslt_1.0.0/bin/xsltproc
|
||||
binary application to do XSL transformations on the command line
|
||||
.SH AUTHORS
|
||||
Daniel Veillard ([email protected]).
|
||||
If you download and install this package look at instructions on the
|
||||
Web site https://gitlab.gnome.org/GNOME/libxslt .
|
||||
Manual page by Heiko W. Rupp ([email protected])
|
||||
.SH SEE ALSO
|
||||
.IR libexslt (3),
|
||||
.IR libxml (3),
|
||||
.IR xsltproc (1),
|
||||
.IR xmllint (1)
|
||||
.\" end of manual page
|
||||
Vendored
+242
@@ -0,0 +1,242 @@
|
||||
@ cdecl xslDebugStatus()
|
||||
@ cdecl xsltAddKey()
|
||||
@ cdecl xsltAddStackElemList()
|
||||
@ cdecl xsltAddTemplate()
|
||||
@ cdecl xsltAllocateExtra()
|
||||
@ cdecl xsltAllocateExtraCtxt()
|
||||
@ cdecl xsltApplyAttributeSet()
|
||||
@ cdecl xsltApplyImports()
|
||||
@ cdecl xsltApplyOneTemplate()
|
||||
@ cdecl xsltApplyStripSpaces()
|
||||
@ cdecl xsltApplyStylesheet()
|
||||
@ cdecl xsltApplyStylesheetUser()
|
||||
@ cdecl xsltApplyTemplates()
|
||||
@ cdecl xsltAttrListTemplateProcess()
|
||||
@ cdecl xsltAttrTemplateProcess()
|
||||
@ cdecl xsltAttrTemplateValueProcess()
|
||||
@ cdecl xsltAttrTemplateValueProcessNode()
|
||||
@ cdecl xsltAttribute()
|
||||
@ cdecl xsltCallTemplate()
|
||||
@ cdecl xsltCheckExtPrefix()
|
||||
@ cdecl xsltCheckExtURI()
|
||||
@ cdecl xsltCheckRead()
|
||||
@ cdecl xsltCheckWrite()
|
||||
@ cdecl xsltChoose()
|
||||
@ cdecl xsltCleanupGlobals()
|
||||
@ cdecl xsltCleanupTemplates()
|
||||
@ cdecl xsltComment()
|
||||
@ cdecl xsltCompMatchClearCache()
|
||||
@ cdecl xsltCompileAttr()
|
||||
@ cdecl xsltCompilePattern()
|
||||
@ cdecl xsltComputeSortResult()
|
||||
@ cdecl xsltCopy()
|
||||
@ cdecl xsltCopyNamespace()
|
||||
@ cdecl xsltCopyNamespaceList()
|
||||
@ cdecl xsltCopyOf()
|
||||
@ cdecl xsltCopyTextString()
|
||||
@ cdecl xsltCreateRVT()
|
||||
@ cdecl xsltDebug()
|
||||
@ cdecl xsltDebugDumpExtensions()
|
||||
@ cdecl xsltDebugGetDefaultTrace()
|
||||
@ cdecl xsltDebugSetDefaultTrace()
|
||||
@ cdecl xsltDecimalFormatGetByName()
|
||||
@ cdecl xsltDecimalFormatGetByQName()
|
||||
@ cdecl xsltDefaultSortFunction()
|
||||
@ cdecl xsltDoSortFunction()
|
||||
@ cdecl xsltDocDefaultLoader()
|
||||
@ cdecl xsltDocumentComp()
|
||||
@ cdecl xsltDocumentElem()
|
||||
@ cdecl xsltDocumentFunction()
|
||||
@ cdecl xsltDocumentSortFunction()
|
||||
@ cdecl xsltElement()
|
||||
@ cdecl xsltElementAvailableFunction()
|
||||
@ cdecl xsltEngineVersion()
|
||||
@ cdecl xsltEvalAVT()
|
||||
@ cdecl xsltEvalAttrValueTemplate()
|
||||
@ cdecl xsltEvalGlobalVariables()
|
||||
@ cdecl xsltEvalOneUserParam()
|
||||
@ cdecl xsltEvalStaticAttrValueTemplate()
|
||||
@ cdecl xsltEvalTemplateString()
|
||||
@ cdecl xsltEvalUserParams()
|
||||
@ cdecl xsltEvalXPathPredicate()
|
||||
@ cdecl xsltEvalXPathString()
|
||||
@ cdecl xsltEvalXPathStringNs()
|
||||
@ cdecl xsltExtElementLookup()
|
||||
@ cdecl xsltExtMarker()
|
||||
@ cdecl xsltExtModuleElementLookup()
|
||||
@ cdecl xsltExtModuleElementPreComputeLookup()
|
||||
@ cdecl xsltExtModuleFunctionLookup()
|
||||
@ cdecl xsltExtModuleTopLevelLookup()
|
||||
@ cdecl xsltExtensionInstructionResultFinalize()
|
||||
@ cdecl xsltExtensionInstructionResultRegister()
|
||||
@ cdecl xsltFindDocument()
|
||||
@ cdecl xsltFindElemSpaceHandling()
|
||||
@ cdecl xsltFindTemplate()
|
||||
@ cdecl xsltFlagRVTs()
|
||||
@ cdecl xsltForEach()
|
||||
@ cdecl xsltFormatNumberConversion()
|
||||
@ cdecl xsltFormatNumberFunction()
|
||||
@ cdecl xsltFreeAVTList()
|
||||
@ cdecl xsltFreeAttributeSetsHashes()
|
||||
@ cdecl xsltFreeCompMatchList()
|
||||
@ cdecl xsltFreeCtxtExts()
|
||||
@ cdecl xsltFreeDocumentKeys()
|
||||
@ cdecl xsltFreeDocuments()
|
||||
@ cdecl xsltFreeExts()
|
||||
@ cdecl xsltFreeGlobalVariables()
|
||||
@ cdecl xsltFreeKeys()
|
||||
@ cdecl xsltFreeLocale()
|
||||
@ cdecl xsltFreeLocales()
|
||||
@ cdecl xsltFreeNamespaceAliasHashes()
|
||||
@ cdecl xsltFreeRVTs()
|
||||
@ cdecl xsltFreeSecurityPrefs()
|
||||
@ cdecl xsltFreeStackElemList()
|
||||
@ cdecl xsltFreeStyleDocuments()
|
||||
@ cdecl xsltFreeStylePreComps()
|
||||
@ cdecl xsltFreeStylesheet()
|
||||
@ cdecl xsltFreeTemplateHashes()
|
||||
@ cdecl xsltFreeTransformContext()
|
||||
@ cdecl xsltFunctionAvailableFunction()
|
||||
@ cdecl xsltFunctionNodeSet()
|
||||
@ cdecl xsltGenerateIdFunction()
|
||||
@ cdecl xsltGenericDebug()
|
||||
@ cdecl xsltGenericDebugContext()
|
||||
@ cdecl xsltGenericError()
|
||||
@ cdecl xsltGenericErrorContext()
|
||||
@ cdecl xsltGetCNsProp()
|
||||
@ cdecl xsltGetDebuggerStatus()
|
||||
@ cdecl xsltGetDefaultSecurityPrefs()
|
||||
@ cdecl xsltGetExtData()
|
||||
@ cdecl xsltGetExtInfo()
|
||||
@ cdecl xsltGetKey()
|
||||
@ cdecl xsltGetNamespace()
|
||||
@ cdecl xsltGetNsProp()
|
||||
@ cdecl xsltGetPlainNamespace()
|
||||
@ cdecl xsltGetQNameURI()
|
||||
@ cdecl xsltGetQNameURI2()
|
||||
@ cdecl xsltGetSecurityPrefs()
|
||||
@ cdecl xsltGetSpecialNamespace()
|
||||
@ cdecl xsltGetTemplate()
|
||||
@ cdecl xsltGetUTF8Char()
|
||||
@ cdecl xsltGetUTF8CharZ()
|
||||
@ cdecl xsltGetXIncludeDefault()
|
||||
@ cdecl xsltIf()
|
||||
@ cdecl xsltInit()
|
||||
@ cdecl xsltInitAllDocKeys()
|
||||
@ cdecl xsltInitCtxtExts()
|
||||
@ cdecl xsltInitCtxtKey()
|
||||
@ cdecl xsltInitCtxtKeys()
|
||||
@ cdecl xsltInitElemPreComp()
|
||||
@ cdecl xsltInitGlobals()
|
||||
@ cdecl xsltIsBlank()
|
||||
@ cdecl xsltKeyFunction()
|
||||
@ cdecl xsltLibxmlVersion()
|
||||
@ cdecl xsltLibxsltVersion()
|
||||
@ cdecl xsltLoadDocument()
|
||||
@ cdecl xsltLoadStyleDocument()
|
||||
@ cdecl xsltLoadStylesheetPI()
|
||||
@ cdecl xsltLocalVariablePop()
|
||||
@ cdecl xsltLocalVariablePush()
|
||||
@ cdecl xsltLocaleStrcmp()
|
||||
@ cdecl xsltMaxDepth()
|
||||
@ cdecl xsltMaxVars()
|
||||
@ cdecl xsltMessage()
|
||||
@ cdecl xsltNamespaceAlias()
|
||||
@ cdecl xsltNeedElemSpaceHandling()
|
||||
@ cdecl xsltNewDocument()
|
||||
@ cdecl xsltNewElemPreComp()
|
||||
@ cdecl xsltNewLocale()
|
||||
@ cdecl xsltNewSecurityPrefs()
|
||||
@ cdecl xsltNewStyleDocument()
|
||||
@ cdecl xsltNewStylesheet()
|
||||
@ cdecl xsltNewTransformContext()
|
||||
@ cdecl xsltNextImport()
|
||||
@ cdecl xsltNormalizeCompSteps()
|
||||
@ cdecl xsltNumber()
|
||||
@ cdecl xsltNumberFormat()
|
||||
@ cdecl xsltParseGlobalParam()
|
||||
@ cdecl xsltParseGlobalVariable()
|
||||
@ cdecl xsltParseStylesheetAttributeSet()
|
||||
@ cdecl xsltParseStylesheetCallerParam()
|
||||
@ cdecl xsltParseStylesheetDoc()
|
||||
@ cdecl xsltParseStylesheetFile()
|
||||
@ cdecl xsltParseStylesheetImport()
|
||||
@ cdecl xsltParseStylesheetImportedDoc()
|
||||
@ cdecl xsltParseStylesheetInclude()
|
||||
@ cdecl xsltParseStylesheetOutput()
|
||||
@ cdecl xsltParseStylesheetParam()
|
||||
@ cdecl xsltParseStylesheetProcess()
|
||||
@ cdecl xsltParseStylesheetUser()
|
||||
@ cdecl xsltParseStylesheetVariable()
|
||||
@ cdecl xsltParseTemplateContent()
|
||||
@ cdecl xsltPreComputeExtModuleElement()
|
||||
@ cdecl xsltPrintErrorContext()
|
||||
@ cdecl xsltProcessOneNode()
|
||||
@ cdecl xsltProcessingInstruction()
|
||||
@ cdecl xsltProfileStylesheet()
|
||||
@ cdecl xsltQuoteOneUserParam()
|
||||
@ cdecl xsltQuoteUserParams()
|
||||
@ cdecl xsltRegisterAllElement()
|
||||
@ cdecl xsltRegisterAllExtras()
|
||||
@ cdecl xsltRegisterAllFunctions()
|
||||
@ cdecl xsltRegisterExtElement()
|
||||
@ cdecl xsltRegisterExtFunction()
|
||||
@ cdecl xsltRegisterExtModule()
|
||||
@ cdecl xsltRegisterExtModuleElement()
|
||||
@ cdecl xsltRegisterExtModuleFull()
|
||||
@ cdecl xsltRegisterExtModuleFunction()
|
||||
@ cdecl xsltRegisterExtModuleTopLevel()
|
||||
@ cdecl xsltRegisterExtPrefix()
|
||||
@ cdecl xsltRegisterExtras()
|
||||
@ cdecl xsltRegisterLocalRVT()
|
||||
@ cdecl xsltRegisterPersistRVT()
|
||||
@ cdecl xsltRegisterTestModule()
|
||||
@ cdecl xsltRegisterTmpRVT()
|
||||
@ cdecl xsltReleaseRVT()
|
||||
@ cdecl xsltResolveStylesheetAttributeSet()
|
||||
@ cdecl xsltRunStylesheet()
|
||||
@ cdecl xsltRunStylesheetUser()
|
||||
@ cdecl xsltSaveResultTo()
|
||||
@ cdecl xsltSaveResultToFd()
|
||||
@ cdecl xsltSaveResultToFile()
|
||||
@ cdecl xsltSaveResultToFilename()
|
||||
@ cdecl xsltSaveResultToString()
|
||||
@ cdecl xsltSecurityAllow()
|
||||
@ cdecl xsltSecurityForbid()
|
||||
@ cdecl xsltSetCtxtLocaleHandlers()
|
||||
@ cdecl xsltSetCtxtParseOptions()
|
||||
@ cdecl xsltSetCtxtSecurityPrefs()
|
||||
@ cdecl xsltSetCtxtSortFunc()
|
||||
@ cdecl xsltSetDefaultSecurityPrefs()
|
||||
@ cdecl xsltSetGenericDebugFunc()
|
||||
@ cdecl xsltSetGenericErrorFunc()
|
||||
@ cdecl xsltSetLoaderFunc()
|
||||
@ cdecl xsltSetSecurityPrefs()
|
||||
@ cdecl xsltSetSortFunc()
|
||||
@ cdecl xsltSetTransformErrorFunc()
|
||||
@ cdecl xsltSetXIncludeDefault()
|
||||
@ cdecl xsltShutdownCtxtExts()
|
||||
@ cdecl xsltShutdownExts()
|
||||
@ cdecl xsltSort()
|
||||
@ cdecl xsltSplitQName()
|
||||
@ cdecl xsltStrxfrm()
|
||||
@ cdecl xsltStyleGetExtData()
|
||||
@ cdecl xsltStylePreCompute()
|
||||
@ cdecl xsltSystemPropertyFunction()
|
||||
@ cdecl xsltTemplateProcess()
|
||||
@ cdecl xsltTestCompMatchList()
|
||||
@ cdecl xsltText()
|
||||
@ cdecl xsltTransformError()
|
||||
@ cdecl xsltUninit()
|
||||
@ cdecl xsltUnparsedEntityURIFunction()
|
||||
@ cdecl xsltUnregisterExtModule()
|
||||
@ cdecl xsltUnregisterExtModuleElement()
|
||||
@ cdecl xsltUnregisterExtModuleFunction()
|
||||
@ cdecl xsltUnregisterExtModuleTopLevel()
|
||||
@ cdecl xsltValueOf()
|
||||
@ cdecl xsltVariableLookup()
|
||||
@ cdecl xsltXPathCompile()
|
||||
@ cdecl xsltXPathCompileFlags()
|
||||
@ cdecl xsltXPathFunctionLookup()
|
||||
@ cdecl xsltXPathGetTransformContext()
|
||||
@ cdecl xsltXPathVariableLookup()
|
||||
Vendored
+21
-1
@@ -9,7 +9,27 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifndef XSLT_NEED_TRIO
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <trio.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/uri.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "namespaces.h"
|
||||
#include "imports.h"
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
|
||||
Vendored
+75
-40
@@ -10,7 +10,24 @@
|
||||
* Bjorn Reese <[email protected]>
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include "xsltutils.h"
|
||||
#include "pattern.h"
|
||||
#include "templates.h"
|
||||
#include "transform.h"
|
||||
#include "numbersInternals.h"
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE (0 == 1)
|
||||
@@ -99,7 +116,7 @@ xsltIsLetterDigit(int val) {
|
||||
#define IS_DIGIT_ONE(x) xsltIsDigitZero((x)-1)
|
||||
|
||||
static int
|
||||
xsltIsDigitZero(unsigned int ch)
|
||||
xsltIsDigitZero(int ch)
|
||||
{
|
||||
/*
|
||||
* Reference: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
|
||||
@@ -166,7 +183,7 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
|
||||
i = -1;
|
||||
break;
|
||||
}
|
||||
*(--pointer) = (xmlChar)val;
|
||||
*(--pointer) = val;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
@@ -336,8 +353,7 @@ xsltNumberFormatTokenize(const xmlChar *format,
|
||||
* Insert initial non-alphanumeric token.
|
||||
* There is always such a token in the list, even if NULL
|
||||
*/
|
||||
while (!xsltIsLetterDigit(val = xmlStringCurrentChar(NULL, format+ix,
|
||||
&len))) {
|
||||
while (!xsltIsLetterDigit(val = xsltGetUTF8CharZ(format+ix, &len))) {
|
||||
if (format[ix] == 0) /* if end of format string */
|
||||
break; /* while */
|
||||
ix += len;
|
||||
@@ -360,19 +376,19 @@ xsltNumberFormatTokenize(const xmlChar *format,
|
||||
tokens->end = NULL;
|
||||
}
|
||||
|
||||
val = xmlStringCurrentChar(NULL, format+ix, &len);
|
||||
val = xsltGetUTF8CharZ(format+ix, &len);
|
||||
if (IS_DIGIT_ONE(val) ||
|
||||
IS_DIGIT_ZERO(val)) {
|
||||
tokens->tokens[tokens->nTokens].width = 1;
|
||||
while (IS_DIGIT_ZERO(val)) {
|
||||
tokens->tokens[tokens->nTokens].width++;
|
||||
ix += len;
|
||||
val = xmlStringCurrentChar(NULL, format+ix, &len);
|
||||
val = xsltGetUTF8CharZ(format+ix, &len);
|
||||
}
|
||||
if (IS_DIGIT_ONE(val)) {
|
||||
tokens->tokens[tokens->nTokens].token = val - 1;
|
||||
ix += len;
|
||||
val = xmlStringCurrentChar(NULL, format+ix, &len);
|
||||
val = xsltGetUTF8CharZ(format+ix, &len);
|
||||
} else {
|
||||
tokens->tokens[tokens->nTokens].token = '0';
|
||||
tokens->tokens[tokens->nTokens].width = 1;
|
||||
@@ -383,7 +399,7 @@ xsltNumberFormatTokenize(const xmlChar *format,
|
||||
(val == 'i') ) {
|
||||
tokens->tokens[tokens->nTokens].token = val;
|
||||
ix += len;
|
||||
val = xmlStringCurrentChar(NULL, format+ix, &len);
|
||||
val = xsltGetUTF8CharZ(format+ix, &len);
|
||||
} else {
|
||||
/* XSLT section 7.7
|
||||
* "Any other format token indicates a numbering sequence
|
||||
@@ -405,7 +421,7 @@ xsltNumberFormatTokenize(const xmlChar *format,
|
||||
*/
|
||||
while (xsltIsLetterDigit(val)) {
|
||||
ix += len;
|
||||
val = xmlStringCurrentChar(NULL, format+ix, &len);
|
||||
val = xsltGetUTF8CharZ(format+ix, &len);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -416,7 +432,7 @@ xsltNumberFormatTokenize(const xmlChar *format,
|
||||
if (val == 0)
|
||||
break; /* while */
|
||||
ix += len;
|
||||
val = xmlStringCurrentChar(NULL, format+ix, &len);
|
||||
val = xsltGetUTF8CharZ(format+ix, &len);
|
||||
}
|
||||
if (ix > j)
|
||||
tokens->end = xmlStrndup(&format[j], ix - j);
|
||||
@@ -948,6 +964,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
|
||||
xmlChar *the_format, *prefix = NULL, *suffix = NULL;
|
||||
xmlChar *nprefix, *nsuffix = NULL;
|
||||
int prefix_length, suffix_length = 0, nprefix_length, nsuffix_length;
|
||||
int exp10;
|
||||
double scale;
|
||||
int j, len = 0;
|
||||
int self_grouping_len;
|
||||
@@ -968,32 +985,12 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
|
||||
"Invalid format (0-length)\n");
|
||||
}
|
||||
*result = NULL;
|
||||
switch (xmlXPathIsInf(number)) {
|
||||
case -1:
|
||||
if (self->minusSign == NULL)
|
||||
*result = xmlStrdup(BAD_CAST "-");
|
||||
else
|
||||
*result = xmlStrdup(self->minusSign);
|
||||
/* Intentional fall-through */
|
||||
case 1:
|
||||
if ((self == NULL) || (self->infinity == NULL))
|
||||
*result = xmlStrcat(*result, BAD_CAST "Infinity");
|
||||
else
|
||||
*result = xmlStrcat(*result, self->infinity);
|
||||
return(status);
|
||||
default:
|
||||
if (xmlXPathIsNaN(number)) {
|
||||
if ((self == NULL) || (self->noNumber == NULL))
|
||||
*result = xmlStrdup(BAD_CAST "NaN");
|
||||
else
|
||||
*result = xmlStrdup(self->noNumber);
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
|
||||
buffer = xmlBufferCreate();
|
||||
if (buffer == NULL) {
|
||||
return XPATH_MEMORY_ERROR;
|
||||
if (xmlXPathIsNaN(number)) {
|
||||
if ((self == NULL) || (self->noNumber == NULL))
|
||||
*result = xmlStrdup(BAD_CAST "NaN");
|
||||
else
|
||||
*result = xmlStrdup(self->noNumber);
|
||||
return(status);
|
||||
}
|
||||
|
||||
format_info.integer_hash = 0;
|
||||
@@ -1266,6 +1263,30 @@ OUTPUT_NUMBER:
|
||||
format_info.add_decimal = TRUE;
|
||||
}
|
||||
|
||||
/* Apply multiplier */
|
||||
number *= (double)format_info.multiplier;
|
||||
switch (xmlXPathIsInf(number)) {
|
||||
case -1:
|
||||
if (self->minusSign == NULL)
|
||||
*result = xmlStrdup(BAD_CAST "-");
|
||||
else
|
||||
*result = xmlStrdup(self->minusSign);
|
||||
/* Intentional fall-through */
|
||||
case 1:
|
||||
if ((self == NULL) || (self->infinity == NULL))
|
||||
*result = xmlStrcat(*result, BAD_CAST "Infinity");
|
||||
else
|
||||
*result = xmlStrcat(*result, self->infinity);
|
||||
return(status);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
buffer = xmlBufferCreate();
|
||||
if (buffer == NULL) {
|
||||
return XPATH_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
/* Ready to output our number. First see if "default sign" is required */
|
||||
if (default_sign != 0)
|
||||
xmlBufferAdd(buffer, self->minusSign, xmlUTF8Strsize(self->minusSign, 1));
|
||||
@@ -1280,10 +1301,24 @@ OUTPUT_NUMBER:
|
||||
j += len;
|
||||
}
|
||||
|
||||
/* Round to n digits */
|
||||
number = fabs(number);
|
||||
exp10 = format_info.frac_digits + format_info.frac_hash;
|
||||
/* DBL_MAX_10_EXP should be 308 on IEEE platforms. */
|
||||
if (exp10 > DBL_MAX_10_EXP) {
|
||||
if (format_info.frac_digits > DBL_MAX_10_EXP) {
|
||||
format_info.frac_digits = DBL_MAX_10_EXP;
|
||||
format_info.frac_hash = 0;
|
||||
} else {
|
||||
format_info.frac_hash = DBL_MAX_10_EXP - format_info.frac_digits;
|
||||
}
|
||||
exp10 = DBL_MAX_10_EXP;
|
||||
}
|
||||
scale = pow(10.0, (double) exp10);
|
||||
number += .5 / scale;
|
||||
number -= fmod(number, 1 / scale);
|
||||
|
||||
/* Next do the integer part of the number */
|
||||
number = fabs(number) * (double)format_info.multiplier;
|
||||
scale = pow(10.0, (double)(format_info.frac_digits + format_info.frac_hash));
|
||||
number = floor((scale * number + 0.5)) / scale;
|
||||
if ((self->grouping != NULL) &&
|
||||
(self->grouping[0] != 0)) {
|
||||
int gchar;
|
||||
|
||||
Vendored
+49
-64
@@ -14,7 +14,26 @@
|
||||
* TODO: detect [number] at compilation, optimize accordingly
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "imports.h"
|
||||
#include "templates.h"
|
||||
#include "keys.h"
|
||||
#include "pattern.h"
|
||||
#include "documents.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_PATTERN
|
||||
@@ -292,10 +311,6 @@ xsltCompMatchAdd(xsltParserContextPtr ctxt, xsltCompMatchPtr comp,
|
||||
"xsltCompMatchAdd: memory re-allocation failure.\n");
|
||||
if (ctxt->style != NULL)
|
||||
ctxt->style->errors++;
|
||||
if (value)
|
||||
xmlFree(value);
|
||||
if (value2)
|
||||
xmlFree(value2);
|
||||
return (-1);
|
||||
}
|
||||
comp->maxStep *= 2;
|
||||
@@ -464,16 +479,12 @@ xsltReverseCompMatch(xsltParserContextPtr ctxt, xsltCompMatchPtr comp) {
|
||||
static int
|
||||
xsltPatPushState(xsltTransformContextPtr ctxt, xsltStepStates *states,
|
||||
int step, xmlNodePtr node) {
|
||||
if ((states->states == NULL) || (states->maxstates <= 0)) {
|
||||
states->maxstates = 4;
|
||||
states->nbstates = 0;
|
||||
states->states = xmlMalloc(4 * sizeof(xsltStepState));
|
||||
}
|
||||
else if (states->maxstates <= states->nbstates) {
|
||||
if (states->maxstates <= states->nbstates) {
|
||||
xsltStepState *tmp;
|
||||
int newMax = states->maxstates == 0 ? 4 : 2 * states->maxstates;
|
||||
|
||||
tmp = (xsltStepStatePtr) xmlRealloc(states->states,
|
||||
2 * states->maxstates * sizeof(xsltStepState));
|
||||
newMax * sizeof(xsltStepState));
|
||||
if (tmp == NULL) {
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"xsltPatPushState: memory re-allocation failure.\n");
|
||||
@@ -481,7 +492,7 @@ xsltPatPushState(xsltTransformContextPtr ctxt, xsltStepStates *states,
|
||||
return(-1);
|
||||
}
|
||||
states->states = tmp;
|
||||
states->maxstates *= 2;
|
||||
states->maxstates = newMax;
|
||||
}
|
||||
states->states[states->nbstates].step = step;
|
||||
states->states[states->nbstates++].node = node;
|
||||
@@ -1215,10 +1226,10 @@ xsltScanLiteral(xsltParserContextPtr ctxt) {
|
||||
if (CUR == '"') {
|
||||
NEXT;
|
||||
cur = q = CUR_PTR;
|
||||
val = xmlStringCurrentChar(NULL, cur, &len);
|
||||
val = xsltGetUTF8CharZ(cur, &len);
|
||||
while ((xmlIsCharQ(val)) && (val != '"')) {
|
||||
cur += len;
|
||||
val = xmlStringCurrentChar(NULL, cur, &len);
|
||||
val = xsltGetUTF8CharZ(cur, &len);
|
||||
}
|
||||
if (!xmlIsCharQ(val)) {
|
||||
ctxt->error = 1;
|
||||
@@ -1231,10 +1242,10 @@ xsltScanLiteral(xsltParserContextPtr ctxt) {
|
||||
} else if (CUR == '\'') {
|
||||
NEXT;
|
||||
cur = q = CUR_PTR;
|
||||
val = xmlStringCurrentChar(NULL, cur, &len);
|
||||
val = xsltGetUTF8CharZ(cur, &len);
|
||||
while ((xmlIsCharQ(val)) && (val != '\'')) {
|
||||
cur += len;
|
||||
val = xmlStringCurrentChar(NULL, cur, &len);
|
||||
val = xsltGetUTF8CharZ(cur, &len);
|
||||
}
|
||||
if (!xmlIsCharQ(val)) {
|
||||
ctxt->error = 1;
|
||||
@@ -1269,7 +1280,7 @@ xsltScanNCName(xsltParserContextPtr ctxt) {
|
||||
SKIP_BLANKS;
|
||||
|
||||
cur = q = CUR_PTR;
|
||||
val = xmlStringCurrentChar(NULL, cur, &len);
|
||||
val = xsltGetUTF8CharZ(cur, &len);
|
||||
if (!xmlIsBaseCharQ(val) && !xmlIsIdeographicQ(val) && (val != '_'))
|
||||
return(NULL);
|
||||
|
||||
@@ -1280,7 +1291,7 @@ xsltScanNCName(xsltParserContextPtr ctxt) {
|
||||
xmlIsCombiningQ(val) ||
|
||||
xmlIsExtenderQ(val)) {
|
||||
cur += len;
|
||||
val = xmlStringCurrentChar(NULL, cur, &len);
|
||||
val = xsltGetUTF8CharZ(cur, &len);
|
||||
}
|
||||
ret = xmlStrndup(q, cur - q);
|
||||
CUR_PTR = cur;
|
||||
@@ -1493,6 +1504,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token, int novar) {
|
||||
xmlChar *name = NULL;
|
||||
const xmlChar *URI = NULL;
|
||||
xmlChar *URL = NULL;
|
||||
xmlChar *ret = NULL;
|
||||
int level;
|
||||
xsltAxis axis = 0;
|
||||
|
||||
@@ -1569,7 +1581,6 @@ parse_node_test:
|
||||
xsltTransformError(NULL, NULL, NULL,
|
||||
"xsltCompileStepPattern : Name expected\n");
|
||||
ctxt->error = 1;
|
||||
xmlFree(URL);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
@@ -1632,7 +1643,6 @@ parse_predicate:
|
||||
level = 0;
|
||||
while (CUR == '[') {
|
||||
const xmlChar *q;
|
||||
xmlChar *ret = NULL;
|
||||
|
||||
level++;
|
||||
NEXT;
|
||||
@@ -1676,6 +1686,10 @@ error:
|
||||
xmlFree(token);
|
||||
if (name != NULL)
|
||||
xmlFree(name);
|
||||
if (URL != NULL)
|
||||
xmlFree(URL);
|
||||
if (ret != NULL)
|
||||
xmlFree(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2068,6 +2082,8 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
|
||||
if (pat == NULL)
|
||||
return(-1);
|
||||
while (pat) {
|
||||
int success = 0;
|
||||
|
||||
next = pat->next;
|
||||
pat->next = NULL;
|
||||
name = NULL;
|
||||
@@ -2139,17 +2155,15 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
|
||||
if (name != NULL) {
|
||||
if (style->templatesHash == NULL) {
|
||||
style->templatesHash = xmlHashCreate(1024);
|
||||
if (style->templatesHash == NULL) {
|
||||
xsltFreeCompMatch(pat);
|
||||
return(-1);
|
||||
}
|
||||
xmlHashAddEntry3(style->templatesHash, name, mode, modeURI, pat);
|
||||
success = (style->templatesHash != NULL) &&
|
||||
(xmlHashAddEntry3(style->templatesHash, name, mode,
|
||||
modeURI, pat) >= 0);
|
||||
} else {
|
||||
list = (xsltCompMatchPtr) xmlHashLookup3(style->templatesHash,
|
||||
name, mode, modeURI);
|
||||
if (list == NULL) {
|
||||
xmlHashAddEntry3(style->templatesHash, name,
|
||||
mode, modeURI, pat);
|
||||
success = (xmlHashAddEntry3(style->templatesHash, name,
|
||||
mode, modeURI, pat) >= 0);
|
||||
} else {
|
||||
/*
|
||||
* Note '<=' since one must choose among the matching
|
||||
@@ -2169,6 +2183,7 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
|
||||
pat->next = list->next;
|
||||
list->next = pat;
|
||||
}
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
} else if (top != NULL) {
|
||||
@@ -2188,10 +2203,13 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
|
||||
pat->next = list->next;
|
||||
list->next = pat;
|
||||
}
|
||||
} else {
|
||||
success = 1;
|
||||
}
|
||||
if (success == 0) {
|
||||
xsltTransformError(NULL, style, NULL,
|
||||
"xsltAddTemplate: invalid compiled pattern\n");
|
||||
xsltFreeCompMatch(pat);
|
||||
xsltFreeCompMatchList(next);
|
||||
return(-1);
|
||||
}
|
||||
#ifdef WITH_XSLT_DEBUG_PATTERN
|
||||
@@ -2264,7 +2282,6 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
const xmlChar *name = NULL;
|
||||
xsltCompMatchPtr list = NULL;
|
||||
float priority;
|
||||
int keyed = 0;
|
||||
|
||||
if ((ctxt == NULL) || (node == NULL))
|
||||
return(NULL);
|
||||
@@ -2342,37 +2359,25 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
list = curstyle->rootMatch;
|
||||
else
|
||||
list = curstyle->elemMatch;
|
||||
if (node->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE: {
|
||||
xmlAttrPtr attr;
|
||||
|
||||
list = curstyle->attrMatch;
|
||||
attr = (xmlAttrPtr) node;
|
||||
if (attr->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
}
|
||||
case XML_PI_NODE:
|
||||
list = curstyle->piMatch;
|
||||
if (node->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE: {
|
||||
xmlDocPtr doc;
|
||||
|
||||
list = curstyle->rootMatch;
|
||||
doc = (xmlDocPtr) node;
|
||||
if (doc->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
}
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
list = curstyle->textMatch;
|
||||
if (node->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_COMMENT_NODE:
|
||||
list = curstyle->commentMatch;
|
||||
if (node->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_ENTITY_REF_NODE:
|
||||
case XML_ENTITY_NODE:
|
||||
@@ -2442,7 +2447,7 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
}
|
||||
|
||||
keyed_match:
|
||||
if (keyed) {
|
||||
if (xsltGetSourceNodeFlags(node) & XSLT_SOURCE_NODE_HAS_KEY) {
|
||||
list = curstyle->keyMatch;
|
||||
while ((list != NULL) &&
|
||||
((ret == NULL) ||
|
||||
@@ -2470,27 +2475,7 @@ keyed_match:
|
||||
if (xsltComputeAllKeys(ctxt, node) == -1)
|
||||
goto error;
|
||||
|
||||
switch (node->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
if (node->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
if (((xmlAttrPtr) node)->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
case XML_PI_NODE:
|
||||
if (node->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
if (((xmlDocPtr) node)->psvi != NULL) keyed = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (keyed)
|
||||
if (xsltGetSourceNodeFlags(node) & XSLT_SOURCE_NODE_HAS_KEY)
|
||||
goto keyed_match;
|
||||
}
|
||||
if (ret != NULL)
|
||||
|
||||
Vendored
+25
-11
@@ -15,7 +15,31 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltutils.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "transform.h"
|
||||
#include "templates.h"
|
||||
#include "variables.h"
|
||||
#include "numbersInternals.h"
|
||||
#include "preproc.h"
|
||||
#include "extra.h"
|
||||
#include "imports.h"
|
||||
#include "extensions.h"
|
||||
#include "pattern.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_PREPROC
|
||||
@@ -368,8 +392,6 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
|
||||
break;
|
||||
case XSLT_FUNC_SORT: {
|
||||
xsltStyleItemSortPtr item = (xsltStyleItemSortPtr) comp;
|
||||
if (item->locale != (xsltLocale)0)
|
||||
xsltFreeLocale(item->locale);
|
||||
if (item->comp != NULL)
|
||||
xmlXPathFreeCompExpr(item->comp);
|
||||
}
|
||||
@@ -472,8 +494,6 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (comp->locale != (xsltLocale)0)
|
||||
xsltFreeLocale(comp->locale);
|
||||
if (comp->comp != NULL)
|
||||
xmlXPathFreeCompExpr(comp->comp);
|
||||
if (comp->numdata.countPat != NULL)
|
||||
@@ -719,12 +739,6 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
|
||||
comp->lang = xsltEvalStaticAttrValueTemplate(style, inst,
|
||||
(const xmlChar *)"lang",
|
||||
NULL, &comp->has_lang);
|
||||
if (comp->lang != NULL) {
|
||||
comp->locale = xsltNewLocale(comp->lang);
|
||||
}
|
||||
else {
|
||||
comp->locale = (xsltLocale)0;
|
||||
}
|
||||
|
||||
comp->select = xsltGetCNsProp(style, inst,(const xmlChar *)"select", XSLT_NAMESPACE);
|
||||
if (comp->select == NULL) {
|
||||
|
||||
Vendored
+31
-2
@@ -6,13 +6,20 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#ifndef INVALID_FILE_ATTRIBUTES
|
||||
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
||||
#endif
|
||||
@@ -29,6 +36,16 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/uri.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "extensions.h"
|
||||
#include "security.h"
|
||||
|
||||
|
||||
struct _xsltSecurityPrefs {
|
||||
xsltSecurityCheck readFile;
|
||||
xsltSecurityCheck createFile;
|
||||
@@ -405,6 +422,19 @@ xsltCheckRead(xsltSecurityPrefsPtr sec,
|
||||
xmlURIPtr uri;
|
||||
xsltSecurityCheck check;
|
||||
|
||||
if (xmlStrstr(URL, BAD_CAST "://") == NULL) {
|
||||
check = xsltGetSecurityPrefs(sec, XSLT_SECPREF_READ_FILE);
|
||||
if (check != NULL) {
|
||||
ret = check(sec, ctxt, (const char *) URL);
|
||||
if (ret == 0) {
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"Local file read for %s refused\n", URL);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
uri = xmlParseURI((const char *)URL);
|
||||
if (uri == NULL) {
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
@@ -446,4 +476,3 @@ xsltCheckRead(xsltSecurityPrefsPtr sec,
|
||||
xmlFreeURI(uri);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+21
-3
@@ -9,9 +9,27 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/globals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "variables.h"
|
||||
#include "functions.h"
|
||||
#include "templates.h"
|
||||
#include "transform.h"
|
||||
#include "namespaces.h"
|
||||
#include "attributes.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_TEMPLATES
|
||||
@@ -133,7 +151,7 @@ xsltEvalXPathStringNs(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp,
|
||||
if (res != NULL) {
|
||||
if (res->type != XPATH_STRING)
|
||||
res = xmlXPathConvertString(res);
|
||||
if (res->type == XPATH_STRING) {
|
||||
if ((res != NULL) && (res->type == XPATH_STRING)) {
|
||||
ret = res->stringval;
|
||||
res->stringval = NULL;
|
||||
} else {
|
||||
@@ -211,7 +229,7 @@ xsltEvalTemplateString(xsltTransformContextPtr ctxt,
|
||||
insert = xmlNewDocNode(ctxt->output, NULL,
|
||||
(const xmlChar *)"fake", NULL);
|
||||
if (insert == NULL) {
|
||||
xsltTransformError(ctxt, NULL, contextNode,
|
||||
xsltTransformError(ctxt, NULL, inst,
|
||||
"Failed to create temporary node\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
Vendored
+127
-41
@@ -16,9 +16,45 @@
|
||||
* [email protected]
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/debugXML.h>
|
||||
#include <libxml/uri.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "xsltlocale.h"
|
||||
#include "pattern.h"
|
||||
#include "transform.h"
|
||||
#include "variables.h"
|
||||
#include "numbersInternals.h"
|
||||
#include "namespaces.h"
|
||||
#include "attributes.h"
|
||||
#include "templates.h"
|
||||
#include "imports.h"
|
||||
#include "keys.h"
|
||||
#include "documents.h"
|
||||
#include "extensions.h"
|
||||
#include "extra.h"
|
||||
#include "preproc.h"
|
||||
#include "security.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_EXTRA
|
||||
@@ -84,26 +120,18 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
|
||||
static int
|
||||
templPush(xsltTransformContextPtr ctxt, xsltTemplatePtr value)
|
||||
{
|
||||
if (ctxt->templMax == 0) {
|
||||
ctxt->templMax = 4;
|
||||
ctxt->templTab =
|
||||
(xsltTemplatePtr *) xmlMalloc(ctxt->templMax *
|
||||
sizeof(ctxt->templTab[0]));
|
||||
if (ctxt->templTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
else if (ctxt->templNr >= ctxt->templMax) {
|
||||
ctxt->templMax *= 2;
|
||||
ctxt->templTab =
|
||||
(xsltTemplatePtr *) xmlRealloc(ctxt->templTab,
|
||||
ctxt->templMax *
|
||||
sizeof(ctxt->templTab[0]));
|
||||
if (ctxt->templTab == NULL) {
|
||||
if (ctxt->templNr >= ctxt->templMax) {
|
||||
xsltTemplatePtr *tmp;
|
||||
int newMax = ctxt->templMax == 0 ? 4 : ctxt->templMax * 2;
|
||||
|
||||
tmp = (xsltTemplatePtr *) xmlRealloc(ctxt->templTab,
|
||||
newMax * sizeof(*tmp));
|
||||
if (tmp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
|
||||
return (0);
|
||||
}
|
||||
ctxt->templTab = tmp;
|
||||
ctxt->templMax = newMax;
|
||||
}
|
||||
ctxt->templTab[ctxt->templNr] = value;
|
||||
ctxt->templ = value;
|
||||
@@ -457,7 +485,7 @@ void xsltDebugSetDefaultTrace(xsltDebugTraceCodes val) {
|
||||
*
|
||||
* Returns the current default debug tracing level mask
|
||||
*/
|
||||
xsltDebugTraceCodes xsltDebugGetDefaultTrace() {
|
||||
xsltDebugTraceCodes xsltDebugGetDefaultTrace(void) {
|
||||
return xsltDefaultTrace;
|
||||
}
|
||||
|
||||
@@ -671,6 +699,10 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
|
||||
cur->xinclude = xsltGetXIncludeDefault();
|
||||
cur->keyInitLevel = 0;
|
||||
|
||||
cur->newLocale = xsltNewLocale;
|
||||
cur->freeLocale = xsltFreeLocale;
|
||||
cur->genSortKey = xsltStrxfrm;
|
||||
|
||||
return(cur);
|
||||
|
||||
internal_err:
|
||||
@@ -681,7 +713,7 @@ internal_err:
|
||||
|
||||
/**
|
||||
* xsltFreeTransformContext:
|
||||
* @ctxt: an XSLT parser context
|
||||
* @ctxt: an XSLT transform context
|
||||
*
|
||||
* Free up the memory allocated by @ctxt
|
||||
*/
|
||||
@@ -1055,8 +1087,10 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
|
||||
if (xmlDictOwns(ctxt->dict, cur->content))
|
||||
copy->content = cur->content;
|
||||
else {
|
||||
if ((copy->content = xmlStrdup(cur->content)) == NULL)
|
||||
if ((copy->content = xmlStrdup(cur->content)) == NULL) {
|
||||
xmlFreeNode(copy);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ctxt->lasttext = NULL;
|
||||
@@ -1958,7 +1992,21 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
case XML_ELEMENT_NODE:
|
||||
ctxt->xpathCtxt->contextSize = nbchild;
|
||||
ctxt->xpathCtxt->proximityPosition = childno;
|
||||
|
||||
if (ctxt->depth >= ctxt->maxTemplateDepth) {
|
||||
xsltTransformError(ctxt, NULL, cur,
|
||||
"xsltDefaultProcessOneNode: Maximum template depth "
|
||||
"exceeded.\n"
|
||||
"You can adjust xsltMaxDepth (--maxdepth) in order to "
|
||||
"raise the maximum number of nested template calls and "
|
||||
"variables/params (currently set to %d).\n",
|
||||
ctxt->maxTemplateDepth);
|
||||
ctxt->state = XSLT_STATE_STOPPED;
|
||||
return;
|
||||
}
|
||||
ctxt->depth++;
|
||||
xsltProcessOneNode(ctxt, cur, params);
|
||||
ctxt->depth--;
|
||||
break;
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
template = xsltGetTemplate(ctxt, cur, NULL);
|
||||
@@ -2189,26 +2237,18 @@ xsltLocalVariablePush(xsltTransformContextPtr ctxt,
|
||||
xsltStackElemPtr variable,
|
||||
int level)
|
||||
{
|
||||
if (ctxt->varsMax == 0) {
|
||||
ctxt->varsMax = 10;
|
||||
ctxt->varsTab =
|
||||
(xsltStackElemPtr *) xmlMalloc(ctxt->varsMax *
|
||||
sizeof(ctxt->varsTab[0]));
|
||||
if (ctxt->varsTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (ctxt->varsNr >= ctxt->varsMax) {
|
||||
ctxt->varsMax *= 2;
|
||||
ctxt->varsTab =
|
||||
(xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
|
||||
ctxt->varsMax *
|
||||
sizeof(ctxt->varsTab[0]));
|
||||
if (ctxt->varsTab == NULL) {
|
||||
xsltStackElemPtr *tmp;
|
||||
int newMax = ctxt->varsMax == 0 ? 10 : 2 * ctxt->varsMax;
|
||||
|
||||
tmp = (xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
|
||||
newMax * sizeof(*tmp));
|
||||
if (tmp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
ctxt->varsTab = tmp;
|
||||
ctxt->varsMax = newMax;
|
||||
}
|
||||
ctxt->varsTab[ctxt->varsNr++] = variable;
|
||||
ctxt->vars = variable;
|
||||
@@ -2240,17 +2280,17 @@ xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
|
||||
do {
|
||||
tmp = cur;
|
||||
cur = (xmlDocPtr) cur->next;
|
||||
if (tmp->psvi == XSLT_RVT_LOCAL) {
|
||||
if (tmp->compression == XSLT_RVT_LOCAL) {
|
||||
xsltReleaseRVT(ctxt, tmp);
|
||||
} else if (tmp->psvi == XSLT_RVT_GLOBAL) {
|
||||
} else if (tmp->compression == XSLT_RVT_GLOBAL) {
|
||||
xsltRegisterPersistRVT(ctxt, tmp);
|
||||
} else if (tmp->psvi == XSLT_RVT_FUNC_RESULT) {
|
||||
} else if (tmp->compression == XSLT_RVT_FUNC_RESULT) {
|
||||
/*
|
||||
* This will either register the RVT again or move it to the
|
||||
* context variable.
|
||||
*/
|
||||
xsltRegisterLocalRVT(ctxt, tmp);
|
||||
tmp->psvi = XSLT_RVT_FUNC_RESULT;
|
||||
tmp->compression = XSLT_RVT_FUNC_RESULT;
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xsltReleaseLocalRVTs: Unexpected RVT flag %p\n",
|
||||
@@ -5711,6 +5751,49 @@ xsltCountKeys(xsltTransformContextPtr ctxt)
|
||||
return(ctxt->nbKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltCleanupSourceDoc:
|
||||
* @doc: Document
|
||||
*
|
||||
* Resets source node flags and ids stored in 'psvi' member.
|
||||
*/
|
||||
static void
|
||||
xsltCleanupSourceDoc(xmlDocPtr doc) {
|
||||
xmlNodePtr cur = (xmlNodePtr) doc;
|
||||
void **psviPtr;
|
||||
|
||||
while (1) {
|
||||
xsltClearSourceNodeFlags(cur, XSLT_SOURCE_NODE_MASK);
|
||||
psviPtr = xsltGetPSVIPtr(cur);
|
||||
if (psviPtr)
|
||||
*psviPtr = NULL;
|
||||
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
xmlAttrPtr prop = cur->properties;
|
||||
|
||||
while (prop) {
|
||||
prop->atype &= ~(XSLT_SOURCE_NODE_MASK << 27);
|
||||
prop->psvi = NULL;
|
||||
prop = prop->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur->children != NULL && cur->type != XML_ENTITY_REF_NODE) {
|
||||
cur = cur->children;
|
||||
} else {
|
||||
if (cur == (xmlNodePtr) doc)
|
||||
return;
|
||||
while (cur->next == NULL) {
|
||||
cur = cur->parent;
|
||||
if (cur == (xmlNodePtr) doc)
|
||||
return;
|
||||
}
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltApplyStylesheetInternal:
|
||||
* @style: a parsed XSLT stylesheet
|
||||
@@ -6109,6 +6192,9 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
|
||||
printf("# Reused variables : %d\n", ctxt->cache->dbgReusedVars);
|
||||
#endif
|
||||
|
||||
if (ctxt->sourceDocDirty)
|
||||
xsltCleanupSourceDoc(doc);
|
||||
|
||||
if ((ctxt != NULL) && (userCtxt == NULL))
|
||||
xsltFreeTransformContext(ctxt);
|
||||
|
||||
|
||||
Vendored
+80
-55
@@ -9,7 +9,28 @@
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/dict.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "variables.h"
|
||||
#include "transform.h"
|
||||
#include "imports.h"
|
||||
#include "preproc.h"
|
||||
#include "keys.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_VARIABLE
|
||||
@@ -102,7 +123,7 @@ xsltRegisterTmpRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
|
||||
return(-1);
|
||||
|
||||
RVT->prev = NULL;
|
||||
RVT->psvi = XSLT_RVT_LOCAL;
|
||||
RVT->compression = XSLT_RVT_LOCAL;
|
||||
|
||||
/*
|
||||
* We'll restrict the lifetime of user-created fragments
|
||||
@@ -142,7 +163,7 @@ xsltRegisterLocalRVT(xsltTransformContextPtr ctxt,
|
||||
return(-1);
|
||||
|
||||
RVT->prev = NULL;
|
||||
RVT->psvi = XSLT_RVT_LOCAL;
|
||||
RVT->compression = XSLT_RVT_LOCAL;
|
||||
|
||||
/*
|
||||
* When evaluating "select" expressions of xsl:variable
|
||||
@@ -234,7 +255,7 @@ xsltExtensionInstructionResultRegister(
|
||||
* Returns 0 in case of success and -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xsltFlagRVTs(xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj, void *val) {
|
||||
xsltFlagRVTs(xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj, int val) {
|
||||
int i;
|
||||
xmlNodePtr cur;
|
||||
xmlDocPtr doc;
|
||||
@@ -281,34 +302,36 @@ xsltFlagRVTs(xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj, void *val) {
|
||||
return(-1);
|
||||
}
|
||||
if (doc->name && (doc->name[0] == ' ') &&
|
||||
doc->psvi != XSLT_RVT_GLOBAL) {
|
||||
doc->compression != XSLT_RVT_GLOBAL) {
|
||||
/*
|
||||
* This is a result tree fragment.
|
||||
* We store ownership information in the @psvi field.
|
||||
* We store ownership information in the @compression field.
|
||||
* TODO: How do we know if this is a doc acquired via the
|
||||
* document() function?
|
||||
*/
|
||||
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
||||
XSLT_TRACE(ctxt,XSLT_TRACE_VARIABLES,xsltGenericDebug(xsltGenericDebugContext,
|
||||
"Flagging RVT %p: %p -> %p\n", doc, doc->psvi, val));
|
||||
XSLT_TRACE(ctxt, XSLT_TRACE_VARIABLES,
|
||||
xsltGenericDebug(xsltGenericDebugContext,
|
||||
"Flagging RVT %p: %d -> %d\n",
|
||||
(void *) doc, doc->compression, val));
|
||||
#endif
|
||||
|
||||
if (val == XSLT_RVT_LOCAL) {
|
||||
if (doc->psvi == XSLT_RVT_FUNC_RESULT)
|
||||
doc->psvi = XSLT_RVT_LOCAL;
|
||||
if (doc->compression == XSLT_RVT_FUNC_RESULT)
|
||||
doc->compression = XSLT_RVT_LOCAL;
|
||||
} else if (val == XSLT_RVT_GLOBAL) {
|
||||
if (doc->psvi != XSLT_RVT_LOCAL) {
|
||||
if (doc->compression != XSLT_RVT_LOCAL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xsltFlagRVTs: Invalid transition %p => GLOBAL\n",
|
||||
doc->psvi);
|
||||
doc->psvi = XSLT_RVT_GLOBAL;
|
||||
"xsltFlagRVTs: Invalid transition %d => GLOBAL\n",
|
||||
doc->compression);
|
||||
doc->compression = XSLT_RVT_GLOBAL;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Will be registered as persistant in xsltReleaseLocalRVTs. */
|
||||
doc->psvi = XSLT_RVT_GLOBAL;
|
||||
doc->compression = XSLT_RVT_GLOBAL;
|
||||
} else if (val == XSLT_RVT_FUNC_RESULT) {
|
||||
doc->psvi = val;
|
||||
doc->compression = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -356,7 +379,7 @@ xsltReleaseRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
|
||||
/*
|
||||
* Reset the ownership information.
|
||||
*/
|
||||
RVT->psvi = NULL;
|
||||
RVT->compression = 0;
|
||||
|
||||
RVT->next = (xmlNodePtr) ctxt->cache->RVT;
|
||||
ctxt->cache->RVT = RVT;
|
||||
@@ -395,7 +418,7 @@ xsltRegisterPersistRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
|
||||
{
|
||||
if ((ctxt == NULL) || (RVT == NULL)) return(-1);
|
||||
|
||||
RVT->psvi = XSLT_RVT_GLOBAL;
|
||||
RVT->compression = XSLT_RVT_GLOBAL;
|
||||
RVT->prev = NULL;
|
||||
RVT->next = (xmlNodePtr) ctxt->persistRVT;
|
||||
if (ctxt->persistRVT != NULL)
|
||||
@@ -554,15 +577,15 @@ xsltFreeStackElem(xsltStackElemPtr elem) {
|
||||
cur = elem->fragment;
|
||||
elem->fragment = (xmlDocPtr) cur->next;
|
||||
|
||||
if (cur->psvi == XSLT_RVT_LOCAL) {
|
||||
if (cur->compression == XSLT_RVT_LOCAL) {
|
||||
xsltReleaseRVT(elem->context, cur);
|
||||
} else if (cur->psvi == XSLT_RVT_FUNC_RESULT) {
|
||||
} else if (cur->compression == XSLT_RVT_FUNC_RESULT) {
|
||||
xsltRegisterLocalRVT(elem->context, cur);
|
||||
cur->psvi = XSLT_RVT_FUNC_RESULT;
|
||||
cur->compression = XSLT_RVT_FUNC_RESULT;
|
||||
} else {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xsltFreeStackElem: Unexpected RVT flag %p\n",
|
||||
cur->psvi);
|
||||
"xsltFreeStackElem: Unexpected RVT flag %d\n",
|
||||
cur->compression);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -734,26 +757,18 @@ xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
|
||||
return(-1);
|
||||
|
||||
do {
|
||||
if (ctxt->varsMax == 0) {
|
||||
ctxt->varsMax = 10;
|
||||
ctxt->varsTab =
|
||||
(xsltStackElemPtr *) xmlMalloc(ctxt->varsMax *
|
||||
sizeof(ctxt->varsTab[0]));
|
||||
if (ctxt->varsTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (ctxt->varsNr >= ctxt->varsMax) {
|
||||
ctxt->varsMax *= 2;
|
||||
ctxt->varsTab =
|
||||
(xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
|
||||
ctxt->varsMax *
|
||||
sizeof(ctxt->varsTab[0]));
|
||||
if (ctxt->varsTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
xsltStackElemPtr *tmp;
|
||||
int newMax = ctxt->varsMax == 0 ? 10 : 2 * ctxt->varsMax;
|
||||
|
||||
tmp = (xsltStackElemPtr *) xmlRealloc(ctxt->varsTab,
|
||||
newMax * sizeof(*tmp));
|
||||
if (tmp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
ctxt->varsTab = tmp;
|
||||
ctxt->varsMax = newMax;
|
||||
}
|
||||
ctxt->varsTab[ctxt->varsNr++] = elem;
|
||||
ctxt->vars = elem;
|
||||
@@ -965,7 +980,7 @@ xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable,
|
||||
* the Result Tree Fragment.
|
||||
*/
|
||||
variable->fragment = container;
|
||||
container->psvi = XSLT_RVT_LOCAL;
|
||||
container->compression = XSLT_RVT_LOCAL;
|
||||
|
||||
oldOutput = ctxt->output;
|
||||
oldInsert = ctxt->insert;
|
||||
@@ -995,10 +1010,10 @@ xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable,
|
||||
if (result == NULL) {
|
||||
result = xmlXPathNewCString("");
|
||||
} else {
|
||||
/*
|
||||
* Freeing is not handled there anymore.
|
||||
* QUESTION TODO: What does the above comment mean?
|
||||
*/
|
||||
/*
|
||||
* This stops older libxml2 versions from freeing the nodes
|
||||
* in the tree.
|
||||
*/
|
||||
result->boolval = 0;
|
||||
}
|
||||
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
||||
@@ -1217,7 +1232,11 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt)
|
||||
if (result == NULL) {
|
||||
result = xmlXPathNewCString("");
|
||||
} else {
|
||||
result->boolval = 0; /* Freeing is not handled there anymore */
|
||||
/*
|
||||
* This stops older libxml2 versions from freeing the nodes
|
||||
* in the tree.
|
||||
*/
|
||||
result->boolval = 0;
|
||||
}
|
||||
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
||||
#ifdef LIBXML_DEBUG_ENABLED
|
||||
@@ -1295,8 +1314,13 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
|
||||
if (def == NULL) {
|
||||
|
||||
def = xsltCopyStackElem(elem);
|
||||
xmlHashAddEntry2(ctxt->globalVars,
|
||||
elem->name, elem->nameURI, def);
|
||||
if (xmlHashAddEntry2(ctxt->globalVars,
|
||||
elem->name, elem->nameURI, def) < 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"hash update failed\n");
|
||||
xsltFreeStackElem(def);
|
||||
return(-1);
|
||||
}
|
||||
} else if ((elem->comp != NULL) &&
|
||||
(elem->comp->type == XSLT_FUNC_VARIABLE)) {
|
||||
/*
|
||||
@@ -1660,7 +1684,7 @@ xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
|
||||
|
||||
int
|
||||
xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
||||
int indx = 0;
|
||||
size_t indx = 0;
|
||||
const xmlChar *name;
|
||||
const xmlChar *value;
|
||||
|
||||
@@ -1690,7 +1714,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
||||
|
||||
int
|
||||
xsltQuoteUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
||||
int indx = 0;
|
||||
size_t indx = 0;
|
||||
const xmlChar *name;
|
||||
const xmlChar *value;
|
||||
|
||||
@@ -1854,7 +1878,10 @@ xsltRegisterVariable(xsltTransformContextPtr ctxt,
|
||||
#endif /* else of XSLT_REFACTORED */
|
||||
|
||||
variable = xsltBuildVariable(ctxt, (xsltStylePreCompPtr) comp, tree);
|
||||
xsltAddStackElem(ctxt, variable);
|
||||
if (xsltAddStackElem(ctxt, variable) < 0) {
|
||||
xsltFreeStackElem(variable);
|
||||
return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -2352,5 +2379,3 @@ local_variable_found:
|
||||
|
||||
return(valueObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -45,7 +45,7 @@ __inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
|
||||
#endif /* defined(_MSC_VER) && _MSC_VER < 1900 */
|
||||
|
||||
#define HAVE_SYS_STAT_H
|
||||
#define HAVE__STAT
|
||||
#define HAVE_STAT
|
||||
|
||||
#endif /* __LIBXSLT_WIN32_CONFIG__ */
|
||||
|
||||
|
||||
Vendored
+102
-60
@@ -13,7 +13,36 @@
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/valid.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/uri.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "pattern.h"
|
||||
#include "variables.h"
|
||||
#include "namespaces.h"
|
||||
#include "attributes.h"
|
||||
#include "xsltutils.h"
|
||||
#include "imports.h"
|
||||
#include "keys.h"
|
||||
#include "documents.h"
|
||||
#include "extensions.h"
|
||||
#include "preproc.h"
|
||||
#include "extra.h"
|
||||
#include "security.h"
|
||||
#include "xsltlocale.h"
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_PARSING
|
||||
@@ -62,13 +91,7 @@ const xmlChar *xsltXSLTAttrMarker = (const xmlChar *) "LRE XSLT Attr";
|
||||
#ifdef XSLT_LOCALE_WINAPI
|
||||
extern xmlRMutexPtr xsltLocaleMutex;
|
||||
#endif
|
||||
/*
|
||||
* Harmless but avoiding a problem when compiling against a
|
||||
* libxml <= 2.3.11 without LIBXML_DEBUG_ENABLED
|
||||
*/
|
||||
#ifndef LIBXML_DEBUG_ENABLED
|
||||
double xmlXPathStringEvalNumber(const xmlChar *str);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Useful macros
|
||||
*/
|
||||
@@ -128,31 +151,23 @@ exclPrefixPush(xsltStylesheetPtr style, xmlChar * value)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (style->exclPrefixMax == 0) {
|
||||
style->exclPrefixMax = 4;
|
||||
style->exclPrefixTab =
|
||||
(xmlChar * *)xmlMalloc(style->exclPrefixMax *
|
||||
sizeof(style->exclPrefixTab[0]));
|
||||
if (style->exclPrefixTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
/* do not push duplicates */
|
||||
for (i = 0;i < style->exclPrefixNr;i++) {
|
||||
if (xmlStrEqual(style->exclPrefixTab[i], value))
|
||||
return(-1);
|
||||
}
|
||||
if (style->exclPrefixNr >= style->exclPrefixMax) {
|
||||
style->exclPrefixMax *= 2;
|
||||
style->exclPrefixTab =
|
||||
(xmlChar * *)xmlRealloc(style->exclPrefixTab,
|
||||
style->exclPrefixMax *
|
||||
sizeof(style->exclPrefixTab[0]));
|
||||
if (style->exclPrefixTab == NULL) {
|
||||
xmlChar **tmp;
|
||||
size_t max = style->exclPrefixMax ? style->exclPrefixMax * 2 : 4;
|
||||
|
||||
tmp = xmlRealloc(style->exclPrefixTab,
|
||||
max * sizeof(style->exclPrefixTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
style->exclPrefixTab = tmp;
|
||||
style->exclPrefixMax = max;
|
||||
}
|
||||
style->exclPrefixTab[style->exclPrefixNr] = value;
|
||||
style->exclPrefix = value;
|
||||
@@ -1088,9 +1103,9 @@ xsltGetInheritedNsList(xsltStylesheetPtr style,
|
||||
xmlNodePtr node)
|
||||
{
|
||||
xmlNsPtr cur;
|
||||
xmlNsPtr *ret = NULL;
|
||||
xmlNsPtr *ret = NULL, *tmp;
|
||||
int nbns = 0;
|
||||
int maxns = 10;
|
||||
int maxns = 0;
|
||||
int i;
|
||||
|
||||
if ((style == NULL) || (template == NULL) || (node == NULL) ||
|
||||
@@ -1115,17 +1130,6 @@ xsltGetInheritedNsList(xsltStylesheetPtr style,
|
||||
if (xmlStrEqual(cur->href, style->exclPrefixTab[i]))
|
||||
goto skip_ns;
|
||||
}
|
||||
if (ret == NULL) {
|
||||
ret =
|
||||
(xmlNsPtr *) xmlMalloc((maxns + 1) *
|
||||
sizeof(xmlNsPtr));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xsltGetInheritedNsList : out of memory!\n");
|
||||
return(0);
|
||||
}
|
||||
ret[nbns] = NULL;
|
||||
}
|
||||
/*
|
||||
* Skip shadowed namespace bindings.
|
||||
*/
|
||||
@@ -1136,16 +1140,16 @@ xsltGetInheritedNsList(xsltStylesheetPtr style,
|
||||
}
|
||||
if (i >= nbns) {
|
||||
if (nbns >= maxns) {
|
||||
maxns *= 2;
|
||||
ret = (xmlNsPtr *) xmlRealloc(ret,
|
||||
(maxns +
|
||||
1) *
|
||||
sizeof(xmlNsPtr));
|
||||
if (ret == NULL) {
|
||||
maxns = (maxns == 0) ? 10 : 2 * maxns;
|
||||
tmp = (xmlNsPtr *) xmlRealloc(ret,
|
||||
(maxns + 1) * sizeof(xmlNsPtr));
|
||||
if (tmp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xsltGetInheritedNsList : realloc failed!\n");
|
||||
xmlFree(ret);
|
||||
return(0);
|
||||
}
|
||||
ret = tmp;
|
||||
}
|
||||
ret[nbns++] = cur;
|
||||
ret[nbns] = NULL;
|
||||
@@ -1301,8 +1305,10 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
|
||||
if (elements != NULL) {
|
||||
if (style->cdataSection == NULL)
|
||||
style->cdataSection = xmlHashCreate(10);
|
||||
if (style->cdataSection == NULL)
|
||||
if (style->cdataSection == NULL) {
|
||||
xmlFree(elements);
|
||||
return;
|
||||
}
|
||||
|
||||
element = elements;
|
||||
while (*element != 0) {
|
||||
@@ -1540,8 +1546,10 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
|
||||
if (style->stripSpaces == NULL)
|
||||
style->stripSpaces = xmlHashCreate(10);
|
||||
if (style->stripSpaces == NULL)
|
||||
if (style->stripSpaces == NULL) {
|
||||
xmlFree(elements);
|
||||
return;
|
||||
}
|
||||
|
||||
element = elements;
|
||||
while (*element != 0) {
|
||||
@@ -1669,6 +1677,11 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
|
||||
return;
|
||||
|
||||
if (style->stripSpaces == NULL)
|
||||
style->stripSpaces = xmlHashCreate(10);
|
||||
if (style->stripSpaces == NULL)
|
||||
return;
|
||||
|
||||
elements = xmlGetNsProp(cur, (const xmlChar *)"elements", NULL);
|
||||
if (elements == NULL) {
|
||||
xsltTransformError(NULL, style, cur,
|
||||
@@ -1677,11 +1690,6 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (style->stripSpaces == NULL)
|
||||
style->stripSpaces = xmlHashCreate(10);
|
||||
if (style->stripSpaces == NULL)
|
||||
return;
|
||||
|
||||
element = elements;
|
||||
while (*element != 0) {
|
||||
while (IS_BLANK(*element)) element++;
|
||||
@@ -4452,6 +4460,8 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
|
||||
* NOTE that this content model does *not* allow xsl:param.
|
||||
*/
|
||||
while (cur != NULL) {
|
||||
cctxt->style->principal->opCount += 1;
|
||||
|
||||
if (deleteNode != NULL) {
|
||||
#ifdef WITH_XSLT_DEBUG_BLANKS
|
||||
xsltGenericDebug(xsltGenericDebugContext,
|
||||
@@ -4492,7 +4502,11 @@ xsltParseSequenceConstructor(xsltCompilerCtxtPtr cctxt, xmlNodePtr cur)
|
||||
* Leave the contained text-node in the tree.
|
||||
*/
|
||||
xmlUnlinkNode(tmp);
|
||||
xmlAddPrevSibling(cur, tmp);
|
||||
if (xmlAddPrevSibling(cur, tmp) == NULL) {
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"out of memory\n");
|
||||
xmlFreeNode(tmp);
|
||||
}
|
||||
} else {
|
||||
tmp = NULL;
|
||||
xsltTransformError(NULL, cctxt->style, cur,
|
||||
@@ -4846,6 +4860,8 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
|
||||
* user-defined extension instruction if needed).
|
||||
*/
|
||||
do {
|
||||
style->principal->opCount += 1;
|
||||
|
||||
if ((child->type == XML_ELEMENT_NODE) &&
|
||||
IS_XSLT_ELEM_FAST(child) &&
|
||||
IS_XSLT_NAME(child, "param"))
|
||||
@@ -4889,6 +4905,8 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
|
||||
cur = templ->children;
|
||||
delete = NULL;
|
||||
while (cur != NULL) {
|
||||
style->principal->opCount += 1;
|
||||
|
||||
if (delete != NULL) {
|
||||
#ifdef WITH_XSLT_DEBUG_BLANKS
|
||||
xsltGenericDebug(xsltGenericDebugContext,
|
||||
@@ -4978,7 +4996,11 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ) {
|
||||
|
||||
next = text->next;
|
||||
xmlUnlinkNode(text);
|
||||
xmlAddPrevSibling(cur, text);
|
||||
if (xmlAddPrevSibling(cur, text) == NULL) {
|
||||
xsltTransformError(NULL, style, NULL,
|
||||
"out of memory\n");
|
||||
xmlFreeNode(text);
|
||||
}
|
||||
text = next;
|
||||
}
|
||||
}
|
||||
@@ -5358,6 +5380,15 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
|
||||
(template->type != XML_ELEMENT_NODE))
|
||||
return;
|
||||
|
||||
if (style->principal->opLimit > 0) {
|
||||
if (style->principal->opCount > style->principal->opLimit) {
|
||||
xsltTransformError(NULL, style, NULL,
|
||||
"XSLT parser operation limit exceeded\n");
|
||||
style->errors++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create and link the structure
|
||||
*/
|
||||
@@ -5497,9 +5528,6 @@ xsltCompileXSLTIncludeElem(xsltCompilerCtxtPtr cctxt, xmlNodePtr node) {
|
||||
return(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltParseFindTopLevelElem:
|
||||
*/
|
||||
static int
|
||||
xsltParseFindTopLevelElem(xsltCompilerCtxtPtr cctxt,
|
||||
xmlNodePtr cur,
|
||||
@@ -6085,6 +6113,15 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
|
||||
if ((top == NULL) || (top->type != XML_ELEMENT_NODE))
|
||||
return;
|
||||
|
||||
if (style->principal->opLimit > 0) {
|
||||
if (style->principal->opCount > style->principal->opLimit) {
|
||||
xsltTransformError(NULL, style, NULL,
|
||||
"XSLT parser operation limit exceeded\n");
|
||||
style->errors++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
prop = xmlGetNsProp(top, (const xmlChar *)"version", NULL);
|
||||
if (prop == NULL) {
|
||||
xsltTransformError(NULL, style, top,
|
||||
@@ -6108,6 +6145,8 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
|
||||
*/
|
||||
cur = top->children;
|
||||
while (cur != NULL) {
|
||||
style->principal->opCount += 1;
|
||||
|
||||
if (IS_BLANK_NODE(cur)) {
|
||||
cur = cur->next;
|
||||
continue;
|
||||
@@ -6124,6 +6163,8 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
|
||||
* process other top-level elements
|
||||
*/
|
||||
while (cur != NULL) {
|
||||
style->principal->opCount += 1;
|
||||
|
||||
if (IS_BLANK_NODE(cur)) {
|
||||
cur = cur->next;
|
||||
continue;
|
||||
@@ -6658,6 +6699,9 @@ xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc) {
|
||||
}
|
||||
#endif /* else of XSLT_REFACTORED */
|
||||
|
||||
if (style->parent == NULL)
|
||||
xsltResolveStylesheetAttributeSet(style);
|
||||
|
||||
if (style->errors != 0) {
|
||||
/*
|
||||
* Detach the doc from the stylesheet; otherwise the doc
|
||||
@@ -6672,15 +6716,12 @@ xsltParseStylesheetUser(xsltStylesheetPtr style, xmlDocPtr doc) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if (style->parent == NULL)
|
||||
xsltResolveStylesheetAttributeSet(style);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltParseStylesheetDoc:
|
||||
* @doc: and xmlDoc parsed XML
|
||||
* @doc: an xmlDoc parsed XML
|
||||
*
|
||||
* parse an XSLT stylesheet, building the associated structures. doc
|
||||
* is kept as a reference within the returned stylesheet, so changes
|
||||
@@ -6815,7 +6856,8 @@ xsltParseStylesheetPI(const xmlChar *value) {
|
||||
if (val == NULL)
|
||||
return(NULL);
|
||||
if ((xmlStrcasecmp(val, BAD_CAST "text/xml")) &&
|
||||
(xmlStrcasecmp(val, BAD_CAST "text/xsl"))) {
|
||||
(xmlStrcasecmp(val, BAD_CAST "text/xsl")) &&
|
||||
(xmlStrcasecmp(val, BAD_CAST "application/xslt+xml"))) {
|
||||
xmlFree(val);
|
||||
break;
|
||||
}
|
||||
|
||||
Vendored
-179
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
* Summary: compile-time version information for the XSLT engine
|
||||
* Description: compile-time version information for the XSLT engine
|
||||
* this module is autogenerated.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XSLTCONFIG_H__
|
||||
#define __XML_XSLTCONFIG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LIBXSLT_DOTTED_VERSION:
|
||||
*
|
||||
* the version string like "1.2.3"
|
||||
*/
|
||||
#define LIBXSLT_DOTTED_VERSION "@VERSION@"
|
||||
|
||||
/**
|
||||
* LIBXSLT_VERSION:
|
||||
*
|
||||
* the version number: 1.2.3 value is 10203
|
||||
*/
|
||||
#define LIBXSLT_VERSION @LIBXSLT_VERSION_NUMBER@
|
||||
|
||||
/**
|
||||
* LIBXSLT_VERSION_STRING:
|
||||
*
|
||||
* the version number string, 1.2.3 value is "10203"
|
||||
*/
|
||||
#define LIBXSLT_VERSION_STRING "@LIBXSLT_VERSION_NUMBER@"
|
||||
|
||||
/**
|
||||
* LIBXSLT_VERSION_EXTRA:
|
||||
*
|
||||
* extra version information, used to show a Git commit description
|
||||
*/
|
||||
#define LIBXSLT_VERSION_EXTRA "@LIBXSLT_VERSION_EXTRA@"
|
||||
|
||||
/**
|
||||
* WITH_XSLT_DEBUG:
|
||||
*
|
||||
* Activate the compilation of the debug reporting. Speed penalty
|
||||
* is insignifiant and being able to run xsltpoc -v is useful. On
|
||||
* by default unless --without-debug is passed to configure
|
||||
*/
|
||||
#if @WITH_XSLT_DEBUG@
|
||||
#define WITH_XSLT_DEBUG
|
||||
#endif
|
||||
|
||||
#if @WITH_MEM_DEBUG@
|
||||
/**
|
||||
* DEBUG_MEMORY:
|
||||
*
|
||||
* should be activated only when debugging libxslt. It replaces the
|
||||
* allocator with a collect and debug shell to the libc allocator.
|
||||
* Use configure --with-mem-debug to activate it on both library
|
||||
*/
|
||||
#define DEBUG_MEMORY
|
||||
|
||||
/**
|
||||
* DEBUG_MEMORY_LOCATION:
|
||||
*
|
||||
* should be activated only when debugging libxslt.
|
||||
* DEBUG_MEMORY_LOCATION should be activated only when libxml has
|
||||
* been configured with --with-debug-mem too
|
||||
*/
|
||||
#define DEBUG_MEMORY_LOCATION
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XSLT_NEED_TRIO:
|
||||
*
|
||||
* should be activated if the existing libc library lacks some of the
|
||||
* string formatting function, in that case reuse the Trio ones already
|
||||
* compiled in the libxml2 library.
|
||||
*/
|
||||
|
||||
#if @WITH_TRIO@
|
||||
#define XSLT_NEED_TRIO
|
||||
#endif
|
||||
#ifdef __VMS
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#ifndef XSLT_NEED_TRIO
|
||||
#define XSLT_NEED_TRIO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XSLT_NEED_TRIO
|
||||
#define TRIO_REPLACE_STDIO
|
||||
#endif
|
||||
|
||||
/**
|
||||
* WITH_XSLT_DEBUGGER:
|
||||
*
|
||||
* Activate the compilation of the debugger support. Speed penalty
|
||||
* is insignifiant.
|
||||
* On by default unless --without-debugger is passed to configure
|
||||
*/
|
||||
#if @WITH_DEBUGGER@
|
||||
#ifndef WITH_DEBUGGER
|
||||
#define WITH_DEBUGGER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* WITH_PROFILER:
|
||||
*
|
||||
* Activate the compilation of the profiler. Speed penalty
|
||||
* is insignifiant.
|
||||
* On by default unless --without-profiler is passed to configure
|
||||
*/
|
||||
#if @WITH_PROFILER@
|
||||
#ifndef WITH_PROFILER
|
||||
#define WITH_PROFILER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* WITH_MODULES:
|
||||
*
|
||||
* Whether module support is configured into libxslt
|
||||
* Note: no default module path for win32 platforms
|
||||
*/
|
||||
#if @WITH_MODULES@
|
||||
#ifndef WITH_MODULES
|
||||
#define WITH_MODULES
|
||||
#endif
|
||||
#define LIBXSLT_DEFAULT_PLUGINS_PATH() "@LIBXSLT_DEFAULT_PLUGINS_PATH@"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ATTRIBUTE_UNUSED:
|
||||
*
|
||||
* This macro is used to flag unused function parameters to GCC
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||
#endif
|
||||
#else
|
||||
#define ATTRIBUTE_UNUSED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LIBXSLT_ATTR_FORMAT:
|
||||
*
|
||||
* This macro is used to indicate to GCC the parameters are printf-like
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define LIBXSLT_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
|
||||
#else
|
||||
#define LIBXSLT_ATTR_FORMAT(fmt,args)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LIBXSLT_PUBLIC:
|
||||
*
|
||||
* This macro is used to declare PUBLIC variables for Cygwin and for MSC on Windows
|
||||
*/
|
||||
#if !defined LIBXSLT_PUBLIC
|
||||
#if (defined(__CYGWIN__) || defined _MSC_VER) && !defined IN_LIBXSLT && !defined LIBXSLT_STATIC
|
||||
#define LIBXSLT_PUBLIC __declspec(dllimport)
|
||||
#else
|
||||
#define LIBXSLT_PUBLIC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLTCONFIG_H__ */
|
||||
Vendored
+114
-70
@@ -10,9 +10,39 @@
|
||||
* winapi port: Roumen Petrov
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/threads.h>
|
||||
|
||||
#include "xsltlocale.h"
|
||||
#include "xsltutils.h"
|
||||
|
||||
#ifdef HAVE_STRXFRM_L
|
||||
|
||||
#define XSLT_LOCALE_POSIX
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#ifdef HAVE_XLOCALE_H
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#define XSLT_LOCALE_WINAPI
|
||||
|
||||
#include <windows.h>
|
||||
#include <winnls.h>
|
||||
|
||||
#else
|
||||
|
||||
#define XSLT_LOCALE_NONE
|
||||
|
||||
#endif
|
||||
|
||||
#define TOUPPER(c) (c & ~0x20)
|
||||
#define TOLOWER(c) (c | 0x20)
|
||||
@@ -32,8 +62,7 @@ xmlRMutexPtr xsltLocaleMutex = NULL;
|
||||
struct xsltRFC1766Info_s {
|
||||
/*note typedef unsigned char xmlChar !*/
|
||||
xmlChar tag[XSLTMAX_LANGTAGLEN+1];
|
||||
/*note typedef LCID xsltLocale !*/
|
||||
xsltLocale lcid;
|
||||
LCID lcid;
|
||||
};
|
||||
typedef struct xsltRFC1766Info_s xsltRFC1766Info;
|
||||
|
||||
@@ -41,14 +70,15 @@ static int xsltLocaleListSize = 0;
|
||||
static xsltRFC1766Info *xsltLocaleList = NULL;
|
||||
|
||||
|
||||
static xsltLocale
|
||||
static void *
|
||||
xslt_locale_WINAPI(const xmlChar *languageTag) {
|
||||
int k;
|
||||
xsltRFC1766Info *p = xsltLocaleList;
|
||||
|
||||
for (k=0; k<xsltLocaleListSize; k++, p++)
|
||||
if (xmlStrcmp(p->tag, languageTag) == 0) return p->lcid;
|
||||
return((xsltLocale)0);
|
||||
if (xmlStrcmp(p->tag, languageTag) == 0)
|
||||
return(&p->lcid);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
static void xsltEnumSupportedLocales(void);
|
||||
@@ -78,17 +108,17 @@ xsltFreeLocales(void) {
|
||||
*
|
||||
* Returns the locale or NULL on error or if no matching locale was found
|
||||
*/
|
||||
xsltLocale
|
||||
xsltNewLocale(const xmlChar *languageTag) {
|
||||
void *
|
||||
xsltNewLocale(const xmlChar *languageTag, int lowerFirst ATTRIBUTE_UNUSED) {
|
||||
#ifdef XSLT_LOCALE_POSIX
|
||||
xsltLocale locale;
|
||||
char localeName[XSLTMAX_LANGTAGLEN+6]; /* 6 chars for ".utf8\0" */
|
||||
locale_t locale;
|
||||
char localeName[XSLTMAX_LANGTAGLEN+7]; /* 7 chars for ".UTF-8\0" */
|
||||
const xmlChar *p = languageTag;
|
||||
const char *region = NULL;
|
||||
char *q = localeName;
|
||||
int i, llen;
|
||||
|
||||
/* Convert something like "pt-br" to "pt_BR.utf8" */
|
||||
/* Convert something like "pt-br" to "pt_BR.UTF-8" */
|
||||
|
||||
if (languageTag == NULL)
|
||||
return(NULL);
|
||||
@@ -112,8 +142,8 @@ xsltNewLocale(const xmlChar *languageTag) {
|
||||
if (i == 0 || *p)
|
||||
return(NULL);
|
||||
|
||||
memcpy(q, ".utf8", 6);
|
||||
locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
|
||||
memcpy(q, ".UTF-8", 7);
|
||||
locale = newlocale(LC_ALL_MASK, localeName, NULL);
|
||||
if (locale != NULL)
|
||||
return(locale);
|
||||
|
||||
@@ -124,8 +154,8 @@ xsltNewLocale(const xmlChar *languageTag) {
|
||||
|
||||
/* Try locale without territory, e.g. for Esperanto (eo) */
|
||||
|
||||
memcpy(q, ".utf8", 6);
|
||||
locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
|
||||
memcpy(q, ".UTF-8", 7);
|
||||
locale = newlocale(LC_ALL_MASK, localeName, NULL);
|
||||
if (locale != NULL)
|
||||
return(locale);
|
||||
|
||||
@@ -142,15 +172,15 @@ xsltNewLocale(const xmlChar *languageTag) {
|
||||
*q++ = '_';
|
||||
*q++ = region[0];
|
||||
*q++ = region[1];
|
||||
memcpy(q, ".utf8", 6);
|
||||
locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
|
||||
memcpy(q, ".UTF-8", 7);
|
||||
locale = newlocale(LC_ALL_MASK, localeName, NULL);
|
||||
|
||||
return(locale);
|
||||
#endif
|
||||
|
||||
#ifdef XSLT_LOCALE_WINAPI
|
||||
{
|
||||
xsltLocale locale = (xsltLocale)0;
|
||||
void *locale = NULL;
|
||||
xmlChar localeName[XSLTMAX_LANGTAGLEN+1];
|
||||
xmlChar *q = localeName;
|
||||
const xmlChar *p = languageTag;
|
||||
@@ -339,10 +369,12 @@ xsltDefaultRegion(const xmlChar *localeName) {
|
||||
* Frees a locale created with xsltNewLocale
|
||||
*/
|
||||
void
|
||||
xsltFreeLocale(xsltLocale locale) {
|
||||
xsltFreeLocale(void *locale) {
|
||||
#ifdef XSLT_LOCALE_POSIX
|
||||
if (locale != NULL)
|
||||
freelocale(locale);
|
||||
#else
|
||||
(void) locale;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -351,57 +383,82 @@ xsltFreeLocale(xsltLocale locale) {
|
||||
* @locale: locale created with xsltNewLocale
|
||||
* @string: UTF-8 string to transform
|
||||
*
|
||||
* Transforms a string according to locale. The transformed string must then be
|
||||
* compared with xsltLocaleStrcmp and freed with xmlFree.
|
||||
* Transforms a string according to locale. The transformed string must be
|
||||
* freed with xmlFree.
|
||||
*
|
||||
* Returns the transformed string or NULL on error
|
||||
*/
|
||||
xsltLocaleChar *
|
||||
xsltStrxfrm(xsltLocale locale, const xmlChar *string)
|
||||
xmlChar *
|
||||
xsltStrxfrm(void *vlocale, const xmlChar *string)
|
||||
{
|
||||
#ifdef XSLT_LOCALE_NONE
|
||||
return(NULL);
|
||||
#else
|
||||
size_t xstrlen, r;
|
||||
xsltLocaleChar *xstr;
|
||||
xmlChar *xstr;
|
||||
|
||||
#ifdef XSLT_LOCALE_POSIX
|
||||
xstrlen = strxfrm_l(NULL, (const char *)string, 0, locale) + 1;
|
||||
xstr = (xsltLocaleChar *) xmlMalloc(xstrlen);
|
||||
size_t xstrlen, r;
|
||||
|
||||
xstrlen = strxfrm_l(NULL, (const char *)string, 0, vlocale) + 1;
|
||||
xstr = (xmlChar *) xmlMalloc(xstrlen);
|
||||
if (xstr == NULL) {
|
||||
xsltTransformError(NULL, NULL, NULL,
|
||||
"xsltStrxfrm : out of memory error\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
r = strxfrm_l((char *)xstr, (const char *)string, xstrlen, locale);
|
||||
#endif
|
||||
|
||||
#ifdef XSLT_LOCALE_WINAPI
|
||||
xstrlen = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, NULL, 0);
|
||||
if (xstrlen == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar check failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
xstr = (xsltLocaleChar*) xmlMalloc(xstrlen * sizeof(xsltLocaleChar));
|
||||
if (xstr == NULL) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
r = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, xstr, xstrlen);
|
||||
if (r == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar failed\n");
|
||||
xmlFree(xstr);
|
||||
return(NULL);
|
||||
}
|
||||
return(xstr);
|
||||
#endif /* XSLT_LOCALE_WINAPI */
|
||||
r = strxfrm_l((char *)xstr, (const char *)string, xstrlen, vlocale);
|
||||
|
||||
if (r >= xstrlen) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : strxfrm failed\n");
|
||||
xmlFree(xstr);
|
||||
return(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XSLT_LOCALE_WINAPI
|
||||
int wstrlen, xstrlen, r;
|
||||
wchar_t *wstr;
|
||||
LCID *lcid = vlocale;
|
||||
|
||||
wstrlen = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, NULL, 0);
|
||||
if (wstrlen == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar check failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
wstr = (wchar_t *) xmlMalloc(wstrlen * sizeof(wchar_t));
|
||||
if (wstr == NULL) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
r = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, wstr, wstrlen);
|
||||
if (r == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar failed\n");
|
||||
xmlFree(wstr);
|
||||
return(NULL);
|
||||
}
|
||||
/* This returns the size in bytes. */
|
||||
xstrlen = LCMapStringW(*lcid, LCMAP_SORTKEY, wstr, wstrlen, NULL, 0);
|
||||
if (xstrlen == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : LCMapStringW failed\n");
|
||||
xmlFree(wstr);
|
||||
return(NULL);
|
||||
}
|
||||
xstr = (xmlChar*) xmlMalloc(xstrlen);
|
||||
if (xstr == NULL) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
|
||||
xmlFree(wstr);
|
||||
return(NULL);
|
||||
}
|
||||
r = LCMapStringW(*lcid, LCMAP_SORTKEY, wstr, wstrlen, (wchar_t *) xstr,
|
||||
xstrlen);
|
||||
xmlFree(wstr);
|
||||
if (r == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : LCMapStringW failed\n");
|
||||
xmlFree(xstr);
|
||||
return(NULL);
|
||||
}
|
||||
#endif /* XSLT_LOCALE_WINAPI */
|
||||
|
||||
return(xstr);
|
||||
#endif /* XSLT_LOCALE_NONE */
|
||||
@@ -409,35 +466,22 @@ xsltStrxfrm(xsltLocale locale, const xmlChar *string)
|
||||
|
||||
/**
|
||||
* xsltLocaleStrcmp:
|
||||
* @locale: a locale identifier
|
||||
* @locale: unused
|
||||
* @str1: a string transformed with xsltStrxfrm
|
||||
* @str2: a string transformed with xsltStrxfrm
|
||||
*
|
||||
* Compares two strings transformed with xsltStrxfrm
|
||||
* DEPRECATED: Same as xmlStrcmp.
|
||||
*
|
||||
* Compares two strings transformed with xsltStrxfrm.
|
||||
*
|
||||
* Returns a value < 0 if str1 sorts before str2,
|
||||
* a value > 0 if str1 sorts after str2,
|
||||
* 0 if str1 and str2 are equal wrt sorting
|
||||
*/
|
||||
int
|
||||
xsltLocaleStrcmp(xsltLocale locale, const xsltLocaleChar *str1, const xsltLocaleChar *str2) {
|
||||
xsltLocaleStrcmp(void *locale, const xmlChar *str1, const xmlChar *str2) {
|
||||
(void)locale;
|
||||
#ifdef XSLT_LOCALE_WINAPI
|
||||
{
|
||||
int ret;
|
||||
if (str1 == str2) return(0);
|
||||
if (str1 == NULL) return(-1);
|
||||
if (str2 == NULL) return(1);
|
||||
ret = CompareStringW(locale, 0, str1, -1, str2, -1);
|
||||
if (ret == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL, "xsltLocaleStrcmp : CompareStringW fail\n");
|
||||
return(0);
|
||||
}
|
||||
return(ret - 2);
|
||||
}
|
||||
#else
|
||||
return(xmlStrcmp(str1, str2));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef XSLT_LOCALE_WINAPI
|
||||
@@ -449,7 +493,7 @@ xsltLocaleStrcmp(xsltLocale locale, const xsltLocaleChar *str1, const xsltLocale
|
||||
*
|
||||
* Returns TRUE
|
||||
*/
|
||||
BOOL CALLBACK
|
||||
static BOOL CALLBACK
|
||||
xsltCountSupportedLocales(LPSTR lcid) {
|
||||
(void) lcid;
|
||||
++xsltLocaleListSize;
|
||||
@@ -464,7 +508,7 @@ xsltCountSupportedLocales(LPSTR lcid) {
|
||||
*
|
||||
* Returns TRUE if not at the end of the array
|
||||
*/
|
||||
BOOL CALLBACK
|
||||
static BOOL CALLBACK
|
||||
xsltIterateSupportedLocales(LPSTR lcid) {
|
||||
static int count = 0;
|
||||
xmlChar iso639lang [XSLTMAX_ISO639LANGLEN +1];
|
||||
@@ -472,7 +516,7 @@ xsltIterateSupportedLocales(LPSTR lcid) {
|
||||
int k, l;
|
||||
xsltRFC1766Info *p = xsltLocaleList + count;
|
||||
|
||||
k = sscanf(lcid, "%lx", (long*)&p->lcid);
|
||||
k = sscanf(lcid, "%lx", (unsigned long*)&p->lcid);
|
||||
if (k < 1) goto end;
|
||||
/*don't count terminating null character*/
|
||||
k = GetLocaleInfoA(p->lcid, LOCALE_SISO639LANGNAME,
|
||||
|
||||
Vendored
+346
-110
@@ -9,7 +9,19 @@
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#ifndef XSLT_NEED_TRIO
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <trio.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
@@ -18,7 +30,19 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/HTMLtree.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#include "xsltutils.h"
|
||||
#include "templates.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "imports.h"
|
||||
#include "transform.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#define XSLT_WIN32_PERFORMANCE_COUNTER
|
||||
#endif
|
||||
|
||||
@@ -281,6 +305,66 @@ error:
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltGetUTF8CharZ:
|
||||
* @utf: a sequence of UTF-8 encoded bytes
|
||||
* @len: a pointer to @bytes len
|
||||
*
|
||||
* Read one UTF8 Char from a null-terminated string.
|
||||
*
|
||||
* Returns the char value or -1 in case of error and update @len with the
|
||||
* number of bytes used
|
||||
*/
|
||||
int
|
||||
xsltGetUTF8CharZ(const unsigned char *utf, int *len) {
|
||||
unsigned int c;
|
||||
|
||||
if (utf == NULL)
|
||||
goto error;
|
||||
if (len == NULL)
|
||||
goto error;
|
||||
|
||||
c = utf[0];
|
||||
if (c & 0x80) {
|
||||
if ((utf[1] & 0xc0) != 0x80)
|
||||
goto error;
|
||||
if ((c & 0xe0) == 0xe0) {
|
||||
if ((utf[2] & 0xc0) != 0x80)
|
||||
goto error;
|
||||
if ((c & 0xf0) == 0xf0) {
|
||||
if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
|
||||
goto error;
|
||||
*len = 4;
|
||||
/* 4-byte code */
|
||||
c = (utf[0] & 0x7) << 18;
|
||||
c |= (utf[1] & 0x3f) << 12;
|
||||
c |= (utf[2] & 0x3f) << 6;
|
||||
c |= utf[3] & 0x3f;
|
||||
} else {
|
||||
/* 3-byte code */
|
||||
*len = 3;
|
||||
c = (utf[0] & 0xf) << 12;
|
||||
c |= (utf[1] & 0x3f) << 6;
|
||||
c |= utf[2] & 0x3f;
|
||||
}
|
||||
} else {
|
||||
/* 2-byte code */
|
||||
*len = 2;
|
||||
c = (utf[0] & 0x1f) << 6;
|
||||
c |= utf[1] & 0x3f;
|
||||
}
|
||||
} else {
|
||||
/* 1-byte code */
|
||||
*len = 1;
|
||||
}
|
||||
return(c);
|
||||
|
||||
error:
|
||||
if (len != NULL)
|
||||
*len = 0;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
#ifdef XSLT_REFACTORED
|
||||
|
||||
/**
|
||||
@@ -924,10 +1008,11 @@ xsltDocumentSortFunction(xmlNodeSetPtr list) {
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltComputeSortResultiInternal:
|
||||
* xsltComputeSortResultInternal:
|
||||
* @ctxt: a XSLT process context
|
||||
* @sort: node list
|
||||
* @xfrm: Transform strings according to locale
|
||||
* @sort: xsl:sort node
|
||||
* @number: data-type is number
|
||||
* @locale: transform strings according to locale
|
||||
*
|
||||
* reorder the current node list accordingly to the set of sorting
|
||||
* requirement provided by the array of nodes.
|
||||
@@ -936,11 +1021,11 @@ xsltDocumentSortFunction(xmlNodeSetPtr list) {
|
||||
*/
|
||||
static xmlXPathObjectPtr *
|
||||
xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort,
|
||||
int xfrm) {
|
||||
int number, void *locale) {
|
||||
#ifdef XSLT_REFACTORED
|
||||
xsltStyleItemSortPtr comp;
|
||||
#else
|
||||
xsltStylePreCompPtr comp;
|
||||
const xsltStylePreComp *comp;
|
||||
#endif
|
||||
xmlXPathObjectPtr *results = NULL;
|
||||
xmlNodeSetPtr list = NULL;
|
||||
@@ -1008,10 +1093,12 @@ xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort,
|
||||
if (res != NULL) {
|
||||
if (res->type != XPATH_STRING)
|
||||
res = xmlXPathConvertString(res);
|
||||
if (comp->number)
|
||||
if (number)
|
||||
res = xmlXPathConvertNumber(res);
|
||||
}
|
||||
if (res != NULL) {
|
||||
res->index = i; /* Save original pos for dupl resolv */
|
||||
if (comp->number) {
|
||||
if (number) {
|
||||
if (res->type == XPATH_NUMBER) {
|
||||
results[i] = res;
|
||||
} else {
|
||||
@@ -1023,10 +1110,17 @@ xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort,
|
||||
}
|
||||
} else {
|
||||
if (res->type == XPATH_STRING) {
|
||||
if ((xfrm) && (comp->locale != (xsltLocale)0)) {
|
||||
if (locale != NULL) {
|
||||
xmlChar *str = res->stringval;
|
||||
res->stringval = (xmlChar *) xsltStrxfrm(comp->locale, str);
|
||||
xmlFree(str);
|
||||
xmlChar *sortKey = ctxt->genSortKey(locale, str);
|
||||
|
||||
if (sortKey == NULL) {
|
||||
xsltTransformError(ctxt, NULL, sort,
|
||||
"xsltComputeSortResult: sort key is null\n");
|
||||
} else {
|
||||
res->stringval = sortKey;
|
||||
xmlFree(str);
|
||||
}
|
||||
}
|
||||
|
||||
results[i] = res;
|
||||
@@ -1065,7 +1159,13 @@ xsltComputeSortResultInternal(xsltTransformContextPtr ctxt, xmlNodePtr sort,
|
||||
*/
|
||||
xmlXPathObjectPtr *
|
||||
xsltComputeSortResult(xsltTransformContextPtr ctxt, xmlNodePtr sort) {
|
||||
return xsltComputeSortResultInternal(ctxt, sort, /* xfrm */ 0);
|
||||
const xsltStylePreComp *comp = sort->psvi;
|
||||
int number = 0;
|
||||
|
||||
if (comp != NULL)
|
||||
number = comp->number;
|
||||
return xsltComputeSortResultInternal(ctxt, sort, number,
|
||||
/* locale */ NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1083,20 +1183,19 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
#ifdef XSLT_REFACTORED
|
||||
xsltStyleItemSortPtr comp;
|
||||
#else
|
||||
xsltStylePreCompPtr comp;
|
||||
const xsltStylePreComp *comp;
|
||||
#endif
|
||||
xmlXPathObjectPtr *resultsTab[XSLT_MAX_SORT];
|
||||
xmlXPathObjectPtr *results = NULL, *res;
|
||||
xmlNodeSetPtr list = NULL;
|
||||
int descending, number, desc, numb;
|
||||
int len = 0;
|
||||
int i, j, incr;
|
||||
int tst;
|
||||
int depth;
|
||||
xmlNodePtr node;
|
||||
xmlXPathObjectPtr tmp;
|
||||
int tempstype[XSLT_MAX_SORT], temporder[XSLT_MAX_SORT],
|
||||
templang[XSLT_MAX_SORT];
|
||||
int number[XSLT_MAX_SORT], desc[XSLT_MAX_SORT];
|
||||
void *locale[XSLT_MAX_SORT];
|
||||
|
||||
if ((ctxt == NULL) || (sorts == NULL) || (nbsorts <= 0) ||
|
||||
(nbsorts >= XSLT_MAX_SORT))
|
||||
@@ -1112,72 +1211,74 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
return; /* nothing to do */
|
||||
|
||||
for (j = 0; j < nbsorts; j++) {
|
||||
xmlChar *lang;
|
||||
|
||||
comp = sorts[j]->psvi;
|
||||
tempstype[j] = 0;
|
||||
if ((comp->stype == NULL) && (comp->has_stype != 0)) {
|
||||
comp->stype =
|
||||
xmlChar *stype =
|
||||
xsltEvalAttrValueTemplate(ctxt, sorts[j],
|
||||
(const xmlChar *) "data-type",
|
||||
NULL);
|
||||
if (comp->stype != NULL) {
|
||||
tempstype[j] = 1;
|
||||
if (xmlStrEqual(comp->stype, (const xmlChar *) "text"))
|
||||
comp->number = 0;
|
||||
else if (xmlStrEqual(comp->stype, (const xmlChar *) "number"))
|
||||
comp->number = 1;
|
||||
BAD_CAST "data-type", NULL);
|
||||
number[j] = 0;
|
||||
if (stype != NULL) {
|
||||
if (xmlStrEqual(stype, (const xmlChar *) "text"))
|
||||
;
|
||||
else if (xmlStrEqual(stype, (const xmlChar *) "number"))
|
||||
number[j] = 1;
|
||||
else {
|
||||
xsltTransformError(ctxt, NULL, sorts[j],
|
||||
"xsltDoSortFunction: no support for data-type = %s\n",
|
||||
comp->stype);
|
||||
comp->number = 0; /* use default */
|
||||
stype);
|
||||
}
|
||||
xmlFree(stype);
|
||||
}
|
||||
}
|
||||
temporder[j] = 0;
|
||||
} else {
|
||||
number[j] = comp->number;
|
||||
}
|
||||
if ((comp->order == NULL) && (comp->has_order != 0)) {
|
||||
comp->order = xsltEvalAttrValueTemplate(ctxt, sorts[j],
|
||||
(const xmlChar *) "order",
|
||||
NULL);
|
||||
if (comp->order != NULL) {
|
||||
temporder[j] = 1;
|
||||
if (xmlStrEqual(comp->order, (const xmlChar *) "ascending"))
|
||||
comp->descending = 0;
|
||||
else if (xmlStrEqual(comp->order,
|
||||
(const xmlChar *) "descending"))
|
||||
comp->descending = 1;
|
||||
xmlChar *order = xsltEvalAttrValueTemplate(ctxt, sorts[j],
|
||||
BAD_CAST "order", NULL);
|
||||
desc[j] = 0;
|
||||
if (order != NULL) {
|
||||
if (xmlStrEqual(order, (const xmlChar *) "ascending"))
|
||||
;
|
||||
else if (xmlStrEqual(order, (const xmlChar *) "descending"))
|
||||
desc[j] = 1;
|
||||
else {
|
||||
xsltTransformError(ctxt, NULL, sorts[j],
|
||||
"xsltDoSortFunction: invalid value %s for order\n",
|
||||
comp->order);
|
||||
comp->descending = 0; /* use default */
|
||||
order);
|
||||
}
|
||||
xmlFree(order);
|
||||
}
|
||||
} else {
|
||||
desc[j] = comp->descending;
|
||||
}
|
||||
templang[j] = 0;
|
||||
if ((comp->lang == NULL) && (comp->has_lang != 0)) {
|
||||
xmlChar *lang = xsltEvalAttrValueTemplate(ctxt, sorts[j],
|
||||
lang = xsltEvalAttrValueTemplate(ctxt, sorts[j],
|
||||
(xmlChar *) "lang",
|
||||
NULL);
|
||||
if (lang != NULL) {
|
||||
templang[j] = 1;
|
||||
comp->locale = xsltNewLocale(lang);
|
||||
} else {
|
||||
lang = (xmlChar *) comp->lang;
|
||||
}
|
||||
if (lang != NULL) {
|
||||
locale[j] = ctxt->newLocale(lang, comp->lower_first);
|
||||
if (lang != comp->lang)
|
||||
xmlFree(lang);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
locale[j] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
len = list->nodeNr;
|
||||
|
||||
resultsTab[0] = xsltComputeSortResultInternal(ctxt, sorts[0],
|
||||
/* xfrm */ 1);
|
||||
resultsTab[0] = xsltComputeSortResultInternal(ctxt, sorts[0], number[0],
|
||||
locale[0]);
|
||||
for (i = 1;i < XSLT_MAX_SORT;i++)
|
||||
resultsTab[i] = NULL;
|
||||
|
||||
results = resultsTab[0];
|
||||
|
||||
comp = sorts[0]->psvi;
|
||||
descending = comp->descending;
|
||||
number = comp->number;
|
||||
if (results == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@@ -1192,7 +1293,7 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
if (results[j] == NULL)
|
||||
tst = 1;
|
||||
else {
|
||||
if (number) {
|
||||
if (number[0]) {
|
||||
/* We make NaN smaller than number in accordance
|
||||
with XSLT spec */
|
||||
if (xmlXPathIsNaN(results[j]->floatval)) {
|
||||
@@ -1209,16 +1310,11 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
results[j + incr]->floatval)
|
||||
tst = 1;
|
||||
else tst = -1;
|
||||
} else if(comp->locale != (xsltLocale)0) {
|
||||
tst = xsltLocaleStrcmp(
|
||||
comp->locale,
|
||||
(xsltLocaleChar *) results[j]->stringval,
|
||||
(xsltLocaleChar *) results[j + incr]->stringval);
|
||||
} else {
|
||||
tst = xmlStrcmp(results[j]->stringval,
|
||||
results[j + incr]->stringval);
|
||||
}
|
||||
if (descending)
|
||||
if (desc[0])
|
||||
tst = -tst;
|
||||
}
|
||||
if (tst == 0) {
|
||||
@@ -1232,8 +1328,6 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
comp = sorts[depth]->psvi;
|
||||
if (comp == NULL)
|
||||
break;
|
||||
desc = comp->descending;
|
||||
numb = comp->number;
|
||||
|
||||
/*
|
||||
* Compute the result of the next level for the
|
||||
@@ -1243,7 +1337,8 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
resultsTab[depth] =
|
||||
xsltComputeSortResultInternal(ctxt,
|
||||
sorts[depth],
|
||||
/* xfrm */ 1);
|
||||
number[depth],
|
||||
locale[depth]);
|
||||
res = resultsTab[depth];
|
||||
if (res == NULL)
|
||||
break;
|
||||
@@ -1253,7 +1348,7 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
} else if (res[j+incr] == NULL) {
|
||||
tst = -1;
|
||||
} else {
|
||||
if (numb) {
|
||||
if (number[depth]) {
|
||||
/* We make NaN smaller than number in
|
||||
accordance with XSLT spec */
|
||||
if (xmlXPathIsNaN(res[j]->floatval)) {
|
||||
@@ -1272,16 +1367,11 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
res[j + incr]->floatval)
|
||||
tst = 1;
|
||||
else tst = -1;
|
||||
} else if(comp->locale != (xsltLocale)0) {
|
||||
tst = xsltLocaleStrcmp(
|
||||
comp->locale,
|
||||
(xsltLocaleChar *) res[j]->stringval,
|
||||
(xsltLocaleChar *) res[j + incr]->stringval);
|
||||
} else {
|
||||
tst = xmlStrcmp(res[j]->stringval,
|
||||
res[j + incr]->stringval);
|
||||
}
|
||||
if (desc)
|
||||
if (desc[depth])
|
||||
tst = -tst;
|
||||
}
|
||||
|
||||
@@ -1325,21 +1415,9 @@ xsltDefaultSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts,
|
||||
|
||||
cleanup:
|
||||
for (j = 0; j < nbsorts; j++) {
|
||||
comp = sorts[j]->psvi;
|
||||
if (tempstype[j] == 1) {
|
||||
/* The data-type needs to be recomputed each time */
|
||||
xmlFree((void *)(comp->stype));
|
||||
comp->stype = NULL;
|
||||
}
|
||||
if (temporder[j] == 1) {
|
||||
/* The order needs to be recomputed each time */
|
||||
xmlFree((void *)(comp->order));
|
||||
comp->order = NULL;
|
||||
}
|
||||
if (templang[j] == 1) {
|
||||
xsltFreeLocale(comp->locale);
|
||||
comp->locale = (xsltLocale)0;
|
||||
}
|
||||
if (locale[j] != NULL) {
|
||||
ctxt->freeLocale(locale[j]);
|
||||
}
|
||||
if (resultsTab[j] != NULL) {
|
||||
for (i = 0;i < len;i++)
|
||||
xmlXPathFreeObject(resultsTab[j][i]);
|
||||
@@ -1379,6 +1457,8 @@ xsltDoSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr * sorts,
|
||||
* xsltSetSortFunc:
|
||||
* @handler: the new handler function
|
||||
*
|
||||
* DEPRECATED: Use xsltSetCtxtLocaleHandlers.
|
||||
*
|
||||
* Function to reset the global handler for XSLT sorting.
|
||||
* If the handler is NULL, the default sort function will be used.
|
||||
*/
|
||||
@@ -1395,6 +1475,8 @@ xsltSetSortFunc(xsltSortFunc handler) {
|
||||
* @ctxt: a XSLT process context
|
||||
* @handler: the new handler function
|
||||
*
|
||||
* DEPRECATED: Use xsltSetCtxtLocaleHandlers.
|
||||
*
|
||||
* Function to set the handler for XSLT sorting
|
||||
* for the specified context.
|
||||
* If the handler is NULL, then the global
|
||||
@@ -1405,6 +1487,28 @@ xsltSetCtxtSortFunc(xsltTransformContextPtr ctxt, xsltSortFunc handler) {
|
||||
ctxt->sortfunc = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltSetCtxtLocaleHandlers:
|
||||
* @ctxt: an XSLT transform context
|
||||
* @newLocale: locale constructor
|
||||
* @freeLocale: locale destructor
|
||||
* @genSortKey: sort key generator
|
||||
*
|
||||
* Set the locale handlers.
|
||||
*/
|
||||
void
|
||||
xsltSetCtxtLocaleHandlers(xsltTransformContextPtr ctxt,
|
||||
xsltNewLocaleFunc newLocale,
|
||||
xsltFreeLocaleFunc freeLocale,
|
||||
xsltGenSortKeyFunc genSortKey) {
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
|
||||
ctxt->newLocale = newLocale;
|
||||
ctxt->freeLocale = freeLocale;
|
||||
ctxt->genSortKey = genSortKey;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Parsing options *
|
||||
@@ -1646,13 +1750,12 @@ xsltSaveResultToFilename(const char *URL, xmlDocPtr result,
|
||||
|
||||
XSLT_GET_IMPORT_PTR(encoding, style, encoding)
|
||||
if (encoding != NULL) {
|
||||
xmlCharEncodingHandlerPtr encoder;
|
||||
xmlCharEncodingHandlerPtr encoder = NULL;
|
||||
|
||||
encoder = xmlFindCharEncodingHandler((char *)encoding);
|
||||
if ((encoder != NULL) &&
|
||||
(xmlStrEqual((const xmlChar *)encoder->name,
|
||||
(const xmlChar *) "UTF-8")))
|
||||
encoder = NULL;
|
||||
/* Don't use UTF-8 dummy encoder */
|
||||
if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
|
||||
(xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
|
||||
encoder = xmlFindCharEncodingHandler((char *) encoding);
|
||||
buf = xmlOutputBufferCreateFilename(URL, encoder, compression);
|
||||
} else {
|
||||
buf = xmlOutputBufferCreateFilename(URL, NULL, compression);
|
||||
@@ -1689,13 +1792,12 @@ xsltSaveResultToFile(FILE *file, xmlDocPtr result, xsltStylesheetPtr style) {
|
||||
|
||||
XSLT_GET_IMPORT_PTR(encoding, style, encoding)
|
||||
if (encoding != NULL) {
|
||||
xmlCharEncodingHandlerPtr encoder;
|
||||
xmlCharEncodingHandlerPtr encoder = NULL;
|
||||
|
||||
encoder = xmlFindCharEncodingHandler((char *)encoding);
|
||||
if ((encoder != NULL) &&
|
||||
(xmlStrEqual((const xmlChar *)encoder->name,
|
||||
(const xmlChar *) "UTF-8")))
|
||||
encoder = NULL;
|
||||
/* Don't use UTF-8 dummy encoder */
|
||||
if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
|
||||
(xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
|
||||
encoder = xmlFindCharEncodingHandler((char *) encoding);
|
||||
buf = xmlOutputBufferCreateFile(file, encoder);
|
||||
} else {
|
||||
buf = xmlOutputBufferCreateFile(file, NULL);
|
||||
@@ -1733,13 +1835,12 @@ xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style) {
|
||||
|
||||
XSLT_GET_IMPORT_PTR(encoding, style, encoding)
|
||||
if (encoding != NULL) {
|
||||
xmlCharEncodingHandlerPtr encoder;
|
||||
xmlCharEncodingHandlerPtr encoder = NULL;
|
||||
|
||||
encoder = xmlFindCharEncodingHandler((char *)encoding);
|
||||
if ((encoder != NULL) &&
|
||||
(xmlStrEqual((const xmlChar *)encoder->name,
|
||||
(const xmlChar *) "UTF-8")))
|
||||
encoder = NULL;
|
||||
/* Don't use UTF-8 dummy encoder */
|
||||
if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
|
||||
(xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
|
||||
encoder = xmlFindCharEncodingHandler((char *) encoding);
|
||||
buf = xmlOutputBufferCreateFd(fd, encoder);
|
||||
} else {
|
||||
buf = xmlOutputBufferCreateFd(fd, NULL);
|
||||
@@ -1776,14 +1877,15 @@ xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len,
|
||||
|
||||
XSLT_GET_IMPORT_PTR(encoding, style, encoding)
|
||||
if (encoding != NULL) {
|
||||
xmlCharEncodingHandlerPtr encoder;
|
||||
xmlCharEncodingHandlerPtr encoder = NULL;
|
||||
|
||||
encoder = xmlFindCharEncodingHandler((char *)encoding);
|
||||
if ((encoder != NULL) &&
|
||||
(xmlStrEqual((const xmlChar *)encoder->name,
|
||||
(const xmlChar *) "UTF-8")))
|
||||
encoder = NULL;
|
||||
/* Don't use UTF-8 dummy encoder */
|
||||
if ((xmlStrcasecmp(encoding, BAD_CAST "UTF-8") != 0) &&
|
||||
(xmlStrcasecmp(encoding, BAD_CAST "UTF8") != 0))
|
||||
encoder = xmlFindCharEncodingHandler((char *) encoding);
|
||||
buf = xmlAllocOutputBuffer(encoder);
|
||||
if (buf == NULL)
|
||||
xmlCharEncCloseFunc(encoder);
|
||||
} else {
|
||||
buf = xmlAllocOutputBuffer(NULL);
|
||||
}
|
||||
@@ -1811,6 +1913,141 @@ xsltSaveResultToString(xmlChar **doc_txt_ptr, int * doc_txt_len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltGetSourceNodeFlags:
|
||||
* @node: Node from source document
|
||||
*
|
||||
* Returns the flags for a source node.
|
||||
*/
|
||||
int
|
||||
xsltGetSourceNodeFlags(xmlNodePtr node) {
|
||||
/*
|
||||
* Squeeze the bit flags into the upper bits of
|
||||
*
|
||||
* - 'int properties' member in struct _xmlDoc
|
||||
* - 'xmlAttributeType atype' member in struct _xmlAttr
|
||||
* - 'unsigned short extra' member in struct _xmlNode
|
||||
*/
|
||||
switch (node->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
return ((xmlDocPtr) node)->properties >> 27;
|
||||
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
return ((xmlAttrPtr) node)->atype >> 27;
|
||||
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
return node->extra >> 12;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltSetSourceNodeFlags:
|
||||
* @node: Node from source document
|
||||
* @flags: Flags
|
||||
*
|
||||
* Sets the specified flags to 1.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
xsltSetSourceNodeFlags(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
int flags) {
|
||||
if (node->doc == ctxt->initialContextDoc)
|
||||
ctxt->sourceDocDirty = 1;
|
||||
|
||||
switch (node->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
((xmlDocPtr) node)->properties |= flags << 27;
|
||||
return 0;
|
||||
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
((xmlAttrPtr) node)->atype |= flags << 27;
|
||||
return 0;
|
||||
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
node->extra |= flags << 12;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltClearSourceNodeFlags:
|
||||
* @node: Node from source document
|
||||
* @flags: Flags
|
||||
*
|
||||
* Sets the specified flags to 0.
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
xsltClearSourceNodeFlags(xmlNodePtr node, int flags) {
|
||||
switch (node->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
((xmlDocPtr) node)->properties &= ~(flags << 27);
|
||||
return 0;
|
||||
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
((xmlAttrPtr) node)->atype &= ~(flags << 27);
|
||||
return 0;
|
||||
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
node->extra &= ~(flags << 12);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltGetPSVIPtr:
|
||||
* @cur: Node
|
||||
*
|
||||
* Returns a pointer to the psvi member of a node or NULL on error.
|
||||
*/
|
||||
void **
|
||||
xsltGetPSVIPtr(xmlNodePtr cur) {
|
||||
switch (cur->type) {
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
return &((xmlDocPtr) cur)->psvi;
|
||||
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
return &((xmlAttrPtr) cur)->psvi;
|
||||
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
return &cur->psvi;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_PROFILER
|
||||
|
||||
/************************************************************************
|
||||
@@ -2487,4 +2724,3 @@ xslDropCall(void)
|
||||
}
|
||||
|
||||
#endif /* WITH_DEBUGGER */
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef __XSLT_LIBXSLT_H__
|
||||
#define __XSLT_LIBXSLT_H__
|
||||
|
||||
#if defined(_WIN32) && !defined (__MINGW32__)
|
||||
#ifdef _WIN32
|
||||
#include <win32config.h>
|
||||
#else
|
||||
#include "config.h"
|
||||
@@ -27,10 +27,16 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#define mkdir(p,m) _mkdir(p)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define ATTRIBUTE_UNUSED
|
||||
#endif
|
||||
|
||||
#endif /* ! __XSLT_LIBXSLT_H__ */
|
||||
|
||||
@@ -43,7 +43,7 @@ extern "C" {
|
||||
*
|
||||
* RVT is destroyed after the current instructions ends.
|
||||
*/
|
||||
#define XSLT_RVT_LOCAL ((void *)1)
|
||||
#define XSLT_RVT_LOCAL 1
|
||||
|
||||
/**
|
||||
* XSLT_RVT_FUNC_RESULT:
|
||||
@@ -52,14 +52,14 @@ extern "C" {
|
||||
* destroyed after exiting a template and will be reset to XSLT_RVT_LOCAL or
|
||||
* XSLT_RVT_VARIABLE in the template that receives the return value.
|
||||
*/
|
||||
#define XSLT_RVT_FUNC_RESULT ((void *)2)
|
||||
#define XSLT_RVT_FUNC_RESULT 2
|
||||
|
||||
/**
|
||||
* XSLT_RVT_GLOBAL:
|
||||
*
|
||||
* RVT is part of a global variable.
|
||||
*/
|
||||
#define XSLT_RVT_GLOBAL ((void *)3)
|
||||
#define XSLT_RVT_GLOBAL 3
|
||||
|
||||
/*
|
||||
* Interfaces for the variable module.
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxslt/xslt.h>
|
||||
#include "xsltexports.h"
|
||||
#include "xsltlocale.h"
|
||||
#include "numbersInternals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -1047,7 +1046,6 @@ struct _xsltStyleItemSort {
|
||||
int descending; /* sort */
|
||||
const xmlChar *lang; /* sort */
|
||||
int has_lang; /* sort */
|
||||
xsltLocale locale; /* sort */
|
||||
const xmlChar *case_order; /* sort */
|
||||
int lower_first; /* sort */
|
||||
|
||||
@@ -1377,7 +1375,6 @@ struct _xsltStylePreComp {
|
||||
int descending; /* sort */
|
||||
const xmlChar *lang; /* sort */
|
||||
int has_lang; /* sort */
|
||||
xsltLocale locale; /* sort */
|
||||
const xmlChar *case_order; /* sort */
|
||||
int lower_first; /* sort */
|
||||
|
||||
@@ -1637,6 +1634,9 @@ struct _xsltStylesheet {
|
||||
xmlHashTablePtr namedTemplates; /* hash table of named templates */
|
||||
|
||||
xmlXPathContextPtr xpathCtxt;
|
||||
|
||||
unsigned long opLimit;
|
||||
unsigned long opCount;
|
||||
};
|
||||
|
||||
typedef struct _xsltTransformCache xsltTransformCache;
|
||||
@@ -1663,6 +1663,13 @@ typedef enum {
|
||||
XSLT_OUTPUT_TEXT
|
||||
} xsltOutputType;
|
||||
|
||||
typedef void *
|
||||
(*xsltNewLocaleFunc)(const xmlChar *lang, int lowerFirst);
|
||||
typedef void
|
||||
(*xsltFreeLocaleFunc)(void *locale);
|
||||
typedef xmlChar *
|
||||
(*xsltGenSortKeyFunc)(void *locale, const xmlChar *lang);
|
||||
|
||||
typedef enum {
|
||||
XSLT_STATE_OK = 0,
|
||||
XSLT_STATE_ERROR,
|
||||
@@ -1786,6 +1793,12 @@ struct _xsltTransformContext {
|
||||
int maxTemplateVars;
|
||||
unsigned long opLimit;
|
||||
unsigned long opCount;
|
||||
int sourceDocDirty;
|
||||
unsigned long currentId; /* For generate-id() */
|
||||
|
||||
xsltNewLocaleFunc newLocale;
|
||||
xsltFreeLocaleFunc freeLocale;
|
||||
xsltGenSortKeyFunc genSortKey;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1915,7 +1928,7 @@ XSLTPUBFUN int XSLTCALL
|
||||
xsltFlagRVTs(
|
||||
xsltTransformContextPtr ctxt,
|
||||
xmlXPathObjectPtr obj,
|
||||
void *val);
|
||||
int val);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltFreeRVTs (xsltTransformContextPtr ctxt);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
@@ -1979,4 +1992,3 @@ XSLTPUBFUN int XSLTCALL
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLT_H__ */
|
||||
|
||||
|
||||
@@ -20,21 +20,21 @@ extern "C" {
|
||||
*
|
||||
* the version string like "1.2.3"
|
||||
*/
|
||||
#define LIBXSLT_DOTTED_VERSION "1.1.37"
|
||||
#define LIBXSLT_DOTTED_VERSION "1.1.42"
|
||||
|
||||
/**
|
||||
* LIBXSLT_VERSION:
|
||||
*
|
||||
* the version number: 1.2.3 value is 10203
|
||||
*/
|
||||
#define LIBXSLT_VERSION 10137
|
||||
#define LIBXSLT_VERSION 10142
|
||||
|
||||
/**
|
||||
* LIBXSLT_VERSION_STRING:
|
||||
*
|
||||
* the version number string, 1.2.3 value is "10203"
|
||||
*/
|
||||
#define LIBXSLT_VERSION_STRING "10137"
|
||||
#define LIBXSLT_VERSION_STRING "10142"
|
||||
|
||||
/**
|
||||
* LIBXSLT_VERSION_EXTRA:
|
||||
@@ -50,11 +50,11 @@ extern "C" {
|
||||
* is insignifiant and being able to run xsltpoc -v is useful. On
|
||||
* by default unless --without-debug is passed to configure
|
||||
*/
|
||||
#if 1
|
||||
#if 0
|
||||
#define WITH_XSLT_DEBUG
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
/**
|
||||
* DEBUG_MEMORY:
|
||||
*
|
||||
@@ -103,7 +103,7 @@ extern "C" {
|
||||
* is insignifiant.
|
||||
* On by default unless --without-debugger is passed to configure
|
||||
*/
|
||||
#if 1
|
||||
#if 0
|
||||
#ifndef WITH_DEBUGGER
|
||||
#define WITH_DEBUGGER
|
||||
#endif
|
||||
@@ -132,7 +132,7 @@ extern "C" {
|
||||
#ifndef WITH_MODULES
|
||||
#define WITH_MODULES
|
||||
#endif
|
||||
#define LIBXSLT_DEFAULT_PLUGINS_PATH() "/usr/lib/libxslt-plugins"
|
||||
#define LIBXSLT_DEFAULT_PLUGINS_PATH() "/usr/local/lib/libxslt-plugins"
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,69 +14,31 @@
|
||||
#include <libxml/xmlstring.h>
|
||||
#include "xsltexports.h"
|
||||
|
||||
#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>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef locale_t xsltLocale;
|
||||
typedef xmlChar xsltLocaleChar;
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
/*
|
||||
* XSLT_LOCALE_WINAPI:
|
||||
* Macro indicating to use WinAPI for extended locale support
|
||||
*/
|
||||
#define XSLT_LOCALE_WINAPI
|
||||
|
||||
#ifdef __REACTOS__
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#else /* __REACTOS__ */
|
||||
#include <windows.h>
|
||||
#endif /* __REACTOS__ */
|
||||
#include <winnls.h>
|
||||
|
||||
typedef LCID xsltLocale;
|
||||
typedef wchar_t xsltLocaleChar;
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* XSLT_LOCALE_NONE:
|
||||
* Macro indicating that there's no extended locale support
|
||||
*/
|
||||
#define XSLT_LOCALE_NONE
|
||||
|
||||
typedef void *xsltLocale;
|
||||
typedef xmlChar xsltLocaleChar;
|
||||
|
||||
#endif
|
||||
|
||||
XSLTPUBFUN xsltLocale XSLTCALL
|
||||
xsltNewLocale (const xmlChar *langName);
|
||||
XSLTPUBFUN void * XSLTCALL
|
||||
xsltNewLocale (const xmlChar *langName,
|
||||
int lowerFirst);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltFreeLocale (xsltLocale locale);
|
||||
XSLTPUBFUN xsltLocaleChar * XSLTCALL
|
||||
xsltStrxfrm (xsltLocale locale,
|
||||
xsltFreeLocale (void *locale);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltStrxfrm (void *locale,
|
||||
const xmlChar *string);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltLocaleStrcmp (xsltLocale locale,
|
||||
const xsltLocaleChar *str1,
|
||||
const xsltLocaleChar *str2);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltFreeLocales (void);
|
||||
|
||||
/* Backward compatibility */
|
||||
typedef void *xsltLocale;
|
||||
typedef xmlChar xsltLocaleChar;
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltLocaleStrcmp (void *locale,
|
||||
const xmlChar *str1,
|
||||
const xmlChar *str2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLTLOCALE_H__ */
|
||||
|
||||
@@ -91,6 +91,13 @@ XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetUTF8Char (const unsigned char *utf,
|
||||
int *len);
|
||||
#ifdef IN_LIBXSLT
|
||||
/** DOC_DISABLE */
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetUTF8CharZ (const unsigned char *utf,
|
||||
int *len);
|
||||
/** DOC_ENABLE */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XSLT Debug Tracing Tracing Types
|
||||
@@ -178,6 +185,11 @@ XSLTPUBFUN void XSLTCALL
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt,
|
||||
xsltSortFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetCtxtLocaleHandlers (xsltTransformContextPtr ctxt,
|
||||
xsltNewLocaleFunc newLocale,
|
||||
xsltFreeLocaleFunc freeLocale,
|
||||
xsltGenSortKeyFunc genSortKey);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDefaultSortFunction (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr *sorts,
|
||||
@@ -244,6 +256,24 @@ XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
|
||||
const xmlChar *str,
|
||||
int flags);
|
||||
|
||||
#ifdef IN_LIBXSLT
|
||||
/** DOC_DISABLE */
|
||||
#define XSLT_SOURCE_NODE_MASK 15u
|
||||
#define XSLT_SOURCE_NODE_HAS_KEY 1u
|
||||
#define XSLT_SOURCE_NODE_HAS_ID 2u
|
||||
int
|
||||
xsltGetSourceNodeFlags(xmlNodePtr node);
|
||||
int
|
||||
xsltSetSourceNodeFlags(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||
int flags);
|
||||
int
|
||||
xsltClearSourceNodeFlags(xmlNodePtr node, int flags);
|
||||
void **
|
||||
xsltGetPSVIPtr(xmlNodePtr cur);
|
||||
/** DOC_ENABLE */
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PROFILER
|
||||
/*
|
||||
* Profiling.
|
||||
*/
|
||||
@@ -257,6 +287,7 @@ XSLTPUBFUN long XSLTCALL
|
||||
xsltTimestamp (void);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltCalibrateAdjust (long delta);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XSLT_TIMESTAMP_TICS_PER_SEC:
|
||||
@@ -289,10 +320,11 @@ typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
|
||||
typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
|
||||
typedef void (*xsltDropCallCallback) (void);
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetDebuggerStatus (int value);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetDebuggerStatus (void);
|
||||
#ifdef WITH_DEBUGGER
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetDebuggerStatus (int value);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSetDebuggerCallbacks (int no, void *block);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
@@ -300,11 +332,10 @@ XSLTPUBFUN int XSLTCALL
|
||||
xmlNodePtr source);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xslDropCall (void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLTUTILS_H__ */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user