Skip to content

Commit e3bb41c

Browse files
marijnhgraydon
authored andcommitted
---
yaml --- r: 1935 b: refs/heads/master c: 6a75740 h: refs/heads/master i: 1933: c45b60a 1931: 6768c0d 1927: c3609c1 1919: 9086a67 v: v3
1 parent fcca871 commit e3bb41c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 39f0656b4f428b81bd6be06b89a8de1e63b72e87
2+
refs/heads/master: 6a75740e96334407e8fcfcf5728eff2e7b8c3482

trunk/src/comp/front/lexer.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impure fn consume_any_line_comment(reader rdr) {
282282
if (rdr.curr() == '/') {
283283
alt (rdr.next()) {
284284
case ('/') {
285-
while (rdr.curr() != '\n') {
285+
while (rdr.curr() != '\n' && !rdr.is_eof()) {
286286
rdr.bump();
287287
}
288288
// Restart whitespace munch.
@@ -317,6 +317,10 @@ impure fn consume_block_comment(reader rdr) {
317317
rdr.bump();
318318
}
319319
}
320+
if (rdr.is_eof()) {
321+
log "unterminated block comment";
322+
fail;
323+
}
320324
}
321325
// restart whitespace munch.
322326
be consume_any_whitespace(rdr);
@@ -800,9 +804,9 @@ impure fn consume_whitespace(reader rdr) -> uint {
800804
impure fn read_line_comment(reader rdr) -> cmnt {
801805
auto p = rdr.get_curr_pos();
802806
rdr.bump(); rdr.bump();
803-
consume_whitespace(rdr);
807+
while (rdr.curr() == ' ') {rdr.bump();}
804808
auto val = "";
805-
while (rdr.curr() != '\n') {
809+
while (rdr.curr() != '\n' && !rdr.is_eof()) {
806810
_str.push_char(val, rdr.curr());
807811
rdr.bump();
808812
}
@@ -814,7 +818,7 @@ impure fn read_line_comment(reader rdr) -> cmnt {
814818
impure fn read_block_comment(reader rdr) -> cmnt {
815819
auto p = rdr.get_curr_pos();
816820
rdr.bump(); rdr.bump();
817-
consume_whitespace(rdr);
821+
while (rdr.curr() == ' ') {rdr.bump();}
818822
let vec[str] lines = vec();
819823
auto val = "";
820824
auto level = 1;
@@ -837,6 +841,7 @@ impure fn read_block_comment(reader rdr) -> cmnt {
837841
_str.push_char(val, rdr.curr());
838842
rdr.bump();
839843
}
844+
if (rdr.is_eof()) {fail;}
840845
}
841846
ret rec(val=cmnt_block(lines),
842847
pos=p,

0 commit comments

Comments
 (0)