Skip to content

Commit

Permalink
Changed logic for null/eol checks.
Browse files Browse the repository at this point in the history
- only check once for "not at end of line"
- check for null before we check for newline characters (the
  previous patch would fail for NULL + CR)

See #160.
  • Loading branch information
jgm committed Oct 11, 2016
1 parent 1f51da2 commit 89c8d70
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,21 @@ static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer,
}

buffer += chunk_len;
// skip over line ending characters:
if (buffer < end && *buffer == '\r') {
buffer++;
if (buffer == end)
parser->last_buffer_ended_with_cr = true;
if (buffer < end) {
if (*buffer == '\0') {
// skip over NULL
buffer++;
} else {
// skip over line ending characters
if (*buffer == '\r') {
buffer++;
if (buffer == end)
parser->last_buffer_ended_with_cr = true;
}
if (*buffer == '\n')
buffer++;
}
}
if (buffer < end && *buffer == '\0')
buffer++;
else if (buffer < end && *buffer == '\n')
buffer++;
}
}

Expand Down

0 comments on commit 89c8d70

Please sign in to comment.