tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsandb...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/tester/web/golden SSIConfig03.txt SSIFsize02.txt SSIInclude01.txt
Date Wed, 05 Jun 2002 19:09:18 GMT
dsandberg    2002/06/05 12:09:18

  Modified:    catalina/src/share/org/apache/catalina/ssi SSIFsize.java
               tester/web/golden SSIConfig03.txt SSIFsize02.txt
                        SSIInclude01.txt
  Log:
  Updated golden tester files to match Apache output for SSI.
  Modified SSIFsize so behavior matches Apache output for SSI.
  SSITest now passed by both Apache and Catalina
  
  Revision  Changes    Path
  1.2       +34 -6     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi/SSIFsize.java
  
  Index: SSIFsize.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi/SSIFsize.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SSIFsize.java	24 May 2002 04:38:58 -0000	1.1
  +++ SSIFsize.java	5 Jun 2002 19:09:17 -0000	1.2
  @@ -1,8 +1,8 @@
   /*
    * SSIFsize.java
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi/SSIFsize.java,v
1.1 2002/05/24 04:38:58 billbarker Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/05/24 04:38:58 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi/SSIFsize.java,v
1.2 2002/06/05 19:09:17 dsandberg Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/06/05 19:09:17 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    *
    * @author Bip Thelin
    * @author Dan Sandberg
  - * @version $Revision: 1.1 $, $Date: 2002/05/24 04:38:58 $
  + * @version $Revision: 1.2 $, $Date: 2002/06/05 19:09:17 $
    */
   public final class SSIFsize implements SSICommand {
       protected final static int ONE_KILOBYTE = 1024;
  @@ -110,7 +110,31 @@
   	}
       }
   
  +    public String repeat( char aChar, int numChars ) {
  +	if ( numChars < 0 ) {
  +	    throw new IllegalArgumentException("Num chars can't be negative");
  +	}
  +	StringBuffer buf = new StringBuffer();
  +	for ( int i=0; i < numChars; i++ ) {
  +	    buf.append( aChar );
  +	}
  +	return buf.toString();
  +    }
  +
  +    public String padLeft( String str, int maxChars ) {
  +	String result = str;
  +	int charsToAdd = maxChars - str.length();
  +	if ( charsToAdd > 0 ) {
  +	    result = repeat( ' ', charsToAdd ) + str;
  +	}
  +	return result;
  +    }
  +
  +
  +
  +
       //We try to mimick Apache here, as we do everywhere
  +    //All the 'magic' numbers are from the util_script.c Apache source file.
       protected String formatSize(long size, String format) {
           String retString = "";
   
  @@ -119,16 +143,20 @@
   	    retString = decimalFormat.format( size );
           } else {
   	    if ( size == 0 ) {
  -		retString = " 0k";
  +		retString = "0k";
               } else if ( size < ONE_KILOBYTE ) {
  -		retString = " 1k";
  +		retString = "1k";
   	    } else if ( size < ONE_MEGABYTE ) {
  -		DecimalFormat decimalFormat = new DecimalFormat(" 0k");
  -		retString = decimalFormat.format( size  / (double) ONE_KILOBYTE );
  -            } else {
  -		DecimalFormat decimalFormat = new DecimalFormat(" #,##0.0M");
  +		retString = Long.toString( (size + 512) / ONE_KILOBYTE );
  +		retString += "k";
  +            } else if ( size  < 99 * ONE_MEGABYTE ) {
  +		DecimalFormat decimalFormat = new DecimalFormat("0.0M");
   		retString = decimalFormat.format( size  / (double) ONE_MEGABYTE );
  +	    } else {
  +		retString = Long.toString( (size + ( 529 * ONE_KILOBYTE) ) / ONE_MEGABYTE );
  +		retString += "M";
   	    }
  +	    retString = padLeft( retString, 5 );
           }
   
           return retString;
  
  
  
  1.4       +1 -1      jakarta-tomcat-4.0/tester/web/golden/SSIConfig03.txt
  
  Index: SSIConfig03.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/golden/SSIConfig03.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SSIConfig03.txt	25 Apr 2001 17:19:44 -0000	1.3
  +++ SSIConfig03.txt	5 Jun 2002 19:09:17 -0000	1.4
  @@ -1,4 +1,4 @@
   
   34
   
  -34 bytes
  +   1k
  
  
  
  1.3       +1 -1      jakarta-tomcat-4.0/tester/web/golden/SSIFsize02.txt
  
  Index: SSIFsize02.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/golden/SSIFsize02.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SSIFsize02.txt	22 Apr 2001 21:03:47 -0000	1.2
  +++ SSIFsize02.txt	5 Jun 2002 19:09:17 -0000	1.3
  @@ -1 +1 @@
  -34 bytes
  +   1k
  
  
  
  1.2       +1 -1      jakarta-tomcat-4.0/tester/web/golden/SSIInclude01.txt
  
  Index: SSIInclude01.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/tester/web/golden/SSIInclude01.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SSIInclude01.txt	18 Apr 2001 03:02:15 -0000	1.1
  +++ SSIInclude01.txt	5 Jun 2002 19:09:17 -0000	1.2
  @@ -1 +1 @@
  -[an error occurred while processing this directive]
  +
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message