###### internal functions
- static void do_strip(struct token_state *state)
+ static int do_strip(struct token_state *state)
{
+ int indent = 0;
if (state->node->needs_strip) {
int n = 4;
while (n && state->node->code.txt[state->offset] == ' ') {
+ indent += 1;
state->offset += 1;
n -= 1;
}
while (n == 4 && state->node->code.txt[state->offset] == '\t') {
+ indent = indent_tab(indent);
state->offset += 1;
n -= 4;
}
}
+ return indent;
}
static wint_t get_char(struct token_state *state)
state->offset = 0;
if (state->node == NULL)
return WEOF;
- do_strip(state);
state->line = state->node->line_no;
- state->col = state->node->indent;
+ state->col = do_strip(state);
}
## before get_char
state->col += 1;
} else if (is_newline(next)) {
state->line += 1;
- state->col = state->node->indent;
- do_strip(state);
+ state->col = do_strip(state);
} else if (next == '\t') {
state->col = indent_tab(state->col);
}
memset(state, 0, sizeof(*state));
state->node = code;
state->line = code->line_no;
- state->col = code->indent;
+ state->col = do_strip(state);
state->conf = conf;
- do_strip(state);
return state;
}
void token_close(struct token_state *state)