variables, lift plot_cur->pl_env up to the invoker of cp_usrvars()

This commit is contained in:
rlar 2016-08-05 21:44:46 +02:00
parent e0db4aa665
commit bc325b17c5
3 changed files with 21 additions and 2 deletions

View File

@ -100,14 +100,14 @@ cp_enqvar(char *word)
}
/* Return the plot and ckt env vars, $plots, and $curplot{name,title,date,} */
/* Return $plots, $curplot, $curplottitle, $curplotname, $curplotdate */
struct variable *
cp_usrvars(void)
{
struct variable *v, *tv;
v = plot_cur ? plot_cur->pl_env : NULL;
v = NULL;
if ((tv = cp_enqvar("plots")) != NULL) {
tv->va_next = v;

View File

@ -418,6 +418,11 @@ cp_remvar(char *varname)
if (eq((*p)->va_name, varname))
break;
if (*p == NULL && plot_cur)
for (p = &plot_cur->pl_env; *p; p = &(*p)->va_next)
if (eq((*p)->va_name, varname))
break;
if (*p == NULL && ft_curckt)
for (p = &ft_curckt->ci_vars; *p; p = &(*p)->va_next)
if (eq((*p)->va_name, varname))
@ -525,6 +530,11 @@ cp_getvar(char *name, enum cp_types type, void *retval)
if (eq(name, v->va_name))
break;
if (!v && plot_cur)
for (v = plot_cur->pl_env; v; v = v->va_next)
if (eq(name, v->va_name))
break;
if (!v && ft_curckt)
for (v = ft_curckt->ci_vars; v; v = v->va_next)
if (eq(name, v->va_name))
@ -882,6 +892,9 @@ cp_vprint(void)
i++;
for (v = uv1; v; v = v->va_next)
i++;
if (plot_cur)
for (v = plot_cur->pl_env; v; v = v->va_next)
i++;
if (ft_curckt)
for (v = ft_curckt->ci_vars; v; v = v->va_next)
i++;
@ -897,6 +910,11 @@ cp_vprint(void)
vars[i].x_v = v;
vars[i].x_char = '*';
}
if (plot_cur)
for (v = plot_cur->pl_env; v; v = v->va_next, i++) {
vars[i].x_v = v;
vars[i].x_char = '*';
}
if (ft_curckt)
for (v = ft_curckt->ci_vars; v; v = v->va_next, i++) {
vars[i].x_v = v;

View File

@ -31,6 +31,7 @@ bool cp_nocc = TRUE;
bool ft_stricterror = FALSE;
bool ft_parsedb = FALSE;
struct circ *ft_curckt = NULL;
struct plot *plot_cur = NULL;
char *cp_program = "sconvert";