changes:

1) <jsp-config> will work by default (even if no web-app version is defined).

2) add static method for simple comparing string version numbers to JspUtil

Michal
Index: JspConfig.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspConfig.java,v
retrieving revision 1.9
diff -r1.9 JspConfig.java
113c113,119
<       if (webApp == null || !"2.4".equals(webApp.findAttribute("version"))) {
---
>       if (webApp == null){
>           defaultIsELIgnored = "true";
>           return;
>       }
>       String version = webApp.findAttribute("version");
>         if( version == null) version = "2.4";
>       if( JspUtil.compareVersions("2.4", version) ) {
Index: JspUtil.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspUtil.java,v
retrieving revision 1.32
diff -r1.32 JspUtil.java
1033a1034,1141
> 
>       /** Compare two version numbers
>        *
>        * @author: Michal Lindner
>        * @param v1,v2 version numbers in string format
>        * @return: v1==v2 -> 0
>        *         v1>v2 -> -1
>        *         v1<v2 -> 1
>        *
>        */
> 
>       public static int compareVersions(String v1,String v2){
>               int pos1=0,pos2=0;
>               if(v1==null)
>                       v1="0";
>               if(v2==null)
>                       v2="0";
>               v1=v1.toLowerCase();
>               v2=v2.toLowerCase();
> 
>               do{
>                       String s1,s2;
> 
>                       int _pos1=v1.indexOf('.',pos1);
>                       if(pos1<0)
>                               s1="";
>                       if(_pos1<0)
>                               s1=v1.substring(pos1);
>                       else
>                               s1=v1.substring(pos1,_pos1);
>                       pos1+=s1.length()+(_pos1<0?0:1);
>                       if(s1.equals(""))s1="0";
> 
>                       int _pos2=v2.indexOf('.',pos2);
>                       if(pos2<0)
>                               s2="";
>                       if(_pos2<0)
>                               s2=v2.substring(pos2);
>                       else
>                               s2=v2.substring(pos2,_pos2);
>                       pos2+=s2.length()+(_pos2<0?0:1);
>                       if(s2.equals(""))s2="0";
> 
> 
>                       try{
>                               int ret=(new Integer(s1)).compareTo(new Integer(s2));
>                               if(ret!=0)
>                                       return ret;
>                       }catch(NumberFormatException e){
>                               int ret=s1.compareTo(s2);
>                               if(ret!=0)
>                                       return (ret<0?-1:1);
>                       }
>               }while( pos1<v1.length() || pos2<v2.length() );
> 
>               if( pos1==v1.length() && pos2==v2.length())
>                       return 0;
>               if( pos1<v1.length() )
>                       return 1;
>               return -1;
>       }
> 
>       /** Test function of compareVersion method
>         * @author Michal Lindner
>         * @returns true  - if all test passed
>         *          false - if some test din't passed
>         */
>       public static boolean compareVersionsTest(){
>               // test version order
>               String test[]={
>                       "0",
>                       ".1",
>                       ".98a",
>                       ".99a",
>                       ".99b",
>                       "1.0",
>                       "1.0.0.1",
>                       "2",
>                       "2.0.0.1",
>                       "10.1"
>               };
>               
>               for(int j=0;j<test.length;j++)
>                       for(int i=0;i<test.length;i++){
>                               int ret=compareVersions(test[j],test[i]);
>                               if(ret==0 && (i!=j))
>                                       return false;
>                               if(ret>0 && (i>j))
>                                       return false;
>                               if(ret<0 && (i<j))
>                                       return false;
>                       }
> 
>               // test equal version numbers
>               String equals[][]={
>                       {null,"","0","0.0"},
>                       {"1","1.0","1.0.0","1."}
>               };
>               for(int k=0;k<equals.length;k++)
>                       for(int i=0;i<equals[k].length;i++)
>                               for(int j=0;j<equals[k].length;j++){
>                                       int 
> ret=compareVersions(equals[k][j],equals[k][i]);
>                                       if(ret!=0)
>                                               return false;
>                               }
>               return true;
>       }
> 

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

Reply via email to