sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 07c4f784a64dd79032cfbd4ef5ebeb73089a2e77
parent 90751ab4ba7b0772c3816cf86783fd3490cf9172
Author: Evan Gates <evan.gates@gmail.com>
Date:   Thu,  5 Mar 2015 17:20:40 -0800

don't mix declarations and code (and one ** to *[])

Diffstat:
Mexpr.c | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/expr.c b/expr.c @@ -64,7 +64,8 @@ match(Val vstr, Val vregx) { regex_t re; regmatch_t matches[2]; - char buf1[intlen], buf2[intlen]; + intmax_t d; + char *s, *p, buf1[intlen], buf2[intlen]; char *str = valstr(vstr, buf1, sizeof(buf1)); char *regx = valstr(vregx, buf2, sizeof(buf2));; char anchreg[strlen(regx) + 2]; @@ -79,9 +80,9 @@ match(Val vstr, Val vregx) } if (re.re_nsub) { - intmax_t d; - char *s = str + matches[1].rm_so, *p = str + matches[1].rm_eo; regfree(&re); + s = str + matches[1].rm_so; + p = str + matches[1].rm_eo; *p = '\0'; d = strtoimax(s, &p, 10); @@ -193,11 +194,11 @@ lex(char *s, Val *v) * ops is the operator stack, opp points to one past last op on the stack */ static int -parse(char **expr, int exprlen) +parse(char *expr[], int exprlen) { - Val vals[exprlen], *valp = vals; + Val vals[exprlen], *valp = vals, v; int ops[exprlen], *opp = ops; - int i, lasttype = 0; + int i, type, lasttype = 0; char prec[] = { /* precedence of operators */ ['|'] = 1, ['&'] = 2, @@ -208,10 +209,7 @@ parse(char **expr, int exprlen) }; for (i = 0; i < exprlen; i++) { - Val v; - int type = lex(expr[i], &v); - - switch (type) { + switch ((type = lex(expr[i], &v))) { case VAL: *valp++ = v; break;