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>
This commit is contained in:
Denys Vlasenko 2018-12-13 19:58:58 +01:00
parent 915c72b273
commit 0fe270e775

View File

@ -7010,7 +7010,9 @@ static BC_STATUS zbc_vm_process(const char *text)
static BC_STATUS zbc_vm_file(const char *file) static BC_STATUS zbc_vm_file(const char *file)
{ {
const char *sv_file; // So far bc/dc have no way to include a file from another file,
// therefore we know G.prog.file == NULL on entry
//const char *sv_file;
char *data; char *data;
BcStatus s; BcStatus s;
BcFunc *main_func; BcFunc *main_func;
@ -7019,7 +7021,7 @@ static BC_STATUS zbc_vm_file(const char *file)
data = bc_read_file(file); data = bc_read_file(file);
if (!data) RETURN_STATUS(bc_error_fmt("file '%s' is not text", file)); if (!data) RETURN_STATUS(bc_error_fmt("file '%s' is not text", file));
sv_file = G.prog.file; //sv_file = G.prog.file;
G.prog.file = file; G.prog.file = file;
bc_lex_file(&G.prs.l); bc_lex_file(&G.prs.l);
s = zbc_vm_process(data); s = zbc_vm_process(data);
@ -7032,7 +7034,8 @@ static BC_STATUS zbc_vm_file(const char *file)
s = bc_error_fmt("file '%s' is not executable", file); s = bc_error_fmt("file '%s' is not executable", file);
err: err:
G.prog.file = sv_file; //G.prog.file = sv_file;
G.prog.file = NULL;
free(data); free(data);
RETURN_STATUS(s); RETURN_STATUS(s);
} }
@ -7047,7 +7050,7 @@ static BC_STATUS zbc_vm_stdin(void)
size_t str; size_t str;
bool comment; bool comment;
G.prog.file = NULL; //G.prog.file = NULL; - already is
bc_lex_file(&G.prs.l); bc_lex_file(&G.prs.l);
bc_char_vec_init(&buffer); bc_char_vec_init(&buffer);