From c351c72220406d3e934049808ecd09e599487a85 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 5 Feb 2016 22:43:22 -0800 Subject: Added partially_consumed_tab to parser. This keeps track of when we have gotten partway through a tab when consuming initial indentation. --- src/blocks.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/blocks.c') 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; -- cgit v1.2.3