cmark

Unnamed repository; edit this file 'description' to name the repository.

commit 366af1187ad409b2fca12cd7a2b939019727db7d
parent 4cf29883ef1307de329bf381d53e9aeb8e1f65a7
Author: John MacFarlane <jgm@berkeley.edu>
Date:   Tue,  2 Dec 2014 16:20:58 -0800

Merge pull request #232 from nwellnhof/eof_detection

Fix EOF detection
Diffstat:
Msrc/blocks.c | 3+++
Msrc/main.c | 6++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/blocks.c b/src/blocks.c
@@ -435,6 +435,9 @@ cmark_node *cmark_parse_file(FILE *f)
 	while ((bytes = fread(buffer, 1, sizeof(buffer), f)) > 0) {
 		bool eof = bytes < sizeof(buffer);
 		S_parser_feed(parser, buffer, bytes, eof);
+		if (eof) {
+			break;
+		}
 	}
 
 	document = cmark_parser_finish(parser);
diff --git a/src/main.c b/src/main.c
@@ -71,6 +71,9 @@ int main(int argc, char *argv[])
 		start_timer();
 		while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
 			cmark_parser_feed(parser, buffer, bytes);
+			if (bytes < sizeof(buffer)) {
+				break;
+			}
 		}
 		end_timer("processing lines");
 
@@ -86,6 +89,9 @@ int main(int argc, char *argv[])
 
 		while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
 			cmark_parser_feed(parser, buffer, bytes);
+			if (bytes < sizeof(buffer)) {
+				break;
+			}
 		}
 	}