Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
Merge 67bda27 into 6e308d7
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Aug 22, 2016
2 parents 6e308d7 + 67bda27 commit c63f92a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/rules/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ fn string_nowdoc(input: &[u8]) -> Result<&[u8], Literal> {
return Result::Error(Error::Code(ErrorKind::Custom(StringError::InvalidOpeningCharacter as u32)));
}

offset = 2;
offset = 1;

for (index, item) in next_input[offset..].iter().enumerate() {
if *item == '\n' as u8 {
Expand All @@ -357,9 +357,16 @@ fn string_nowdoc(input: &[u8]) -> Result<&[u8], Literal> {
}

if next_input[lookahead_offset] == '\n' as u8 {
if index == 0 {
return Result::Done(
&next_input[lookahead_offset + 1..],
Literal::String(Vec::new())
);
}

return Result::Done(
&next_input[lookahead_offset + 1..],
Literal::String(next_input[offset..offset + index].to_vec())
Literal::String(next_input[offset + 1..offset + index].to_vec())
);
}
}
Expand Down Expand Up @@ -1033,7 +1040,7 @@ mod tests {

#[test]
fn case_string_nowdoc_empty() {
let input = b"<<<'FOO'\n\nFOO\n";
let input = b"<<<'FOO'\nFOO\n";
let output = Result::Done(&b""[..], Literal::String(Vec::new()));

assert_eq!(string_nowdoc(input), output);
Expand Down

0 comments on commit c63f92a

Please sign in to comment.