From 5d116d1fb979e817c93b5169f0748bd98456e47a Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 18 Sep 2021 14:57:22 +0200 Subject: [PATCH] command listing: add option r (runable) listing r > $inputdir/mycirc_runable.cir will save the expanded netlist without line numbers, ready to be sourced again and run in ngspice. --- src/frontend/inp.c | 23 ++++++++++++++++++----- src/include/ngspice/fteinp.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 650ac04e5..29323975b 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -134,7 +134,7 @@ Xprintf(FILE *fdst, const char *fmt, ...) } -/* Do a listing. Use is listing [expanded] [logical] [physical] [deck] */ +/* Do a listing. Use is listing [expanded] [logical] [physical] [deck] [runable] */ void com_listing(wordlist *wl) { @@ -165,6 +165,11 @@ com_listing(wordlist *wl) case 'E': expand = TRUE; break; + case 'r': + case 'R': + expand = TRUE; + type = LS_RUNABLE; + break; default: fprintf(cp_err, "Error: bad listing type %s\n", s); return; /* SJB - don't go on after an error */ @@ -176,7 +181,7 @@ com_listing(wordlist *wl) if (do_param_listing) { nupa_list_params(cp_out); } else { - if (type != LS_DECK) + if (type != LS_DECK && type != LS_RUNABLE) fprintf(cp_out, "\t%s\n\n", ft_curckt->ci_name); inp_list(cp_out, expand ? ft_curckt->ci_deck : ft_curckt->ci_origdeck, @@ -233,18 +238,23 @@ inp_list(FILE *file, struct card *deck, struct card *extras, int type) renumber = cp_getvar("renumber", CP_BOOL, NULL, 0); - if (type == LS_LOGICAL) { + if (type == LS_LOGICAL || type == LS_RUNABLE) { top1: for (here = deck; here; here = here->nextcard) { if (renumber) here->linenum = i; if (ciprefix(".end", here->line) && !isalpha_c(here->line[4])) continue; - if (*here->line != '*') { + if ((*here->line != '*') && (type == LS_LOGICAL)) { Xprintf(file, "%6d : %s\n", here->linenum, upper(here->line)); if (here->error) Xprintf(file, "%s\n", here->error); } + else if ((*here->line != '*') && (type == LS_RUNABLE)) { + Xprintf(file, "%s\n", upper(here->line)); + if (here->error) + Xprintf(file, "%s\n", here->error); + } i++; } @@ -254,7 +264,10 @@ inp_list(FILE *file, struct card *deck, struct card *extras, int type) goto top1; } - Xprintf(file, "%6d : .end\n", i); + if (type == LS_LOGICAL) + Xprintf(file, "%6d : .end\n", i); + else if (type == LS_RUNABLE) + Xprintf(file, ".end\n"); } else if ((type == LS_PHYSICAL) || (type == LS_DECK)) { diff --git a/src/include/ngspice/fteinp.h b/src/include/ngspice/fteinp.h index 215cb10ed..07db884b0 100644 --- a/src/include/ngspice/fteinp.h +++ b/src/include/ngspice/fteinp.h @@ -13,6 +13,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #define LS_LOGICAL 1 #define LS_PHYSICAL 2 #define LS_DECK 3 +#define LS_RUNABLE 4 #endif