cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r416672 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
Date Fri, 23 Jun 2006 11:26:21 GMT
Author: giacomo
Date: Fri Jun 23 04:26:10 2006
New Revision: 416672

URL: http://svn.apache.org/viewvc?rev=416672&view=rev
Log:
fixed an AOOBE

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java?rev=416672&r1=416671&r2=416672&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
Fri Jun 23 04:26:10 2006
@@ -218,8 +218,10 @@
                 if(ipat >= lpat) {
                     // if the remaining length of the string isn't the same as that found
in the pattern 
                     // we do not match
-                    if(strncmp(apat, sipat, astr, lstr - (lpat - sipat), lpat - sipat)) {
-                        add(new String(astr, istr, lstr - (lpat - sipat) - istr));
+                    final int l = lpat - sipat; // calculate length of comparison
+                    final int ostr = lstr - l; // calculate offset into string
+                    if(ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) {
+                        add(new String(astr, istr, ostr - istr));
 
                         return true;
                     }
@@ -239,8 +241,7 @@
 
                 add(new String(astr, sistr, istr - sistr));
                 istr += l;
-            } else // if it is a single star pattern
-             {
+            } else {// if it is a single star pattern
                 // skip the star
                 ++ipat;
 
@@ -274,8 +275,10 @@
                 // if we reached the end of the pattern just do a String compare with the
corresponding part from 
                 // the end of the string
                 if(ipat >= lpat) {
-                    if(strncmp(apat, sipat, astr, lstr - (ipat - sipat), ipat - sipat)) {
-                        add(new String(astr, istr, lstr - (ipat - sipat) - istr)); // TODO:
this is wrong
+                    final int l = ipat - sipat; // calculate length of comparison
+                    final int ostr = lstr - l; // calculate offset into string
+                    if(ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) {
+                        add(new String(astr, istr, ostr - istr));
 
                         return true;
                     }
@@ -341,7 +344,7 @@
             }
             int i = 0;
 
-            for(i = 0; i < l && o1 + i < a1.length && o2 + i < a2.length
&& a1[o1 + i] == a2[o2 + i]; i++);
+            while(i < l && o1 + i < a1.length && o2 + i < a2.length
&& a1[o1 + i] == a2[o2 + i]) i++;
 
             return i == l;
         }



Mime
View raw message