Handle \r\n

This commit is contained in:
Alex Crichton 2014-06-23 22:25:54 -07:00
parent 6e30770355
commit b663d6ae99

View file

@ -141,7 +141,8 @@ impl<'a> Parser<'a> {
self.ws(); self.ws();
match self.cur.clone().next() { match self.cur.clone().next() {
Some((_, '#')) => { self.comment(); } Some((_, '#')) => { self.comment(); }
Some((_, '\n')) => { self.cur.next(); } Some((_, '\n')) |
Some((_, '\r')) => { self.cur.next(); }
Some((start, '[')) => { Some((start, '[')) => {
self.cur.next(); self.cur.next();
let array = self.eat('['); let array = self.eat('[');
@ -193,7 +194,8 @@ impl<'a> Parser<'a> {
self.ws(); self.ws();
match self.cur.clone().next() { match self.cur.clone().next() {
Some((_, '#')) => self.comment(), Some((_, '#')) => self.comment(),
Some((_, '\n')) => { self.cur.next(); } Some((_, '\n')) |
Some((_, '\r')) => { self.cur.next(); }
Some((_, '[')) => break, Some((_, '[')) => break,
Some((start, _)) => { Some((start, _)) => {
let mut key = String::new(); let mut key = String::new();
@ -225,6 +227,7 @@ impl<'a> Parser<'a> {
self.insert(into, key, value, start); self.insert(into, key, value, start);
self.ws(); self.ws();
self.comment(); self.comment();
self.eat('\r');
self.eat('\n'); self.eat('\n');
} }
None => break, None => break,
@ -481,7 +484,8 @@ impl<'a> Parser<'a> {
me.ws(); me.ws();
match me.cur.clone().next() { match me.cur.clone().next() {
Some((_, '#')) => { me.comment(); } Some((_, '#')) => { me.comment(); }
Some((_, '\n')) => { me.cur.next(); } Some((_, '\n')) |
Some((_, '\r')) => { me.cur.next(); }
_ => break, _ => break,
} }
} }