summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2015-04-18 14:31:07 +0000
committerRich Felker <dalias@aerifal.cx>2016-01-30 20:51:58 -0500
commita8cc2253843e30dfbdf0bb2954439d9f2b2e8704 (patch)
tree8173ad73162abc8302d692a826bf2dbd21a8f84d
parent9ee57db8834ee0d9adb1e6a84a75b0818dbfca69 (diff)
downloadmusl-a8cc2253843e30dfbdf0bb2954439d9f2b2e8704.tar.gz
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.
-rw-r--r--src/regex/regcomp.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index 330de467..ac207c89 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -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;