From 4514742da7ace95abb3e607ddf49993b196ffd3a Mon Sep 17 00:00:00 2001 From: h_vogt Date: Tue, 5 Mar 2013 20:03:25 +0100 Subject: [PATCH] make database dbs local to each circuit --- src/frontend/breakp.c | 9 +++++---- src/frontend/breakp2.c | 2 +- src/frontend/inp.c | 10 ++++++---- src/frontend/plotting/graf.c | 2 +- src/frontend/runcoms.c | 5 ++++- src/frontend/runcoms2.c | 3 +++ src/include/ngspice/ftedefs.h | 1 + 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index 5b27f7517..066aa3d25 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -142,7 +142,7 @@ com_stop(wordlist *wl) ; d->db_next = thisone; } else { - dbs = thisone; + ft_curckt->ci_dbs = dbs = thisone; } (void) sprintf(buf, "%d", debugnumber); cp_addkword(CT_DBNUMS, buf); @@ -200,7 +200,7 @@ com_iplot(wordlist *wl) ; td->db_next = currentdb; } else { - dbs = currentdb; + ft_curckt->ci_dbs = dbs = currentdb; } } @@ -224,6 +224,7 @@ com_step(wordlist *wl) * off the event numbers (with UNIX, that is). -- I don't like this. */ +#undef isatty #define isatty(xxxx) 1 @@ -319,7 +320,7 @@ com_delete(wordlist *wl) d = dt->db_next; dbfree(dt); } - dbs = NULL; + ft_curckt->ci_dbs = dbs = NULL; return; } else if (!wl) { if (!dbs) { @@ -352,7 +353,7 @@ com_delete(wordlist *wl) if (dt) dt->db_next = d->db_next; else - dbs = d->db_next; + ft_curckt->ci_dbs = dbs = d->db_next; dbfree(d); (void) sprintf(buf, "%d", i); cp_remkword(CT_DBNUMS, buf); diff --git a/src/frontend/breakp2.c b/src/frontend/breakp2.c index 707f43455..f636116f8 100644 --- a/src/frontend/breakp2.c +++ b/src/frontend/breakp2.c @@ -93,7 +93,7 @@ settrace(wordlist *wl, int what, char *name) ; td->db_next = d; } else { - dbs = d; + ft_curckt->ci_dbs = dbs = d; } wl = wl->wl_next; diff --git a/src/frontend/inp.c b/src/frontend/inp.c index c3a2b731c..aadc66051 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -363,8 +363,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename) /* free the control deck */ line_free(deck, TRUE); /* do this here and in the 'else' branch of 'if (comfile)' */ - if (dbs) - dbfree(dbs); +/* if (dbs) + dbfree(dbs); */ + /* set to NULL to allow generation of a new dbs */ dbs = NULL; ft_dotsaves(); } /* end if (comfile) */ @@ -660,8 +661,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename) /* linked list dbs is used to store the "save" or .save data (defined in breakp2.c), (When controls are executed later on, also stores TRACE, IPLOT, and STOP data) */ - if (dbs) - dbfree(dbs); +/* if (dbs) + dbfree(dbs); */ + /* set to NULL to allow generation of a new dbs */ dbs = NULL; /* .save data stored in dbs. Do this here before controls are run: .save is thus recognized even if diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index d398dbc3c..8c198ae84 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -988,7 +988,7 @@ gr_end_iplot(void) if (prev) prev->db_next = next; else - dbs = next; + ft_curckt->ci_dbs = dbs = next; dbfree(db); } } else if (db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL) { diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index da351a2ff..475c25ead 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -30,7 +30,8 @@ Modified: 2000 AlansFixes static int dosim(char *what, wordlist *wl); -extern INPmodel *modtab; +extern struct INPmodel *modtab; +extern struct dbcomm *dbs; /* Routines for the commands op, tran, ac, dc, listing, device, state, * resume, stop, trace, run, end. Op, tran, ac, and dc cause the action @@ -106,6 +107,8 @@ com_scirc(wordlist *wl) ft_curckt = p; /* get the model table for the current circuit, store it in the global variable modtab */ modtab = ft_curckt->ci_modtab; + /* get the database for save, iplot, stop */ + dbs = ft_curckt->ci_dbs; } diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index 0f87ad06f..de7f2058f 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -204,6 +204,9 @@ com_remcirc(wordlist *wl) fprintf(cp_err, "Error: there is no circuit loaded.\n"); return; } + + dbfree(ft_curckt->ci_dbs); + /* The next lines stem from com_rset */ INPkillMods(); diff --git a/src/include/ngspice/ftedefs.h b/src/include/ngspice/ftedefs.h index c03dcd8ab..2a9bc5dc4 100644 --- a/src/include/ngspice/ftedefs.h +++ b/src/include/ngspice/ftedefs.h @@ -32,6 +32,7 @@ struct circ { CKTcircuit *ci_ckt; /* The CKTcircuit structure. */ INPtables *ci_symtab; /* The INP symbol table. */ INPmodel *ci_modtab; /* The INP model table. */ + struct dbcomm *ci_dbs; /* The database storing save, iplot, stop data */ struct line *ci_deck; /* The input deck. */ struct line *ci_origdeck;/* The input deck, before subckt expansion. */ struct line *ci_options;/* The .option cards from the deck... */