From 8fbcb16a571d8546af014c79ad4c380e3926c0ea Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 21 Jul 2018 22:15:01 +0200 Subject: [PATCH] add fourth parameter to cp_getvar(), in functions missing so far --- src/frontend/hpgl.c | 2 +- src/frontend/inp.c | 2 +- src/frontend/inpcom.c | 6 +++--- src/frontend/plotting/x11.c | 10 +++++----- src/frontend/wdisp/windisp.c | 12 ++++++------ src/main.c | 2 +- src/nghelp.c | 4 ++-- src/sharedspice.c | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/frontend/hpgl.c b/src/frontend/hpgl.c index 53565adc4..d6a2a434d 100644 --- a/src/frontend/hpgl.c +++ b/src/frontend/hpgl.c @@ -87,7 +87,7 @@ static int hcopygraphid; int GL_Init(void) { - if (!cp_getvar("hcopyscale", CP_STRING, psscale, 32)) { + if (!cp_getvar("hcopyscale", CP_STRING, psscale, sizeof(psscale))) { scale = 1.0; } else { sscanf(psscale, "%lf", &scale); diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 24214f356..f4908b4a1 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -1357,7 +1357,7 @@ doedit(char *filename) { char buf[BSIZE_SP], buf2[BSIZE_SP], *editor; - if (cp_getvar("editor", CP_STRING, buf2, 512)) { + if (cp_getvar("editor", CP_STRING, buf2, sizeof(buf2))) { editor = buf2; } else { if ((editor = getenv("EDITOR")) == NULL) { diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 8b8667f8a..c79195fb1 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -491,7 +491,7 @@ ngspice_compat_mode(void) { char behaviour[80]; - if (cp_getvar("ngbehavior", CP_STRING, behaviour, 80)) { + if (cp_getvar("ngbehavior", CP_STRING, behaviour, sizeof(behaviour))) { if (strcasecmp(behaviour, "all") == 0) return COMPATMODE_ALL; if (strcasecmp(behaviour, "hs") == 0) @@ -1512,7 +1512,7 @@ inp_add_control_section(struct card *deck, int *line_number) found_run = TRUE; } - if (cp_getvar("rawfile", CP_STRING, rawfile, 1000)) { + if (cp_getvar("rawfile", CP_STRING, rawfile, sizeof(rawfile))) { line = tprintf("write %s", rawfile); 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) deck = insert_new_line(deck, copy(op_line), (*line_number)++, 0); - if (cp_getvar("rawfile", CP_STRING, rawfile, 1000)) { + if (cp_getvar("rawfile", CP_STRING, rawfile, sizeof(rawfile))) { line = tprintf("write %s", rawfile); deck = insert_new_line(deck, line, (*line_number)++, 0); } diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index fcd4d5779..6b03f8ec0 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -132,7 +132,7 @@ X11_Init(void) char *argv[2]; int argc = 2; - if (cp_getvar("display", CP_STRING, buf)) { + if (cp_getvar("display", CP_STRING, buf, sizeof(buf))) { displayname = buf; } else if (!(displayname = getenv("DISPLAY"))) { internalerror("Can't open X display."); @@ -233,7 +233,7 @@ initcolors(GRAPH *graph) for (i = 0; i < xmaxcolors; i++) { (void) sprintf(buf, "color%d", i); - if (!cp_getvar(buf, CP_STRING, colorstring)) + if (!cp_getvar(buf, CP_STRING, colorstring, sizeof(colorstring))) (void) strcpy(colorstring, colornames[i]); if (!XAllocNamedColor(display, DefaultColormap(display, DefaultScreen(display)), @@ -425,7 +425,7 @@ X11_NewViewport(GRAPH *graph) XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, hardcopy, graph); /* set up fonts */ - if (!cp_getvar("xfont", CP_STRING, fontname)) + if (!cp_getvar("xfont", CP_STRING, fontname, sizeof(fontname))) (void) strcpy(fontname, DEF_FONT); for (p = fontname; *p && *p <= ' '; p++) @@ -529,7 +529,7 @@ X11_Arc(int x0, int y0, int radius, double theta, double delta_theta) { int t1, t2; - if (0 && !cp_getvar("x11lineararcs", CP_BOOL, NULL)) + if (0 && !cp_getvar("x11lineararcs", CP_BOOL, NULL, 0)) linear_arc(x0, y0, radius, theta, delta_theta); if (DEVDEP(currentgraph).isopen) { @@ -837,7 +837,7 @@ zoomin(GRAPH *graph) /* hack for Gordon Jacobs */ /* add to history list if plothistory is set */ - if (cp_getvar("plothistory", CP_BOOL, NULL)) { + if (cp_getvar("plothistory", CP_BOOL, NULL, 0)) { wl = cp_parse(buf); (void) cp_addhistent(cp_event++, wl); } diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index 47272fc55..ed08fb571 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -121,11 +121,11 @@ WIN_Init(void) /* always, user may have set color0 to white */ /* get background color information from spinit, only "white" is recognized as a suitable option! */ - if (cp_getvar("color0", CP_STRING, colorstring)) + if (cp_getvar("color0", CP_STRING, colorstring, sizeof(colorstring))) isblack = !cieq(colorstring, "white"); /* get linewidth information from spinit */ - if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) + if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0)) linewidth = 0; if (linewidth < 0) linewidth = 0; @@ -136,7 +136,7 @@ WIN_Init(void) isblackold = isblack; /* get linewidth information from spinit - * if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth)) + * if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0)) * linewidth = 0; * if (linewidth < 0) * linewidth = 0; @@ -265,7 +265,7 @@ HcpyPlotBW(HWND hwnd) { int bgcolor; NG_IGNORE(hwnd); - if (cp_getvar("hcopypscolor", CP_NUM, &bgcolor)) + if (cp_getvar("hcopypscolor", CP_NUM, &bgcolor, 0)) cp_remvar("hcopypscolor"); com_hardcopy(NULL); return 0; @@ -889,10 +889,10 @@ WIN_Text(char *text, int x, int y) lf.lfPitchAndFamily = 0; /* set up fonts */ - if (!cp_getvar("wfont", CP_STRING, lf.lfFaceName)) + if (!cp_getvar("wfont", CP_STRING, lf.lfFaceName, sizeof(lf.lfFaceName))) (void) lstrcpy(lf.lfFaceName, DEF_FONTW); - if (!cp_getvar("wfont_size", CP_NUM, &(lf.lfHeight))) + if (!cp_getvar("wfont_size", CP_NUM, &(lf.lfHeight), 0)) lf.lfHeight = (int) (1.1 * currentgraph->fontheight); // lstrcpy (lf.lfFaceName, "Courier"/*"Times New Roman"*/); diff --git a/src/main.c b/src/main.c index 1d5672c6c..daf41e0e5 100644 --- a/src/main.c +++ b/src/main.c @@ -1167,7 +1167,7 @@ main(int argc, char **argv) { unsigned int rseed = 66; initnorm(0, 0); - if (!cp_getvar("rndseed", CP_NUM, &rseed)) { + if (!cp_getvar("rndseed", CP_NUM, &rseed, 0)) { time_t acttime = time(NULL); rseed = (unsigned int) acttime; } diff --git a/src/nghelp.c b/src/nghelp.c index 6d63007f1..97652c68d 100644 --- a/src/nghelp.c +++ b/src/nghelp.c @@ -57,7 +57,7 @@ main(int ac, char **av) #ifndef X_DISPLAY_MISSING - if (cp_getvar("display", CP_STRING, buf)) { + if (cp_getvar("display", CP_STRING, buf, sizeof(buf))) { displayname = buf; } else if (!(displayname = getenv("DISPLAY"))) { fprintf(stderr, "Can't open X display."); @@ -111,7 +111,7 @@ cp_printword(s) */ bool -cp_getvar(char *n, enum cp_types type, void *r) +cp_getvar(char *n, enum cp_types type, void *r, size_t rs) { return (FALSE); } diff --git a/src/sharedspice.c b/src/sharedspice.c index 2ce0da9dd..f58bc1f00 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -733,7 +733,7 @@ bot: { unsigned int rseed = 66; initnorm (0, 0); - if (!cp_getvar("rndseed", CP_NUM, &rseed)) { + if (!cp_getvar("rndseed", CP_NUM, &rseed, 0)) { time_t acttime = time(NULL); rseed = (unsigned int) acttime; }