Skip to content

Commit

Permalink
Convert cooked_byte_string trailing backslash logic to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 24, 2023
1 parent 231e8c8 commit 07ffd04
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,17 +465,17 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> {
Some((_, b'n')) | Some((_, b'r')) | Some((_, b't')) | Some((_, b'\\'))
| Some((_, b'0')) | Some((_, b'\'')) | Some((_, b'"')) => {}
Some((newline, b @ b'\n')) | Some((newline, b @ b'\r')) => {
let mut last = b as char;
let mut last = b;
let rest = input.advance(newline + 1);
let mut chars = rest.char_indices();
let mut whitespace = rest.bytes().enumerate();
loop {
if last == '\r' && chars.next().map_or(true, |(_, ch)| ch != '\n') {
if last == b'\r' && whitespace.next().map_or(true, |(_, b)| b != b'\n') {
return Err(Reject);
}
match chars.next() {
Some((_, ch @ ' ')) | Some((_, ch @ '\t')) | Some((_, ch @ '\n'))
| Some((_, ch @ '\r')) => {
last = ch;
match whitespace.next() {
Some((_, b @ b' ')) | Some((_, b @ b'\t')) | Some((_, b @ b'\n'))
| Some((_, b @ b'\r')) => {
last = b;
}
Some((offset, _)) => {
input = rest.advance(offset);
Expand Down

0 comments on commit 07ffd04

Please sign in to comment.