You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by tm...@apache.org on 2002/03/06 17:28:12 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/runtime AbstractTranslet.java

tmiller     02/03/06 08:28:12

  Modified:    java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java
  Log:
  bug fixes for 6257,6851,6665,6809; Santiago Pericas-Geerston
  
  Revision  Changes    Path
  1.32      +36 -48    xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- AbstractTranslet.java	10 Dec 2001 10:15:12 -0000	1.31
  +++ AbstractTranslet.java	6 Mar 2002 16:28:12 -0000	1.32
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AbstractTranslet.java,v 1.31 2001/12/10 10:15:12 morten Exp $
  + * @(#)$Id: AbstractTranslet.java,v 1.32 2002/03/06 16:28:12 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -143,44 +143,15 @@
        */
       public final void popParamFrame() {
   	if (pbase > 0) {
  -	    int bot = pbase - 1;
  -	    int top = pframe - 1;
  -	    pframe = pbase - 1;
  -	    pbase = ((Integer) paramsStack.elementAt(pframe)).intValue();
  -	    // bug fix #3424, John Howard.
  -	    // remove objects that are in the stack since objects are	
  -	    // added with insertElementAt(int) and will cause memory retention
  -	    for (int i=top; i>=bot; i--) {
  -		paramsStack.removeElementAt(i);
  +	    final int oldpbase = ((Integer)paramsStack.elementAt(--pbase)).intValue();
  +	    for (int i = pbase; i < pframe; i++) {
  +		paramsStack.setElementAt(null, i);	// for the GC
   	    }
  +	    pframe = pbase; pbase = oldpbase;
   	}
       }
   
       /**
  -     * Replace a certain character in a string with a new substring.
  -     */
  -    private static String replace(String base, char c, String str) {
  -	final int len = base.length() - 1;
  -	int pos;
  -	while ((pos = base.indexOf(c)) > -1) {
  -	    if (pos == 0) {
  -		final String after = base.substring(1);
  -		base = str + after;
  -	    }
  -	    else if (pos == len) {
  -		final String before = base.substring(0, pos);
  -		base = before + str;
  -	    }
  -	    else {
  -		final String before = base.substring(0, pos);
  -		final String after = base.substring(pos+1);
  -		base = before + str + after;
  -	    }
  -	}
  -	return base;
  -    }
  -
  -    /**
        * Add a new global parameter if not already in the current frame.
        */
       public final Object addParameter(String name, Object value) {
  @@ -224,6 +195,7 @@
        * Clears the parameter stack.
        */
       public void clearParameters() {  
  +	pbase = pframe = 0;
   	paramsStack.clear();
       }
   
  @@ -246,6 +218,7 @@
   	varsStack.insertElementAt(new Integer(vbase), vframe);
   	vbase = ++vframe;
   	vframe += frameSize;
  +	varsStack.setSize(vframe + 1);	// clear stack frame
       }
   
       /**
  @@ -253,16 +226,11 @@
        */
       public final void popVarFrame() {
   	if (vbase > 0) {
  -	    int bot = vbase - 1;
  -	    int top = vframe - 1;
  -	    vframe = vbase - 1;
  -	    vbase = ((Integer)varsStack.elementAt(vframe)).intValue();
  -	    // bug fix 3424, John Howard
  -	    // remove objects that are in the stack since objects are	
  -	    // added with insertElementAt(int) and will cause memory retention
  -	    for (int i=top; i>=bot; i--) {
  -		varsStack.removeElementAt(i);
  +	    final int oldvbase = ((Integer)varsStack.elementAt(--vbase)).intValue();
  +	    for (int i = vbase; i < vframe; i++) {
  +		varsStack.setElementAt(null, i);	// for the GC
   	    }
  +	    vframe = vbase; vbase = oldvbase;
   	}
       }
   
  @@ -270,18 +238,38 @@
        * Get the value of a variable given its index.
        */
       public final Object getVariable(int vindex) {
  -	// bug fix 3424, John Howard
   	return varsStack.elementAt(vbase + vindex);
       }
   	
  -
       /**
        * Set the value of a variable in the current frame.
        */
       public final void addVariable(int vindex, Object value) {
  -	final int index = vbase + vindex;
  -	if (index > varsStack.size()) varsStack.setSize(index);
  -	varsStack.insertElementAt(value, index);
  +	varsStack.setElementAt(value, vbase + vindex);
  +    }
  +
  +    /**
  +     * Replace a certain character in a string with a new substring.
  +     */
  +    private static String replace(String base, char c, String str) {
  +	final int len = base.length() - 1;
  +	int pos;
  +	while ((pos = base.indexOf(c)) > -1) {
  +	    if (pos == 0) {
  +		final String after = base.substring(1);
  +		base = str + after;
  +	    }
  +	    else if (pos == len) {
  +		final String before = base.substring(0, pos);
  +		base = before + str;
  +	    }
  +	    else {
  +		final String before = base.substring(0, pos);
  +		final String after = base.substring(pos+1);
  +		base = before + str + after;
  +	    }
  +	}
  +	return base;
       }
   
       /************************************************************************
  
  
  

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