Disambiguate "" empty strings from multiline strings properly.
Previously `""` would go into multiline mode and thus *require* a following ".
This commit is contained in:
parent
05f8c0bc41
commit
e756f56b62
|
@ -265,11 +265,16 @@ impl<'a> Parser<'a> {
|
|||
let mut multiline = false;
|
||||
let mut ret = String::new();
|
||||
|
||||
// detect multiline literals
|
||||
// detect multiline literals, but be careful about empty ""
|
||||
// strings
|
||||
if self.eat('"') {
|
||||
if self.eat('"') {
|
||||
multiline = true;
|
||||
if !self.expect('"') { return None }
|
||||
self.eat('\n');
|
||||
} else {
|
||||
// empty
|
||||
return Some(String(ret))
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
|
|
|
@ -122,6 +122,9 @@ test!(long_float,
|
|||
test!(long_integer,
|
||||
include_str!("valid/long-integer.toml"),
|
||||
include_str!("valid/long-integer.json"))
|
||||
test!(string_empty,
|
||||
include_str!("valid/string-empty.toml"),
|
||||
include_str!("valid/string-empty.json"))
|
||||
test!(string_escapes,
|
||||
include_str!("valid/string-escapes.toml"),
|
||||
include_str!("valid/string-escapes.json"))
|
||||
|
|
6
src/test/valid/string-empty.json
Normal file
6
src/test/valid/string-empty.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"answer": {
|
||||
"type": "string",
|
||||
"value": ""
|
||||
}
|
||||
}
|
1
src/test/valid/string-empty.toml
Normal file
1
src/test/valid/string-empty.toml
Normal file
|
@ -0,0 +1 @@
|
|||
answer = ""
|
Loading…
Reference in a new issue