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.
This commit is contained in:
Szabolcs Nagy 2015-04-18 14:31:07 +00:00 committed by Rich Felker
parent 9ee57db883
commit a8cc225384
1 changed files with 2 additions and 4 deletions

View File

@ -834,22 +834,20 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s)
return REG_EBRACE; return REG_EBRACE;
s++; s++;
} }
node = tre_ast_new_literal(ctx->mem, v, v, ctx->position); node = tre_ast_new_literal(ctx->mem, v, v, ctx->position++);
ctx->position++;
s--; s--;
break; break;
default: default:
if (!ere && (unsigned)*s-'1' < 9) { if (!ere && (unsigned)*s-'1' < 9) {
/* back reference */ /* back reference */
int val = *s - '0'; 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); ctx->max_backref = MAX(val, ctx->max_backref);
} else { } else {
/* extension: accept unknown escaped char /* extension: accept unknown escaped char
as a literal */ as a literal */
goto parse_literal; goto parse_literal;
} }
ctx->position++;
} }
s++; s++;
break; break;