cmark

My personal build of CMark ✏️

Commit
e2b08df1099f43e618596aa60a0ce38589f20287
Parent
565f01476b463149bbc04ed6a2f7362f884481d1
Author
John MacFarlane <jgm@berkeley.edu>
Date

Merge pull request #116 from nwellnhof/win-eol-fix

Open files in binary mode

Diffstat

3 files changed, 3 insertions, 3 deletions

Status File Name N° Changes Insertions Deletions
Modified man/man3/cmark.3 2 1 1
Modified src/cmark.h 2 1 1
Modified src/main.c 2 1 1
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
@@ -543,7 +543,7 @@ Streaming interface:
 .nf
 \f[C]
 cmark_parser *parser = cmark_parser_new(CMARK_OPT_DEFAULT);
-FILE *fp = fopen("myfile.md", "r");
+FILE *fp = fopen("myfile.md", "rb");
 while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
 	   cmark_parser_feed(parser, buffer, bytes);
 	   if (bytes < sizeof(buffer)) {
diff --git a/src/cmark.h b/src/cmark.h
@@ -418,7 +418,7 @@ CMARK_EXPORT void cmark_consolidate_text_nodes(cmark_node *root);
  * Streaming interface:
  *
  *     cmark_parser *parser = cmark_parser_new(CMARK_OPT_DEFAULT);
- *     FILE *fp = fopen("myfile.md", "r");
+ *     FILE *fp = fopen("myfile.md", "rb");
  *     while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
  *     	   cmark_parser_feed(parser, buffer, bytes);
  *     	   if (bytes < sizeof(buffer)) {
diff --git a/src/main.c b/src/main.c
@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
 
   parser = cmark_parser_new(options);
   for (i = 0; i < numfps; i++) {
-    FILE *fp = fopen(argv[files[i]], "r");
+    FILE *fp = fopen(argv[files[i]], "rb");
     if (fp == NULL) {
       fprintf(stderr, "Error opening file %s: %s\n", argv[files[i]],
               strerror(errno));