aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-07-01 16:02:16 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-07-01 16:17:33 +0200
commit1573487e2100892d06e3628828690692313a48d5 (patch)
tree4ca53ea057c89dda604a1cb893734cf89c557dba
parentd7354df169603807fe2ac4f8a0f9f72c9703184f (diff)
downloadbusybox-w32-1573487e2100892d06e3628828690692313a48d5.tar.gz
busybox-w32-1573487e2100892d06e3628828690692313a48d5.tar.bz2
busybox-w32-1573487e2100892d06e3628828690692313a48d5.zip
awk: rename temp variables, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 47bbc10a6..2c2cb74d7 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1775,14 +1775,14 @@ static node *mk_splitter(const char *s, tsplitter *spl)
1775static regex_t *as_regex(node *op, regex_t *preg) 1775static regex_t *as_regex(node *op, regex_t *preg)
1776{ 1776{
1777 int cflags; 1777 int cflags;
1778 var *v; 1778 var *tmpvar;
1779 const char *s; 1779 const char *s;
1780 1780
1781 if ((op->info & OPCLSMASK) == OC_REGEXP) { 1781 if ((op->info & OPCLSMASK) == OC_REGEXP) {
1782 return icase ? op->r.ire : op->l.re; 1782 return icase ? op->r.ire : op->l.re;
1783 } 1783 }
1784 v = nvalloc(1); 1784 tmpvar = nvalloc(1);
1785 s = getvar_s(evaluate(op, v)); 1785 s = getvar_s(evaluate(op, tmpvar));
1786 1786
1787 cflags = icase ? REG_EXTENDED | REG_ICASE : REG_EXTENDED; 1787 cflags = icase ? REG_EXTENDED | REG_ICASE : REG_EXTENDED;
1788 /* Testcase where REG_EXTENDED fails (unpaired '{'): 1788 /* Testcase where REG_EXTENDED fails (unpaired '{'):
@@ -1794,7 +1794,7 @@ static regex_t *as_regex(node *op, regex_t *preg)
1794 cflags &= ~REG_EXTENDED; 1794 cflags &= ~REG_EXTENDED;
1795 xregcomp(preg, s, cflags); 1795 xregcomp(preg, s, cflags);
1796 } 1796 }
1797 nvfree(v, 1); 1797 nvfree(tmpvar, 1);
1798 return preg; 1798 return preg;
1799} 1799}
1800 1800
@@ -2243,12 +2243,12 @@ static char *awk_printf(node *n, int *len)
2243 const char *s1; 2243 const char *s1;
2244 int i, j, incr, bsize; 2244 int i, j, incr, bsize;
2245 char c, c1; 2245 char c, c1;
2246 var *v, *arg; 2246 var *tmpvar, *arg;
2247 2247
2248 v = nvalloc(1); 2248 tmpvar = nvalloc(1);
2249//TODO: above, to avoid allocating a single temporary var, take a pointer 2249//TODO: above, to avoid allocating a single temporary var, take a pointer
2250//to a temporary that our caller (evaluate()) already has? 2250//to a temporary that our caller (evaluate()) already has?
2251 fmt = f = xstrdup(getvar_s(evaluate(nextarg(&n), v))); 2251 fmt = f = xstrdup(getvar_s(evaluate(nextarg(&n), tmpvar)));
2252 2252
2253 i = 0; 2253 i = 0;
2254 while (*f) { 2254 while (*f) {
@@ -2268,7 +2268,7 @@ static char *awk_printf(node *n, int *len)
2268 f++; 2268 f++;
2269 c1 = *f; 2269 c1 = *f;
2270 *f = '\0'; 2270 *f = '\0';
2271 arg = evaluate(nextarg(&n), v); 2271 arg = evaluate(nextarg(&n), tmpvar);
2272 2272
2273 j = i; 2273 j = i;
2274 if (c == 'c' || !c) { 2274 if (c == 'c' || !c) {
@@ -2289,7 +2289,7 @@ static char *awk_printf(node *n, int *len)
2289 } 2289 }
2290 2290
2291 free(fmt); 2291 free(fmt);
2292 nvfree(v, 1); 2292 nvfree(tmpvar, 1);
2293 b = xrealloc(b, i + 1); 2293 b = xrealloc(b, i + 1);
2294 b[i] = '\0'; 2294 b[i] = '\0';
2295#if ENABLE_FEATURE_AWK_GNU_EXTENSIONS 2295#if ENABLE_FEATURE_AWK_GNU_EXTENSIONS
@@ -2429,7 +2429,7 @@ static NOINLINE var *exec_builtin(node *op, var *res)
2429{ 2429{
2430#define tspl (G.exec_builtin__tspl) 2430#define tspl (G.exec_builtin__tspl)
2431 2431
2432 var *tv; 2432 var *tmpvars;
2433 node *an[4]; 2433 node *an[4];
2434 var *av[4]; 2434 var *av[4];
2435 const char *as[4]; 2435 const char *as[4];
@@ -2441,7 +2441,12 @@ static NOINLINE var *exec_builtin(node *op, var *res)
2441 time_t tt; 2441 time_t tt;
2442 int i, l, ll, n; 2442 int i, l, ll, n;
2443 2443
2444 tv = nvalloc(4); 2444 tmpvars = nvalloc(4);
2445#define TMPVAR0 (tmpvars)
2446#define TMPVAR1 (tmpvars + 1)
2447#define TMPVAR2 (tmpvars + 2)
2448#define TMPVAR3 (tmpvars + 3)
2449#define TMPVAR(i) (tmpvars + (i))
2445 isr = info = op->info; 2450 isr = info = op->info;
2446 op = op->l.n; 2451 op = op->l.n;
2447 2452
@@ -2449,7 +2454,7 @@ static NOINLINE var *exec_builtin(node *op, var *res)
2449 for (i = 0; i < 4 && op; i++) { 2454 for (i = 0; i < 4 && op; i++) {
2450 an[i] = nextarg(&op); 2455 an[i] = nextarg(&op);
2451 if (isr & 0x09000000) 2456 if (isr & 0x09000000)
2452 av[i] = evaluate(an[i], &tv[i]); 2457 av[i] = evaluate(an[i], TMPVAR(i));
2453 if (isr & 0x08000000) 2458 if (isr & 0x08000000)
2454 as[i] = getvar_s(av[i]); 2459 as[i] = getvar_s(av[i]);
2455 isr >>= 1; 2460 isr >>= 1;
@@ -2474,7 +2479,7 @@ static NOINLINE var *exec_builtin(node *op, var *res)
2474 2479
2475 if (nargs > 2) { 2480 if (nargs > 2) {
2476 spl = (an[2]->info & OPCLSMASK) == OC_REGEXP ? 2481 spl = (an[2]->info & OPCLSMASK) == OC_REGEXP ?
2477 an[2] : mk_splitter(getvar_s(evaluate(an[2], &tv[2])), &tspl); 2482 an[2] : mk_splitter(getvar_s(evaluate(an[2], TMPVAR2)), &tspl);
2478 } else { 2483 } else {
2479 spl = &fsplitter.n; 2484 spl = &fsplitter.n;
2480 } 2485 }
@@ -2617,7 +2622,13 @@ static NOINLINE var *exec_builtin(node *op, var *res)
2617 break; 2622 break;
2618 } 2623 }
2619 2624
2620 nvfree(tv, 4); 2625 nvfree(tmpvars, 4);
2626#undef TMPVAR0
2627#undef TMPVAR1
2628#undef TMPVAR2
2629#undef TMPVAR3
2630#undef TMPVAR
2631
2621 return res; 2632 return res;
2622#undef tspl 2633#undef tspl
2623} 2634}
@@ -2636,14 +2647,16 @@ static var *evaluate(node *op, var *res)
2636#define seed (G.evaluate__seed) 2647#define seed (G.evaluate__seed)
2637#define sreg (G.evaluate__sreg) 2648#define sreg (G.evaluate__sreg)
2638 2649
2639 var *v1; 2650 var *tmpvars;
2651#define TMPVAR0 (tmpvars)
2652#define TMPVAR1 (tmpvars + 1)
2640 2653
2641 if (!op) 2654 if (!op)
2642 return setvar_s(res, NULL); 2655 return setvar_s(res, NULL);
2643 2656
2644 debug_printf_eval("entered %s()\n", __func__); 2657 debug_printf_eval("entered %s()\n", __func__);
2645 2658
2646 v1 = nvalloc(2); 2659 tmpvars = nvalloc(2);
2647 2660
2648 while (op) { 2661 while (op) {
2649 struct { 2662 struct {
@@ -2683,7 +2696,7 @@ static var *evaluate(node *op, var *res)
2683 } 2696 }
2684 if (op1->r.n) { /* array ref? */ 2697 if (op1->r.n) { /* array ref? */
2685 const char *s; 2698 const char *s;
2686 s = getvar_s(evaluate(op1->r.n, v1)); 2699 s = getvar_s(evaluate(op1->r.n, TMPVAR0));
2687 hash_remove(iamarray(v), s); 2700 hash_remove(iamarray(v), s);
2688 } else { 2701 } else {
2689 clear_array(iamarray(v)); 2702 clear_array(iamarray(v));
@@ -2693,7 +2706,7 @@ static var *evaluate(node *op, var *res)
2693 2706
2694 /* execute inevitable things */ 2707 /* execute inevitable things */
2695 if (opinfo & OF_RES1) 2708 if (opinfo & OF_RES1)
2696 L.v = evaluate(op1, v1); 2709 L.v = evaluate(op1, TMPVAR0);
2697 if (opinfo & OF_STR1) { 2710 if (opinfo & OF_STR1) {
2698 L.s = getvar_s(L.v); 2711 L.s = getvar_s(L.v);
2699 debug_printf_eval("L.s:'%s'\n", L.s); 2712 debug_printf_eval("L.s:'%s'\n", L.s);
@@ -2710,7 +2723,7 @@ static var *evaluate(node *op, var *res)
2710 * (Seen trying to evaluate "$444 $44444") 2723 * (Seen trying to evaluate "$444 $44444")
2711 */ 2724 */
2712 if (opinfo & OF_RES2) { 2725 if (opinfo & OF_RES2) {
2713 R.v = evaluate(op->r.n, v1+1); 2726 R.v = evaluate(op->r.n, TMPVAR1);
2714 //TODO: L.v may be invalid now, set L.v to NULL to catch bugs? 2727 //TODO: L.v may be invalid now, set L.v to NULL to catch bugs?
2715 //L.v = NULL; 2728 //L.v = NULL;
2716 } 2729 }
@@ -2793,7 +2806,7 @@ static var *evaluate(node *op, var *res)
2793 fputs(getvar_s(intvar[F0]), F); 2806 fputs(getvar_s(intvar[F0]), F);
2794 } else { 2807 } else {
2795 for (;;) { 2808 for (;;) {
2796 var *v = evaluate(nextarg(&op1), v1); 2809 var *v = evaluate(nextarg(&op1), TMPVAR0);
2797 if (v->type & VF_NUMBER) { 2810 if (v->type & VF_NUMBER) {
2798 fmt_num(g_buf, MAXVARFMT, getvar_s(intvar[OFMT]), 2811 fmt_num(g_buf, MAXVARFMT, getvar_s(intvar[OFMT]),
2799 getvar_i(v), TRUE); 2812 getvar_i(v), TRUE);
@@ -2892,7 +2905,7 @@ static var *evaluate(node *op, var *res)
2892 /* if source is a temporary string, jusk relink it to dest */ 2905 /* if source is a temporary string, jusk relink it to dest */
2893//Disabled: if R.v is numeric but happens to have cached R.v->string, 2906//Disabled: if R.v is numeric but happens to have cached R.v->string,
2894//then L.v ends up being a string, which is wrong 2907//then L.v ends up being a string, which is wrong
2895// if (R.v == v1+1 && R.v->string) { 2908// if (R.v == TMPVAR1 && R.v->string) {
2896// res = setvar_p(L.v, R.v->string); 2909// res = setvar_p(L.v, R.v->string);
2897// R.v->string = NULL; 2910// R.v->string = NULL;
2898// } else { 2911// } else {
@@ -2908,7 +2921,7 @@ static var *evaluate(node *op, var *res)
2908 break; 2921 break;
2909 2922
2910 case XC( OC_FUNC ): { 2923 case XC( OC_FUNC ): {
2911 var *tv, *sv_fnargs; 2924 var *argvars, *sv_fnargs;
2912 const char *sv_progname; 2925 const char *sv_progname;
2913 int nargs, i; 2926 int nargs, i;
2914 2927
@@ -2919,10 +2932,10 @@ static var *evaluate(node *op, var *res)
2919 2932
2920 /* The body might be empty, still has to eval the args */ 2933 /* The body might be empty, still has to eval the args */
2921 nargs = op->r.f->nargs; 2934 nargs = op->r.f->nargs;
2922 tv = nvalloc(nargs); 2935 argvars = nvalloc(nargs);
2923 i = 0; 2936 i = 0;
2924 while (op1) { 2937 while (op1) {
2925 var *arg = evaluate(nextarg(&op1), v1); 2938 var *arg = evaluate(nextarg(&op1), TMPVAR0);
2926 if (i == nargs) { 2939 if (i == nargs) {
2927 /* call with more arguments than function takes. 2940 /* call with more arguments than function takes.
2928 * (gawk warns: "warning: function 'f' called with more arguments than declared"). 2941 * (gawk warns: "warning: function 'f' called with more arguments than declared").
@@ -2930,18 +2943,18 @@ static var *evaluate(node *op, var *res)
2930 clrvar(arg); 2943 clrvar(arg);
2931 continue; 2944 continue;
2932 } 2945 }
2933 copyvar(&tv[i], arg); 2946 copyvar(&argvars[i], arg);
2934 tv[i].type |= VF_CHILD; 2947 argvars[i].type |= VF_CHILD;
2935 tv[i].x.parent = arg; 2948 argvars[i].x.parent = arg;
2936 i++; 2949 i++;
2937 } 2950 }
2938 2951
2939 sv_fnargs = fnargs; 2952 sv_fnargs = fnargs;
2940 sv_progname = g_progname; 2953 sv_progname = g_progname;
2941 2954
2942 fnargs = tv; 2955 fnargs = argvars;
2943 res = evaluate(op->r.f->body.first, res); 2956 res = evaluate(op->r.f->body.first, res);
2944 nvfree(fnargs, nargs); 2957 nvfree(argvars, nargs);
2945 2958
2946 g_progname = sv_progname; 2959 g_progname = sv_progname;
2947 fnargs = sv_fnargs; 2960 fnargs = sv_fnargs;
@@ -3266,7 +3279,10 @@ static var *evaluate(node *op, var *res)
3266 break; 3279 break;
3267 } /* while (op) */ 3280 } /* while (op) */
3268 3281
3269 nvfree(v1, 2); 3282 nvfree(tmpvars, 2);
3283#undef TMPVAR0
3284#undef TMPVAR1
3285
3270 debug_printf_eval("returning from %s(): %p\n", __func__, res); 3286 debug_printf_eval("returning from %s(): %p\n", __func__, res);
3271 return res; 3287 return res;
3272#undef fnargs 3288#undef fnargs