diff options
author | Shevek <[email protected]> | 2011-01-19 18:53:09 +0000 |
---|---|---|
committer | Shevek <[email protected]> | 2011-01-19 18:53:09 +0000 |
commit | eb03d86b63e26d6b524a86e10359a476c83f8af0 (patch) | |
tree | 320089050c666a147616c9f26471fd652693cc4d /src | |
parent | 5a763f6be337781c7844ca2d48c1a977bdc1e69c (diff) |
Fix line offsets in read after unget.
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/anarres/cpp/LexerSource.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/java/org/anarres/cpp/LexerSource.java b/src/java/org/anarres/cpp/LexerSource.java index d252569..90869bc 100644 --- a/src/java/org/anarres/cpp/LexerSource.java +++ b/src/java/org/anarres/cpp/LexerSource.java @@ -151,20 +151,25 @@ public class LexerSource extends Source { private int read() throws IOException, LexerException { + int c; assert ucount <= 2 : "Illegal ucount: " + ucount; switch (ucount) { case 2: ucount = 1; - return u1; + c = u1; + break; case 1: ucount = 0; - return u0; + c = u0; + break; + default: + if (reader == null) + c = -1; + else + c = reader.read(); + break; } - if (reader == null) - return -1; - - int c = reader.read(); switch (c) { case '\r': cr = true; @@ -188,6 +193,9 @@ public class LexerSource extends Source { lastcolumn = column; column = 0; break; + case -1: + cr = false; + break; default: cr = false; column++; |