diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-08-09 11:14:21 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-08-09 11:14:21 -0700 |
commit | 6c416f20273cd427af18e25c0911ef6cf0da96d0 (patch) | |
tree | 894ef834a1e128116cd0dcbdb82dde1a66d2d1a9 | |
parent | f2ac8b6aa69a4765e44f815a031b7aa574d44b57 (diff) |
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.
-rwxr-xr-x | src/blocks.c | 9 |
1 files 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++; } } |