{
BcStatus s;
BcNum num1, num2, half, f, fprime, *x0, *x1, *temp;
+ BcDig half_digs[1];
size_t pow, len, digs, digs1, resrdx, req, times = 0;
ssize_t cmp = 1, cmp1 = SSIZE_MAX, cmp2 = SSIZE_MAX;
bc_num_init(&num1, len);
bc_num_init(&num2, len);
- bc_num_init_DEF_SIZE(&half);
+ half.cap = ARRAY_SIZE(half_digs);
+ half.num = half_digs;
bc_num_one(&half);
- half.num[0] = 5;
+ half_digs[0] = 5;
half.rdx = 1;
bc_num_init(&f, len);
err:
bc_num_free(&fprime);
bc_num_free(&f);
- bc_num_free(&half);
bc_num_free(&num2);
bc_num_free(&num1);
RETURN_STATUS(s);
{
BcStatus s;
BcNum base, exp, two, temp;
- BcDig two_digs[2];
+ BcDig two_digs[1];
if (c->len == 0)
RETURN_STATUS(bc_error("divide by zero"));
case XC_RESULT_ARRAY:
case XC_RESULT_ARRAY_ELEM: {
BcVec *v;
-
+ void *p;
v = xc_program_search(r->d.id.name, r->t == XC_RESULT_VAR);
-
+// dc variables are all stacks, so here we have this:
+ p = bc_vec_top(v);
+// TODO: eliminate these stacks for bc-only config?
if (r->t == XC_RESULT_ARRAY_ELEM) {
- v = bc_vec_top(v);
- if (v->len <= r->d.id.idx) bc_array_expand(v, r->d.id.idx + 1);
+ v = p;
+ if (v->len <= r->d.id.idx)
+ bc_array_expand(v, r->d.id.idx + 1);
*num = bc_vec_item(v, r->d.id.idx);
- } else
- *num = bc_vec_top(v);
+ } else {
+ *num = p;
+ }
break;
}
#if ENABLE_BC