You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2001/02/05 23:47:44 UTC

cvs commit: xml-xalan/c/src/XPath SimpleNodeLocator.cpp XPathExpression.cpp XPathExpression.hpp XPathProcessorImpl.cpp

dbertoni    01/02/05 14:47:44

  Modified:    c/src/XPath SimpleNodeLocator.cpp XPathExpression.cpp
                        XPathExpression.hpp XPathProcessorImpl.cpp
  Log:
  Fix for bug with patterns of the form IdkeyPattern//RelativePathPattern
  
  Revision  Changes    Path
  1.33      +43 -9     xml-xalan/c/src/XPath/SimpleNodeLocator.cpp
  
  Index: SimpleNodeLocator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/SimpleNodeLocator.cpp,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- SimpleNodeLocator.cpp	2001/01/26 16:23:14	1.32
  +++ SimpleNodeLocator.cpp	2001/02/05 22:47:43	1.33
  @@ -352,7 +352,10 @@
   
   		scoreHolder = xpath.s_MatchScoreOther;
   
  -		localContext = DOMServices::getParentOfNode(*localContext);
  +		if (nextStepType != XPathExpression::eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL)
  +		{
  +			localContext = DOMServices::getParentOfNode(*localContext);
  +		}
   
   		if(0 == localContext)
   		{
  @@ -369,6 +372,10 @@
   
   	switch(stepType)
   	{
  +	case XPathExpression::eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL:
  +		score = scoreHolder;
  +		break;
  +
   	case XPathExpression::eOP_FUNCTION:
   		{
   			argLen = currentExpression.getOpCodeLength(opPos);
  @@ -382,18 +389,45 @@
   
   			score = xpath.s_MatchScoreNone;
   
  -			for(unsigned int i = 0; i < len; i++)
  +			if (nextStepType == XPathExpression::eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL)
   			{
  -				XalanNode* const	n = nl.item(i);
  -
  -				score = n == localContext ?
  -					xpath.s_MatchScoreOther : xpath.s_MatchScoreNone;
  +				bool	fFound = false;
   
  -				if(score == xpath.s_MatchScoreOther)
  +				while(localContext != 0 && fFound == false)
   				{
  -					localContext = n;
  +					for(unsigned int i = 0; i < len; i++)
  +					{
  +						XalanNode* const	n = nl.item(i);
  +
  +						if(n == localContext)
  +						{
  +							score = xpath.s_MatchScoreOther;
  +
  +							localContext = n;
  +
  +							fFound = true;
  +
  +							break;
  +						}
  +					}
  +
  +					localContext = DOMServices::getParentOfNode(*localContext);
  +				}
  +			}
  +			else
  +			{
  +				for(unsigned int i = 0; i < len; i++)
  +				{
  +					XalanNode* const	n = nl.item(i);
  +
  +					if(n == localContext)
  +					{
  +						score = xpath.s_MatchScoreOther;
  +
  +						localContext = n;
   
  -					break;
  +						break;
  +					}
   				}
   			}
   		}
  
  
  
  1.26      +1 -10     xml-xalan/c/src/XPath/XPathExpression.cpp
  
  Index: XPathExpression.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- XPathExpression.cpp	2001/01/29 02:35:39	1.25
  +++ XPathExpression.cpp	2001/02/05 22:47:44	1.26
  @@ -851,11 +851,6 @@
   	theMap[eFROM_PRECEDING_SIBLINGS] = 2 + s__opCodeMapLengthIndex;
   	theMap[eFROM_SELF] = 2 + s__opCodeMapLengthIndex;
   	theMap[eFROM_NAMESPACE] = 2 + s__opCodeMapLengthIndex;
  -//	theMap[eFROM_ATTRIBUTE] = -1;
  -//	theMap[eFROM_DOC] = -1;
  -//	theMap[eFROM_DOCREF] = -1;
  -//	theMap[eFROM_ID] = -1;
  -//	theMap[eFROM_IDREF] = -1;
   	theMap[eFROM_ROOT] = 2 + s__opCodeMapLengthIndex;
   	theMap[eOP_MATCHPATTERN] = 1 + s__opCodeMapLengthIndex;
   	theMap[eOP_LOCATIONPATHPATTERN] = 1 + s__opCodeMapLengthIndex;
  @@ -863,6 +858,7 @@
   	theMap[eMATCH_ANY_ANCESTOR] = 1 + s__opCodeMapLengthIndex;
   	theMap[eMATCH_IMMEDIATE_ANCESTOR] = 1 + s__opCodeMapLengthIndex;
   	theMap[eMATCH_ANY_ANCESTOR_WITH_PREDICATE] = 2 + s__opCodeMapLengthIndex;
  +	theMap[eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL] = 2 + s__opCodeMapLengthIndex;
   
   	return theMap;
   }
  @@ -893,11 +889,6 @@
   	theSet.insert(eFROM_PRECEDING_SIBLINGS);
   	theSet.insert(eFROM_SELF);
   	theSet.insert(eFROM_NAMESPACE);
  -	// theSet.insert(eFROM_ATTRIBUTE);
  -	// theSet.insert(eFROM_DOC);
  -	// theSet.insert(eFROM_DOCREF);
  -	// theSet.insert(eFROM_ID);
  -	// theSet.insert(eFROM_IDREF);
   	theSet.insert(eFROM_ROOT);
   	theSet.insert(eOP_OR);
   
  
  
  
  1.15      +1 -0      xml-xalan/c/src/XPath/XPathExpression.hpp
  
  Index: XPathExpression.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.hpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XPathExpression.hpp	2001/01/26 01:23:03	1.14
  +++ XPathExpression.hpp	2001/02/05 22:47:44	1.15
  @@ -596,6 +596,7 @@
   		eMATCH_ANY_ANCESTOR = 95,
   		eMATCH_IMMEDIATE_ANCESTOR = 96,
   		eMATCH_ANY_ANCESTOR_WITH_PREDICATE = 97,
  +		eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL = 98,
   
   		// Always add _before_ this one.
   		eOpCodeNextAvailable
  
  
  
  1.34      +1 -3      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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- XPathProcessorImpl.cpp	2001/01/31 01:40:33	1.33
  +++ XPathProcessorImpl.cpp	2001/02/05 22:47:44	1.34
  @@ -2246,10 +2246,8 @@
   			// Tell how long the step is without the predicate
   			const XPathExpression::OpCodeMapValueVectorType		theArgs(1, 4);
   
  -			m_expression->appendOpCode(XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE,
  +			m_expression->appendOpCode(XPathExpression::eMATCH_ANY_ANCESTOR_WITH_FUNCTION_CALL,
   									   theArgs);
  -
  -			m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
   
   			m_expression->updateOpCodeLength(newOpPos);