harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r429379 - in /incubator/harmony/enhanced/classlib/trunk/modules/regex/src: main/java/java/util/regex/SequenceSet.java test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
Date Mon, 07 Aug 2006 16:14:56 GMT
Author: gharley
Date: Mon Aug  7 09:14:55 2006
New Revision: 429379

URL: http://svn.apache.org/viewvc?rev=429379&view=rev
Log:
HARMONY 713 : [regex] Matcher.find() ignores the specified region when the pattern is "c"

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/SequenceSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/SequenceSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/SequenceSet.java?rev=429379&r1=429378&r2=429379&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/SequenceSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/SequenceSet.java
Mon Aug  7 09:14:55 2006
@@ -62,11 +62,11 @@
 
     public int find(int strIndex, CharSequence testString,
             MatchResultImpl matchResult) {
-        String testStr = testString.toString();
+        
         int strLength = matchResult.getRightBound();
 
         while (strIndex <= strLength) {
-            strIndex = indexOf(testStr, strIndex);
+            strIndex = indexOf(testString, strIndex, strLength);
 
             if (strIndex < 0)
                 return -1;
@@ -111,12 +111,11 @@
         return true;
     }
 
-    protected int indexOf(CharSequence str, int from) {
+    protected int indexOf(CharSequence str, int from, int to) {
         int last = string.charAt(charCount - 1);
         int i = from;
-        int size = str.length();
 
-        while (i <= size - charCount) {
+        while (i <= to - charCount) {
             char ch = str.charAt(i + charCount - 1);
             if (ch == last && startsWith(str, i)) {
                 return i;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java?rev=429379&r1=429378&r2=429379&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
Mon Aug  7 09:14:55 2006
@@ -638,6 +638,21 @@
 
 	}
 
+    /*
+     * Verify if the Matcher behaves correct with pattern "c" when region is
+     * changed
+     */
+    public void testFindRegionChanged2() {
+        // Regression for HARMONY-713
+        Pattern pattern = Pattern.compile("c");
+
+        String inputStr = "aabb.c";
+        Matcher matcher = pattern.matcher(inputStr);
+        matcher.region(0, 3);
+
+        assertFalse(matcher.find());
+    }
+    
 	/*
 	 * Regression test for HARMONY-674
 	 */
@@ -645,6 +660,7 @@
         Pattern pattern = Pattern.compile("(?:\\d+)(?:pt)");
         assertTrue(pattern.matcher("14pt").matches());
     } 
+
 
 	public static void main(String[] args) {
 		junit.textui.TestRunner.run(MatcherTest.class);



Mime
View raw message