grchiu      2003/06/25 14:54:18

  Modified:    java/src/org/apache/xpath NodeSet.java
  Log:
  Patch from John Lambe ([EMAIL PROTECTED]) for bugzilla 20819
  with some modifications. removeElement() and removeElementAt() were
  not removing nodes correctly.
  
  Revision  Changes    Path
  1.19      +13 -8     xml-xalan/java/src/org/apache/xpath/NodeSet.java
  
  Index: NodeSet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSet.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- NodeSet.java      30 Jan 2003 18:46:22 -0000      1.18
  +++ NodeSet.java      25 Jun 2003 21:54:18 -0000      1.19
  @@ -1248,12 +1248,11 @@
   
         if ((null != node) && node.equals(s))
         {
  -        if (i > m_firstFree)
  -          System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
  -        else
  -          m_map[i] = null;
  +        if (i < m_firstFree - 1)
  +          System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1);
   
           m_firstFree--;
  +        m_map[m_firstFree] = null;
   
           return true;
         }
  @@ -1275,11 +1274,17 @@
   
       if (null == m_map)
         return;
  +      
  +    if (i >= m_firstFree)
  +      throw new ArrayIndexOutOfBoundsException(i + " >= " + m_firstFree);
  +    else if (i < 0)
  +      throw new ArrayIndexOutOfBoundsException(i);
   
  -    if (i > m_firstFree)
  -      System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
  -    else
  -      m_map[i] = null;
  +    if (i < m_firstFree - 1)
  +      System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1);
  +
  +    m_firstFree--;
  +    m_map[m_firstFree] = null;
     }
   
     /**
  
  
  

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

Reply via email to