From dea300d88d38115e432f52bc2e050c9cce9de2bc Mon Sep 17 00:00:00 2001 From: h_vogt Date: Tue, 19 Jul 2011 23:06:29 +0000 Subject: [PATCH] command 'remcirc' --- ChangeLog | 4 +++ src/frontend/commands.c | 4 +++ src/frontend/plotting/plotting.c | 4 ++- src/frontend/runcoms2.c | 60 ++++++++++++++++++++++++++++++-- src/frontend/runcoms2.h | 2 +- 5 files changed, 69 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11ca1e180..852b58ab9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-07-20 Holger Vogt + * commands.c, runcoms2.c, runcoms2.h: + command 'remcirc': remove the current circuit + 2011-07-17 Robert Larice * src/frontend/plotting/plotit.c : cleanup, `getlims()' has to be used with number arg >= 1 diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 47540b60b..a92f2dd65 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -389,6 +389,10 @@ struct comm spcp_coms[] = { { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, NULL, "[number] : Iterate number times, or one." } , + { "remcirc", com_remcirc, TRUE, TRUE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, + NULL, + ": Remove current citcuit." } , { "reset", com_rset, TRUE, TRUE, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, NULL, diff --git a/src/frontend/plotting/plotting.c b/src/frontend/plotting/plotting.c index d445a6564..999b4c072 100644 --- a/src/frontend/plotting/plotting.c +++ b/src/frontend/plotting/plotting.c @@ -1,11 +1,13 @@ #include #include "plotting.h" +#include "../../conf.h" /* Where 'constants' go when defined on initialization. */ struct plot constantplot = { - "Constant values", "Sat Aug 16 10:55:15 PDT 1986", "constants", +// "Constant values", "Sat Aug 16 10:55:15 PDT 1986", "constants", + "Constant values", Spice_Build_Date, "constants", "const", NULL, NULL, NULL, NULL, NULL, NULL, TRUE, 0 } ; diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index a7688f44f..f4e10dd3b 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -27,13 +27,13 @@ $Id$ #define RAWBUF_SIZE 32768 extern char rawfileBuf[RAWBUF_SIZE]; +extern void line_free_x(struct line * deck, bool recurse); +#define line_free(line,flag) { line_free_x(line,flag); line = NULL; } /* Continue a simulation. If there is non in progress, this is the * equivalent of "run". */ -/* ARGSUSED */ - /* This is a hack to tell iplot routine to redraw the grid and initialize the display device */ @@ -168,7 +168,6 @@ com_resume(wordlist *wl) * should be obsolete. */ -/* ARGSUSED */ void com_rset(wordlist *wl) { @@ -193,3 +192,58 @@ com_rset(wordlist *wl) TRUE, ft_curckt->ci_options, ft_curckt->ci_filename); return; } + +void +com_remcirc(wordlist *wl) +{ + struct variable *v, *next; + struct line *dd; /*in: the spice deck */ + struct circ *p, *prev = NULL; + + NG_IGNORE(wl); + + if (ft_curckt == NULL) { + fprintf(cp_err, "Error: there is no circuit loaded.\n"); + return; + } + /* The next lines stem from com_rset */ + INPkillMods(); + + if_cktfree(ft_curckt->ci_ckt, ft_curckt->ci_symtab); + for (v = ft_curckt->ci_vars; v; v = next) { + next = v->va_next; + tfree(v); + } + ft_curckt->ci_vars = NULL; + /* delete the deck in ft_curckt */ + dd = ft_curckt->ci_deck; + line_free(dd,TRUE); + if (ft_curckt->ci_name) + tfree(ft_curckt->ci_name); + if (ft_curckt->ci_filename) + tfree(ft_curckt->ci_filename); + + /* delete the actual circuit entry from ft_circuits */ + for (p = ft_circuits; p; p = p->ci_next) { + if (ft_curckt == p) { + if (prev == NULL) { + ft_circuits = p->ci_next; + tfree(p); + p = NULL; + break; + } + else { + prev->ci_next = p->ci_next; + tfree(p); + p = NULL; + break; + } + } + prev = p; + } + /* make first entry in ft_circuits the actual circuit (or NULL) */ + ft_curckt = ft_circuits; + + return; +} + diff --git a/src/frontend/runcoms2.h b/src/frontend/runcoms2.h index ac89626df..337eabe3b 100644 --- a/src/frontend/runcoms2.h +++ b/src/frontend/runcoms2.h @@ -8,6 +8,6 @@ void com_resume(wordlist *wl); void com_rset(wordlist *wl); - +void com_remcirc(wordlist *wl); #endif