summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-29 17:05:00 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2014-11-29 17:16:31 +0100
commit46ec4da981af45591d25cb54c47a0afd061306c2 (patch)
treeeb1f9078be2db3db72a1d85804477f6255dc3baf /src/main.c
parentad8b39e550f2ff9a8b8e409d1654fc26135dc9fa (diff)
Push parser interface
Replace cmark_parser_process_line with cmark_parser_push that takes arbitrary chunks of data. Also fixes #211.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index 3a7ea4c..87cc151 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
int *files;
char buffer[4096];
cmark_parser *parser;
- size_t offset;
+ size_t bytes;
cmark_node *document;
parser = cmark_parser_new();
@@ -69,9 +69,8 @@ int main(int argc, char *argv[])
}
start_timer();
- while (fgets((char *)buffer, sizeof(buffer), fp)) {
- offset = strlen((char *)buffer);
- cmark_parser_process_line(parser, buffer, offset);
+ while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
+ cmark_parser_push(parser, buffer, bytes);
}
end_timer("processing lines");
@@ -85,9 +84,8 @@ int main(int argc, char *argv[])
exit(0);
*/
- while (fgets((char *)buffer, sizeof(buffer), stdin)) {
- offset = strlen((char *)buffer);
- cmark_parser_process_line(parser, buffer, offset);
+ while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
+ cmark_parser_push(parser, buffer, bytes);
}
}