[kaffe] Bug report (java.io.StreamTokenizer)
Ito Kazumitsu
ito.kazumitsu at hitachi-cable.co.jp
Mon Jun 30 18:11:01 PDT 2003
In message "Re: [kaffe] Bug report (java.io.StreamTokenizer)"
on 03/07/01, Ito Kazumitsu <ito.kazumitsu at hitachi-cable.co.jp> writes:
> (From the API doc) Each byte read from the input stream is regarded
> as a character in the range '\u0000' through '\u00FF'. The character
> value is used to look up five possible attributes of the character:
> white space, alphabetic, numeric, string quote, and comment character.
> Each character can have zero or more of these attributes.
> (And I guess) BUT ONLY THE ATTRIBUTE MOST RECENTLY ASSIGNED IS EFFECTIVE.
And additionally, THE NUMERIC ATTRIBUTE IS KEPT EFFECTIVE EVEN IF
OTHER ATTIBUTES ARE ASSIGNED.
Applying the attached patch, I am getting the same results as Sun's.
--- java/io/StreamTokenizer.java.orig Tue Feb 19 09:47:49 2002
+++ java/io/StreamTokenizer.java Tue Jul 1 10:02:54 2003
@@ -74,6 +74,7 @@
public void commentChar(int ch) {
if (ch >= 0 && ch <= 255) {
+ ordinaryCharKeepNumeric(ch);
lookup(ch).isComment = true;
}
}
@@ -430,11 +431,24 @@
}
}
+private void ordinaryCharKeepNumeric(int c) {
+ if (c >= 0 && c <= 255) {
+ TableEntry e = lookup(c);
+ e.isAlphabetic = false;
+ e.isStringQuote = false;
+ e.isComment = false;
+ e.isWhitespace = false;
+ }
+}
+
public void parseNumbers() {
for (int letter = '0'; letter <= '9'; letter++) {
+ ordinaryChar(letter);
lookup(letter).isNumeric = true;
}
+ ordinaryChar('.');
lookup('.').isNumeric = true;
+ ordinaryChar('-');
lookup('-').isNumeric = true;
}
@@ -444,6 +458,7 @@
public void quoteChar(int ch) {
if (ch >= 0 && ch <= 255) {
+ ordinaryCharKeepNumeric(ch);
lookup(ch).isStringQuote = true;
}
}
@@ -545,10 +560,8 @@
}
for (int letter = low; letter <= hi; letter++) {
- TableEntry e = lookup(letter);
- e.isWhitespace = true;
- e.isAlphabetic = false;
- e.isNumeric = false;
+ ordinaryCharKeepNumeric(letter);
+ lookup(letter).isWhitespace = true;
}
}
@@ -562,6 +575,7 @@
}
for (int letter = low; letter <= hi; letter++) {
+ ordinaryCharKeepNumeric(letter);
lookup(letter).isAlphabetic = true;
}
}
More information about the kaffe
mailing list