Skip to content

Commit

Permalink
Merge pull request #399 from dtolnay/carriagereturn
Browse files Browse the repository at this point in the history
Revert "Require \r whitespace to be followed by \n"
  • Loading branch information
dtolnay authored Jul 9, 2023
2 parents bdfb5c1 + 261ad4d commit 9c812bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,10 @@ fn skip_whitespace(input: Cursor) -> Cursor {
}
}
match byte {
b' ' | 0x09..=0x0c => {
b' ' | 0x09..=0x0d => {
s = s.advance(1);
continue;
}
b'\r' if s.as_bytes().get(1) == Some(&b'\n') => {
s = s.advance(2);
continue;
}
b if b <= 0x7f => {}
_ => {
let ch = s.chars().next().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ fn whitespace() {
let tokens = various_spaces.parse::<TokenStream>().unwrap();
assert_eq!(tokens.into_iter().count(), 0);

let lone_carriage_return = " \r ";
lone_carriage_return.parse::<TokenStream>().unwrap_err();
let lone_carriage_returns = " \r \r\r\n ";
lone_carriage_returns.parse::<TokenStream>().unwrap();
}

#[test]
Expand Down

0 comments on commit 9c812bc

Please sign in to comment.