mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
configparser: fix windows EOL handling
Summary: Without this patch, all hg commands will fail with our current config: hg: parse error: <filename> --> 6:5 | 6 | commandexception | ^--- | = expected new_line The config is: [blackbox] track = command commandexception ... Because "\r\n" was treated as the same as double "\n"s. Reviewed By: ryanmce Differential Revision: D9494909 fbshipit-source-id: 64ef173c69f3cf61d4e71116c581dbca72fb2c4b
This commit is contained in:
parent
f32aa15ebd
commit
8356dbd506
@ -610,7 +610,7 @@ mod tests {
|
||||
\n\
|
||||
[x]\n\
|
||||
m = this\n \
|
||||
value has\n \
|
||||
value has\r\n \
|
||||
multi lines\n\
|
||||
; comment again\n\
|
||||
n =\n",
|
||||
@ -637,7 +637,7 @@ mod tests {
|
||||
assert_eq!(sources[1].source(), "test_parse_basic");
|
||||
assert_eq!(sources[0].location().unwrap(), (PathBuf::new(), 8..9));
|
||||
assert_eq!(sources[1].location().unwrap(), (PathBuf::new(), 38..40));
|
||||
assert_eq!(sources[1].file_content().unwrap().len(), 99);
|
||||
assert_eq!(sources[1].file_content().unwrap().len(), 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -11,7 +11,7 @@
|
||||
// However, `#[grammar = "spec.pest"]` does not play well with Buck build,
|
||||
// because pest_derive cannot find "spec.pest" in buck build environment.
|
||||
// Therefore this file is @generated. @no-lint.
|
||||
// pest-checksum: 1fa4fbe929a8b3e6c073fcd1e46cae2bc30d23f7.
|
||||
// pest-checksum: d00ac1967ce2bd9ff78af9d3e1345058a648964c.
|
||||
|
||||
|
||||
#[allow(dead_code, non_camel_case_types)]
|
||||
@ -58,7 +58,7 @@ impl ::pest::Parser<Rule> for ConfigParser {
|
||||
{
|
||||
pos.match_string("\n").or_else(|pos|
|
||||
{
|
||||
pos.match_string("\r")
|
||||
pos.match_string("\r\n")
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -764,12 +764,12 @@ impl ::pest::Parser<Rule> for ConfigParser {
|
||||
})
|
||||
}
|
||||
#[inline]
|
||||
fn soi<'i>(pos: ::pest::Position<'i>,
|
||||
fn any<'i>(pos: ::pest::Position<'i>,
|
||||
_: &mut ::pest::ParserState<'i, Rule>)
|
||||
->
|
||||
::std::result::Result<::pest::Position<'i>,
|
||||
::pest::Position<'i>> {
|
||||
pos.at_start()
|
||||
pos.skip(1)
|
||||
}
|
||||
#[inline]
|
||||
fn eoi<'i>(pos: ::pest::Position<'i>,
|
||||
@ -780,12 +780,12 @@ impl ::pest::Parser<Rule> for ConfigParser {
|
||||
pos.at_end()
|
||||
}
|
||||
#[inline]
|
||||
fn any<'i>(pos: ::pest::Position<'i>,
|
||||
fn soi<'i>(pos: ::pest::Position<'i>,
|
||||
_: &mut ::pest::ParserState<'i, Rule>)
|
||||
->
|
||||
::std::result::Result<::pest::Position<'i>,
|
||||
::pest::Position<'i>> {
|
||||
pos.skip(1)
|
||||
pos.at_start()
|
||||
}
|
||||
#[inline]
|
||||
#[allow(dead_code)]
|
||||
|
@ -22,7 +22,7 @@
|
||||
// Same applies to "directive" and "bracket"s.
|
||||
|
||||
|
||||
new_line = { "\n" | "\r" }
|
||||
new_line = { "\n" | "\r\n" }
|
||||
space = { " " | "\t" }
|
||||
comment_start = { ("#" | ";") }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user