}
// 'num' need not be initialized on entry
-static BC_STATUS zxc_program_num(BcResult *r, BcNum **num, bool hex)
+static BC_STATUS zxc_program_num(BcResult *r, BcNum **num)
{
switch (r->t) {
case XC_RESULT_STR:
case XC_RESULT_CONSTANT: {
BcStatus s;
char *str;
- unsigned base_t;
size_t len;
str = *xc_program_const(r->d.id.idx);
bc_num_init(&r->d.n, len);
- hex = hex && len == 1;
- base_t = hex ? 16 : G.prog.ib_t;
- s = zxc_num_parse(&r->d.n, str, base_t);
+ s = zxc_num_parse(&r->d.n, str, G.prog.ib_t);
if (s) {
bc_num_free(&r->d.n);
RETURN_STATUS(s);
BcResult **r, BcNum **rn, bool assign)
{
BcStatus s;
- bool hex;
BcResultType lt, rt;
if (!STACK_HAS_MORE_THAN(&G.prog.results, 1))
*r = bc_vec_item_rev(&G.prog.results, 0);
*l = bc_vec_item_rev(&G.prog.results, 1);
- lt = (*l)->t;
- rt = (*r)->t;
- hex = assign && (lt == XC_RESULT_IBASE || lt == XC_RESULT_OBASE);
-
- s = zxc_program_num(*l, ln, false);
+ s = zxc_program_num(*l, ln);
if (s) RETURN_STATUS(s);
- s = zxc_program_num(*r, rn, hex);
+ s = zxc_program_num(*r, rn);
if (s) RETURN_STATUS(s);
+ lt = (*l)->t;
+ rt = (*r)->t;
+
// We run this again under these conditions in case any vector has been
// reallocated out from under the BcNums or arrays we had.
if (lt == rt && (lt == XC_RESULT_VAR || lt == XC_RESULT_ARRAY_ELEM)) {
- s = zxc_program_num(*l, ln, false);
+ s = zxc_program_num(*l, ln);
if (s) RETURN_STATUS(s);
}
RETURN_STATUS(bc_error_stack_has_too_few_elements());
*r = bc_vec_top(&G.prog.results);
- s = zxc_program_num(*r, n, false);
+ s = zxc_program_num(*r, n);
if (s) RETURN_STATUS(s);
if (!BC_PROG_NUM((*r), (*n)))
RETURN_STATUS(bc_error_stack_has_too_few_elements());
r = bc_vec_item_rev(&G.prog.results, idx);
- s = zxc_program_num(r, &num, false);
+ s = zxc_program_num(r, &num);
if (s) RETURN_STATUS(s);
if (BC_PROG_NUM(r, num)) {
RETURN_STATUS(zdc_program_assignStr(ptr, v, true));
#endif
- s = zxc_program_num(ptr, &n, false);
+ s = zxc_program_num(ptr, &n);
if (s) RETURN_STATUS(s);
// Do this once more to make sure that pointers were not invalidated.
BcNum *num;
BcResult *operand = bc_vec_top(&G.prog.results);
- s = zxc_program_num(operand, &num, false);
+ s = zxc_program_num(operand, &num);
if (s) RETURN_STATUS(s);
bc_num_init(&res.d.n, num->len);
bc_num_copy(&res.d.n, num);
RETURN_STATUS(bc_error_stack_has_too_few_elements());
opnd = bc_vec_top(&G.prog.results);
- s = zxc_program_num(opnd, &num, false);
+ s = zxc_program_num(opnd, &num);
if (s) RETURN_STATUS(s);
#if ENABLE_DC
if (s) RETURN_STATUS(s);
r1 = bc_vec_item_rev(&G.prog.results, 2);
- s = zxc_program_num(r1, &n1, false);
+ s = zxc_program_num(r1, &n1);
if (s) RETURN_STATUS(s);
if (!BC_PROG_NUM(r1, n1))
RETURN_STATUS(bc_error_variable_is_wrong_type());
// Make sure that the values have their pointers updated, if necessary.
if (r1->t == XC_RESULT_VAR || r1->t == XC_RESULT_ARRAY_ELEM) {
if (r1->t == r2->t) {
- s = zxc_program_num(r2, &n2, false);
+ s = zxc_program_num(r2, &n2);
if (s) RETURN_STATUS(s);
}
if (r1->t == r3->t) {
- s = zxc_program_num(r3, &n3, false);
+ s = zxc_program_num(r3, &n3);
if (s) RETURN_STATUS(s);
}
}
RETURN_STATUS(bc_error_stack_has_too_few_elements());
r = bc_vec_top(&G.prog.results);
- s = zxc_program_num(r, &num, false);
+ s = zxc_program_num(r, &num);
if (s) RETURN_STATUS(s);
if (BC_PROG_NUM(r, num)) {
RETURN_STATUS(bc_error_stack_has_too_few_elements());
r = bc_vec_top(&G.prog.results);
- s = zxc_program_num(r, &n, false);
+ s = zxc_program_num(r, &n);
if (s) RETURN_STATUS(s);
if (BC_PROG_NUM(r, n)) {
sidx = r->d.id.idx;
} else if (r->t == XC_RESULT_VAR) {
BcNum *n;
- s = zxc_program_num(r, &n, false);
+ s = zxc_program_num(r, &n);
if (s || !BC_PROG_STR(n)) goto exit;
sidx = n->rdx;
} else