Browse Source

struct variable, #7/18, reorder struct variable operations

pre-master-46
rlar 10 years ago
parent
commit
41b5f17906
  1. 30
      src/frontend/options.c
  2. 15
      src/frontend/spiceif.c

30
src/frontend/options.c

@ -58,12 +58,8 @@ cp_enqvar(char *word)
vv->va_type = CP_REAL; vv->va_type = CP_REAL;
vv->va_real = value; vv->va_real = value;
} else { } else {
struct variable *list = NULL;
int i; int i;
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_LIST;
vv->va_vlist = NULL;
for (i = d->v_length; --i >= 0;) { for (i = d->v_length; --i >= 0;) {
double value = isreal(d) double value = isreal(d)
? d->v_realdata[i] ? d->v_realdata[i]
@ -71,11 +67,16 @@ cp_enqvar(char *word)
struct variable *tv; struct variable *tv;
tv = TMALLOC(struct variable, 1); tv = TMALLOC(struct variable, 1);
tv->va_name = NULL; tv->va_name = NULL;
tv->va_next = vv->va_vlist;
tv->va_next = list;
tv->va_type = CP_REAL; tv->va_type = CP_REAL;
tv->va_real = value; tv->va_real = value;
vv->va_vlist = tv;
list = tv;
} }
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_LIST;
vv->va_vlist = list;
} }
if (d->v_link2) if (d->v_link2)
@ -114,21 +115,22 @@ cp_enqvar(char *word)
vv->va_type = CP_STRING; vv->va_type = CP_STRING;
vv->va_string = copy(plot_cur->pl_typename); vv->va_string = copy(plot_cur->pl_typename);
} else if (eq(word, "plots")) { } else if (eq(word, "plots")) {
struct variable *list = NULL;
struct plot *pl; struct plot *pl;
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_LIST;
vv->va_vlist = NULL;
for (pl = plot_list; pl; pl = pl->pl_next) { for (pl = plot_list; pl; pl = pl->pl_next) {
struct variable *tv; struct variable *tv;
tv = TMALLOC(struct variable, 1); tv = TMALLOC(struct variable, 1);
tv->va_name = NULL; tv->va_name = NULL;
tv->va_next = vv->va_vlist;
tv->va_next = list;
tv->va_type = CP_STRING; tv->va_type = CP_STRING;
tv->va_string = copy(pl->pl_typename); tv->va_string = copy(pl->pl_typename);
vv->va_vlist = tv;
list = tv;
} }
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(word);
vv->va_next = NULL;
vv->va_type = CP_LIST;
vv->va_vlist = list;
} }
if (vv) if (vv)
return (vv); return (vv);

15
src/frontend/spiceif.c

@ -993,21 +993,22 @@ parmtovar(IFvalue *pv, IFparm *opt)
vv->va_bool = pv->iValue ? TRUE : FALSE; vv->va_bool = pv->iValue ? TRUE : FALSE;
return vv; return vv;
case IF_REALVEC: { case IF_REALVEC: {
struct variable *list = NULL;
int i; int i;
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_LIST;
vv->va_vlist = NULL;
for (i = pv->v.numValue; --i >= 0;) { for (i = pv->v.numValue; --i >= 0;) {
struct variable *nv; struct variable *nv;
nv = TMALLOC(struct variable, 1); nv = TMALLOC(struct variable, 1);
nv->va_name = NULL; nv->va_name = NULL;
nv->va_next = vv->va_vlist;
nv->va_next = list;
nv->va_type = CP_REAL; nv->va_type = CP_REAL;
nv->va_real = pv->v.vec.rVec[i]; nv->va_real = pv->v.vec.rVec[i];
vv->va_vlist = nv;
list = nv;
} }
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_LIST;
vv->va_vlist = list;
return vv; return vv;
/* It is a linked list where the first node is a variable /* It is a linked list where the first node is a variable
* pointing to the different values of the variables. * pointing to the different values of the variables.

Loading…
Cancel
Save