dbertoni 02/03/07 21:11:31
Modified: c/src/XPath XPathProcessorImpl.cpp
Log:
Removed any leading "//" when parsing match patterns. Cheap fix for bug 4804.
Revision Changes Path
1.51 +36 -7 xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
Index: XPathProcessorImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- XPathProcessorImpl.cpp 7 Mar 2002 05:44:51 -0000 1.50
+++ XPathProcessorImpl.cpp 8 Mar 2002 05:11:31 -0000 1.51
@@ -166,6 +166,24 @@
nextToken();
+ // This is an optimization, but it's mostly a hacky
+ // bug fix. We don't handle match patterns with
+ // leading "//" correctly. Since the semantics
+ // of a match pattern with "//" are identical to
+ // those of one without "//", there's no point
+ // in even encoding them, so we just re-parse
+ // the XPath stripping off the leading "//".
+ // Parsing once _with_ the "//" ensures that
+ // we detect any errors with the unmodified
+ // match pattern.
+ bool fStripAndReparse = false;
+
+ if (tokenIs(XalanUnicode::charSolidus) == true &&
+ lookahead(XalanUnicode::charSolidus, 1) == true)
+ {
+ fStripAndReparse = true;
+ }
+
Pattern();
if (length(m_token) != 0)
@@ -173,15 +191,26 @@
error("Extra illegal tokens!");
}
- // Terminate for safety.
- m_expression->appendOpCode(XPathExpression::eENDOP);
+ if (fStripAndReparse == true)
+ {
+ initMatchPattern(
+ pathObj,
+ substring(expression, 2),
+ prefixResolver,
+ locator);
+ }
+ else
+ {
+ // Terminate for safety.
+ m_expression->appendOpCode(XPathExpression::eENDOP);
- m_expression->shrink();
+ m_expression->shrink();
- m_xpath = 0;
- m_expression = 0;
- m_prefixResolver = 0;
- m_locator = 0;
+ m_xpath = 0;
+ m_expression = 0;
+ m_prefixResolver = 0;
+ m_locator = 0;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]