You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@apache.org on 2006/07/10 16:57:57 UTC

svn commit: r420553 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/WildcardMatcherHelper.java

Author: giacomo
Date: Mon Jul 10 07:57:57 2006
New Revision: 420553

URL: http://svn.apache.org/viewvc?rev=420553&view=rev
Log:
fixed additional test case

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/WildcardMatcherHelper.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/WildcardMatcherHelper.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/WildcardMatcherHelper.java?rev=420553&r1=420552&r2=420553&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/WildcardMatcherHelper.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/util/WildcardMatcherHelper.java Mon Jul 10 07:57:57 2006
@@ -179,7 +179,7 @@
          * @return wether the pstring matches the pattern
          */
         private boolean match() {
-            // scan a common literal suffix
+            // scan a common literal prefix
             scanLiteralPrefix();
 
             // if we are already at the end of both strings 
@@ -228,7 +228,7 @@
                 // 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) {
-                    return checkEnds(sipat);
+                    return checkEnds(sipat, false);
                 }
 
                 // Now we need to check whether the litteral substring of the pattern 
@@ -247,7 +247,7 @@
                 // skip the star
                 ++ipat;
 
-                // if we are at the beginning of the pattern we have to check there is not PATH_SEP in string
+                // if we are at the beginning of the pattern we have to check there is no PATH_SEP in string
                 if(ipat >= lpat) {
                     final int sistr = istr;
 
@@ -277,7 +277,7 @@
                 // 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) {
-                    return checkEnds(sipat);
+                    return checkEnds(sipat, true);
                 }
 
                 // If we stopped at an other wildcard
@@ -341,13 +341,25 @@
             return i == l;
         }
         
-        private final boolean checkEnds(final int sipat)
+        private final boolean checkEnds(final int sipat, final boolean isSingleStart)
         {
             // if the remaining length of the string isn't the same as that found in the pattern 
             // we do not match
             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)) {
+                if( isSingleStart )
+                {
+                    // if the ends matches make sure there isn't a PATHSEP in the candidate string part
+                    int i = ostr - istr;
+                    while( i > istr )
+                    {
+                        if( astr[--i] == PATHSEP )
+                        {
+                            return false; // we cannot match because of a PATHSEP in the matched part
+                        }
+                    }
+                }
                 add(new String(astr, istr, ostr - istr));
 
                 return true;