diff --git a/src/frontend/com_plot.c b/src/frontend/com_plot.c index 6758dbd04..b151849bb 100644 --- a/src/frontend/com_plot.c +++ b/src/frontend/com_plot.c @@ -7,11 +7,17 @@ #include "com_plot.h" +extern bool ft_batchmode; /* plot name ... [xl[imit]] xlo xhi] [yl[imit ylo yhi] [vs xname] */ void com_plot(wordlist *wl) { + if (ft_batchmode) { + fprintf(stderr, "\nWarning: command 'plot' is not available during batch simulation, ignored!\n"); + fprintf(stderr, " You may use Gnuplot instead.\n\n"); + return; + } plotit(wl, NULL, NULL); } diff --git a/src/frontend/display.c b/src/frontend/display.c index a85a30726..a286289f5 100644 --- a/src/frontend/display.c +++ b/src/frontend/display.c @@ -129,7 +129,7 @@ DISPDEVICE device[] = { (disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, (disp_fn_Input_t *) NODEV, gen_DatatoScreen, }, - { "PrinterOnly", 0, 0, 24, 80, 0, 0, + { "BatchMode/PrinterOnly", 0, 0, 24, 80, 0, 0, (disp_fn_Init_t *) NODEV, (disp_fn_NewViewport_t *) NODEV, (disp_fn_Close_t *) NOP, (disp_fn_Clear_t *) NODEV, (disp_fn_DrawLine_t *) NODEV, (disp_fn_Arc_t *) NODEV, (disp_fn_Text_t *) NODEV, diff --git a/src/frontend/inp.c b/src/frontend/inp.c index ed9415156..0b0c21f2c 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -980,6 +980,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) } for (dd = deck; dd; dd = dd->nextcard) { + /* first line is title line, skip it */ + if (deck == dd) { + prev_card = dd; + continue; + } /* all parameter lines should be sequentially ordered and placed at beginning of deck */ if (ciprefix(".para", dd->line)) { diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 7df535340..e7ce0e1ee 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -1395,6 +1395,8 @@ nupa_assignment(dico_t *dico, const char *s, char mode) bug: we cannot rely on the transformed line, must re-parse everything! */ { + if (!s || !*s) + return 1; /* s has the format: ident = expression; ident= expression ... */ const char * const s_end = s + strlen(s); const char *p = s; diff --git a/src/main.c b/src/main.c index bba99a714..7957cc7f2 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,7 @@ #ifdef HAVE_GNUREADLINE # include # include +# include "../misc/tilde.h" #endif /* editline development has added the following typdef to readline.h in 06/2018. @@ -614,11 +615,15 @@ static void app_rl_init(void) { #if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) + char *home; + /* --- set up readline params --- */ - strcpy(history_file, getenv("HOME")); - strcat(history_file, "/."); - strcat(history_file, application_name); - strcat(history_file, "_history"); + + if (get_local_home(0, &home) < 0) + return; + snprintf(history_file, sizeof history_file, "%s/.%s_history", + home, application_name); + tfree(home); using_history(); read_history(history_file); @@ -1403,6 +1408,8 @@ int main(int argc, char **argv) if (ft_batchmode) { + int error3 = 1; + /* If we get back here in batch mode then something is wrong, * so exit. */ @@ -1425,6 +1432,9 @@ int main(int argc, char **argv) cp_interactive = FALSE; + /* Check if a simulation has run from a .control section */ + cp_getvar("sim_status", CP_NUM, &error3, 0); + if (rflag) { /* If -r is specified, then dot cards (.width, .plot, .print, .op, .meas, .tf) are ignored, except .save, which has been handled by ft_dotsaves() @@ -1443,6 +1453,10 @@ int main(int argc, char **argv) if (ft_cktcoms(FALSE) || error2) sp_shutdown(EXIT_BAD); } + else if (error3 == 0) { + fprintf(stdout, "Note: Simulation executed from .control section \n"); + sp_shutdown(EXIT_NORMAL); + } else { fprintf(stderr, "Note: No \".plot\", \".print\", or \".fourier\" lines; " diff --git a/src/sharedspice.c b/src/sharedspice.c index af9dccd02..5e4145a55 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -2033,7 +2033,8 @@ ATTRIBUTE_NORETURN void shared_exit(int status) fl_exited = TRUE; bgtr(fl_exited, ng_ident, userptr); // set a flag that ngspice wants to be detached - ngexit(status, FALSE, coquit, ng_ident, userptr); + if(ngexit) + ngexit(status, FALSE, coquit, ng_ident, userptr); // finish and exit the worker thread #ifdef HAVE_LIBPTHREAD pthread_exit(NULL); @@ -2042,7 +2043,8 @@ ATTRIBUTE_NORETURN void shared_exit(int status) #endif } // set a flag in caller to detach ngspice.dll - ngexit(status, immediate, coquit, ng_ident, userptr); + if(ngexit) + ngexit(status, immediate, coquit, ng_ident, userptr); // jump back to finish the calling function if (!intermj) diff --git a/src/spicelib/devices/isrc/isrctemp.c b/src/spicelib/devices/isrc/isrctemp.c index 207ed69a8..92f3e64a0 100644 --- a/src/spicelib/devices/isrc/isrctemp.c +++ b/src/spicelib/devices/isrc/isrctemp.c @@ -42,7 +42,9 @@ ISRCtemp(GENmodel *inModel, CKTcircuit *ckt) here->ISRCname); } else if (here->ISRCdcGiven && here->ISRCfuncTGiven - && here->ISRCfunctionType != TRNOISE && here->ISRCfunctionType != TRRANDOM) { + && here->ISRCfunctionType != TRNOISE + && here->ISRCfunctionType != TRRANDOM + && here->ISRCfunctionType != EXTERNAL) { /* DC value and transient time 0 values given */ double time0value; /* determine transient time 0 value */ diff --git a/src/spicelib/devices/vsrc/vsrctemp.c b/src/spicelib/devices/vsrc/vsrctemp.c index 413a7392e..413e356e9 100644 --- a/src/spicelib/devices/vsrc/vsrctemp.c +++ b/src/spicelib/devices/vsrc/vsrctemp.c @@ -48,7 +48,9 @@ VSRCtemp(GENmodel *inModel, CKTcircuit *ckt) here->VSRCname); } else if (here->VSRCdcGiven && here->VSRCfuncTGiven - && here->VSRCfunctionType != TRNOISE && here->VSRCfunctionType != TRRANDOM) { + && here->VSRCfunctionType != TRNOISE + && here->VSRCfunctionType != TRRANDOM + && here->VSRCfunctionType != EXTERNAL) { /* DC value and transient time 0 values given */ double time0value; /* determine transient time 0 value */ diff --git a/src/spicelib/parser/inp2dot.c b/src/spicelib/parser/inp2dot.c index f1ba03623..bf035e52d 100644 --- a/src/spicelib/parser/inp2dot.c +++ b/src/spicelib/parser/inp2dot.c @@ -182,6 +182,7 @@ dot_ac(char *line, CKTcircuit *ckt, INPtables *tab, struct card *current, IFvalue *parm; /* a pointer to a value struct for function returns */ int which; /* which analysis we are performing */ char *steptype; /* ac analysis, type of stepping function */ + bool pdef = FALSE; /* issue a warning if default parameters are used */ NG_IGNORE(gnode); @@ -193,15 +194,33 @@ dot_ac(char *line, CKTcircuit *ckt, INPtables *tab, struct card *current, } IFC(newAnalysis, (ckt, which, "AC Analysis", &foo, task)); INPgetTok(&line, &steptype, 1); /* get DEC, OCT, or LIN */ + if (!*steptype || (!ciprefix("dec", steptype) && !ciprefix("oct", steptype) && !ciprefix("lin", steptype))) { + current->error = "Missing DEC, OCT, or LIN\n"; + return (0); + } ptemp.iValue = 1; GCA(INPapName, (ckt, which, foo, steptype, &ptemp)); tfree(steptype); + parm = INPgetValue(ckt, &line, IF_INTEGER, tab); /* number of points */ + if (parm->iValue == 0) + pdef = TRUE; GCA(INPapName, (ckt, which, foo, "numsteps", parm)); + + if(!isdigit(*line)) + pdef = TRUE; parm = INPgetValue(ckt, &line, IF_REAL, tab); /* fstart */ GCA(INPapName, (ckt, which, foo, "start", parm)); + parm = INPgetValue(ckt, &line, IF_REAL, tab); /* fstop */ + if (parm->rValue == 0) + pdef = TRUE; GCA(INPapName, (ckt, which, foo, "stop", parm)); + + if (pdef) { + fprintf(stderr, "Warning, ngspice assumes default parameter(s) for ac simulation\n"); + fprintf(stderr, " Check your ac or .ac line\n\n"); + } return (0); } diff --git a/src/spicelib/parser/inpgtok.c b/src/spicelib/parser/inpgtok.c index 58ece2fc1..be17a1a3f 100644 --- a/src/spicelib/parser/inpgtok.c +++ b/src/spicelib/parser/inpgtok.c @@ -31,6 +31,11 @@ INPgetTok(char **line, char **token, int gobble) char *point; int signstate; + if (!*line) { + *token = NULL; + return (E_PARMVAL); + } + /* scan along throwing away garbage characters until end of line or a separation char is found */ for (point = *line; *point != '\0'; point++) {