cmark

My personal build of CMark ✏️

Commit
6c416f20273cd427af18e25c0911ef6cf0da96d0
Parent
f2ac8b6aa69a4765e44f815a031b7aa574d44b57
Author
John MacFarlane <jgm@berkeley.edu>
Date

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.

Diffstat

1 file changed, 5 insertions, 4 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 9 5 4
diff --git 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++;
   }
 }