summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Trask <bentrask@comcast.net>2015-04-07 05:27:45 -0400
committerBen Trask <bentrask@comcast.net>2015-04-07 09:27:00 -0400
commitb8aa64967e328d2d9fa0bc1f21c0970ec32d259f (patch)
tree6e7e0c466a8174e89e834adb932bdb273ccffe8b /src
parent6f99ff72519a34517285b070cb222de42d8acdfd (diff)
Bug fixes for CRLF support.
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 338d4e9..06521d1 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -90,9 +90,6 @@ static bool is_blank(cmark_strbuf *s, int offset)
while (offset < s->size) {
switch (s->ptr[offset]) {
case '\r':
- if (s->ptr[offset + 1] == '\n')
- offset++;
- return true;
case '\n':
return true;
case ' ':
@@ -151,10 +148,6 @@ static void remove_trailing_blank_lines(cmark_strbuf *ln)
if (c != '\r' && c != '\n')
continue;
- // Don't cut a CRLF in half
- if (c == '\r' && i+1 < ln->size && ln->ptr[i+1] == '\n')
- ++i;
-
cmark_strbuf_truncate(ln, i);
break;
}
@@ -568,10 +561,13 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
// Add a newline to the end if not present:
// TODO this breaks abstraction:
- // Note: we assume output is LF-only
- if (parser->curline->ptr[parser->curline->size - 1] != '\n') {
- cmark_strbuf_putc(parser->curline, '\n');
+ if (parser->curline->ptr[parser->curline->size - 1] == '\n') {
+ cmark_strbuf_truncate(parser->curline, parser->curline->size - 1);
+ }
+ if (parser->curline->ptr[parser->curline->size - 1] == '\r') {
+ cmark_strbuf_truncate(parser->curline, parser->curline->size - 1);
}
+ cmark_strbuf_putc(parser->curline, '\n');
input.data = parser->curline->ptr;
input.len = parser->curline->size;