aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/bc.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 4257511f0..ee05cd4b4 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -5872,49 +5872,50 @@ static BcStatus bc_program_assign(char inst)
5872 return s; 5872 return s;
5873} 5873}
5874 5874
5875#if !ENABLE_DC
5876#define bc_program_pushVar(code, bgn, pop, copy) \
5877 bc_program_pushVar(code, bgn)
5878// for bc, 'pop' and 'copy' are always false
5879#endif
5875static BcStatus bc_program_pushVar(char *code, size_t *bgn, 5880static BcStatus bc_program_pushVar(char *code, size_t *bgn,
5876 bool pop, bool copy) 5881 bool pop, bool copy)
5877{ 5882{
5878 BcStatus s = BC_STATUS_SUCCESS; 5883 BcStatus s = BC_STATUS_SUCCESS;
5879 BcResult r; 5884 BcResult r;
5880 char *name = bc_program_name(code, bgn); 5885 char *name = bc_program_name(code, bgn);
5881#if ENABLE_DC // Exclude
5882 BcNum *num;
5883 BcVec *v;
5884#else
5885 (void) pop, (void) copy;
5886#endif
5887 5886
5888 r.t = BC_RESULT_VAR; 5887 r.t = BC_RESULT_VAR;
5889 r.d.id.name = name; 5888 r.d.id.name = name;
5890 5889
5891#if ENABLE_DC 5890#if ENABLE_DC
5892 v = bc_program_search(name, true); 5891 {
5893 num = bc_vec_top(v); 5892 BcVec *v = bc_program_search(name, true);
5893 BcNum *num = bc_vec_top(v);
5894 5894
5895 if (pop || copy) { 5895 if (pop || copy) {
5896
5897 if (!BC_PROG_STACK(v, 2 - copy)) {
5898 free(name);
5899 return BC_STATUS_EXEC_STACK;
5900 }
5896 5901
5897 if (!BC_PROG_STACK(v, 2 - copy)) {
5898 free(name); 5902 free(name);
5899 return BC_STATUS_EXEC_STACK; 5903 name = NULL;
5900 }
5901 5904
5902 free(name); 5905 if (!BC_PROG_STR(num)) {
5903 name = NULL;
5904 5906
5905 if (!BC_PROG_STR(num)) { 5907 r.t = BC_RESULT_TEMP;
5906 5908
5907 r.t = BC_RESULT_TEMP; 5909 bc_num_init(&r.d.n, BC_NUM_DEF_SIZE);
5910 bc_num_copy(&r.d.n, num);
5911 }
5912 else {
5913 r.t = BC_RESULT_STR;
5914 r.d.id.idx = num->rdx;
5915 }
5908 5916
5909 bc_num_init(&r.d.n, BC_NUM_DEF_SIZE); 5917 if (!copy) bc_vec_pop(v);
5910 bc_num_copy(&r.d.n, num);
5911 }
5912 else {
5913 r.t = BC_RESULT_STR;
5914 r.d.id.idx = num->rdx;
5915 } 5918 }
5916
5917 if (!copy) bc_vec_pop(v);
5918 } 5919 }
5919#endif // ENABLE_DC 5920#endif // ENABLE_DC
5920 5921