Patch to error instead of crashing when parsing unmatched double quotes

Patch to error and fail instead of using all available memory
then crashing to detect the error condition of an unmatched
double quote before the end of a file.

I couldn't get it to show nice error messages, so this may not be
the ideal fix.

A test case for this situation has also been added.
This commit is contained in:
Wade Mealing 2011-09-28 04:15:24 +10:00 committed by Brian Anderson
parent a96b16e8c3
commit f375391cb6
2 changed files with 15 additions and 0 deletions

View File

@ -490,8 +490,15 @@ fn next_token_inner(rdr: reader) -> token::token {
ret token::LIT_CHAR(c2);
}
'"' {
let n = rdr.get_chpos();
rdr.bump();
while rdr.curr() != '"' {
if rdr.is_eof() {
rdr.err(#fmt["unterminated double quote string: %s",
rdr.get_str_from(n)]);
fail;
}
let ch = rdr.curr();
rdr.bump();
alt ch {

View File

@ -0,0 +1,8 @@
// -*- rust -*-
// error-pattern: unterminated double quote string
fn main() {
"
}