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 2002/06/20 03:01:22 UTC

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

dbertoni    2002/06/19 18:01:22

  Modified:    c/src/XPath XPathProcessorImpl.cpp
  Log:
  Fixed bug with patterns starting with //, and removed work-around hack.
  
  Revision  Changes    Path
  1.56      +21 -43    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.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- XPathProcessorImpl.cpp	19 Jun 2002 21:00:54 -0000	1.55
  +++ XPathProcessorImpl.cpp	20 Jun 2002 01:01:22 -0000	1.56
  @@ -171,24 +171,6 @@
   
   	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)
  @@ -196,27 +178,16 @@
   		error("Extra illegal tokens!");
   	}
   
  -	if (fStripAndReparse == true)
  -	{
  -		initMatchPattern(
  -			pathObj,
  -			XalanDOMString(expression, 2, expression.length() - 2),
  -			prefixResolver,
  -			locator);
  -	}
  -	else
  -	{
  -		// Terminate for safety.
  -		m_expression->appendOpCode(XPathExpression::eENDOP);
  +	// 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_positionPredicateStack.clear();
  -	}
  +	m_xpath = 0;
  +	m_expression = 0;
  +	m_prefixResolver = 0;
  +	m_locator = 0;
  +	m_positionPredicateStack.clear();
   }
   
   
  @@ -2353,16 +2324,21 @@
   
   		if(lookahead(XalanUnicode::charSolidus, 1) == true)
   		{
  -			m_expression->appendOpCode(XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE,
  -									   theArgs);
  +			m_expression->appendOpCode(
  +				XPathExpression::eMATCH_ANY_ANCESTOR_WITH_PREDICATE,
  +				theArgs);
  +
  +			m_expression->appendOpCode(XPathExpression::eNODETYPE_NODE);
  +
  +			nextToken();
   		}
   		else
   		{
   			m_expression->appendOpCode(XPathExpression::eFROM_ROOT,
   									   theArgs);
  -		}
   
  -		m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
  +			m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
  +		}
   
   		m_expression->updateOpCodeLength(newOpPos);
   
  @@ -2465,9 +2441,11 @@
   	}
   	else if(tokenIs(XalanUnicode::charSolidus) == true)
   	{
  +		matchTypePos = m_expression->opCodeMapLength();
  +
   		if(lookahead(s_axisString, 2) == false)
   		{
  -			axisType = XPathExpression::eMATCH_ANY_ANCESTOR;
  +			axisType = XPathExpression::eMATCH_IMMEDIATE_ANCESTOR;
   
   			m_expression->appendOpCode(axisType);
   		}
  @@ -2483,7 +2461,7 @@
   			}
   			else if(tokenIs(s_childString) == true)
   			{
  -				axisType = XPathExpression::eMATCH_ANY_ANCESTOR;
  +				axisType = XPathExpression::eMATCH_IMMEDIATE_ANCESTOR;
   
   				m_expression->appendOpCode(axisType);
   			}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org