From 03a6547b8cea55c8917214a363cadda5b7cffd31 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 26 Mar 2016 12:20:28 +0100 Subject: Open files in binary mode Now that cmark supports different line endings, files must be openend in binary mode on Windows. Fixes issue #113. --- man/man3/cmark.3 | 2 +- src/cmark.h | 2 +- src/main.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/man3/cmark.3 b/man/man3/cmark.3 index 523a3d4..283b9cc 100644 --- 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 index 31bbf01..3c5d6b6 100644 --- 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 index f9fa29c..c44ba13 100644 --- 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)); -- cgit v1.2.3