dbertoni    02/02/18 14:30:28

  Modified:    c/src/XSLT VariablesStack.cpp VariablesStack.hpp
  Log:
  Return an index into the stack, instead of a pointer to an entry (bug 6505).
  
  Revision  Changes    Path
  1.22      +26 -17    xml-xalan/c/src/XSLT/VariablesStack.cpp
  
  Index: VariablesStack.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- VariablesStack.cpp        20 Dec 2001 04:20:52 -0000      1.21
  +++ VariablesStack.cpp        18 Feb 2002 22:30:28 -0000      1.22
  @@ -78,7 +78,7 @@
        m_currentStackFrameIndex(0),
        m_guardStack()
   {
  -     m_stack.reserve(eDefaultStackSize);
  +//   m_stack.reserve(eDefaultStackSize);
   }
   
   
  @@ -381,10 +381,15 @@
                        bool                                                    
fSearchGlobalSpace,
                        bool&                                                   
fNameFound)
   {
  -     StackEntry* const       theEntry =
  +     typedef VariableStackStackType::size_type       size_type;
  +
  +     // findEntry() returns an index into the stack.  We should
  +     // _never_ take the address of anything in the stack, since
  +     // the address could change at unexpected times.
  +     size_type       theEntryIndex =
                findEntry(name, fIsParam, fSearchGlobalSpace);
   
  -     if (theEntry == 0)
  +     if (theEntryIndex == m_stack.size())
        {
                fNameFound = false;
   
  @@ -392,13 +397,15 @@
        }
        else
        {
  +             assert(theEntryIndex < m_stack.size());
  +
                fNameFound = true;
   
  -             assert(theEntry->getType() == StackEntry::eVariable ||
  -                        theEntry->getType() == StackEntry::eParam ||
  -                        theEntry->getType() == StackEntry::eActiveParam);
  +             assert(m_stack[theEntryIndex].getType() == 
StackEntry::eVariable ||
  +                        m_stack[theEntryIndex].getType() == 
StackEntry::eParam ||
  +                        m_stack[theEntryIndex].getType() == 
StackEntry::eActiveParam);
   
  -             const XObjectPtr&       theValue = theEntry->getValue();
  +             const XObjectPtr&       theValue = 
m_stack[theEntryIndex].getValue();
   
                if (theValue.null() == false)
                {
  @@ -406,7 +413,7 @@
                }
                else
                {
  -                     const ElemVariable* const       var = 
theEntry->getVariable();
  +                     const ElemVariable* const       var = 
m_stack[theEntryIndex].getVariable();
   
                        XObjectPtr                                      
theNewValue;
   
  @@ -442,8 +449,8 @@
   
                                m_guardStack.pop_back();
   
  -                             theEntry->setValue(theNewValue);
  -                             theEntry->activate();
  +                             m_stack[theEntryIndex].setValue(theNewValue);
  +                             m_stack[theEntryIndex].activate();
                        }
   
                        return theNewValue;
  @@ -453,13 +460,15 @@
   
   
   
  -VariablesStack::StackEntry*
  +VariablesStack::VariableStackStackType::size_type
   VariablesStack::findEntry(
                        const XalanQName&       qname,
                        bool                            fIsParam,
                        bool                            fSearchGlobalSpace)
   {
  -     StackEntry*             theResult = 0;
  +     typedef VariableStackStackType::size_type       size_type;
  +
  +     size_type       theEntryIndex = m_stack.size();
   
        const unsigned int      nElems = getCurrentStackFrameIndex();
   
  @@ -479,7 +488,7 @@
   
                        if(theEntry.getName()->equals(qname))
                        {
  -                             theResult = &theEntry;
  +                             theEntryIndex = size_type(i);
   
                                break;
                        }
  @@ -492,7 +501,7 @@
                                {
                                        theEntry.activate();
   
  -                                     theResult = &theEntry;
  +                                     theEntryIndex = size_type(i);
   
                                        break;
                                }
  @@ -504,7 +513,7 @@
                }
        }
   
  -     if(0 == theResult && fIsParam == false && true == fSearchGlobalSpace && 
m_globalStackFrameIndex > 1)
  +     if(theEntryIndex == m_stack.size() && fIsParam == false && true == 
fSearchGlobalSpace && m_globalStackFrameIndex > 1)
        {
                // Look in the global space
                for(unsigned int i = m_globalStackFrameIndex - 1; i > 0; i--)
  @@ -519,7 +528,7 @@
   
                                if(theEntry.getName()->equals(qname))
                                {
  -                                     theResult = &theEntry;
  +                                     theEntryIndex = size_type(i);
   
                                        break;
                                }
  @@ -531,7 +540,7 @@
                }
        }
   
  -     return theResult;
  +     return theEntryIndex;
   }
   
   
  
  
  
  1.16      +1 -1      xml-xalan/c/src/XSLT/VariablesStack.hpp
  
  Index: VariablesStack.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.hpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- VariablesStack.hpp        20 Dec 2001 04:20:52 -0000      1.15
  +++ VariablesStack.hpp        18 Feb 2002 22:30:28 -0000      1.16
  @@ -564,7 +564,7 @@
                        bool                                                    
fSearchGlobalSpace,
                        bool&                                                   
fNameFound);
   
  -     StackEntry*
  +     VariableStackStackType::size_type
        findEntry(
                        const XalanQName&       name,
                        bool                            fIsParam,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to