From d4ced47e8e080eef648cd7afd417aba9cf5904d9 Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 18 Aug 2012 18:27:13 +0200 Subject: [PATCH] drop out_pbuf, which was an ancient workaround obviously an old implementation of out_printf() has been unreliable. --- src/frontend/inp.c | 15 +++++---------- src/frontend/plotting/agraf.c | 21 +++++---------------- src/frontend/postcoms.c | 11 ++++------- src/frontend/terminal.c | 6 ++---- src/frontend/variable.c | 4 +--- src/include/ngspice/cpextern.h | 1 - src/ngsconvert.c | 3 --- 7 files changed, 17 insertions(+), 44 deletions(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index aa82db8a5..1942f3bd8 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -156,9 +156,8 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type) continue; if (*here->li_line != '*') { if (useout) { - sprintf(out_pbuf, "%6d : %s\n", + out_printf("%6d : %s\n", here->li_linenum, upper(here->li_line)); - out_send(out_pbuf); } else { fprintf(file, "%6d : %s\n", here->li_linenum, upper(here->li_line)); @@ -180,8 +179,7 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type) } if (useout) { - sprintf(out_pbuf, "%6d : .end\n", i); - out_send(out_pbuf); + out_printf("%6d : .end\n", i); } else { fprintf(file, "%6d : .end\n", i); } @@ -197,9 +195,8 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type) continue; if (type == LS_PHYSICAL) { if (useout) { - sprintf(out_pbuf, "%6d : %s\n", + out_printf("%6d : %s\n", here->li_linenum, upper(here->li_line)); - out_send(out_pbuf); } else { fprintf(file, "%6d : %s\n", here->li_linenum, upper(here->li_line)); @@ -223,9 +220,8 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type) continue; if (type == LS_PHYSICAL) { if (useout) { - sprintf(out_pbuf, "%6d : %s\n", + out_printf("%6d : %s\n", there->li_linenum, upper(there->li_line)); - out_send(out_pbuf); } else { fprintf(file, "%6d : %s\n", there->li_linenum, upper(there->li_line)); @@ -254,8 +250,7 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type) } if (type == LS_PHYSICAL) { if (useout) { - sprintf(out_pbuf, "%6d : .end\n", i); - out_send(out_pbuf); + out_printf("%6d : .end\n", i); } else { fprintf(file, "%6d : .end\n", i); } diff --git a/src/frontend/plotting/agraf.c b/src/frontend/plotting/agraf.c index bc9b252a1..780e766f8 100644 --- a/src/frontend/plotting/agraf.c +++ b/src/frontend/plotting/agraf.c @@ -271,10 +271,7 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s if (j == 0) j = 1; for (v = vecs; v; v = v->v_link2) { - out_pbuf[0] = (char) v->v_linestyle; - out_pbuf[1] = '\0'; -/* out_printf("%c = %-17s", (char) v->v_linestyle, v->v_name); */ - out_printf("%s = %-17s", out_pbuf, v->v_name); + out_printf("%c = %-17s", (char) v->v_linestyle, v->v_name); if (!(++i % j) && v->v_link2) { out_send("\n "); curline++; @@ -297,23 +294,15 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s else x = xrange[0] + (xrange[1] - xrange[0]) * i / (maxx - 1); if (x < 0.0) { - sprintf(out_pbuf, "%.3e ", x); - out_send(out_pbuf); -/* out_printf("%.3e ", x); */ + out_printf("%.3e ", x); } else { - sprintf(out_pbuf, " %.3e ", x); - out_send(out_pbuf); -/* out_printf(" %.3e ", x); */ + out_printf(" %.3e ", x); } if (!novalue) { if (values[i] < 0.0) { - sprintf(out_pbuf, "%.3e ", values[i]); - out_send(out_pbuf); -/* out_printf("%.3e ", values[i]); */ + out_printf("%.3e ", values[i]); } else { - sprintf(out_pbuf, " %.3e ", values[i]); - out_send(out_pbuf); -/* out_printf(" %.3e ", values[i]); */ + out_printf(" %.3e ", values[i]); } } cb = field[(i + 1) * omaxy]; diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index 033aa620a..c032ec67b 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -317,8 +317,7 @@ pbreak: /* New page. */ lineno += 2; loop: while ((j < npoints) && (lineno < height)) { - sprintf(out_pbuf, "%d\t", j); - out_send(out_pbuf); + out_printf("%d\t", j); for (v = bv; (v && (v != lv)); v = v->v_link2) { if (v->v_length <= j) { if (isreal(v)) @@ -329,8 +328,7 @@ loop: if (isreal(v)) { printnum(numbuf, v->v_realdata[j]); - (void) sprintf(out_pbuf, "%s\t",numbuf); - out_send(out_pbuf); + out_printf("%s\t", numbuf); } else { @@ -339,15 +337,14 @@ loop: imagpart(v->v_compdata[j]) == 0.0) { printnum(numbuf, realpart(v->v_compdata[j])); - (void) sprintf(out_pbuf, "%s\t",numbuf); + out_printf("%s\t", numbuf); } else { printnum(numbuf, realpart(v->v_compdata[j])); printnum(numbuf2, imagpart(v->v_compdata[j])); - (void) sprintf(out_pbuf, "%s,\t%s\t",numbuf,numbuf2); + out_printf("%s,\t%s\t", numbuf, numbuf2); } - out_send(out_pbuf); } } } diff --git a/src/frontend/terminal.c b/src/frontend/terminal.c index f8d6661e8..5005375ba 100644 --- a/src/frontend/terminal.c +++ b/src/frontend/terminal.c @@ -51,10 +51,6 @@ extern int vasprintf(char **out, const char *fmt, va_list ap); #include "variable.h" #include "terminal.h" -/* out_printf doesn't handle double arguments correctly, so we - sprintf into this buf and call out_send w/ it */ -char out_pbuf[8*BSIZE_SP]; - bool out_moremode = TRUE; bool out_isatty = TRUE; @@ -265,12 +261,14 @@ out_printf(char *fmt, ...) out_send(tbuf); FREE(tbuf); #elif defined(HAVE_SNPRINTF) /* the second best */ + static char out_pbuf[8*BSIZE_SP]; va_list ap; va_start (ap, fmt); vsnprintf(out_pbuf, sizeof(out_pbuf), fmt, ap); va_end (ap); out_send(out_pbuf); #else /* guaranteed a bug for long messages */ + static char out_pbuf[8*BSIZE_SP]; va_list ap; va_start (ap, fmt); vsprintf(out_pbuf, fmt, ap); diff --git a/src/frontend/variable.c b/src/frontend/variable.c index 081a8f3ea..b668661c8 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -919,9 +919,7 @@ cp_vprint(void) continue; v = vars[j].x_v; if (v->va_type == CP_BOOL) { - /* out_printf("%c %s\n", vars[j].x_char, v->va_name); */ - sprintf(out_pbuf, "%c %s\n", vars[j].x_char, v->va_name); - out_send(out_pbuf); + out_printf("%c %s\n", vars[j].x_char, v->va_name); } else { out_printf("%c %s\t", vars[j].x_char, v->va_name); wl = vareval(v->va_name); diff --git a/src/include/ngspice/cpextern.h b/src/include/ngspice/cpextern.h index fddbac5cd..b4334e4eb 100644 --- a/src/include/ngspice/cpextern.h +++ b/src/include/ngspice/cpextern.h @@ -116,7 +116,6 @@ extern void cp_init(void); /* output.c */ -extern char out_pbuf[]; extern bool out_moremode; extern bool out_isatty; extern void out_init(void); diff --git a/src/ngsconvert.c b/src/ngsconvert.c index 8d6810243..51238ae6b 100644 --- a/src/ngsconvert.c +++ b/src/ngsconvert.c @@ -33,9 +33,6 @@ struct circ *ft_curckt = NULL; char *cp_program = "sconvert"; -/* doesn't get used, but some unused routine in some file references it */ -char out_pbuf[BSIZE_SP]; - #define tfread(ptr, siz, nit, fp) if (fread((ptr), (siz), \ (nit), (fp)) != (nit)) { \