Skip to content

Commit a5ec51d

Browse files
committedJul 12, 2011
Fix pretty-printing of literals again. Issue #672
The pos variable is one character beyond where I thought it was.
1 parent a8b1ea1 commit a5ec51d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/comp/syntax/parse/lexer.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ fn new_reader(&codemap::codemap cm, str src, codemap::filemap filemap,
4545
@interner::interner[str] itr) {
4646
fn is_eof() -> bool { ret ch == -1 as char; }
4747
fn mark() { mark_pos = pos; mark_chpos = chpos; }
48-
fn get_mark_str() -> str { ret str::slice(src, mark_pos, pos); }
48+
fn get_mark_str() -> str {
49+
// I'm pretty skeptical about this subtraction. What if there's a
50+
// multi-byte character before the mark?
51+
ret str::slice(src, mark_pos - 1u,
52+
pos - 1u);
53+
}
4954
fn get_mark_chpos() -> uint { ret mark_chpos; }
5055
fn get_chpos() -> uint { ret chpos; }
5156
fn curr() -> char { ret ch; }

0 commit comments

Comments
 (0)
Please sign in to comment.