[xslt] Some rebased patches
- From: Nick Wellnhofer <wellnhofer aevum de>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Cc: veillard redhat com
- Subject: [xslt] Some rebased patches
- Date: Sat, 06 Nov 2010 00:50:36 +0100
Here are some of my smaller patches rebased against trunk and formatted
with git format-patch. I don't really remember about all of them, but I
think they should be safe to apply. The fix for bug #602515 is also
included.
Nick
>From fada724b7c5397d7810308fbff4fd711bb3933a1 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <nik yoshi dyn aevum de>
Date: Sat, 7 Nov 2009 18:41:23 +0100
Subject: [PATCH 1/8] Fix direct pattern matching bug
---
libxslt/pattern.c | 6 +++++-
tests/docs/bug-170.xml | 3 +++
tests/general/Makefile.am | 1 +
tests/general/bug-170.out | 4 ++++
tests/general/bug-170.xsl | 6 ++++++
5 files changed, 19 insertions(+), 1 deletions(-)
create mode 100644 tests/docs/bug-170.xml
create mode 100644 tests/general/bug-170.out
create mode 100644 tests/general/bug-170.xsl
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index 8ce74e3..58bd6ed 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -546,13 +546,15 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
xmlNodePtr parent = node->parent;
xmlDocPtr olddoc;
xmlNodePtr oldnode;
- int oldNsNr;
+ int oldNsNr, oldContextSize, oldProximityPosition;
xmlNsPtr *oldNamespaces;
oldnode = ctxt->xpathCtxt->node;
olddoc = ctxt->xpathCtxt->doc;
oldNsNr = ctxt->xpathCtxt->nsNr;
oldNamespaces = ctxt->xpathCtxt->namespaces;
+ oldContextSize = ctxt->xpathCtxt->contextSize;
+ oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
ctxt->xpathCtxt->node = node;
ctxt->xpathCtxt->doc = doc;
ctxt->xpathCtxt->namespaces = nsList;
@@ -562,6 +564,8 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
ctxt->xpathCtxt->doc = olddoc;
ctxt->xpathCtxt->namespaces = oldNamespaces;
ctxt->xpathCtxt->nsNr = oldNsNr;
+ ctxt->xpathCtxt->contextSize = oldContextSize;
+ ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
if (newlist == NULL)
return(-1);
if (newlist->type != XPATH_NODESET) {
diff --git a/tests/docs/bug-170.xml b/tests/docs/bug-170.xml
new file mode 100644
index 0000000..08c3c4d
--- /dev/null
+++ b/tests/docs/bug-170.xml
@@ -0,0 +1,3 @@
+<root>
+ <a type="b"/>
+</root>
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index 5d5baf0..e33a6c6 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -177,6 +177,7 @@ EXTRA_DIST = \
bug-167.out bug-167.xsl \
bug-168.out bug-168.xsl \
bug-169.out bug-169.xsl bug-169.imp \
+ bug-170.out bug-170.xsl \
character.out character.xsl \
character2.out character2.xsl \
itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-170.out b/tests/general/bug-170.out
new file mode 100644
index 0000000..e24f8d3
--- /dev/null
+++ b/tests/general/bug-170.out
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+
+
+
diff --git a/tests/general/bug-170.xsl b/tests/general/bug-170.xsl
new file mode 100644
index 0000000..393bc4b
--- /dev/null
+++ b/tests/general/bug-170.xsl
@@ -0,0 +1,6 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="a[ type='b']" >
+ <xsl:if test="position()"/>
+ </xsl:template>
+ <xsl:template match="a[ type='XX'][.]"/>
+</xsl:stylesheet>
--
1.7.2.3
>From 668db6ced6451145d0a57543cc3e6e951827d1bc Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <nik yoshi dyn aevum de>
Date: Thu, 3 Dec 2009 01:56:22 +0100
Subject: [PATCH 2/8] Fix popping of vars in xsltCompilerNodePop
---
libxslt/xslt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index dd58f81..8e8c414 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -2437,13 +2437,13 @@ xsltCompilerNodePop(xsltCompilerCtxtPtr cctxt, xmlNodePtr node)
"xsltCompilerNodePop: Depth mismatch.\n");
goto mismatch;
}
+ cctxt->depth--;
/*
* Pop information of variables.
*/
if ((cctxt->ivar) && (cctxt->ivar->depth > cctxt->depth))
xsltCompilerVarInfoPop(cctxt);
- cctxt->depth--;
cctxt->inode = cctxt->inode->prev;
if (cctxt->inode != NULL)
cctxt->inode->curChildType = 0;
--
1.7.2.3
>From b66b71f71a9e5298ac8c4d83bf66e3b412dcde67 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue, 29 Dec 2009 06:13:17 +0100
Subject: [PATCH 3/8] Fix bug 602515
Pattern matching with predicates
---
libxslt/pattern.c | 17 ++++++++---------
tests/docs/bug-171.xml | 4 ++++
tests/general/Makefile.am | 1 +
tests/general/bug-171.out | 2 ++
tests/general/bug-171.xsl | 7 +++++++
5 files changed, 22 insertions(+), 9 deletions(-)
create mode 100644 tests/docs/bug-171.xml
create mode 100644 tests/general/bug-171.out
create mode 100644 tests/general/bug-171.xsl
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index 58bd6ed..6161376 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -888,11 +888,10 @@ restart:
(node->type == XML_ELEMENT_NODE) &&
(node->parent != NULL)) {
xmlNodePtr previous;
- int ix, nocache = 0;
+ int nocache = 0;
previous = (xmlNodePtr)
XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
- ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
if ((previous != NULL) &&
(previous->parent == node->parent)) {
/*
@@ -904,7 +903,7 @@ restart:
while (sibling != NULL) {
if (sibling == previous)
break;
- if ((previous->type == XML_ELEMENT_NODE) &&
+ if ((sibling->type == XML_ELEMENT_NODE) &&
(previous->name != NULL) &&
(sibling->name != NULL) &&
(previous->name[0] == sibling->name[0]) &&
@@ -925,7 +924,7 @@ restart:
while (sibling != NULL) {
if (sibling == previous)
break;
- if ((previous->type == XML_ELEMENT_NODE) &&
+ if ((sibling->type == XML_ELEMENT_NODE) &&
(previous->name != NULL) &&
(sibling->name != NULL) &&
(previous->name[0] == sibling->name[0]) &&
@@ -943,7 +942,8 @@ restart:
}
}
if (sibling != NULL) {
- pos = ix + indx;
+ pos = XSLT_RUNTIME_EXTRA(ctxt,
+ sel->indexExtra, ival) + indx;
/*
* If the node is in a Value Tree we need to
* save len, but cannot cache the node!
@@ -959,7 +959,6 @@ restart:
sel->indexExtra, ival) = pos;
}
}
- ix = pos;
} else
pos = 0;
} else {
@@ -1020,11 +1019,10 @@ restart:
} else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) &&
(node->type == XML_ELEMENT_NODE)) {
xmlNodePtr previous;
- int ix, nocache = 0;
+ int nocache = 0;
previous = (xmlNodePtr)
XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
- ix = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival);
if ((previous != NULL) &&
(previous->parent == node->parent)) {
/*
@@ -1053,7 +1051,8 @@ restart:
}
}
if (sibling != NULL) {
- pos = ix + indx;
+ pos = XSLT_RUNTIME_EXTRA(ctxt,
+ sel->indexExtra, ival) + indx;
/*
* If the node is in a Value Tree we cannot
* cache it !
diff --git a/tests/docs/bug-171.xml b/tests/docs/bug-171.xml
new file mode 100644
index 0000000..658021b
--- /dev/null
+++ b/tests/docs/bug-171.xml
@@ -0,0 +1,4 @@
+<root>
+ <text>one</text>
+ <text>two</text>
+</root>
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index e33a6c6..7207e15 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -178,6 +178,7 @@ EXTRA_DIST = \
bug-168.out bug-168.xsl \
bug-169.out bug-169.xsl bug-169.imp \
bug-170.out bug-170.xsl \
+ bug-171.out bug-171.xsl \
character.out character.xsl \
character2.out character2.xsl \
itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-171.out b/tests/general/bug-171.out
new file mode 100644
index 0000000..5b87d4f
--- /dev/null
+++ b/tests/general/bug-171.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+two
diff --git a/tests/general/bug-171.xsl b/tests/general/bug-171.xsl
new file mode 100644
index 0000000..25a7c94
--- /dev/null
+++ b/tests/general/bug-171.xsl
@@ -0,0 +1,7 @@
+<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="text[2]">
+ <xsl:value-of select="."/>
+ </xsl:template>
+
+ <xsl:template match="text()"/>
+</xsl:transform>
--
1.7.2.3
>From b60140391ea48ea783d4ee9db3562cfbd6060497 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue, 29 Dec 2009 09:19:50 +0100
Subject: [PATCH 4/8] Small fixes to locale code
---
libxslt/xsltlocale.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/libxslt/xsltlocale.c b/libxslt/xsltlocale.c
index ec03cde..2caa2ec 100644
--- a/libxslt/xsltlocale.c
+++ b/libxslt/xsltlocale.c
@@ -26,9 +26,9 @@
#define LC_COLLATE_MASK (1 << LC_COLLATE)
#endif
-#define ISALPHA(c) ((c & 0xc0) == 0x40 && (unsigned)((c & 0x1f) - 1) < 26)
#define TOUPPER(c) (c & ~0x20)
#define TOLOWER(c) (c | 0x20)
+#define ISALPHA(c) ((unsigned)(TOUPPER(c) - 'A') < 26)
/*without terminating null character*/
#define XSLTMAX_ISO639LANGLEN 8
@@ -97,11 +97,11 @@ xsltNewLocale(const xmlChar *languageTag) {
return(NULL);
llen = i;
- *q++ = '_';
if (*p) {
if (*p++ != '-')
return(NULL);
+ *q++ = '_';
for (i=0; i<XSLTMAX_ISO3166CNTRYLEN && ISALPHA(*p); ++i)
*q++ = TOUPPER(*p++);
@@ -116,7 +116,7 @@ xsltNewLocale(const xmlChar *languageTag) {
/* Continue without using country code */
- q = localeName + llen + 1;
+ q = localeName + llen;
}
/* Try locale without territory, e.g. for Esperanto (eo) */
@@ -135,7 +135,8 @@ xsltNewLocale(const xmlChar *languageTag) {
if (region == NULL)
return(NULL);
- q = localeName + llen + 1;
+ q = localeName + llen;
+ *q++ = '_';
*q++ = region[0];
*q++ = region[1];
memcpy(q, ".utf8", 6);
--
1.7.2.3
>From c03cdd89eda89ea2a493dbce2514bf1526a86901 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Wed, 10 Feb 2010 02:05:41 +0100
Subject: [PATCH 5/8] Allow whitespace in xsl:variable with select
Comments are also allowed
---
libxslt/preproc.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index b47d809..0e39343 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -1844,6 +1844,9 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->select = xsltGetCNsProp(style, inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select != NULL) {
+#ifndef XSLT_REFACTORED
+ xmlNodePtr cur;
+#endif
comp->comp = xsltXPathCompile(style, comp->select);
if (comp->comp == NULL) {
xsltTransformError(NULL, style, inst,
@@ -1851,12 +1854,25 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->select);
style->errors++;
}
+#ifdef XSLT_REFACTORED
if (inst->children != NULL) {
xsltTransformError(NULL, style, inst,
- "XSLT-variable: The must be no child nodes, since the "
+ "XSLT-variable: There must be no child nodes, since the "
"attribute 'select' was specified.\n");
style->errors++;
}
+#else
+ for (cur = inst->children; cur != NULL; cur = cur->next) {
+ if (cur->type != XML_COMMENT_NODE &&
+ (cur->type != XML_TEXT_NODE || !xsltIsBlank(cur->content)))
+ {
+ xsltTransformError(NULL, style, inst,
+ "XSLT-variable: There must be no child nodes, since the "
+ "attribute 'select' was specified.\n");
+ style->errors++;
+ }
+ }
+#endif
}
}
--
1.7.2.3
>From 8be93155f91a0ce4575bfa832994fdf4229ae27d Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Wed, 10 Feb 2010 02:35:09 +0100
Subject: [PATCH 6/8] Fix some warnings in the refactored code
---
libxslt/namespaces.c | 2 +-
libxslt/variables.c | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/libxslt/namespaces.c b/libxslt/namespaces.c
index 3e3891f..48cf039 100644
--- a/libxslt/namespaces.c
+++ b/libxslt/namespaces.c
@@ -585,7 +585,7 @@ declare_new_prefix:
int counter = 1;
if (nsPrefix == NULL) {
- nsPrefix = "ns";
+ nsPrefix = BAD_CAST "ns";
}
do {
diff --git a/libxslt/variables.c b/libxslt/variables.c
index 43a6156..cb0d4b0 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -675,6 +675,9 @@ xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name,
return(NULL);
}
+#ifdef XSLT_REFACTORED
+#else
+
/**
* xsltCheckStackElem:
* @ctxt: xn XSLT transformation context
@@ -710,6 +713,8 @@ xsltCheckStackElem(xsltTransformContextPtr ctxt, const xmlChar *name,
return(1);
}
+#endif /* XSLT_REFACTORED */
+
/**
* xsltAddStackElem:
* @ctxt: xn XSLT transformation context
@@ -1045,7 +1050,11 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt)
#endif
oldInst = ctxt->inst;
+#ifdef XSLT_REFACTORED
+ comp = (xsltStyleBasicItemVariablePtr) elem->comp;
+#else
comp = elem->comp;
+#endif
oldVarName = elem->name;
elem->name = xsltComputingGlobalVarMarker;
/*
--
1.7.2.3
>From 47857dc971b83df70aba821787da6c75b57f3162 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Sun, 25 Apr 2010 23:26:20 +0200
Subject: [PATCH 7/8] Precompile patterns in xsl:number
---
libxslt/numbers.c | 55 ++++++++++++-------------------------------
libxslt/numbersInternals.h | 6 +++-
libxslt/preproc.c | 20 ++++++++++++---
3 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/libxslt/numbers.c b/libxslt/numbers.c
index 8683ca8..90e536b 100644
--- a/libxslt/numbers.c
+++ b/libxslt/numbers.c
@@ -534,8 +534,8 @@ xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
static int
xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
xmlNodePtr node,
- const xmlChar *count,
- const xmlChar *from,
+ xsltCompMatchPtr countPat,
+ xsltCompMatchPtr fromPat,
double *array,
xmlDocPtr doc,
xmlNodePtr elem)
@@ -543,14 +543,7 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
int amount = 0;
int cnt = 0;
xmlNodePtr cur;
- xsltCompMatchPtr countPat = NULL;
- xsltCompMatchPtr fromPat = NULL;
- if (count != NULL)
- countPat = xsltCompilePattern(count, doc, elem, NULL, context);
- if (from != NULL)
- fromPat = xsltCompilePattern(from, doc, elem, NULL, context);
-
/* select the starting node */
switch (node->type) {
case XML_ELEMENT_NODE:
@@ -571,7 +564,7 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
while (cur != NULL) {
/* process current node */
- if (count == NULL) {
+ if (countPat == NULL) {
if ((node->type == cur->type) &&
/* FIXME: must use expanded-name instead of local name */
xmlStrEqual(node->name, cur->name)) {
@@ -586,7 +579,7 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
if (xsltTestCompMatchList(context, cur, countPat))
cnt++;
}
- if ((from != NULL) &&
+ if ((fromPat != NULL) &&
xsltTestCompMatchList(context, cur, fromPat)) {
break; /* while */
}
@@ -613,18 +606,14 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
array[amount++] = (double) cnt;
- if (countPat != NULL)
- xsltFreeCompMatchList(countPat);
- if (fromPat != NULL)
- xsltFreeCompMatchList(fromPat);
return(amount);
}
static int
xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
xmlNodePtr node,
- const xmlChar *count,
- const xmlChar *from,
+ xsltCompMatchPtr countPat,
+ xsltCompMatchPtr fromPat,
double *array,
int max,
xmlDocPtr doc,
@@ -635,17 +624,7 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
xmlNodePtr ancestor;
xmlNodePtr preceding;
xmlXPathParserContextPtr parser;
- xsltCompMatchPtr countPat;
- xsltCompMatchPtr fromPat;
-
- if (count != NULL)
- countPat = xsltCompilePattern(count, doc, elem, NULL, context);
- else
- countPat = NULL;
- if (from != NULL)
- fromPat = xsltCompilePattern(from, doc, elem, NULL, context);
- else
- fromPat = NULL;
+
context->xpathCtxt->node = node;
parser = xmlXPathNewParserContext(NULL, context->xpathCtxt);
if (parser) {
@@ -654,11 +633,11 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
(ancestor != NULL) && (ancestor->type != XML_DOCUMENT_NODE);
ancestor = xmlXPathNextAncestor(parser, ancestor)) {
- if ((from != NULL) &&
+ if ((fromPat != NULL) &&
xsltTestCompMatchList(context, ancestor, fromPat))
break; /* for */
- if ((count == NULL && node->type == ancestor->type &&
+ if ((countPat == NULL && node->type == ancestor->type &&
xmlStrEqual(node->name, ancestor->name)) ||
xsltTestCompMatchList(context, ancestor, countPat)) {
/* count(preceding-sibling::*) */
@@ -667,7 +646,7 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
preceding != NULL;
preceding =
xmlXPathNextPrecedingSibling(parser, preceding)) {
- if (count == NULL) {
+ if (countPat == NULL) {
if ((preceding->type == ancestor->type) &&
xmlStrEqual(preceding->name, ancestor->name)){
if ((preceding->ns == ancestor->ns) ||
@@ -690,8 +669,6 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
}
xmlXPathFreeParserContext(parser);
}
- xsltFreeCompMatchList(countPat);
- xsltFreeCompMatchList(fromPat);
return amount;
}
@@ -779,8 +756,8 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
if (xmlStrEqual(data->level, (const xmlChar *) "single")) {
amount = xsltNumberFormatGetMultipleLevel(ctxt,
node,
- data->count,
- data->from,
+ data->countPat,
+ data->fromPat,
&number,
1,
data->doc,
@@ -797,8 +774,8 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
int max = sizeof(numarray)/sizeof(numarray[0]);
amount = xsltNumberFormatGetMultipleLevel(ctxt,
node,
- data->count,
- data->from,
+ data->countPat,
+ data->fromPat,
numarray,
max,
data->doc,
@@ -813,8 +790,8 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
} else if (xmlStrEqual(data->level, (const xmlChar *) "any")) {
amount = xsltNumberFormatGetAnyLevel(ctxt,
node,
- data->count,
- data->from,
+ data->countPat,
+ data->fromPat,
&number,
data->doc,
data->node);
diff --git a/libxslt/numbersInternals.h b/libxslt/numbersInternals.h
index 7b3cb17..83f7d4f 100644
--- a/libxslt/numbersInternals.h
+++ b/libxslt/numbersInternals.h
@@ -17,6 +17,8 @@
extern "C" {
#endif
+struct _xsltCompMatch;
+
/**
* xsltNumberData:
*
@@ -27,8 +29,6 @@ typedef xsltNumberData *xsltNumberDataPtr;
struct _xsltNumberData {
const xmlChar *level;
- const xmlChar *count;
- const xmlChar *from;
const xmlChar *value;
const xmlChar *format;
int has_format;
@@ -37,6 +37,8 @@ struct _xsltNumberData {
int groupingCharacterLen;
xmlDocPtr doc;
xmlNodePtr node;
+ struct _xsltCompMatch *countPat;
+ struct _xsltCompMatch *fromPat;
/*
* accelerators
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index 0e39343..81afa67 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -39,6 +39,7 @@
#include "extra.h"
#include "imports.h"
#include "extensions.h"
+#include "pattern.h"
#ifdef WITH_XSLT_DEBUG
#define WITH_XSLT_DEBUG_PREPROC
@@ -420,6 +421,10 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
}
break;
case XSLT_FUNC_NUMBER:
+ if (item->numdata.countPat != NULL)
+ xsltFreeCompMatchList(item->numdata.countPat);
+ if (item->numdata.fromPat != NULL)
+ xsltFreeCompMatchList(item->numdata.fromPat);
break;
case XSLT_FUNC_APPLYIMPORTS:
break;
@@ -1436,10 +1441,17 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
comp->numdata.format = prop;
}
- comp->numdata.count = xsltGetCNsProp(style, cur, (const xmlChar *)"count",
- XSLT_NAMESPACE);
- comp->numdata.from = xsltGetCNsProp(style, cur, (const xmlChar *)"from",
- XSLT_NAMESPACE);
+ prop = xsltGetCNsProp(style, cur, (const xmlChar *)"count", XSLT_NAMESPACE);
+ if (prop != NULL) {
+ comp->numdata.countPat = xsltCompilePattern(prop, cur->doc, cur, style,
+ NULL);
+ }
+
+ prop = xsltGetCNsProp(style, cur, (const xmlChar *)"from", XSLT_NAMESPACE);
+ if (prop != NULL) {
+ comp->numdata.fromPat = xsltCompilePattern(prop, cur->doc, cur, style,
+ NULL);
+ }
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"level", XSLT_NAMESPACE);
if (prop != NULL) {
--
1.7.2.3
>From 0dea1176d6818058e28f21f7b72e818ceff52b94 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue, 29 Jun 2010 19:48:19 +0200
Subject: [PATCH 8/8] Fix curlies in literals for non-compiled AVTs
---
libxslt/templates.c | 12 +++++++++++-
tests/REC/Makefile.am | 1 +
tests/REC/test-7.6.2-2.out | 2 ++
tests/REC/test-7.6.2-2.xml | 1 +
tests/REC/test-7.6.2-2.xsl | 6 ++++++
5 files changed, 21 insertions(+), 1 deletions(-)
create mode 100644 tests/REC/test-7.6.2-2.out
create mode 100644 tests/REC/test-7.6.2-2.xml
create mode 100644 tests/REC/test-7.6.2-2.xsl
diff --git a/libxslt/templates.c b/libxslt/templates.c
index c6250dc..52bb3cf 100644
--- a/libxslt/templates.c
+++ b/libxslt/templates.c
@@ -279,7 +279,17 @@ xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
ret = xmlStrncat(ret, str, cur - str);
str = cur;
cur++;
- while ((*cur != 0) && (*cur != '}')) cur++;
+ while ((*cur != 0) && (*cur != '}')) {
+ /* Need to check for literal (bug539741) */
+ if ((*cur == '\'') || (*cur == '"')) {
+ char delim = *(cur++);
+ while ((*cur != 0) && (*cur != delim))
+ cur++;
+ if (*cur != 0)
+ cur++; /* skip the ending delimiter */
+ } else
+ cur++;
+ }
if (*cur == 0) {
xsltTransformError(ctxt, NULL, inst,
"xsltAttrTemplateValueProcessNode: unmatched '{'\n");
diff --git a/tests/REC/Makefile.am b/tests/REC/Makefile.am
index 9e228b5..0e299d2 100644
--- a/tests/REC/Makefile.am
+++ b/tests/REC/Makefile.am
@@ -65,6 +65,7 @@ EXTRA_DIST = \
test-7.6.1-2.out test-7.6.1-2.xml test-7.6.1-2.xsl \
test-7.6.1-3.out test-7.6.1-3.xml test-7.6.1-3.xsl \
test-7.6.2-1.out test-7.6.2-1.xml test-7.6.2-1.xsl \
+ test-7.6.2-2.out test-7.6.2-2.xml test-7.6.2-2.xsl \
test-7.7-1.out test-7.7-1.xml test-7.7-1.xsl \
test-7.7-2.out test-7.7-2.xml test-7.7-2.xsl \
test-7.7-3.out test-7.7-3.xml test-7.7-3.xsl \
diff --git a/tests/REC/test-7.6.2-2.out b/tests/REC/test-7.6.2-2.out
new file mode 100644
index 0000000..f9301e8
--- /dev/null
+++ b/tests/REC/test-7.6.2-2.out
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<abc/>
diff --git a/tests/REC/test-7.6.2-2.xml b/tests/REC/test-7.6.2-2.xml
new file mode 100644
index 0000000..69d62f2
--- /dev/null
+++ b/tests/REC/test-7.6.2-2.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/REC/test-7.6.2-2.xsl b/tests/REC/test-7.6.2-2.xsl
new file mode 100644
index 0000000..c6f3aba
--- /dev/null
+++ b/tests/REC/test-7.6.2-2.xsl
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:template match="/">
+ <xsl:element name="{substring('abc}', 1, 3)}"/>
+ </xsl:template>
+</xsl:stylesheet>
--
1.7.2.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]