diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2009-07-07 10:27:17 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2009-07-07 10:27:17 +0000 |
commit | d50d3f0c5bcb967a5bcaa999e1c54c51cd78dcd2 (patch) | |
tree | a76ceef9e4d8081721169db1f96375c74595d921 /java/util | |
parent | 51f0782f422554f15cb827bc898e96f5a239558c (diff) | |
download | classpath-d50d3f0c5bcb967a5bcaa999e1c54c51cd78dcd2.tar.gz |
Correctly spot EOF in java.util.Scanner#hasNextLine().
2009-07-07 Andrew John Hughes <ahughes@redhat.com>
PR classpath/40630
* java/util/Scanner.java:
(myCoreNext(boolean, Pattern)): Set tmp2 to
null if the string is empty (i.e. we are at
the end of the file).
* java/util/regex/Matcher.java:
(toMatchResult()): Check that match is non-null
before attempting to clone it.
Diffstat (limited to 'java/util')
-rw-r--r-- | java/util/Scanner.java | 2 | ||||
-rw-r--r-- | java/util/regex/Matcher.java | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/java/util/Scanner.java b/java/util/Scanner.java index a46755f9f..59c4cc0ff 100644 --- a/java/util/Scanner.java +++ b/java/util/Scanner.java @@ -1668,6 +1668,8 @@ public class Scanner // the end of input is matched { tmp2 = this.actBuffer.substring (this.actPos); + if (tmp2.length() == 0) + tmp2 = null; this.lastNextPos = this.actBuffer.length (); if (delete) { diff --git a/java/util/regex/Matcher.java b/java/util/regex/Matcher.java index c27a70bf9..be57471de 100644 --- a/java/util/regex/Matcher.java +++ b/java/util/regex/Matcher.java @@ -603,7 +603,8 @@ public final class Matcher implements MatchResult public MatchResult toMatchResult() { Matcher snapshot = new Matcher(pattern, input); - snapshot.match = (REMatch) match.clone(); + if (match != null) + snapshot.match = (REMatch) match.clone(); return snapshot; } |