diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-02-05 22:43:22 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-02-05 22:43:22 -0800 |
commit | c351c72220406d3e934049808ecd09e599487a85 (patch) | |
tree | cf1772308daead6d773e365fac19aba2d20d7c3a /src | |
parent | 6182bc78cc0531a735a0ffc452f2922485af05c1 (diff) |
Added partially_consumed_tab to parser.
This keeps track of when we have gotten partway
through a tab when consuming initial indentation.
Diffstat (limited to 'src')
-rw-r--r-- | src/blocks.c | 7 | ||||
-rw-r--r-- | src/parser.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/blocks.c b/src/blocks.c index 6d02a84..424257c 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -70,6 +70,7 @@ cmark_parser *cmark_parser_new(int options) { parser->first_nonspace_column = 0; parser->indent = 0; parser->blank = false; + parser->partially_consumed_tab = false; parser->curline = line; parser->last_line_length = 0; parser->linebuf = buf; @@ -574,11 +575,13 @@ static void S_advance_offset(cmark_parser *parser, cmark_chunk *input, while (count > 0 && (c = peek_at(input, parser->offset))) { if (c == '\t') { chars_to_tab = TAB_STOP - (parser->column % TAB_STOP); - chars_to_advance = chars_to_tab > count ? count : chars_to_tab; + parser->partially_consumed_tab = chars_to_tab > count; + chars_to_advance = parser->partially_consumed_tab ? count : chars_to_tab; parser->column += chars_to_advance; - parser->offset += chars_to_advance < chars_to_tab ? 0 : 1; + parser->offset += parser->partially_consumed_tab ? 0 : 1; count -= (columns ? chars_to_advance : 1); } else { + parser->partially_consumed_tab = false; parser->offset += 1; parser->column += 1; // assume ascii; block starts are ascii count -= 1; diff --git a/src/parser.h b/src/parser.h index f359e10..b3ff39b 100644 --- a/src/parser.h +++ b/src/parser.h @@ -22,6 +22,7 @@ struct cmark_parser { bufsize_t first_nonspace_column; int indent; bool blank; + bool partially_consumed_tab; cmark_strbuf *curline; bufsize_t last_line_length; cmark_strbuf *linebuf; |