diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-10-07 09:50:44 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-10-07 09:50:44 -0700 |
commit | 67adf87dd417fb30be92d3778edb07c91f4df72a (patch) | |
tree | 0649ef3ba81f8db77c18139e6c6100bb6fc50745 /src | |
parent | 96c6cd94ec32fb58603764ba33e19319a3165d75 (diff) | |
parent | dea8646b8b98583d15528031138682d1ac9ada85 (diff) | |
download | milf-rs-67adf87dd417fb30be92d3778edb07c91f4df72a.tar.gz milf-rs-67adf87dd417fb30be92d3778edb07c91f4df72a.zip |
Merge pull request #75 from andersforsgren/allow-toml-BOM
Allow BOM (Byte order mark) in toml
Diffstat (limited to 'src')
-rw-r--r-- | src/parser.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs index 394465f..190454c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -190,6 +190,14 @@ impl<'a> Parser<'a> { false } + // Consumes a BOM (Byte Order Mark) if one is next + fn bom(&mut self) -> bool { + match self.peek(0) { + Some((_, '\u{feff}')) => { self.cur.next(); true } + _ => false + } + } + // Consumes whitespace ('\t' and ' ') until another character (or EOF) is // reached. Returns if any whitespace was consumed fn ws(&mut self) -> bool { @@ -234,6 +242,7 @@ impl<'a> Parser<'a> { /// to determine the cause of the parse failure. pub fn parse(&mut self) -> Option<super::Table> { let mut ret = TomlTable { values: BTreeMap::new(), defined: false }; + self.bom(); while self.peek(0).is_some() { self.ws(); if self.newline() { continue } |