You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/08/07 18:14:56 UTC
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
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);