提交 a8cc2253 编写于 作者: S Szabolcs Nagy 提交者: Rich Felker

regex: clean up position accounting for literal nodes

This should not change the meaning of the code, just make the intent
clearer: advancing position is tied to adding a new literal.
上级 9ee57db8
......@@ -834,22 +834,20 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s)
return REG_EBRACE;
s++;
}
node = tre_ast_new_literal(ctx->mem, v, v, ctx->position);
ctx->position++;
node = tre_ast_new_literal(ctx->mem, v, v, ctx->position++);
s--;
break;
default:
if (!ere && (unsigned)*s-'1' < 9) {
/* back reference */
int val = *s - '0';
node = tre_ast_new_literal(ctx->mem, BACKREF, val, ctx->position);
node = tre_ast_new_literal(ctx->mem, BACKREF, val, ctx->position++);
ctx->max_backref = MAX(val, ctx->max_backref);
} else {
/* extension: accept unknown escaped char
as a literal */
goto parse_literal;
}
ctx->position++;
}
s++;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册