X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fparser.c;h=e59f1be9489355a547ea6280787158a05e7eb9c0;hb=b1e0c986d6e531f71d0a3ecc01551ab2d9cd8929;hp=c8120cd31175f8a1f6b333b25bd33c2297e4c10b;hpb=c6516c715699de465423de60089efee1ec5857e1;p=smdp.git diff --git a/src/parser.c b/src/parser.c index c8120cd..e59f1be 100644 --- a/src/parser.c +++ b/src/parser.c @@ -22,8 +22,10 @@ */ #include +#include #include #include +#include #include "parser.h" @@ -48,6 +50,11 @@ deck_t *markdown_load(FILE *input) { sc++; while ((c = fgetc(input)) != EOF) { + if (ferror(input)) { + fprintf(stderr, "markdown_load() failed to read input: %s\n", strerror(errno)); + exit(EXIT_FAILURE); + } + if(c == '\n') { // markdown analyse @@ -266,7 +273,7 @@ deck_t *markdown_load(FILE *input) { } tmp = tmp->next; } - + for(tmp = line; tmp != list_last_level_1; tmp = tmp->next) { SET_BIT(tmp->bits, IS_UNORDERED_LIST_1); } @@ -337,12 +344,12 @@ int markdown_analyse(cstring_t *text) { case 3: SET_BIT(bits, IS_UNORDERED_LIST_3); break; default: break; } - + break; } } } - + if(!CHECK_BIT(bits, IS_UNORDERED_LIST_1) && !CHECK_BIT(bits, IS_UNORDERED_LIST_2) && !CHECK_BIT(bits, IS_UNORDERED_LIST_3)) { @@ -518,4 +525,3 @@ int next_blank(cstring_t *text, int i) { int next_word(cstring_t *text, int i) { return next_nonblank(text, next_blank(text, i)); } -