summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko2021-07-02 14:33:13 +0200
committerDenys Vlasenko2021-07-02 14:33:13 +0200
commit966cafcc77d8cda5d1a95bc73080e9a9b9010a45 (patch)
tree1132e94897f9173c35e3a7c0b0c3344e03258c66 /editors
parent1193c68fa718ff16c47aba23f8532bf1568f294e (diff)
downloadbusybox-966cafcc77d8cda5d1a95bc73080e9a9b9010a45.zip
busybox-966cafcc77d8cda5d1a95bc73080e9a9b9010a45.tar.gz
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>
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/editors/awk.c b/editors/awk.c
index f65449a..9f5a940 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -562,6 +562,8 @@ struct globals2 {
var ptest__tmpvar;
var awk_printf__tmpvar;
var as_regex__tmpvar;
+ var exit__tmpvar;
+ var main__tmpvar;
tsplitter exec_builtin__tspl;
@@ -638,11 +640,6 @@ static void syntax_error(const char *message)
bb_error_msg_and_die("%s:%i: %s", g_progname, g_lineno, message);
}
-static void zero_out_var(var *vp)
-{
- memset(vp, 0, sizeof(*vp));
-}
-
/* ---- hash stuff ---- */
static unsigned hashidx(const char *name)
@@ -3372,11 +3369,9 @@ static int awk_exit(int r)
unsigned i;
if (!exiting) {
- var tv;
exiting = TRUE;
nextrec = FALSE;
- zero_out_var(&tv);
- evaluate(endseq.first, &tv);
+ evaluate(endseq.first, &G.exit__tmpvar);
}
/* waiting for children */
@@ -3404,7 +3399,6 @@ int awk_main(int argc UNUSED_PARAM, char **argv)
llist_t *list_e = NULL;
#endif
int i;
- var tv;
INIT_G();
@@ -3514,8 +3508,7 @@ int awk_main(int argc UNUSED_PARAM, char **argv)
newfile("/dev/stdout")->F = stdout;
newfile("/dev/stderr")->F = stderr;
- zero_out_var(&tv);
- evaluate(beginseq.first, &tv);
+ evaluate(beginseq.first, &G.main__tmpvar);
if (!mainseq.first && !endseq.first)
awk_exit(EXIT_SUCCESS);
@@ -3532,7 +3525,7 @@ int awk_main(int argc UNUSED_PARAM, char **argv)
nextrec = FALSE;
incvar(intvar[NR]);
incvar(intvar[FNR]);
- evaluate(mainseq.first, &tv);
+ evaluate(mainseq.first, &G.main__tmpvar);
if (nextfile)
break;