[libxslt] Fix direct pattern matching bug



commit 2a697a5819f8b22fc7541aae82aacf8b70135a93
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Mon Nov 8 10:42:33 2010 +0100

    Fix direct pattern matching bug
    
    and adds a test case for the problem,
    also adding a .gitignore cleanup

 .gitignore                |    1 +
 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 ++++++
 6 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 978f506..d920d49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -143,3 +143,4 @@ tests/XSLTMark/db10000.xml
 tests/plugins/.libs
 tests/plugins/plugin.res
 xsltproc/testThreads
+xsltproc/.libs/
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>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]