From bc325b17c5508701958a25ec5cc34d2fae9454af Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 5 Aug 2016 21:44:46 +0200 Subject: [PATCH] variables, lift plot_cur->pl_env up to the invoker of cp_usrvars() --- src/frontend/options.c | 4 ++-- src/frontend/variable.c | 18 ++++++++++++++++++ src/ngsconvert.c | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/frontend/options.c b/src/frontend/options.c index 9ff73b61a..e67eaea55 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -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; diff --git a/src/frontend/variable.c b/src/frontend/variable.c index af00a2797..db37b06c3 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -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; diff --git a/src/ngsconvert.c b/src/ngsconvert.c index 54c81db34..7f4355450 100644 --- a/src/ngsconvert.c +++ b/src/ngsconvert.c @@ -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";