This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: regex fixed from Classpath
- From: Anthony Green <green at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Mon, 07 Feb 2005 12:41:10 -0800
- Subject: Patch: regex fixed from Classpath
- Organization: Red Hat, Inc.
I'm merging these fixes from Classpath.
AG
2005-02-07 Mark Wielaard <mark@klomp.org>
Reported by Timo Lindfors <timo.lindfors@iki.fi>
java/util/regex/Matcher.java (lookingAt): Set position when match
found.
(matches): Implemented through lookingAt().
2005-02-07 Mark Wielaard <mark@klomp.org>
Fix suggested by Timo Lindfors <timo.lindfors@iki.fi>
* java/util/regex/Pattern.java (split(CharSequence,int)):
Fix while empties > 0 loops.
diff -rup java/util/regex/Matcher.java /home/green/classpath/classpath/java/util/regex/Matcher.java
--- java/util/regex/Matcher.java 2004-11-18 07:26:41.000000000 -0800
+++ /home/green/classpath/classpath/java/util/regex/Matcher.java 2005-02-07 12:20:24.000000000 -0800
@@ -212,7 +212,10 @@ public final class Matcher
if (match != null)
{
if (match.getStartIndex() == 0)
- return true;
+ {
+ position = match.getEndIndex();
+ return true;
+ }
match = null;
}
return false;
@@ -230,7 +233,13 @@ public final class Matcher
*/
public boolean matches ()
{
- return find(0);
+ if (lookingAt())
+ {
+ if (position == input.length())
+ return true;
+ match = null;
+ }
+ return false;
}
/**
diff -rup java/util/regex/Pattern.java /home/green/classpath/classpath/java/util/regex/Pattern.java
--- java/util/regex/Pattern.java 2004-11-18 07:26:42.000000000 -0800
+++ /home/green/classpath/classpath/java/util/regex/Pattern.java 2005-02-07 12:20:24.000000000 -0800
@@ -198,8 +198,11 @@ public final class Pattern implements Se
empties++;
else
{
- while (empties-- > 0)
- list.add("");
+ while (empties > 0)
+ {
+ list.add("");
+ empties--;
+ }
String text = input.subSequence(start, end).toString();
list.add(text);
@@ -222,8 +225,11 @@ public final class Pattern implements Se
int max = limit - list.size();
empties = (empties > max) ? max : empties;
}
- while (empties-- > 0)
- list.add("");
+ while (empties > 0)
+ {
+ list.add("");
+ empties--;
+ }
}
// last token at end