prevent string overflow by adding the string length

to the cp_getvar parameters. Used only with CP_STRING
This commit is contained in:
Holger Vogt 2018-07-21 18:22:18 +02:00
parent 7592644400
commit 09c876550f
59 changed files with 139 additions and 134 deletions

View File

@ -38,7 +38,7 @@ com_ahelp(wordlist *wl)
env |= E_NOPLOTS; env |= E_NOPLOTS;
/* determine level */ /* determine level */
if (cp_getvar("level", CP_STRING, slevel)) { if (cp_getvar("level", CP_STRING, slevel, sizeof(slevel))) {
switch (*slevel) { switch (*slevel) {
case 'b': level = 1; case 'b': level = 1;
break; break;

View File

@ -66,7 +66,7 @@ com_display(wordlist *wl)
dvs = TMALLOC(struct dvec *, len); dvs = TMALLOC(struct dvec *, len);
for (d = plot_cur->pl_dvecs, i = 0; d; d = d->v_next, i++) for (d = plot_cur->pl_dvecs, i = 0; d; d = d->v_next, i++)
dvs[i] = d; dvs[i] = d;
if (!cp_getvar("nosort", CP_BOOL, NULL)) if (!cp_getvar("nosort", CP_BOOL, NULL, 0))
qsort(dvs, (size_t) len, sizeof(struct dvec *), dcomp); qsort(dvs, (size_t) len, sizeof(struct dvec *), dcomp);
out_printf("Title: %s\n", plot_cur->pl_title); out_printf("Title: %s\n", plot_cur->pl_title);

View File

@ -76,9 +76,9 @@ com_fft(wordlist *wl)
win = TMALLOC(double, length); win = TMALLOC(double, length);
maxt = time[length-1]; maxt = time[length-1];
if (!cp_getvar("specwindow", CP_STRING, window)) if (!cp_getvar("specwindow", CP_STRING, window, sizeof(window)))
strcpy(window, "hanning"); strcpy(window, "hanning");
if (!cp_getvar("specwindoworder", CP_NUM, &order)) if (!cp_getvar("specwindoworder", CP_NUM, &order, 0))
order = 2; order = 2;
if (order < 2) if (order < 2)
order = 2; order = 2;
@ -296,9 +296,9 @@ com_psd(wordlist *wl)
win = TMALLOC(double, length); win = TMALLOC(double, length);
maxt = time[length-1]; maxt = time[length-1];
if (!cp_getvar("specwindow", CP_STRING, window)) if (!cp_getvar("specwindow", CP_STRING, window, sizeof(window)))
strcpy(window, "hanning"); strcpy(window, "hanning");
if (!cp_getvar("specwindoworder", CP_NUM, &order)) if (!cp_getvar("specwindoworder", CP_NUM, &order, 0))
order = 2; order = 2;
if (order < 2) if (order < 2)
order = 2; order = 2;

View File

@ -35,7 +35,7 @@ com_hardcopy(wordlist *wl)
int hc_button; int hc_button;
int foundit; int foundit;
if (!cp_getvar("hcopydev", CP_STRING, device)) if (!cp_getvar("hcopydev", CP_STRING, device, sizeof(device)))
*device = '\0'; *device = '\0';
if (wl) { if (wl) {
@ -48,7 +48,7 @@ com_hardcopy(wordlist *wl)
tempf = TRUE; tempf = TRUE;
} }
if (!cp_getvar("hcopydevtype", CP_STRING, buf)) if (!cp_getvar("hcopydevtype", CP_STRING, buf, sizeof(buf)))
devtype = "postscript"; devtype = "postscript";
else else
devtype = buf; devtype = buf;
@ -161,7 +161,7 @@ com_hardcopy(wordlist *wl)
if (*device) { if (*device) {
#ifdef SYSTEM_PLOT5LPR #ifdef SYSTEM_PLOT5LPR
if (!strcmp(devtype, "plot5") || !strcmp(devtype, "MFB")) { if (!strcmp(devtype, "plot5") || !strcmp(devtype, "MFB")) {
if (!cp_getvar("lprplot5", CP_STRING, format)) if (!cp_getvar("lprplot5", CP_STRING, format, size_of(format)))
strcpy(format, SYSTEM_PLOT5LPR); strcpy(format, SYSTEM_PLOT5LPR);
(void) sprintf(buf, format, device, fname); (void) sprintf(buf, format, device, fname);
fprintf(cp_out, "Printing %s on the %s printer.\n", fname, device); fprintf(cp_out, "Printing %s on the %s printer.\n", fname, device);
@ -172,7 +172,7 @@ com_hardcopy(wordlist *wl)
#ifdef SYSTEM_PSLPR #ifdef SYSTEM_PSLPR
if (!printed && !strcmp(devtype, "postscript")) { if (!printed && !strcmp(devtype, "postscript")) {
/* note: check if that was a postscript printer XXX */ /* note: check if that was a postscript printer XXX */
if (!cp_getvar("lprps", CP_STRING, format)) if (!cp_getvar("lprps", CP_STRING, format, size_of(format)))
strcpy(format, SYSTEM_PSLPR); strcpy(format, SYSTEM_PSLPR);
(void) sprintf(buf, format, device, fname); (void) sprintf(buf, format, device, fname);
fprintf(cp_out, "Printing %s on the %s printer.\n", fname, device); fprintf(cp_out, "Printing %s on the %s printer.\n", fname, device);

View File

@ -235,7 +235,7 @@ static int count;
void void
com_showmod(wordlist *wl) com_showmod(wordlist *wl)
{ {
if (cp_getvar("altshow", CP_BOOL, NULL)) if (cp_getvar("altshow", CP_BOOL, NULL, 0))
all_show(wl, 1); all_show(wl, 1);
else else
all_show_old(wl, 1); all_show_old(wl, 1);
@ -245,7 +245,7 @@ com_showmod(wordlist *wl)
void void
com_show(wordlist *wl) com_show(wordlist *wl)
{ {
if (cp_getvar("altshow", CP_BOOL, NULL)) if (cp_getvar("altshow", CP_BOOL, NULL, 0))
all_show(wl, 0); all_show(wl, 0);
else else
all_show_old(wl, 0); all_show_old(wl, 0);
@ -273,7 +273,7 @@ all_show(wordlist *wl, int mode)
return; return;
} }
if (!cp_getvar("width", CP_NUM, &screen_width)) if (!cp_getvar("width", CP_NUM, &screen_width, 0))
screen_width = DEF_WIDTH; screen_width = DEF_WIDTH;
count = (screen_width - LEFT_WIDTH) / (DEV_WIDTH + 1); count = (screen_width - LEFT_WIDTH) / (DEV_WIDTH + 1);
count = 1; count = 1;
@ -435,7 +435,7 @@ all_show_old(wordlist *wl, int mode)
return; return;
} }
if (!cp_getvar("width", CP_NUM, &screen_width)) if (!cp_getvar("width", CP_NUM, &screen_width, 0))
screen_width = DEF_WIDTH; screen_width = DEF_WIDTH;
count = (screen_width - LEFT_WIDTH) / (DEV_WIDTH + 1); count = (screen_width - LEFT_WIDTH) / (DEV_WIDTH + 1);

View File

@ -123,11 +123,11 @@ com_diff(wordlist *wl)
wordlist *tw; wordlist *tw;
char numbuf[BSIZE_SP], numbuf2[BSIZE_SP], numbuf3[BSIZE_SP], numbuf4[BSIZE_SP]; /* For printnum */ char numbuf[BSIZE_SP], numbuf2[BSIZE_SP], numbuf3[BSIZE_SP], numbuf4[BSIZE_SP]; /* For printnum */
if (!cp_getvar("diff_vntol", CP_REAL, &vntol)) if (!cp_getvar("diff_vntol", CP_REAL, &vntol, 0))
vntol = 1.0e-6; vntol = 1.0e-6;
if (!cp_getvar("diff_abstol", CP_REAL, &abstol)) if (!cp_getvar("diff_abstol", CP_REAL, &abstol, 0))
abstol = 1.0e-12; abstol = 1.0e-12;
if (!cp_getvar("diff_reltol", CP_REAL, &reltol)) if (!cp_getvar("diff_reltol", CP_REAL, &reltol, 0))
reltol = 0.001; reltol = 0.001;
/* Let's try to be clever about defaults. This code is ugly. */ /* Let's try to be clever about defaults. This code is ugly. */

View File

@ -65,11 +65,11 @@ fourier(wordlist *wl, struct plot *current_plot)
return 1; return 1;
} }
if (!cp_getvar("nfreqs", CP_NUM, &nfreqs) || nfreqs < 1) if (!cp_getvar("nfreqs", CP_NUM, &nfreqs, 0) || nfreqs < 1)
nfreqs = 10; nfreqs = 10;
if (!cp_getvar("polydegree", CP_NUM, &polydegree) || polydegree < 0) if (!cp_getvar("polydegree", CP_NUM, &polydegree, 0) || polydegree < 0)
polydegree = 1; polydegree = 1;
if (!cp_getvar("fourgridsize", CP_NUM, &fourgridsize) || fourgridsize < 1) if (!cp_getvar("fourgridsize", CP_NUM, &fourgridsize, 0) || fourgridsize < 1)
fourgridsize = DEF_FOURGRIDSIZE; fourgridsize = DEF_FOURGRIDSIZE;
time = current_plot->pl_scale; time = current_plot->pl_scale;

View File

@ -87,7 +87,7 @@ static int hcopygraphid;
int GL_Init(void) int GL_Init(void)
{ {
if (!cp_getvar("hcopyscale", CP_STRING, psscale)) { if (!cp_getvar("hcopyscale", CP_STRING, psscale, 32)) {
scale = 1.0; scale = 1.0;
} else { } else {
sscanf(psscale, "%lf", &scale); sscanf(psscale, "%lf", &scale);

View File

@ -200,7 +200,7 @@ inp_list(FILE *file, struct card *deck, struct card *extras, int type)
file = cp_more; file = cp_more;
} }
renumber = cp_getvar("renumber", CP_BOOL, NULL); renumber = cp_getvar("renumber", CP_BOOL, NULL, 0);
if (type == LS_LOGICAL) { if (type == LS_LOGICAL) {
top1: top1:
@ -588,7 +588,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
cp_vset("pretemp", CP_REAL, &temperature_value); cp_vset("pretemp", CP_REAL, &temperature_value);
} }
if (ft_ngdebug) { if (ft_ngdebug) {
cp_getvar("pretemp", CP_REAL, &testemp); cp_getvar("pretemp", CP_REAL, &testemp, 0);
printf("test temperature %f\n", testemp); printf("test temperature %f\n", testemp);
} }
@ -600,7 +600,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
SetAnalyse("Prepare Deck", 0); SetAnalyse("Prepare Deck", 0);
#endif #endif
/* Now expand subcircuit macros and substitute numparams.*/ /* Now expand subcircuit macros and substitute numparams.*/
if (!cp_getvar("nosubckt", CP_BOOL, NULL)) if (!cp_getvar("nosubckt", CP_BOOL, NULL, 0))
if ((deck->nextcard = inp_subcktexpand(deck->nextcard)) == NULL) { if ((deck->nextcard = inp_subcktexpand(deck->nextcard)) == NULL) {
line_free(realdeck, TRUE); line_free(realdeck, TRUE);
line_free(deck->actualLine, TRUE); line_free(deck->actualLine, TRUE);
@ -723,7 +723,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
} }
if (ciprefix(".meas", dd->line)) { if (ciprefix(".meas", dd->line)) {
if (cp_getvar("autostop", CP_BOOL, NULL)) { if (cp_getvar("autostop", CP_BOOL, NULL, 0)) {
if (strstr(dd->line, " max ") || if (strstr(dd->line, " max ") ||
strstr(dd->line, " min ") || strstr(dd->line, " min ") ||
strstr(dd->line, " avg ") || strstr(dd->line, " avg ") ||
@ -876,7 +876,7 @@ inp_dodeck(
/*PN FTESTATS*/ /*PN FTESTATS*/
ft_curckt->FTEstats = TMALLOC(FTESTATistics, 1); ft_curckt->FTEstats = TMALLOC(FTESTATistics, 1);
} }
noparse = cp_getvar("noparse", CP_BOOL, NULL); noparse = cp_getvar("noparse", CP_BOOL, NULL, 0);
/* We check preliminary for the scale option. This special processing /* We check preliminary for the scale option. This special processing
@ -944,12 +944,12 @@ inp_dodeck(
out_init(); out_init();
/* if_inpdeck() may return NULL upon error */ /* if_inpdeck() may return NULL upon error */
if (ckt) { if (ckt) {
if (cp_getvar("warn", CP_NUM, &warn)) if (cp_getvar("warn", CP_NUM, &warn, 0))
ckt->CKTsoaCheck = warn; ckt->CKTsoaCheck = warn;
else else
ckt->CKTsoaCheck = 0; ckt->CKTsoaCheck = 0;
if (cp_getvar("maxwarns", CP_NUM, &maxwarns)) if (cp_getvar("maxwarns", CP_NUM, &maxwarns, 0))
ckt->CKTsoaMaxWarns = maxwarns; ckt->CKTsoaMaxWarns = maxwarns;
else else
ckt->CKTsoaMaxWarns = 5; ckt->CKTsoaMaxWarns = 5;
@ -1017,7 +1017,7 @@ inp_dodeck(
} }
/* Only print out netlist if brief is FALSE */ /* Only print out netlist if brief is FALSE */
if (!cp_getvar("brief", CP_BOOL, NULL)) { if (!cp_getvar("brief", CP_BOOL, NULL, 0)) {
/* output deck */ /* output deck */
out_printf("\nProcessed Netlist\n"); out_printf("\nProcessed Netlist\n");
out_printf("=================\n"); out_printf("=================\n");
@ -1137,7 +1137,7 @@ com_edit(wordlist *wl)
bool inter, permfile; bool inter, permfile;
char buf[BSIZE_SP]; char buf[BSIZE_SP];
if (!cp_getvar("interactive", CP_BOOL, NULL)) { if (!cp_getvar("interactive", CP_BOOL, NULL, 0)) {
fprintf(cp_err, fprintf(cp_err,
"Warning: `edit' is disabled because 'interactive' has not been set.\n" "Warning: `edit' is disabled because 'interactive' has not been set.\n"
" perhaps you want to 'set interactive'\n"); " perhaps you want to 'set interactive'\n");
@ -1357,7 +1357,7 @@ doedit(char *filename)
{ {
char buf[BSIZE_SP], buf2[BSIZE_SP], *editor; char buf[BSIZE_SP], buf2[BSIZE_SP], *editor;
if (cp_getvar("editor", CP_STRING, buf2)) { if (cp_getvar("editor", CP_STRING, buf2, 512)) {
editor = buf2; editor = buf2;
} else { } else {
if ((editor = getenv("EDITOR")) == NULL) { if ((editor = getenv("EDITOR")) == NULL) {

View File

@ -491,7 +491,7 @@ ngspice_compat_mode(void)
{ {
char behaviour[80]; char behaviour[80];
if (cp_getvar("ngbehavior", CP_STRING, behaviour)) { if (cp_getvar("ngbehavior", CP_STRING, behaviour, 80)) {
if (strcasecmp(behaviour, "all") == 0) if (strcasecmp(behaviour, "all") == 0)
return COMPATMODE_ALL; return COMPATMODE_ALL;
if (strcasecmp(behaviour, "hs") == 0) if (strcasecmp(behaviour, "hs") == 0)
@ -599,7 +599,7 @@ inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile, bool *expr_w_t
inp_fix_gnd_name(working); inp_fix_gnd_name(working);
inp_chk_for_multi_in_vcvs(working, &rv. line_number); inp_chk_for_multi_in_vcvs(working, &rv. line_number);
if (cp_getvar("addcontrol", CP_BOOL, NULL)) if (cp_getvar("addcontrol", CP_BOOL, NULL, 0))
inp_add_control_section(working, &rv . line_number); inp_add_control_section(working, &rv . line_number);
#ifndef XSPICE #ifndef XSPICE
inp_poly_err(working); inp_poly_err(working);
@ -1144,7 +1144,7 @@ inp_pathresolve(const char *name)
#if defined(__MINGW32__) || defined(_MSC_VER) #if defined(__MINGW32__) || defined(_MSC_VER)
/* If variable 'mingwpath' is set: convert mingw /d/... to d:/... */ /* If variable 'mingwpath' is set: convert mingw /d/... to d:/... */
if (cp_getvar("mingwpath", CP_BOOL, NULL) && name[0] == DIR_TERM_LINUX && isalpha_c(name[1]) && name[2] == DIR_TERM_LINUX) { if (cp_getvar("mingwpath", CP_BOOL, NULL, 0) && name[0] == DIR_TERM_LINUX && isalpha_c(name[1]) && name[2] == DIR_TERM_LINUX) {
strcpy(buf, name); strcpy(buf, name);
buf[0] = buf[1]; buf[0] = buf[1];
buf[1] = ':'; buf[1] = ':';
@ -1158,7 +1158,7 @@ inp_pathresolve(const char *name)
return copy(name); return copy(name);
/* fail if this was an absolute filename or if there is no sourcepath var */ /* fail if this was an absolute filename or if there is no sourcepath var */
if (is_absolute_pathname(name) || !cp_getvar("sourcepath", CP_LIST, &v)) if (is_absolute_pathname(name) || !cp_getvar("sourcepath", CP_LIST, &v, 0))
return NULL; return NULL;
for (; v; v = v->va_next) { for (; v; v = v->va_next) {
@ -1512,7 +1512,7 @@ inp_add_control_section(struct card *deck, int *line_number)
found_run = TRUE; found_run = TRUE;
} }
if (cp_getvar("rawfile", CP_STRING, rawfile)) { if (cp_getvar("rawfile", CP_STRING, rawfile, 1000)) {
line = tprintf("write %s", rawfile); line = tprintf("write %s", rawfile);
prev_card = insert_new_line(prev_card, line, (*line_number)++, 0); prev_card = insert_new_line(prev_card, line, (*line_number)++, 0);
} }
@ -1531,7 +1531,7 @@ inp_add_control_section(struct card *deck, int *line_number)
if (op_line) if (op_line)
deck = insert_new_line(deck, copy(op_line), (*line_number)++, 0); deck = insert_new_line(deck, copy(op_line), (*line_number)++, 0);
if (cp_getvar("rawfile", CP_STRING, rawfile)) { if (cp_getvar("rawfile", CP_STRING, rawfile, 1000)) {
line = tprintf("write %s", rawfile); line = tprintf("write %s", rawfile);
deck = insert_new_line(deck, line, (*line_number)++, 0); deck = insert_new_line(deck, line, (*line_number)++, 0);
} }

View File

@ -239,7 +239,7 @@ do_measure(
} }
/* don't allow autostop if no .meas commands are given in the input file */ /* don't allow autostop if no .meas commands are given in the input file */
if ((cp_getvar("autostop", CP_BOOL, NULL)) && (ft_curckt->ci_meas == NULL)) { if ((cp_getvar("autostop", CP_BOOL, NULL, 0)) && (ft_curckt->ci_meas == NULL)) {
fprintf(cp_err, "\nWarning: No .meas commands found!\n"); fprintf(cp_err, "\nWarning: No .meas commands found!\n");
fprintf(cp_err, " Option autostop is not available, ignored!\n\n"); fprintf(cp_err, " Option autostop is not available, ignored!\n\n");
cp_remvar("autostop"); cp_remvar("autostop");
@ -447,7 +447,7 @@ check_autostop(char* what)
{ {
bool flag = FALSE; bool flag = FALSE;
if (cp_getvar("autostop", CP_BOOL, NULL)) if (cp_getvar("autostop", CP_BOOL, NULL, 0))
flag = do_measure(what, TRUE); flag = do_measure(what, TRUE);
return flag; return flag;

View File

@ -45,7 +45,7 @@ com_quit(wordlist *wl)
bool noask = bool noask =
(wl && wl->wl_word && 1 == sscanf(wl->wl_word, "%d", &exitcode)) || (wl && wl->wl_word && 1 == sscanf(wl->wl_word, "%d", &exitcode)) ||
(wl && wl->wl_word && cieq(wl->wl_word, "noask")) || (wl && wl->wl_word && cieq(wl->wl_word, "noask")) ||
!cp_getvar("askquit", CP_BOOL, NULL); !cp_getvar("askquit", CP_BOOL, NULL, 0);
/* update screen and reset terminal */ /* update screen and reset terminal */
gr_clean(); gr_clean();

View File

@ -359,7 +359,7 @@ nupa_done(void)
if (nerrors) { if (nerrors) {
bool is_interactive = FALSE; bool is_interactive = FALSE;
if (cp_getvar("interactive", CP_BOOL, NULL)) if (cp_getvar("interactive", CP_BOOL, NULL, 0))
is_interactive = TRUE; is_interactive = TRUE;
printf(" Copies=%d Evals=%d Placeholders=%ld Symbols=%d Errors=%d\n", printf(" Copies=%d Evals=%d Placeholders=%ld Symbols=%d Errors=%d\n",
linecountS, evalcountS, placeholder, dictsize, nerrors); linecountS, evalcountS, placeholder, dictsize, nerrors);

View File

@ -156,7 +156,7 @@ inp_nutsource(FILE *fp, bool comfile, char *filename)
* fix the case before we do this but after we * fix the case before we do this but after we
* deal with the commands. * deal with the commands.
*/ */
if (!cp_getvar("nosubckt", CP_BOOL, NULL)) if (!cp_getvar("nosubckt", CP_BOOL, NULL, 0))
deck->nextcard = inp_subcktexpand(deck->nextcard); deck->nextcard = inp_subcktexpand(deck->nextcard);
deck->actualLine = realdeck; deck->actualLine = realdeck;
nutinp_dodeck(deck, tt, wl, FALSE, options, filename); nutinp_dodeck(deck, tt, wl, FALSE, options, filename);

View File

@ -154,11 +154,11 @@ beginPlot(JOB *analysisPtr, CKTcircuit *circuitPtr, char *cktName, char *analNam
/*end saj*/ /*end saj*/
/* Check to see if we want to print informational data. */ /* Check to see if we want to print informational data. */
if (cp_getvar("printinfo", CP_BOOL, NULL)) if (cp_getvar("printinfo", CP_BOOL, NULL, 0))
fprintf(cp_err, "(debug printing enabled)\n"); fprintf(cp_err, "(debug printing enabled)\n");
/* Check to see if we want to save only interpolated data. */ /* Check to see if we want to save only interpolated data. */
if (cp_getvar("interp", CP_BOOL, NULL)) { if (cp_getvar("interp", CP_BOOL, NULL, 0)) {
interpolated = TRUE; interpolated = TRUE;
fprintf(cp_out, "Warning: Interpolated raw file data!\n\n"); fprintf(cp_out, "Warning: Interpolated raw file data!\n\n");
} }
@ -1292,7 +1292,7 @@ OUTerror(int flags, char *format, IFuid *names)
char buf[BSIZE_SP], *s, *bptr; char buf[BSIZE_SP], *s, *bptr;
int nindex = 0; int nindex = 0;
if ((flags == ERR_INFO) && cp_getvar("printinfo", CP_BOOL, NULL)) if ((flags == ERR_INFO) && cp_getvar("printinfo", CP_BOOL, NULL, 0))
return; return;
for (m = msgs; m->flag; m++) for (m = msgs; m->flag; m++)
@ -1325,7 +1325,7 @@ OUTerrorf(int flags, const char *format, ...)
struct mesg *m; struct mesg *m;
va_list args; va_list args;
if ((flags == ERR_INFO) && cp_getvar("printinfo", CP_BOOL, NULL)) if ((flags == ERR_INFO) && cp_getvar("printinfo", CP_BOOL, NULL, 0))
return; return;
for (m = msgs; m->flag; m++) for (m = msgs; m->flag; m++)

View File

@ -58,7 +58,7 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s
/* Make sure the margin is correct */ /* Make sure the margin is correct */
omargin = margin; omargin = margin;
novalue = cp_getvar("noasciiplotvalue", CP_BOOL, NULL); novalue = cp_getvar("noasciiplotvalue", CP_BOOL, NULL, 0);
if (!novalue && !vec_eq(xscale, vecs)) if (!novalue && !vec_eq(xscale, vecs))
margin *= 2; margin *= 2;
else else
@ -67,16 +67,16 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s
if ((xscale->v_gridtype == GRID_YLOG) || (xscale->v_gridtype == GRID_LOGLOG)) if ((xscale->v_gridtype == GRID_YLOG) || (xscale->v_gridtype == GRID_LOGLOG))
ylogscale = TRUE; ylogscale = TRUE;
if (!cp_getvar("width", CP_NUM, &maxy)) if (!cp_getvar("width", CP_NUM, &maxy, 0))
maxy = DEF_WIDTH; maxy = DEF_WIDTH;
if (!cp_getvar("height", CP_NUM, &height)) if (!cp_getvar("height", CP_NUM, &height, 0))
height = DEF_HEIGHT; height = DEF_HEIGHT;
if (ft_nopage) if (ft_nopage)
nobreakp = TRUE; nobreakp = TRUE;
else else
nobreakp = cp_getvar("nobreak", CP_BOOL, NULL); nobreakp = cp_getvar("nobreak", CP_BOOL, NULL, 0);
maxy -= (margin + FUDGE); maxy -= (margin + FUDGE);
maxx = xscale->v_length; maxx = xscale->v_length;

View File

@ -77,7 +77,7 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
extrange = 0.05 * (ylims[1] - ylims[0]); extrange = 0.05 * (ylims[1] - ylims[0]);
if (!cp_getvar("gnuplot_terminal", CP_STRING, terminal)) { if (!cp_getvar("gnuplot_terminal", CP_STRING, terminal, sizeof(terminal))) {
terminal_type = 1; terminal_type = 1;
} else { } else {
terminal_type = 1; terminal_type = 1;
@ -85,11 +85,11 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
terminal_type = 2; terminal_type = 2;
} }
if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0))
linewidth = 1; linewidth = 1;
if (linewidth < 1) linewidth = 1; if (linewidth < 1) linewidth = 1;
if (!cp_getvar("pointstyle", CP_STRING, pointstyle)) { if (!cp_getvar("pointstyle", CP_STRING, pointstyle, sizeof(pointstyle))) {
markers = FALSE; markers = FALSE;
} else { } else {
if (cieq(pointstyle,"markers")) if (cieq(pointstyle,"markers"))
@ -324,9 +324,9 @@ ft_writesimple(double *xlims, double *ylims, char *filename, char *title, char *
NG_IGNORE(gridtype); NG_IGNORE(gridtype);
NG_IGNORE(plottype); NG_IGNORE(plottype);
appendwrite = cp_getvar("appendwrite", CP_BOOL, NULL); appendwrite = cp_getvar("appendwrite", CP_BOOL, NULL, 0);
singlescale = cp_getvar("wr_singlescale", CP_BOOL, NULL); singlescale = cp_getvar("wr_singlescale", CP_BOOL, NULL, 0);
vecnames = cp_getvar("wr_vecnames", CP_BOOL, NULL); vecnames = cp_getvar("wr_vecnames", CP_BOOL, NULL, 0);
/* Sanity checking. */ /* Sanity checking. */
for (v = vecs, numVecs = 0; v; v = v->v_link2) for (v = vecs, numVecs = 0; v; v = v->v_link2)

View File

@ -104,17 +104,17 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */
cur.plotno = 0; cur.plotno = 0;
/* note: should do only once, maybe in gr_init_once */ /* note: should do only once, maybe in gr_init_once */
if (!cp_getvar("pointchars", CP_STRING, pointchars)) if (!cp_getvar("pointchars", CP_STRING, pointchars, sizeof(pointchars)))
(void) strcpy(pointchars, DEFPOINTCHARS); (void) strcpy(pointchars, DEFPOINTCHARS);
if (!cp_getvar("ticmarks", CP_NUM, &graph->ticmarks)) { if (!cp_getvar("ticmarks", CP_NUM, &graph->ticmarks, 0)) {
if (cp_getvar("ticmarks", CP_BOOL, NULL)) if (cp_getvar("ticmarks", CP_BOOL, NULL, 0))
graph->ticmarks = 10; graph->ticmarks = 10;
else else
graph->ticmarks = 0; graph->ticmarks = 0;
} }
if (cp_getvar("ticlist", CP_LIST, ticlist)) { if (cp_getvar("ticlist", CP_LIST, ticlist, 0)) {
wl = vareval("ticlist"); wl = vareval("ticlist");
ticlist = wl_flatten(wl); ticlist = wl_flatten(wl);
graph->ticdata = readtics(ticlist); graph->ticdata = readtics(ticlist);
@ -445,7 +445,7 @@ gr_pmsg(char *text)
DevUpdate(); DevUpdate();
if (cp_getvar("device", CP_STRING, buf) && !(strcmp("/dev/tty", buf) == 0)) if (cp_getvar("device", CP_STRING, buf, sizeof(buf)) && !(strcmp("/dev/tty", buf) == 0))
fprintf(cp_err, "%s", text); fprintf(cp_err, "%s", text);
else if (currentgraph->grid.xlabel) else if (currentgraph->grid.xlabel)
/* MW. grid.xlabel may be NULL */ /* MW. grid.xlabel may be NULL */

View File

@ -41,7 +41,7 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart)
if (nostart) { if (nostart) {
degree = currentgraph->degree; degree = currentgraph->degree;
} else { } else {
if (!cp_getvar("polydegree", CP_NUM, &degree)) if (!cp_getvar("polydegree", CP_NUM, &degree, 0))
degree = 1; degree = 1;
currentgraph->degree = degree; currentgraph->degree = degree;
} }
@ -55,7 +55,7 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart)
return; return;
} }
if (!cp_getvar("gridsize", CP_NUM, &gridsize)) if (!cp_getvar("gridsize", CP_NUM, &gridsize, 0))
gridsize = 0; gridsize = 0;
if ((gridsize < 0) || (gridsize > 10000)) { if ((gridsize < 0) || (gridsize > 10000)) {
@ -325,7 +325,7 @@ plotinterval(struct dvec *v, double lo, double hi, register double *coeffs, int
/* This is a problem -- how do we know what granularity to use? If /* This is a problem -- how do we know what granularity to use? If
* the guy cares about this he will use gridsize. * the guy cares about this he will use gridsize.
*/ */
if (!cp_getvar("polysteps", CP_NUM, &steps)) if (!cp_getvar("polysteps", CP_NUM, &steps, 0))
steps = GRANULARITY; steps = GRANULARITY;
incr = (hi - lo) / (double) (steps + 1); incr = (hi - lo) / (double) (steps + 1);

View File

@ -417,7 +417,7 @@ plotit(wordlist *wl, char *hcopy, char *devname)
} }
if (!sameflag && !gfound) { if (!sameflag && !gfound) {
if (cp_getvar("gridstyle", CP_STRING, buf)) { if (cp_getvar("gridstyle", CP_STRING, buf, sizeof(buf))) {
if (eq(buf, "lingrid")) if (eq(buf, "lingrid"))
gtype = GRID_LIN; gtype = GRID_LIN;
else if (eq(buf, "loglog")) else if (eq(buf, "loglog"))
@ -480,7 +480,7 @@ plotit(wordlist *wl, char *hcopy, char *devname)
} }
if (!sameflag && !pfound) { if (!sameflag && !pfound) {
if (cp_getvar("plotstyle", CP_STRING, buf)) { if (cp_getvar("plotstyle", CP_STRING, buf, sizeof(buf))) {
if (eq(buf, "linplot")) if (eq(buf, "linplot"))
ptype = PLOT_LIN; ptype = PLOT_LIN;
else if (eq(buf, "noretraceplot")) else if (eq(buf, "noretraceplot"))

View File

@ -38,13 +38,13 @@ ft_xgraph(double *xlims, double *ylims, char *filename, char *title, char *xlabe
return; return;
} }
if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0))
linewidth = 1; linewidth = 1;
if (linewidth < 1) if (linewidth < 1)
linewidth = 1; linewidth = 1;
if (!cp_getvar("pointstyle", CP_STRING, pointstyle)) { if (!cp_getvar("pointstyle", CP_STRING, pointstyle, sizeof(pointstyle))) {
markers = FALSE; markers = FALSE;
} else { } else {
if (cieq(pointstyle, "markers")) if (cieq(pointstyle, "markers"))

View File

@ -143,7 +143,7 @@ com_print(wordlist *wl)
out_init(); out_init();
if (!col) { if (!col) {
if (cp_getvar("width", CP_NUM, &i)) if (cp_getvar("width", CP_NUM, &i, 0))
width = i; width = i;
if (width < 60) if (width < 60)
width = 60; width = 60;
@ -219,7 +219,7 @@ com_print(wordlist *wl)
} //end if (v->v_rlength == 1) } //end if (v->v_rlength == 1)
} // end for loop } // end for loop
} else { /* Print in columns. */ } else { /* Print in columns. */
if (cp_getvar("width", CP_NUM, &i)) if (cp_getvar("width", CP_NUM, &i, 0))
width = i; width = i;
if (width < 40) if (width < 40)
width = 40; width = 40;
@ -227,16 +227,16 @@ com_print(wordlist *wl)
buf = TREALLOC(char, buf, width + 1); buf = TREALLOC(char, buf, width + 1);
buf2 = TREALLOC(char, buf2, width + 1); buf2 = TREALLOC(char, buf2, width + 1);
} }
if (cp_getvar("height", CP_NUM, &i)) if (cp_getvar("height", CP_NUM, &i, 0))
height = i; height = i;
if (height < 20) if (height < 20)
height = 20; height = 20;
nobreak = cp_getvar("nobreak", CP_BOOL, NULL); nobreak = cp_getvar("nobreak", CP_BOOL, NULL, 0);
if (!nobreak && !ft_nopage) if (!nobreak && !ft_nopage)
nobreak = FALSE; nobreak = FALSE;
else else
nobreak = TRUE; nobreak = TRUE;
noprintscale = cp_getvar("noprintscale", CP_BOOL, NULL); noprintscale = cp_getvar("noprintscale", CP_BOOL, NULL, 0);
bv = vecs; bv = vecs;
nextpage: nextpage:
/* Make the first vector of every page be the scale... */ /* Make the first vector of every page be the scale... */
@ -397,7 +397,7 @@ com_write(wordlist *wl)
file = ft_rawfile; file = ft_rawfile;
} }
if (cp_getvar("filetype", CP_STRING, buf)) { if (cp_getvar("filetype", CP_STRING, buf, sizeof(buf))) {
if (eq(buf, "binary")) if (eq(buf, "binary"))
ascii = FALSE; ascii = FALSE;
else if (eq(buf, "ascii")) else if (eq(buf, "ascii"))
@ -405,7 +405,7 @@ com_write(wordlist *wl)
else else
fprintf(cp_err, "Warning: strange file type %s\n", buf); fprintf(cp_err, "Warning: strange file type %s\n", buf);
} }
appendwrite = cp_getvar("appendwrite", CP_BOOL, NULL); appendwrite = cp_getvar("appendwrite", CP_BOOL, NULL, 0);
if (wl) if (wl)
names = ft_getpnames(wl, TRUE); names = ft_getpnames(wl, TRUE);

View File

@ -84,7 +84,7 @@ PS_Init(void)
{ {
char pswidth[30], psheight[30]; char pswidth[30], psheight[30];
if (!cp_getvar("hcopyscale", CP_STRING, psscale)) { if (!cp_getvar("hcopyscale", CP_STRING, psscale, sizeof(psscale))) {
scale = 1.0; scale = 1.0;
} else { } else {
sscanf(psscale, "%lf", &scale); sscanf(psscale, "%lf", &scale);
@ -93,7 +93,7 @@ PS_Init(void)
} }
dispdev->numlinestyles = NUMELEMS(linestyle); dispdev->numlinestyles = NUMELEMS(linestyle);
/* plot color */ /* plot color */
if (!cp_getvar("hcopypscolor", CP_NUM, &setbgcolor)) { if (!cp_getvar("hcopypscolor", CP_NUM, &setbgcolor, 0)) {
/* if not set, set plot to b&w and use line styles */ /* if not set, set plot to b&w and use line styles */
colorflag = 0; colorflag = 0;
dispdev->numcolors = 2; dispdev->numcolors = 2;
@ -102,11 +102,11 @@ PS_Init(void)
/* get backgroung color and set plot to color */ /* get backgroung color and set plot to color */
colorflag = 1; colorflag = 1;
dispdev->numcolors = 21; /* don't know what the maximum should be */ dispdev->numcolors = 21; /* don't know what the maximum should be */
cp_getvar("hcopypstxcolor", CP_NUM, &settxcolor); cp_getvar("hcopypstxcolor", CP_NUM, &settxcolor, 0);
} }
/* plot size */ /* plot size */
if (!cp_getvar("hcopywidth", CP_STRING, pswidth)) { if (!cp_getvar("hcopywidth", CP_STRING, pswidth, sizeof( pswidth))) {
dispdev->width = (int)(7.75 * 72.0 * scale); /* (8 1/2 - 3/4) * 72 */ dispdev->width = (int)(7.75 * 72.0 * scale); /* (8 1/2 - 3/4) * 72 */
} else { } else {
sscanf(pswidth, "%d", &(dispdev->width)); sscanf(pswidth, "%d", &(dispdev->width));
@ -115,7 +115,7 @@ PS_Init(void)
if (dispdev->width >= 10000) if (dispdev->width >= 10000)
dispdev->width = 10000; dispdev->width = 10000;
} }
if (!cp_getvar("hcopyheight", CP_STRING, psheight)) { if (!cp_getvar("hcopyheight", CP_STRING, psheight, sizeof(psheight))) {
dispdev->height = dispdev->width; dispdev->height = dispdev->width;
} else { } else {
sscanf(psheight, "%d", &(dispdev->height)); sscanf(psheight, "%d", &(dispdev->height));
@ -135,9 +135,9 @@ PS_Init(void)
* viewport.height = absolute.height - 2 * viewportyoff * viewport.height = absolute.height - 2 * viewportyoff
*/ */
if (!cp_getvar("hcopyfont", CP_STRING, psfont)) if (!cp_getvar("hcopyfont", CP_STRING, psfont, sizeof(psfont)))
strcpy(psfont, "Helvetica"); strcpy(psfont, "Helvetica");
if (!cp_getvar("hcopyfontsize", CP_STRING, psfontsize)) { if (!cp_getvar("hcopyfontsize", CP_STRING, psfontsize, sizeof(psfontsize))) {
fontsize = 10; fontsize = 10;
fontwidth = 6; fontwidth = 6;
fontheight = 14; fontheight = 14;
@ -422,7 +422,7 @@ PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */
/* Extract the rgbcolor, format is: "rgb:<red>/<green>/<blue>" */ /* Extract the rgbcolor, format is: "rgb:<red>/<green>/<blue>" */
sprintf(colorN, "color%d", colorid); sprintf(colorN, "color%d", colorid);
if (cp_getvar(colorN, CP_STRING, colorstring)) { if (cp_getvar(colorN, CP_STRING, colorstring, sizeof(colorstring))) {
for (i = 0; colorstring[i]; i++) for (i = 0; colorstring[i]; i++)
if (colorstring[i] == '/' || colorstring[i] == ':') if (colorstring[i] == '/' || colorstring[i] == ':')
colorstring[i] = ' '; colorstring[i] = ' ';

View File

@ -50,7 +50,7 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
char buf[BSIZE_SP]; char buf[BSIZE_SP];
char *branch; char *branch;
raw_padding = !cp_getvar("nopadding", CP_BOOL, NULL); raw_padding = !cp_getvar("nopadding", CP_BOOL, NULL, 0);
/* Why bother printing out an empty plot? */ /* Why bother printing out an empty plot? */
if (!pl->pl_dvecs) { if (!pl->pl_dvecs) {

View File

@ -215,7 +215,7 @@ dosim(
ww = wl_cons(copy(what), wl); ww = wl_cons(copy(what), wl);
} }
/* reset output file type according to variable given in spinit */ /* reset output file type according to variable given in spinit */
if (cp_getvar("filetype", CP_STRING, buf)) { if (cp_getvar("filetype", CP_STRING, buf, sizeof(buf))) {
if (eq(buf, "binary")) if (eq(buf, "binary"))
ascii = FALSE; ascii = FALSE;
else if (eq(buf, "ascii")) else if (eq(buf, "ascii"))

View File

@ -91,7 +91,7 @@ com_resume(wordlist *wl)
if (last_used_rawfile) if (last_used_rawfile)
dofile = TRUE; dofile = TRUE;
if (cp_getvar("filetype", CP_STRING, buf)) { if (cp_getvar("filetype", CP_STRING, buf, sizeof(buf))) {
if (eq(buf, "binary")) if (eq(buf, "binary"))
ascii = FALSE; ascii = FALSE;
else if (eq(buf, "ascii")) else if (eq(buf, "ascii"))

View File

@ -91,7 +91,7 @@ com_spec(wordlist *wl)
{ {
char window[BSIZE_SP]; char window[BSIZE_SP];
double maxt = time[tlen-1]; double maxt = time[tlen-1];
if (!cp_getvar("specwindow", CP_STRING, window)) if (!cp_getvar("specwindow", CP_STRING, window, sizeof(window)))
strcpy(window, "hanning"); strcpy(window, "hanning");
if (eq(window, "none")) if (eq(window, "none"))
for (i = 0; i < tlen; i++) for (i = 0; i < tlen; i++)
@ -130,7 +130,7 @@ com_spec(wordlist *wl)
} }
else if (eq(window, "blackman")) { else if (eq(window, "blackman")) {
int order; int order;
if (!cp_getvar("specwindoworder", CP_NUM, &order)) if (!cp_getvar("specwindoworder", CP_NUM, &order, 0))
order = 2; order = 2;
if (order < 2) /* only order 2 supported here */ if (order < 2) /* only order 2 supported here */
order = 2; order = 2;
@ -146,7 +146,7 @@ com_spec(wordlist *wl)
} else if (eq(window, "gaussian")) { } else if (eq(window, "gaussian")) {
int order; int order;
double scale; double scale;
if (!cp_getvar("specwindoworder", CP_NUM, &order)) if (!cp_getvar("specwindoworder", CP_NUM, &order, 0))
order = 2; order = 2;
if (order < 2) if (order < 2)
order = 2; order = 2;
@ -237,7 +237,7 @@ com_spec(wordlist *wl)
dc[i] += tdvec[i][k]*amp; dc[i] += tdvec[i][k]*amp;
} }
} }
trace = cp_getvar("spectrace", CP_BOOL, NULL); trace = cp_getvar("spectrace", CP_BOOL, NULL, 0);
for (j = (startf == 0 ? 1 : 0); j < fpts; j++) { for (j = (startf == 0 ? 1 : 0); j < fpts; j++) {
freq[j] = startf + j*stepf; freq[j] = startf + j*stepf;
if (trace) if (trace)

View File

@ -213,18 +213,18 @@ inp_subcktexpand(struct card *deck) {
struct card *c; struct card *c;
wordlist *modnames = NULL; wordlist *modnames = NULL;
if (!cp_getvar("substart", CP_STRING, start)) if (!cp_getvar("substart", CP_STRING, start, sizeof(start)))
strcpy(start, ".subckt"); strcpy(start, ".subckt");
if (!cp_getvar("subend", CP_STRING, sbend)) if (!cp_getvar("subend", CP_STRING, sbend, sizeof(sbend)))
strcpy(sbend, ".ends"); strcpy(sbend, ".ends");
if (!cp_getvar("subinvoke", CP_STRING, invoke)) if (!cp_getvar("subinvoke", CP_STRING, invoke, sizeof(invoke)))
strcpy(invoke, "x"); strcpy(invoke, "x");
if (!cp_getvar("modelcard", CP_STRING, model)) if (!cp_getvar("modelcard", CP_STRING, model, sizeof(model)))
strcpy(model, ".model"); strcpy(model, ".model");
if (!cp_getvar("modelline", CP_STRING, model)) if (!cp_getvar("modelline", CP_STRING, model, sizeof(model)))
strcpy(model, ".model"); strcpy(model, ".model");
use_numparams = cp_getvar("numparams", CP_BOOL, NULL); use_numparams = cp_getvar("numparams", CP_BOOL, NULL, 0);
use_numparams = TRUE; use_numparams = TRUE;

View File

@ -73,7 +73,7 @@ out_init(void)
noprint = nopause = FALSE; noprint = nopause = FALSE;
if (cp_getvar("moremode", CP_BOOL, NULL)) if (cp_getvar("moremode", CP_BOOL, NULL, 0))
out_moremode = TRUE; out_moremode = TRUE;
else else
out_moremode = FALSE; out_moremode = FALSE;
@ -99,9 +99,9 @@ out_init(void)
#endif #endif
if (!xsize) if (!xsize)
(void) cp_getvar("width", CP_NUM, &xsize); (void) cp_getvar("width", CP_NUM, &xsize, 0);
if (!ysize) if (!ysize)
(void) cp_getvar("height", CP_NUM, &ysize); (void) cp_getvar("height", CP_NUM, &ysize, 0);
if (!xsize) if (!xsize)
xsize = DEF_SCRWIDTH; xsize = DEF_SCRWIDTH;

View File

@ -119,7 +119,7 @@ trnoise_state_gen(struct trnoise_state *this, CKTcircuit *ckt)
{ {
if (this->top == 0) { if (this->top == 0) {
if (cp_getvar("notrnoise", CP_BOOL, NULL)) if (cp_getvar("notrnoise", CP_BOOL, NULL, 0))
this -> NA = this -> TS = this -> NALPHA = this -> NAMP = this -> NA = this -> TS = this -> NALPHA = this -> NAMP =
this -> RTSAM = this -> RTSCAPT = this -> RTSEMT = 0.0; this -> RTSAM = this -> RTSCAPT = this -> RTSEMT = 0.0;

View File

@ -509,7 +509,7 @@ cp_remvar(char *varname)
/* Determine the value of a variable. Fail if the variable is unset, /* Determine the value of a variable. Fail if the variable is unset,
* and if the type doesn't match, try and make it work... */ * and if the type doesn't match, try and make it work... */
bool bool
cp_getvar(char *name, enum cp_types type, void *retval) cp_getvar(char *name, enum cp_types type, void *retval, size_t rsize)
{ {
struct variable *v; struct variable *v;
struct variable *uv1; struct variable *uv1;
@ -563,7 +563,12 @@ cp_getvar(char *name, enum cp_types type, void *retval)
case CP_STRING: { /* Gotta be careful to have room. */ case CP_STRING: { /* Gotta be careful to have room. */
char *s = cp_unquote(v->va_string); char *s = cp_unquote(v->va_string);
cp_wstrip(s); cp_wstrip(s);
strcpy((char*) retval, s); if (strlen(s) >= rsize - 1) {
fprintf(stderr, "Internal Error: string length for variable %s is limited to %d chars\n", v->va_name, rsize);
controlled_exit(EXIT_BAD);
}
else
strcpy((char*) retval, s);
tfree(s); tfree(s);
break; break;
} }

View File

@ -169,7 +169,7 @@ extern char *span_var_expr(char *t);
/* var2.c */ /* var2.c */
extern void cp_vprint(void); extern void cp_vprint(void);
extern bool cp_getvar(char *name, enum cp_types type, void *retval); extern bool cp_getvar(char *name, enum cp_types type, void *retval, size_t rsize);
/* cpinterface.c etc -- stuff CP needs from FTE */ /* cpinterface.c etc -- stuff CP needs from FTE */

View File

@ -1177,7 +1177,7 @@ main(int argc, char **argv)
#elif defined(WaGauss) #elif defined(WaGauss)
{ {
unsigned int rseed = 66; unsigned int rseed = 66;
if (!cp_getvar("rndseed", CP_NUM, &rseed)) { if (!cp_getvar("rndseed", CP_NUM, &rseed, 0)) {
time_t acttime = time(NULL); time_t acttime = time(NULL);
rseed = (unsigned int) acttime; rseed = (unsigned int) acttime;
} }

View File

@ -213,7 +213,7 @@ cx_interpolate(void *data, short int type, int length, int *newlength, short int
*newlength = ns->v_length; *newlength = ns->v_length;
d = alloc_d(ns->v_length); d = alloc_d(ns->v_length);
if (!cp_getvar("polydegree", CP_NUM, &degree)) if (!cp_getvar("polydegree", CP_NUM, &degree, 0))
degree = 1; degree = 1;
for (base = 0; base < length; base += grouping) { for (base = 0; base < length; base += grouping) {
@ -248,7 +248,7 @@ cx_deriv(void *data, short int type, int length, int *newlength, short int *newt
return (NULL); return (NULL);
} }
if (!cp_getvar("dpolydegree", CP_NUM, &degree)) if (!cp_getvar("dpolydegree", CP_NUM, &degree, 0))
degree = 2; /* default quadratic */ degree = 2; /* default quadratic */
n = degree + 1; n = degree + 1;
@ -615,9 +615,9 @@ cx_fft(void *data, short int type, int length, int *newlength, short int *newtyp
win = TMALLOC(double, length); win = TMALLOC(double, length);
maxt = time[length-1]; maxt = time[length-1];
if (!cp_getvar("specwindow", CP_STRING, window)) if (!cp_getvar("specwindow", CP_STRING, window, sizeof(window)))
strcpy(window, "none"); strcpy(window, "none");
if (!cp_getvar("specwindoworder", CP_NUM, &order)) if (!cp_getvar("specwindoworder", CP_NUM, &order, 0))
order = 2; order = 2;
if (order < 2) if (order < 2)
order = 2; order = 2;

View File

@ -77,7 +77,7 @@ void checkseed(void)
int newseed; int newseed;
static int oldseed; static int oldseed;
/* printf("Enter checkseed()\n"); */ /* printf("Enter checkseed()\n"); */
if (cp_getvar("rndseed", CP_NUM, &newseed)) { if (cp_getvar("rndseed", CP_NUM, &newseed, 0)) {
if ((newseed > 0) && (oldseed != newseed)) { if ((newseed > 0) && (oldseed != newseed)) {
srand((unsigned int)newseed); srand((unsigned int)newseed);
TausSeed(); TausSeed();

View File

@ -743,7 +743,7 @@ bot:
#elif defined (WaGauss) #elif defined (WaGauss)
{ {
unsigned int rseed = 66; unsigned int rseed = 66;
if (!cp_getvar("rndseed", CP_NUM, &rseed)) { if (!cp_getvar("rndseed", CP_NUM, &rseed, 0)) {
time_t acttime = time(NULL); time_t acttime = time(NULL);
rseed = (unsigned int) acttime; rseed = (unsigned int) acttime;
} }
@ -1114,7 +1114,7 @@ sh_vfprintf(FILE *f, const char *fmt, va_list args)
} }
/* add / to escape characters, if 'set addescape' is called in .spiceinit */ /* add / to escape characters, if 'set addescape' is called in .spiceinit */
if (cp_getvar("addescape", CP_BOOL, NULL)) { if (cp_getvar("addescape", CP_BOOL, NULL, 0)) {
size_t escapes; size_t escapes;
const char * const escape_chars = "$[]\"\\"; const char * const escape_chars = "$[]\"\\";
char *s = p; char *s = p;

View File

@ -79,7 +79,7 @@ CKTdoJob(CKTcircuit *ckt, int reset, TSKtask *task)
may be overridden by 'set xtrtol=newval' */ may be overridden by 'set xtrtol=newval' */
if (ckt->CKTadevFlag && (ckt->CKTtrtol > 1)) { if (ckt->CKTadevFlag && (ckt->CKTtrtol > 1)) {
int newtol; int newtol;
if (cp_getvar("xtrtol", CP_NUM, &newtol)) { if (cp_getvar("xtrtol", CP_NUM, &newtol, 0)) {
printf("Override trtol to %d for xspice 'A' devices\n", newtol); printf("Override trtol to %d for xspice 'A' devices\n", newtol);
ckt->CKTtrtol = newtol; ckt->CKTtrtol = newtol;
} }

View File

@ -63,7 +63,7 @@ CKTsetup(CKTcircuit *ckt)
matrix = ckt->CKTmatrix; matrix = ckt->CKTmatrix;
#ifdef USE_OMP #ifdef USE_OMP
if (!cp_getvar("num_threads", CP_NUM, &nthreads)) if (!cp_getvar("num_threads", CP_NUM, &nthreads, 0))
nthreads = 2; nthreads = 2;
omp_set_num_threads(nthreads); omp_set_num_threads(nthreads);

View File

@ -123,7 +123,7 @@ NOISEan (CKTcircuit *ckt, int restart)
data->freq = job->NstartFreq; data->freq = job->NstartFreq;
data->outNoiz = 0.0; data->outNoiz = 0.0;
data->inNoise = 0.0; data->inNoise = 0.0;
data->squared = cp_getvar("sqrnoise", CP_BOOL, NULL) ? 1 : 0; data->squared = cp_getvar("sqrnoise", CP_BOOL, NULL, 0) ? 1 : 0;
/* the current front-end needs the namelist to be fully /* the current front-end needs the namelist to be fully
declared before an OUTpBeginplot */ declared before an OUTpBeginplot */

View File

@ -28,7 +28,7 @@ IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -20,7 +20,7 @@ BSIM3v0param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -26,7 +26,7 @@ BSIM3v1param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -25,7 +25,7 @@ BSIM3v32param (int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -78,7 +78,7 @@ IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -32,7 +32,7 @@ IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -34,7 +34,7 @@ IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -34,7 +34,7 @@ IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -34,7 +34,7 @@ IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) switch(param)

View File

@ -24,7 +24,7 @@ CAPparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -25,7 +25,7 @@ DIOparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -73,7 +73,7 @@ int HSM2param(
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch (param) { switch (param) {

View File

@ -34,7 +34,7 @@ int HSMHVparam(
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch (param) { switch (param) {

View File

@ -76,7 +76,7 @@ int HSMHV2param(
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch (param) { switch (param) {

View File

@ -25,7 +25,7 @@ MOS1param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -26,7 +26,7 @@ MOS2param(int param, IFvalue *value, GENinstance *inst,
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -25,7 +25,7 @@ MOS3param(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -21,7 +21,7 @@ RESparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -25,7 +25,7 @@ VDMOSparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
NG_IGNORE(select); NG_IGNORE(select);
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
switch(param) { switch(param) {

View File

@ -226,7 +226,7 @@ INPgetModBin(CKTcircuit *ckt, char *name, INPmodel **model, INPtables *tab, char
static char *model_tokens[] = { "lmin", "lmax", "wmin", "wmax" }; static char *model_tokens[] = { "lmin", "lmax", "wmin", "wmax" };
double scale; double scale;
if (!cp_getvar("scale", CP_REAL, &scale)) if (!cp_getvar("scale", CP_REAL, &scale, 0))
scale = 1; scale = 1;
*model = NULL; *model = NULL;