diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-13 19:58:58 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-13 19:58:58 +0100 |
commit | 0fe270e77536c8248bbf1c6045229d7ec3aaf8d3 (patch) | |
tree | 7d54faa7044a054d837ab5554680b5d576a35b8b | |
parent | 915c72b27301c933a8efbf4036293ddc1ea35b7d (diff) | |
download | busybox-w32-0fe270e77536c8248bbf1c6045229d7ec3aaf8d3.tar.gz busybox-w32-0fe270e77536c8248bbf1c6045229d7ec3aaf8d3.tar.bz2 busybox-w32-0fe270e77536c8248bbf1c6045229d7ec3aaf8d3.zip |
bc: simplify filename saving in zbc_vm_file()
function old new delta
bc_vm_run 433 423 -10
zbc_vm_file 187 174 -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-23) Total: -23 bytes
text data bss dec hex filename
980350 485 7296 988131 f13e3 busybox_old
980327 485 7296 988108 f13cc busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 57c9ca565..5930caa32 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -7010,7 +7010,9 @@ static BC_STATUS zbc_vm_process(const char *text) | |||
7010 | 7010 | ||
7011 | static BC_STATUS zbc_vm_file(const char *file) | 7011 | static BC_STATUS zbc_vm_file(const char *file) |
7012 | { | 7012 | { |
7013 | const char *sv_file; | 7013 | // So far bc/dc have no way to include a file from another file, |
7014 | // therefore we know G.prog.file == NULL on entry | ||
7015 | //const char *sv_file; | ||
7014 | char *data; | 7016 | char *data; |
7015 | BcStatus s; | 7017 | BcStatus s; |
7016 | BcFunc *main_func; | 7018 | BcFunc *main_func; |
@@ -7019,7 +7021,7 @@ static BC_STATUS zbc_vm_file(const char *file) | |||
7019 | data = bc_read_file(file); | 7021 | data = bc_read_file(file); |
7020 | if (!data) RETURN_STATUS(bc_error_fmt("file '%s' is not text", file)); | 7022 | if (!data) RETURN_STATUS(bc_error_fmt("file '%s' is not text", file)); |
7021 | 7023 | ||
7022 | sv_file = G.prog.file; | 7024 | //sv_file = G.prog.file; |
7023 | G.prog.file = file; | 7025 | G.prog.file = file; |
7024 | bc_lex_file(&G.prs.l); | 7026 | bc_lex_file(&G.prs.l); |
7025 | s = zbc_vm_process(data); | 7027 | s = zbc_vm_process(data); |
@@ -7032,7 +7034,8 @@ static BC_STATUS zbc_vm_file(const char *file) | |||
7032 | s = bc_error_fmt("file '%s' is not executable", file); | 7034 | s = bc_error_fmt("file '%s' is not executable", file); |
7033 | 7035 | ||
7034 | err: | 7036 | err: |
7035 | G.prog.file = sv_file; | 7037 | //G.prog.file = sv_file; |
7038 | G.prog.file = NULL; | ||
7036 | free(data); | 7039 | free(data); |
7037 | RETURN_STATUS(s); | 7040 | RETURN_STATUS(s); |
7038 | } | 7041 | } |
@@ -7047,7 +7050,7 @@ static BC_STATUS zbc_vm_stdin(void) | |||
7047 | size_t str; | 7050 | size_t str; |
7048 | bool comment; | 7051 | bool comment; |
7049 | 7052 | ||
7050 | G.prog.file = NULL; | 7053 | //G.prog.file = NULL; - already is |
7051 | bc_lex_file(&G.prs.l); | 7054 | bc_lex_file(&G.prs.l); |
7052 | 7055 | ||
7053 | bc_char_vec_init(&buffer); | 7056 | bc_char_vec_init(&buffer); |