diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-11 15:45:15 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-11 15:45:15 +0100 |
commit | b402ff844c75bf6e22842d791d261c6f52c6e157 (patch) | |
tree | 583d146c595da36121c9ef9c0bc646780ae69a0f | |
parent | 2930123279c423e5b29639b6992c524571f2add5 (diff) | |
download | busybox-w32-b402ff844c75bf6e22842d791d261c6f52c6e157.tar.gz busybox-w32-b402ff844c75bf6e22842d791d261c6f52c6e157.tar.bz2 busybox-w32-b402ff844c75bf6e22842d791d261c6f52c6e157.zip |
bc: make bc_program_pushVar "z-function"
function old new delta
bc_program_pushVar 200 198 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 4e5ba804f..6ab3a4252 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -186,7 +186,7 @@ | |||
186 | typedef enum BcStatus { | 186 | typedef enum BcStatus { |
187 | BC_STATUS_SUCCESS = 0, | 187 | BC_STATUS_SUCCESS = 0, |
188 | BC_STATUS_FAILURE = 1, | 188 | BC_STATUS_FAILURE = 1, |
189 | BC_STATUS_PARSE_EMPTY_EXP = 2, // bc_parse_expr() uses this | 189 | BC_STATUS_PARSE_EMPTY_EXP = 2, // bc_parse_expr_empty_ok() uses this |
190 | BC_STATUS_EOF = 3, // bc_vm_stdin() uses this | 190 | BC_STATUS_EOF = 3, // bc_vm_stdin() uses this |
191 | } BcStatus; | 191 | } BcStatus; |
192 | 192 | ||
@@ -1299,6 +1299,7 @@ static int push_input_byte(BcVec *vec, char c) | |||
1299 | return 0; | 1299 | return 0; |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | // This is not a "z" function: can also return BC_STATUS_EOF | ||
1302 | static BcStatus bc_read_line(BcVec *vec) | 1303 | static BcStatus bc_read_line(BcVec *vec) |
1303 | { | 1304 | { |
1304 | BcStatus s; | 1305 | BcStatus s; |
@@ -4906,6 +4907,7 @@ static FAST_FUNC BcStatus bc_parse_parse(BcParse *p) | |||
4906 | return s; | 4907 | return s; |
4907 | } | 4908 | } |
4908 | 4909 | ||
4910 | // This is not a "z" function: can also return BC_STATUS_PARSE_EMPTY_EXP | ||
4909 | static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext next) | 4911 | static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext next) |
4910 | { | 4912 | { |
4911 | BcStatus s = BC_STATUS_SUCCESS; | 4913 | BcStatus s = BC_STATUS_SUCCESS; |
@@ -6109,10 +6111,9 @@ static BcStatus bc_program_assign(char inst) | |||
6109 | bc_program_pushVar(code, bgn) | 6111 | bc_program_pushVar(code, bgn) |
6110 | // for bc, 'pop' and 'copy' are always false | 6112 | // for bc, 'pop' and 'copy' are always false |
6111 | #endif | 6113 | #endif |
6112 | static BcStatus bc_program_pushVar(char *code, size_t *bgn, | 6114 | static BC_STATUS bc_program_pushVar(char *code, size_t *bgn, |
6113 | bool pop, bool copy) | 6115 | bool pop, bool copy) |
6114 | { | 6116 | { |
6115 | BcStatus s = BC_STATUS_SUCCESS; | ||
6116 | BcResult r; | 6117 | BcResult r; |
6117 | char *name = bc_program_name(code, bgn); | 6118 | char *name = bc_program_name(code, bgn); |
6118 | 6119 | ||
@@ -6128,7 +6129,7 @@ static BcStatus bc_program_pushVar(char *code, size_t *bgn, | |||
6128 | 6129 | ||
6129 | if (!BC_PROG_STACK(v, 2 - copy)) { | 6130 | if (!BC_PROG_STACK(v, 2 - copy)) { |
6130 | free(name); | 6131 | free(name); |
6131 | return bc_error_stack_has_too_few_elements(); | 6132 | RETURN_STATUS(bc_error_stack_has_too_few_elements()); |
6132 | } | 6133 | } |
6133 | 6134 | ||
6134 | free(name); | 6135 | free(name); |
@@ -6153,8 +6154,13 @@ static BcStatus bc_program_pushVar(char *code, size_t *bgn, | |||
6153 | 6154 | ||
6154 | bc_vec_push(&G.prog.results, &r); | 6155 | bc_vec_push(&G.prog.results, &r); |
6155 | 6156 | ||
6156 | return s; | 6157 | RETURN_STATUS(BC_STATUS_SUCCESS); |
6157 | } | 6158 | } |
6159 | #if ERRORS_ARE_FATAL | ||
6160 | # define zbc_program_pushVar(...) (bc_program_pushVar(__VA_ARGS__), BC_STATUS_SUCCESS) | ||
6161 | #else | ||
6162 | # define zbc_program_pushVar(...) bc_program_pushVar(__VA_ARGS__) | ||
6163 | #endif | ||
6158 | 6164 | ||
6159 | static BC_STATUS zbc_program_pushArray(char *code, size_t *bgn, | 6165 | static BC_STATUS zbc_program_pushArray(char *code, size_t *bgn, |
6160 | char inst) | 6166 | char inst) |
@@ -6826,7 +6832,7 @@ static BcStatus bc_program_exec(void) | |||
6826 | s = bc_program_read(); | 6832 | s = bc_program_read(); |
6827 | break; | 6833 | break; |
6828 | case BC_INST_VAR: | 6834 | case BC_INST_VAR: |
6829 | s = bc_program_pushVar(code, &ip->idx, false, false); | 6835 | s = zbc_program_pushVar(code, &ip->idx, false, false); |
6830 | break; | 6836 | break; |
6831 | case BC_INST_ARRAY_ELEM: | 6837 | case BC_INST_ARRAY_ELEM: |
6832 | case BC_INST_ARRAY: | 6838 | case BC_INST_ARRAY: |
@@ -6954,7 +6960,7 @@ static BcStatus bc_program_exec(void) | |||
6954 | case BC_INST_LOAD: | 6960 | case BC_INST_LOAD: |
6955 | case BC_INST_PUSH_VAR: { | 6961 | case BC_INST_PUSH_VAR: { |
6956 | bool copy = inst == BC_INST_LOAD; | 6962 | bool copy = inst == BC_INST_LOAD; |
6957 | s = bc_program_pushVar(code, &ip->idx, true, copy); | 6963 | s = zbc_program_pushVar(code, &ip->idx, true, copy); |
6958 | break; | 6964 | break; |
6959 | } | 6965 | } |
6960 | case BC_INST_PUSH_TO_VAR: { | 6966 | case BC_INST_PUSH_TO_VAR: { |