You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/04/01 15:36:49 UTC

svn commit: r929964 - /felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/util/Util.java

Author: rickhall
Date: Thu Apr  1 13:36:48 2010
New Revision: 929964

URL: http://svn.apache.org/viewvc?rev=929964&view=rev
Log:
Backport FELIX-2107 to framework 2.0.5.

Modified:
    felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/util/Util.java

Modified: felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/util/Util.java?rev=929964&r1=929963&r2=929964&view=diff
==============================================================================
--- felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/util/Util.java Thu Apr  1 13:36:48 2010
@@ -587,7 +587,6 @@ loop:   for (;;)
                 {
                     leftstar = true;
                 }
-                ss.setLength(0);
                 wasStar = true;
             }
             else
@@ -619,16 +618,30 @@ loop:   for (;;)
         // assert (pieces.length > 1)
         // minimal case is <string>*<string>
 
-        boolean result = false;
+        boolean result = true;
         int len = pieces.length;
 
+        int index = 0;
+
 loop:   for (int i = 0; i < len; i++)
         {
             String piece = pieces[i];
-            int index = 0;
+
+            // If this is the first piece, then make sure the
+            // string starts with it.
+            if (i == 0)
+            {
+                if (!s.startsWith(piece))
+                {
+                    result = false;
+                    break loop;
+                }
+            }
+
+            // If this is the last piece, then make sure the
+            // string ends with it.
             if (i == len - 1)
             {
-                // this is the last piece
                 if (s.endsWith(piece))
                 {
                     result = true;
@@ -639,19 +652,11 @@ loop:   for (int i = 0; i < len; i++)
                 }
                 break loop;
             }
-            // initial non-star; assert index == 0
-            else if (i == 0)
-            {
-                if (!s.startsWith(piece))
-                {
-                    result = false;
-                    break loop;
-                }
-            }
-            // assert i > 0 && i < len-1
-            else
+
+            // If this is neither the first or last piece, then
+            // make sure the string contains it.
+            if ((i > 0) && (i < (len - 1)))
             {
-                // Sure wish stringbuffer supported e.g. indexOf
                 index = s.indexOf(piece, index);
                 if (index < 0)
                 {
@@ -659,7 +664,8 @@ loop:   for (int i = 0; i < len; i++)
                     break loop;
                 }
             }
-            // start beyond the matching piece
+
+            // Move string index beyond the matching piece.
             index += piece.length();
         }