From 6c416f20273cd427af18e25c0911ef6cf0da96d0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 9 Aug 2015 11:14:21 -0700 Subject: Make sure every line fed to S_process_line ends with `\n`. So `S_process_line` sees only unix style line endings. Closes #72, avoiding mixed line endings. Ultimately we probably want a better solution, allowing the line ending style of the input file to be preserved. This solution forces output with newlines. --- src/blocks.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/blocks.c b/src/blocks.c index 4432f78..38450e0 100755 --- a/src/blocks.c +++ b/src/blocks.c @@ -477,10 +477,6 @@ static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer, bool process = false; for (eol = buffer; eol < end; ++eol) { if (S_is_line_end_char(*eol)) { - if (eol < end && *eol == '\r') - eol++; - if (eol < end && *eol == '\n') - eol++; process = true; break; } @@ -514,6 +510,11 @@ 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 && *buffer == '\n') + buffer++; } } -- cgit v1.2.3