diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-02 14:33:13 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-02 14:33:13 +0200 |
commit | 966cafcc77d8cda5d1a95bc73080e9a9b9010a45 (patch) | |
tree | 1132e94897f9173c35e3a7c0b0c3344e03258c66 | |
parent | 1193c68fa718ff16c47aba23f8532bf1568f294e (diff) | |
download | busybox-w32-966cafcc77d8cda5d1a95bc73080e9a9b9010a45.tar.gz busybox-w32-966cafcc77d8cda5d1a95bc73080e9a9b9010a45.tar.bz2 busybox-w32-966cafcc77d8cda5d1a95bc73080e9a9b9010a45.zip |
awk: use "static" tmpvars in main and exit
function old new delta
awk_exit 103 93 -10
awk_main 850 832 -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-28) Total: -28 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/editors/awk.c b/editors/awk.c index f65449a09..9f5a94037 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -562,6 +562,8 @@ struct globals2 { | |||
562 | var ptest__tmpvar; | 562 | var ptest__tmpvar; |
563 | var awk_printf__tmpvar; | 563 | var awk_printf__tmpvar; |
564 | var as_regex__tmpvar; | 564 | var as_regex__tmpvar; |
565 | var exit__tmpvar; | ||
566 | var main__tmpvar; | ||
565 | 567 | ||
566 | tsplitter exec_builtin__tspl; | 568 | tsplitter exec_builtin__tspl; |
567 | 569 | ||
@@ -638,11 +640,6 @@ static void syntax_error(const char *message) | |||
638 | bb_error_msg_and_die("%s:%i: %s", g_progname, g_lineno, message); | 640 | bb_error_msg_and_die("%s:%i: %s", g_progname, g_lineno, message); |
639 | } | 641 | } |
640 | 642 | ||
641 | static void zero_out_var(var *vp) | ||
642 | { | ||
643 | memset(vp, 0, sizeof(*vp)); | ||
644 | } | ||
645 | |||
646 | /* ---- hash stuff ---- */ | 643 | /* ---- hash stuff ---- */ |
647 | 644 | ||
648 | static unsigned hashidx(const char *name) | 645 | static unsigned hashidx(const char *name) |
@@ -3372,11 +3369,9 @@ static int awk_exit(int r) | |||
3372 | unsigned i; | 3369 | unsigned i; |
3373 | 3370 | ||
3374 | if (!exiting) { | 3371 | if (!exiting) { |
3375 | var tv; | ||
3376 | exiting = TRUE; | 3372 | exiting = TRUE; |
3377 | nextrec = FALSE; | 3373 | nextrec = FALSE; |
3378 | zero_out_var(&tv); | 3374 | evaluate(endseq.first, &G.exit__tmpvar); |
3379 | evaluate(endseq.first, &tv); | ||
3380 | } | 3375 | } |
3381 | 3376 | ||
3382 | /* waiting for children */ | 3377 | /* waiting for children */ |
@@ -3404,7 +3399,6 @@ int awk_main(int argc UNUSED_PARAM, char **argv) | |||
3404 | llist_t *list_e = NULL; | 3399 | llist_t *list_e = NULL; |
3405 | #endif | 3400 | #endif |
3406 | int i; | 3401 | int i; |
3407 | var tv; | ||
3408 | 3402 | ||
3409 | INIT_G(); | 3403 | INIT_G(); |
3410 | 3404 | ||
@@ -3514,8 +3508,7 @@ int awk_main(int argc UNUSED_PARAM, char **argv) | |||
3514 | newfile("/dev/stdout")->F = stdout; | 3508 | newfile("/dev/stdout")->F = stdout; |
3515 | newfile("/dev/stderr")->F = stderr; | 3509 | newfile("/dev/stderr")->F = stderr; |
3516 | 3510 | ||
3517 | zero_out_var(&tv); | 3511 | evaluate(beginseq.first, &G.main__tmpvar); |
3518 | evaluate(beginseq.first, &tv); | ||
3519 | if (!mainseq.first && !endseq.first) | 3512 | if (!mainseq.first && !endseq.first) |
3520 | awk_exit(EXIT_SUCCESS); | 3513 | awk_exit(EXIT_SUCCESS); |
3521 | 3514 | ||
@@ -3532,7 +3525,7 @@ int awk_main(int argc UNUSED_PARAM, char **argv) | |||
3532 | nextrec = FALSE; | 3525 | nextrec = FALSE; |
3533 | incvar(intvar[NR]); | 3526 | incvar(intvar[NR]); |
3534 | incvar(intvar[FNR]); | 3527 | incvar(intvar[FNR]); |
3535 | evaluate(mainseq.first, &tv); | 3528 | evaluate(mainseq.first, &G.main__tmpvar); |
3536 | 3529 | ||
3537 | if (nextfile) | 3530 | if (nextfile) |
3538 | break; | 3531 | break; |