Browse Source

drop out_pbuf, which was an ancient workaround

obviously an old implementation of out_printf()
  has been unreliable.
rlar 14 years ago
parent
commit
d4ced47e8e
  1. 15
      src/frontend/inp.c
  2. 21
      src/frontend/plotting/agraf.c
  3. 11
      src/frontend/postcoms.c
  4. 6
      src/frontend/terminal.c
  5. 4
      src/frontend/variable.c
  6. 1
      src/include/ngspice/cpextern.h
  7. 3
      src/ngsconvert.c

15
src/frontend/inp.c

@ -156,9 +156,8 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
continue; continue;
if (*here->li_line != '*') { if (*here->li_line != '*') {
if (useout) { if (useout) {
sprintf(out_pbuf, "%6d : %s\n",
out_printf("%6d : %s\n",
here->li_linenum, upper(here->li_line)); here->li_linenum, upper(here->li_line));
out_send(out_pbuf);
} else { } else {
fprintf(file, "%6d : %s\n", fprintf(file, "%6d : %s\n",
here->li_linenum, upper(here->li_line)); 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) { if (useout) {
sprintf(out_pbuf, "%6d : .end\n", i);
out_send(out_pbuf);
out_printf("%6d : .end\n", i);
} else { } else {
fprintf(file, "%6d : .end\n", i); fprintf(file, "%6d : .end\n", i);
} }
@ -197,9 +195,8 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
continue; continue;
if (type == LS_PHYSICAL) { if (type == LS_PHYSICAL) {
if (useout) { if (useout) {
sprintf(out_pbuf, "%6d : %s\n",
out_printf("%6d : %s\n",
here->li_linenum, upper(here->li_line)); here->li_linenum, upper(here->li_line));
out_send(out_pbuf);
} else { } else {
fprintf(file, "%6d : %s\n", fprintf(file, "%6d : %s\n",
here->li_linenum, upper(here->li_line)); here->li_linenum, upper(here->li_line));
@ -223,9 +220,8 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
continue; continue;
if (type == LS_PHYSICAL) { if (type == LS_PHYSICAL) {
if (useout) { if (useout) {
sprintf(out_pbuf, "%6d : %s\n",
out_printf("%6d : %s\n",
there->li_linenum, upper(there->li_line)); there->li_linenum, upper(there->li_line));
out_send(out_pbuf);
} else { } else {
fprintf(file, "%6d : %s\n", fprintf(file, "%6d : %s\n",
there->li_linenum, upper(there->li_line)); 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 (type == LS_PHYSICAL) {
if (useout) { if (useout) {
sprintf(out_pbuf, "%6d : .end\n", i);
out_send(out_pbuf);
out_printf("%6d : .end\n", i);
} else { } else {
fprintf(file, "%6d : .end\n", i); fprintf(file, "%6d : .end\n", i);
} }

21
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) if (j == 0)
j = 1; j = 1;
for (v = vecs; v; v = v->v_link2) { 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) { if (!(++i % j) && v->v_link2) {
out_send("\n "); out_send("\n ");
curline++; curline++;
@ -297,23 +294,15 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s
else else
x = xrange[0] + (xrange[1] - xrange[0]) * i / (maxx - 1); x = xrange[0] + (xrange[1] - xrange[0]) * i / (maxx - 1);
if (x < 0.0) { if (x < 0.0) {
sprintf(out_pbuf, "%.3e ", x);
out_send(out_pbuf);
/* out_printf("%.3e ", x); */
out_printf("%.3e ", x);
} else { } else {
sprintf(out_pbuf, " %.3e ", x);
out_send(out_pbuf);
/* out_printf(" %.3e ", x); */
out_printf(" %.3e ", x);
} }
if (!novalue) { if (!novalue) {
if (values[i] < 0.0) { 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 { } 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]; cb = field[(i + 1) * omaxy];

11
src/frontend/postcoms.c

@ -317,8 +317,7 @@ pbreak: /* New page. */
lineno += 2; lineno += 2;
loop: loop:
while ((j < npoints) && (lineno < height)) { 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) { for (v = bv; (v && (v != lv)); v = v->v_link2) {
if (v->v_length <= j) { if (v->v_length <= j) {
if (isreal(v)) if (isreal(v))
@ -329,8 +328,7 @@ loop:
if (isreal(v)) if (isreal(v))
{ {
printnum(numbuf, v->v_realdata[j]); printnum(numbuf, v->v_realdata[j]);
(void) sprintf(out_pbuf, "%s\t",numbuf);
out_send(out_pbuf);
out_printf("%s\t", numbuf);
} }
else else
{ {
@ -339,15 +337,14 @@ loop:
imagpart(v->v_compdata[j]) == 0.0) imagpart(v->v_compdata[j]) == 0.0)
{ {
printnum(numbuf, realpart(v->v_compdata[j])); printnum(numbuf, realpart(v->v_compdata[j]));
(void) sprintf(out_pbuf, "%s\t",numbuf);
out_printf("%s\t", numbuf);
} }
else else
{ {
printnum(numbuf, realpart(v->v_compdata[j])); printnum(numbuf, realpart(v->v_compdata[j]));
printnum(numbuf2, imagpart(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);
} }
} }
} }

6
src/frontend/terminal.c

@ -51,10 +51,6 @@ extern int vasprintf(char **out, const char *fmt, va_list ap);
#include "variable.h" #include "variable.h"
#include "terminal.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_moremode = TRUE;
bool out_isatty = TRUE; bool out_isatty = TRUE;
@ -265,12 +261,14 @@ out_printf(char *fmt, ...)
out_send(tbuf); out_send(tbuf);
FREE(tbuf); FREE(tbuf);
#elif defined(HAVE_SNPRINTF) /* the second best */ #elif defined(HAVE_SNPRINTF) /* the second best */
static char out_pbuf[8*BSIZE_SP];
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
vsnprintf(out_pbuf, sizeof(out_pbuf), fmt, ap); vsnprintf(out_pbuf, sizeof(out_pbuf), fmt, ap);
va_end (ap); va_end (ap);
out_send(out_pbuf); out_send(out_pbuf);
#else /* guaranteed a bug for long messages */ #else /* guaranteed a bug for long messages */
static char out_pbuf[8*BSIZE_SP];
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
vsprintf(out_pbuf, fmt, ap); vsprintf(out_pbuf, fmt, ap);

4
src/frontend/variable.c

@ -919,9 +919,7 @@ cp_vprint(void)
continue; continue;
v = vars[j].x_v; v = vars[j].x_v;
if (v->va_type == CP_BOOL) { 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 { } else {
out_printf("%c %s\t", vars[j].x_char, v->va_name); out_printf("%c %s\t", vars[j].x_char, v->va_name);
wl = vareval(v->va_name); wl = vareval(v->va_name);

1
src/include/ngspice/cpextern.h

@ -116,7 +116,6 @@ extern void cp_init(void);
/* output.c */ /* output.c */
extern char out_pbuf[];
extern bool out_moremode; extern bool out_moremode;
extern bool out_isatty; extern bool out_isatty;
extern void out_init(void); extern void out_init(void);

3
src/ngsconvert.c

@ -33,9 +33,6 @@ struct circ *ft_curckt = NULL;
char *cp_program = "sconvert"; 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), \ #define tfread(ptr, siz, nit, fp) if (fread((ptr), (siz), \
(nit), (fp)) != (nit)) { \ (nit), (fp)) != (nit)) { \

Loading…
Cancel
Save