From b748f2d6d02dea5def4f9a2d6db9fd1095d44d43 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 25 Mar 2016 15:35:50 +0100 Subject: [PATCH] struct variable, #4/18, shrink scope of local variables --- src/frontend/options.c | 8 +++++--- src/frontend/spiceif.c | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/frontend/options.c b/src/frontend/options.c index c66fc4fb6..6967c1f08 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -38,9 +38,7 @@ struct variable * cp_enqvar(char *word) { struct dvec *d; - struct variable *vv, *tv; - struct plot *pl; - int i; + struct variable *vv; if (*word == '&') { @@ -60,6 +58,7 @@ cp_enqvar(char *word) vv->va_type = CP_REAL; vv->va_real = value; } else { + int i; vv = TMALLOC(struct variable, 1); vv->va_name = copy(word); vv->va_next = NULL; @@ -69,6 +68,7 @@ cp_enqvar(char *word) double value = isreal(d) ? d->v_realdata[i] : realpart(d->v_compdata[i]); + struct variable *tv; tv = TMALLOC(struct variable, 1); tv->va_name = NULL; tv->va_next = vv->va_vlist; @@ -114,12 +114,14 @@ cp_enqvar(char *word) vv->va_type = CP_STRING; vv->va_string = copy(plot_cur->pl_typename); } else if (eq(word, "plots")) { + 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) { + struct variable *tv; tv = TMALLOC(struct variable, 1); tv->va_name = NULL; tv->va_next = vv->va_vlist; diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 8297fd6b0..fd5999bc6 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -959,8 +959,6 @@ static struct variable * parmtovar(IFvalue *pv, IFparm *opt) { struct variable *vv = TMALLOC(struct variable, 1); - struct variable *nv; - int i = 0; switch (opt->dataType & IF_VARTYPES) { case IF_INTEGER: @@ -980,10 +978,12 @@ parmtovar(IFvalue *pv, IFparm *opt) vv->va_type = CP_BOOL; vv->va_bool = pv->iValue ? TRUE : FALSE; break; - case IF_REALVEC: + case IF_REALVEC: { + int i; vv->va_type = CP_LIST; vv->va_vlist = NULL; for (i = pv->v.numValue; --i >= 0;) { + struct variable *nv; nv = TMALLOC(struct variable, 1); nv->va_name = NULL; nv->va_next = vv->va_vlist; @@ -1008,6 +1008,7 @@ parmtovar(IFvalue *pv, IFparm *opt) */ break; + } default: fprintf(cp_err, "parmtovar: Internal Error: bad PARM type %d.\n",