X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=parser.c;h=33466347ed89bb85cd726d4883cf93dc03557619;hb=f92a7609f7b4a6c72a892b16d371528213eca283;hp=29dbf83d36c2cb1d70587c7740d3604acd5f109a;hpb=ecb540df90fa1b07218b20e5893a8c58d90447a9;p=smdp.git diff --git a/parser.c b/parser.c index 29dbf83..3346634 100644 --- a/parser.c +++ b/parser.c @@ -81,7 +81,7 @@ deck_t *markdown_load(FILE *input) { } else if(c == '\t') { // expand tab to spaces - for (i = 0; i <= EXPAND_TABS; i++) { + for (i = 0; i < EXPAND_TABS; i++) { (text->expand)(text, ' '); l++; } @@ -172,7 +172,8 @@ deck_t *markdown_load(FILE *input) { // remove line from linked list line->prev->next = line->next; - line->next->prev = line->prev; + if(line->next) + line->next->prev = line->prev; // set bits on revious line if(CHECK_BIT(line->bits, IS_H1)) { @@ -360,12 +361,16 @@ int next_nonblank(cstring_t *text, int i) { ++i; return i; -}; +} int next_blank(cstring_t *text, int i) { while ((i < text->size) && !isspace((text->text)[i])) ++i; return i; -}; +} + +int next_word(cstring_t *text, int i) { + return next_nonblank(text, next_blank(text, i)); +}