Browse Source

Code cleanup.

pre-master-46
pnenzi 26 years ago
parent
commit
c68f3470e4
  1. 2
      src/frontend/arg.c
  2. 2
      src/frontend/aspice.c
  3. 2
      src/frontend/cpitf.c
  4. 6
      src/frontend/device.c
  5. 18
      src/frontend/dimens.c
  6. 4
      src/frontend/dimens.h
  7. 9
      src/frontend/display.c
  8. 3
      src/frontend/dotcards.c
  9. 8
      src/frontend/evaluate.c
  10. 4
      src/frontend/gens.c
  11. 4
      src/frontend/gens.h
  12. 4
      src/frontend/inp.c
  13. 2
      src/frontend/inpcom.c
  14. 4
      src/frontend/nutinp.c
  15. 17
      src/frontend/outitf.c
  16. 5
      src/frontend/plotting/pvec.c
  17. 9
      src/frontend/rawfile.c
  18. 7
      src/frontend/runcoms.c
  19. 2
      src/frontend/spec.c
  20. 4
      src/frontend/variable.c
  21. 6
      src/frontend/vectors.c
  22. 4
      src/include/fteext.h
  23. 1
      src/include/inpdefs.h

2
src/frontend/arg.c

@ -14,7 +14,7 @@ Author: 1987 Jeffrey M. Hsu
#include <fteext.h> #include <fteext.h>
#include "arg.h" #include "arg.h"
#include "variable.h"
static void common(char *string, struct wordlist *wl, struct comm *command); static void common(char *string, struct wordlist *wl, struct comm *command);

2
src/frontend/aspice.c

@ -179,7 +179,7 @@ sigchild(void)
void void
ft_checkkids(void) ft_checkkids(void)
{ {
struct proc *p, *lp;
struct proc *p = NULL, *lp = NULL;
char buf[BSIZE_SP]; char buf[BSIZE_SP];
FILE *fp; FILE *fp;
int pid; int pid;

2
src/frontend/cpitf.c

@ -243,7 +243,7 @@ ft_cpinit(void)
/* Decide whether a condition is TRUE or not. */ /* Decide whether a condition is TRUE or not. */
bool bool
cp_isTRUE(wordlist *wl)
cp_istrue(wordlist *wl)
{ {
int i; int i;
struct dvec *v; struct dvec *v;

6
src/frontend/device.c

@ -191,7 +191,7 @@ all_show(wordlist *wl, int mode)
else if (!params) else if (!params)
param_forall(dg, DGEN_DEFPARAMS); param_forall(dg, DGEN_DEFPARAMS);
if (params) if (params)
wl_forall(params, listparam, dg);
wl_forall(params, (void *)listparam, (void *)dg);
printf("\n"); printf("\n");
} else if (ft_sim->devices[dg->dev_type_no]->numModelParms) { } else if (ft_sim->devices[dg->dev_type_no]->numModelParms) {
@ -213,7 +213,7 @@ all_show(wordlist *wl, int mode)
else if (!params) else if (!params)
param_forall(dg, DGEN_DEFPARAMS); param_forall(dg, DGEN_DEFPARAMS);
if (params) if (params)
wl_forall(params, listparam, dg);
wl_forall(params, (void *) listparam, (void *)dg);
printf("\n"); printf("\n");
} }
} }
@ -328,7 +328,7 @@ listparam(wordlist *p, dgen *dg)
printf("%*.*s", LEFT_WIDTH, LEFT_WIDTH, p->wl_word); printf("%*.*s", LEFT_WIDTH, LEFT_WIDTH, p->wl_word);
else else
printf("%*.*s", LEFT_WIDTH, LEFT_WIDTH, " "); printf("%*.*s", LEFT_WIDTH, LEFT_WIDTH, " ");
k = dgen_for_n(dg, count, printvals, plist + i, j);
k = dgen_for_n(dg, count, printvals, (void *)(plist + i), j);
printf("\n"); printf("\n");
j += 1; j += 1;
} while (k > 0); } while (k > 0);

18
src/frontend/dimens.c

@ -15,14 +15,15 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
/* /*
* Create a string of the form "12,1,10". * Create a string of the form "12,1,10".
*/ */
char *
dimstring(int *data, int length)
void
dimstring(int *data, int length, char *retstring)
{ {
int i; int i;
char buf[BSIZE_SP]; char buf[BSIZE_SP];
if (!data || length < 1) if (!data || length < 1)
return NULL;
retstring = "";
buf[0] = '\0'; buf[0] = '\0';
for (i=0; i < length; i++) { for (i=0; i < length; i++) {
@ -30,26 +31,27 @@ dimstring(int *data, int length)
(i < length - 1) ? "," : ""); (i < length - 1) ? "," : "");
} }
/* XXX Should I return a copy instead? */ /* XXX Should I return a copy instead? */
return(buf);
/* qui ci devo fare una copia */
strcpy(retstring, buf);
} }
/* /*
* Create a string of the form "[12][1][10]". * Create a string of the form "[12][1][10]".
*/ */
char *
indexstring(int *data, int length)
void
indexstring(int *data, int length, char *retstring)
{ {
int i; int i;
char buf[BSIZE_SP]; char buf[BSIZE_SP];
if (!data || length < 1) if (!data || length < 1)
return NULL;
retstring = "";
buf[0] = '\0'; buf[0] = '\0';
for (i=0; i < length; i++) { for (i=0; i < length; i++) {
sprintf(buf + strlen(buf), "[%d]", data[i]); sprintf(buf + strlen(buf), "[%d]", data[i]);
} }
return(buf);
strcpy(retstring, buf);
} }
/* /*

4
src/frontend/dimens.h

@ -6,8 +6,8 @@
#ifndef DIMENS_H_INCLUDED #ifndef DIMENS_H_INCLUDED
#define DIMENS_H_INCLUDED #define DIMENS_H_INCLUDED
char * dimstring(int *data, int length);
char * indexstring(int *data, int length);
void dimstring(int *data, int length, char *retstring);
void indexstring(int *data, int length, char *retstring);
int incindex(int *counts, int numcounts, int *dims, int numdims); int incindex(int *counts, int numcounts, int *dims, int numdims);
int emptydims(int *data, int length); int emptydims(int *data, int length);
int atodims(char *p, int *data, int *outlength); int atodims(char *p, int *data, int *outlength);

9
src/frontend/display.c

@ -15,7 +15,7 @@ Copyright 1990 Regents of the University of California. All rights reserved.
/* static declarations */ /* static declarations */
static void gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny); static void gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny);
static void gen_Input(REQUEST *request, RESPONSE *response);
static int gen_Input(REQUEST *request, RESPONSE *response);
static int nop(void); static int nop(void);
static int nodev(void); static int nodev(void);
@ -51,7 +51,7 @@ DISPDEVICE device[] = {
nop, nop, nop, nop, nop, nop, nop, nop, nop, nop,
nop, nop, nop, nop, nop, nop,
nop, nop, nop, gen_Input, nop, nop, nop, gen_Input,
nop,},
(void *)nop,},
#ifndef X_DISPLAY_MISSING #ifndef X_DISPLAY_MISSING
{"X11", 0, 0, 1024, 864, 0, 0, X11_Init, X11_NewViewport, {"X11", 0, 0, 1024, 864, 0, 0, X11_Init, X11_NewViewport,
@ -82,7 +82,7 @@ DISPDEVICE device[] = {
nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev,
nodev, nodev, nodev, nodev, nodev, nodev,
nodev, nodev, nodev, gen_Input, nodev, nodev, nodev, gen_Input,
nodev,},
(void *)nodev,},
}; };
@ -282,7 +282,7 @@ void Input(REQUEST *request, RESPONSE *response)
} }
static void
static int
gen_Input(REQUEST *request, RESPONSE *response) gen_Input(REQUEST *request, RESPONSE *response)
{ {
@ -297,6 +297,7 @@ gen_Input(REQUEST *request, RESPONSE *response)
response->option = error_option; response->option = error_option;
break; break;
} }
return 0;
} }
/* no operation, do nothing */ /* no operation, do nothing */

3
src/frontend/dotcards.c

@ -434,7 +434,8 @@ fixdotprint(wordlist *wl)
static char * static char *
fixem(char *string) fixem(char *string)
{ {
char buf[BSIZE_SP], *s, *t, *ss = string;
char buf[BSIZE_SP], *s, *t;
char *ss = string; /* Get rid of ss ? */
if (ciprefix("v(", string) &&strchr(string, ',')) { if (ciprefix("v(", string) &&strchr(string, ',')) {
for (s = string; *s && (*s != ','); s++) for (s = string; *s && (*s != ','); s++)

8
src/frontend/evaluate.c

@ -43,7 +43,7 @@ sig_matherr(void)
struct dvec * struct dvec *
ft_evaluate(struct pnode *node) ft_evaluate(struct pnode *node)
{ {
struct dvec *d;
struct dvec *d = NULL;
if (!node) if (!node)
return (NULL); return (NULL);
@ -91,9 +91,9 @@ doop(char what,
struct pnode *arg2) struct pnode *arg2)
{ {
struct dvec *v1, *v2, *res; struct dvec *v1, *v2, *res;
complex *c1, *c2, lc;
double *d1, *d2, ld;
int length, i;
complex *c1 = NULL, *c2 = NULL , lc;
double *d1 = NULL, *d2 = NULL, ld;
int length = 0, i;
void *data; void *data;
bool free1 = FALSE, free2 = FALSE, relflag = FALSE; bool free1 = FALSE, free2 = FALSE, relflag = FALSE;

4
src/frontend/gens.c

@ -16,7 +16,7 @@ static void dgen_next(dgen **dgx);
void void
wl_forall(wordlist *wl, int (*fn) (/* ??? */), char *data)
wl_forall(wordlist *wl, void (*fn) (/* ??? */), void *data)
{ {
while (wl) { while (wl) {
(*fn)(wl, data); (*fn)(wl, data);
@ -56,7 +56,7 @@ dgen_init(GENcircuit *ckt, wordlist *wl, int nomix, int flag, int model)
} }
int int
dgen_for_n(dgen *dg, int n, int (*fn) (/* ??? */), char *data, int subindex)
dgen_for_n(dgen *dg, int n, int (*fn) (/* ??? */), void *data, int subindex)
{ {
dgen dgx, *dgxp; dgen dgx, *dgxp;
int dnum, i, j, k; int dnum, i, j, k;

4
src/frontend/gens.h

@ -6,9 +6,9 @@
#ifndef GENS_H_INCLUDED #ifndef GENS_H_INCLUDED
#define GENS_H_INCLUDED #define GENS_H_INCLUDED
void wl_forall(wordlist *wl, int (*fn) (/* ??? */), char *data);
void wl_forall(wordlist *wl, void (*fn) (/* ??? */), void *data);
dgen * dgen_init(GENcircuit *ckt, wordlist *wl, int nomix, int flag, int model); dgen * dgen_init(GENcircuit *ckt, wordlist *wl, int nomix, int flag, int model);
int dgen_for_n(dgen *dg, int n, int (*fn) (/* ??? */), char *data, int subindex);
int dgen_for_n(dgen *dg, int n, int (*fn) (/* ??? */), void *data, int subindex);
void dgen_nth_next(dgen **dg, int n); void dgen_nth_next(dgen **dg, int n);

4
src/frontend/inp.c

@ -252,8 +252,8 @@ void
inp_spsource(FILE *fp, bool comfile, char *filename) inp_spsource(FILE *fp, bool comfile, char *filename)
{ {
struct line *deck, *dd, *ld; struct line *deck, *dd, *ld;
struct line *realdeck, *options;
char *tt, name[BSIZE_SP], *s, *t;
struct line *realdeck, *options = NULL;
char *tt = NULL, name[BSIZE_SP], *s, *t;
bool nosubckts, commands = FALSE; bool nosubckts, commands = FALSE;
wordlist *wl = NULL, *end = NULL, *wl_first = NULL; wordlist *wl = NULL, *end = NULL, *wl_first = NULL;
wordlist *controls = NULL; wordlist *controls = NULL;

2
src/frontend/inpcom.c

@ -111,7 +111,7 @@ inp_pathopen(char *name, char *mode)
void void
inp_readall(FILE *fp, struct line **data) inp_readall(FILE *fp, struct line **data)
{ {
struct line *end = NULL, *cc, *prev = NULL, *working, *newcard;
struct line *end = NULL, *cc = NULL, *prev = NULL, *working, *newcard;
char *buffer, *s, *t, c,*copys; char *buffer, *s, *t, c,*copys;
int line = 1; int line = 1;
FILE *newfp; FILE *newfp;

4
src/frontend/nutinp.c

@ -29,8 +29,8 @@ void
inp_nutsource(FILE *fp, bool comfile, char *filename) inp_nutsource(FILE *fp, bool comfile, char *filename)
{ {
struct line *deck, *dd, *ld; struct line *deck, *dd, *ld;
struct line *realdeck, *options;
char *tt, name[BSIZE_SP], *s, *t;
struct line *realdeck, *options = NULL;
char *tt = NULL, name[BSIZE_SP], *s, *t;
bool nosubckts, commands = FALSE; bool nosubckts, commands = FALSE;
wordlist *wl = NULL, *end = NULL; wordlist *wl = NULL, *end = NULL;
wordlist *controls = NULL; wordlist *controls = NULL;

17
src/frontend/outitf.c

@ -27,7 +27,7 @@ Modified: 2000 AlansFixes
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
#include "cktdefs.h" #include "cktdefs.h"
#include <inpdefs.h>
extern void gr_end_iplot(void); extern void gr_end_iplot(void);
extern char *spice_analysis_get_name(int index); extern char *spice_analysis_get_name(int index);
@ -114,9 +114,9 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
{ {
runDesc *run; runDesc *run;
struct save_info *saves; struct save_info *saves;
bool *savesused;
bool *savesused = NULL;
int numsaves; int numsaves;
int i, j, depind;
int i, j, depind = 0;
char namebuf[BSIZE_SP], parambuf[BSIZE_SP], depbuf[BSIZE_SP]; char namebuf[BSIZE_SP], parambuf[BSIZE_SP], depbuf[BSIZE_SP];
char *ch, tmpname[BSIZE_SP]; char *ch, tmpname[BSIZE_SP];
bool saveall = TRUE; bool saveall = TRUE;
@ -149,9 +149,9 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
savesused = (bool *) tmalloc(sizeof (bool) * numsaves); savesused = (bool *) tmalloc(sizeof (bool) * numsaves);
saveall = FALSE; saveall = FALSE;
for (i = 0; i < numsaves; i++) { for (i = 0; i < numsaves; i++) {
if (saves[i].analysis && !cieq(saves[i].analysis, an_name)) {
if (saves[i].analysis && !cieq((char *)saves[i].analysis, an_name)) {
/* ignore this one this time around */ /* ignore this one this time around */
savesused[i] = TRUE;
savesused[i] = TRUE;
continue; continue;
} }
@ -323,8 +323,11 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
tfree(savesused); tfree(savesused);
} }
if (numNames && (run->numData == 1 && run->refIndex != -1
|| run->numData == 0 && run->refIndex == -1))
if (numNames &&
(run->numData == 1
&& run->refIndex != -1
|| run->numData == 0
&& run->refIndex == -1))
{ {
fprintf(cp_err, "Error: no data saved for %s; analysis not run\n", fprintf(cp_err, "Error: no data saved for %s; analysis not run\n",
spice_analysis_get_description(((JOB *) analysisPtr)->JOBtype)); spice_analysis_get_description(((JOB *) analysisPtr)->JOBtype));

5
src/frontend/plotting/pvec.c

@ -8,7 +8,7 @@
void void
pvec(struct dvec *d) pvec(struct dvec *d)
{ {
char buf[BSIZE_SP], buf2[BSIZE_SP];
char buf[BSIZE_SP], buf2[BSIZE_SP], buf3[BSIZE_SP];
sprintf(buf, " %-20s: %s, %s, %d long", sprintf(buf, " %-20s: %s, %s, %d long",
d->v_name, d->v_name,
@ -72,7 +72,8 @@ pvec(struct dvec *d)
strcat(buf, buf2); strcat(buf, buf2);
} }
if (d->v_numdims > 1) { if (d->v_numdims > 1) {
sprintf(buf2, ", dims = [%s]", dimstring(d->v_dims, d->v_numdims));
dimstring(d->v_dims, d->v_numdims, buf3);
sprintf(buf2, ", dims = [%s]", buf3);
strcat(buf, buf2); strcat(buf, buf2);
} }
if (d->v_plot->pl_scale == d) { if (d->v_plot->pl_scale == d) {

9
src/frontend/rawfile.c

@ -38,6 +38,7 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
wordlist *wl; wordlist *wl;
struct variable *vv; struct variable *vv;
double dd; double dd;
char *buf[BSIZE_SP];
if (!cp_getvar("nopadding", VT_BOOL, (char *) &raw_padding)) if (!cp_getvar("nopadding", VT_BOOL, (char *) &raw_padding))
raw_padding = FALSE; raw_padding = FALSE;
@ -91,7 +92,8 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
fprintf(fp, "No. Variables: %d\n", nvars); fprintf(fp, "No. Variables: %d\n", nvars);
fprintf(fp, "No. Points: %d\n", length); fprintf(fp, "No. Points: %d\n", length);
if (numdims > 1) { if (numdims > 1) {
fprintf(fp, "Dimensions: %s\n", dimstring(dims, numdims));
dimstring(dims, numdims, buf);
fprintf(fp, "Dimensions: %s\n", *buf);
} }
for (wl = pl->pl_commands; wl; wl = wl->wl_next) for (wl = pl->pl_commands; wl; wl = wl->wl_next)
@ -147,7 +149,8 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
writedims = TRUE; writedims = TRUE;
} }
if (writedims) { if (writedims) {
fprintf(fp, " dims=%s", dimstring(v->v_dims, v->v_numdims));
dimstring(v->v_dims, v->v_numdims, buf);
fprintf(fp, " dims=%s",*buf);
} }
(void) putc('\n', fp); (void) putc('\n', fp);
} }
@ -242,7 +245,7 @@ raw_read(char *name)
char *date = 0; char *date = 0;
struct plot *plots = NULL, *curpl = NULL; struct plot *plots = NULL, *curpl = NULL;
char buf[BSIZE_SP], buf2[BSIZE_SP], *s, *t, *r; char buf[BSIZE_SP], buf2[BSIZE_SP], *s, *t, *r;
int flags, nvars, npoints, i, j;
int flags = 0, nvars = 0, npoints = 0, i, j;
int ndimpoints, numdims=0, dims[MAXDIMS]; int ndimpoints, numdims=0, dims[MAXDIMS];
bool raw_padded = TRUE; bool raw_padded = TRUE;
double junk; double junk;

7
src/frontend/runcoms.c

@ -151,7 +151,7 @@ com_noise(wordlist *wl)
static int static int
dosim(char *what, wordlist *wl) dosim(char *what, wordlist *wl)
{ {
wordlist *ww;
wordlist *ww = NULL;
bool dofile = FALSE; bool dofile = FALSE;
char buf[BSIZE_SP]; char buf[BSIZE_SP];
struct circ *ct; struct circ *ct;
@ -252,13 +252,14 @@ dosim(char *what, wordlist *wl)
} else } else
ft_curckt->ci_inprogress = FALSE; ft_curckt->ci_inprogress = FALSE;
} }
if (rawfileFp)
if (rawfileFp){
if (ftell(rawfileFp)==0) { if (ftell(rawfileFp)==0) {
(void) fclose(rawfileFp); (void) fclose(rawfileFp);
(void) remove(wl->wl_word); (void) remove(wl->wl_word);
} else { } else {
(void) fclose(rawfileFp); (void) fclose(rawfileFp);
};
}
}
ft_curckt->ci_runonce = TRUE; ft_curckt->ci_runonce = TRUE;
ft_setflag = FALSE; ft_setflag = FALSE;
return err; return err;

2
src/frontend/spec.c

@ -25,7 +25,7 @@ com_spec(wordlist *wl)
int fpts, i, j, k, tlen, ngood; int fpts, i, j, k, tlen, ngood;
bool trace; bool trace;
char *s; char *s;
struct dvec *f, *vlist, *lv, *vec;
struct dvec *f, *vlist, *lv = NULL, *vec;
struct pnode *names, *first_name; struct pnode *names, *first_name;
if (!plot_cur || !plot_cur->pl_scale) { if (!plot_cur || !plot_cur->pl_scale) {

4
src/frontend/variable.c

@ -341,7 +341,7 @@ cp_setparse(wordlist *wl)
continue; continue;
} }
ss = cp_unquote(val);
copyval = ss = cp_unquote(val);
td = ft_numparse(&ss, FALSE); td = ft_numparse(&ss, FALSE);
vv = alloc(struct variable); vv = alloc(struct variable);
vv->va_name = copy(name); vv->va_name = copy(name);
@ -355,7 +355,7 @@ cp_setparse(wordlist *wl)
vv->va_type = VT_STRING; vv->va_type = VT_STRING;
vv->va_string = copy(val); vv->va_string = copy(val);
} }
tfree(ss);/*DG: avoid cp_unquote memory leak */
tfree(copyval);/*DG: must free ss any way to avoid cp_unquote memory leak */
} }
return (vars); return (vars);
} }

6
src/frontend/vectors.c

@ -807,7 +807,7 @@ vec_mkfamily(struct dvec *v)
int size, numvecs, i, j, count[MAXDIMS]; int size, numvecs, i, j, count[MAXDIMS];
int totalsize; int totalsize;
struct dvec *vecs, *d; struct dvec *vecs, *d;
char buf[BSIZE_SP];
char buf[BSIZE_SP], buf2[BSIZE_SP];
if (v->v_numdims < 2) if (v->v_numdims < 2)
return (v); return (v);
@ -827,8 +827,8 @@ vec_mkfamily(struct dvec *v)
for (i = 0; i < MAXDIMS; i++) for (i = 0; i < MAXDIMS; i++)
count[i] = 0; count[i] = 0;
for (d = vecs, j = 0; d; j++, d = d->v_link2) { for (d = vecs, j = 0; d; j++, d = d->v_link2) {
(void) sprintf(buf, "%s%s", v->v_name,
indexstring(count, v->v_numdims - 1));
indexstring(count, v->v_numdims - 1, buf2);
(void) sprintf(buf, "%s%s", v->v_name, buf2);
d->v_name = copy(buf); d->v_name = copy(buf);
d->v_type = v->v_type; d->v_type = v->v_type;
d->v_flags = v->v_flags; d->v_flags = v->v_flags;

4
src/include/fteext.h

@ -528,9 +528,9 @@ extern void com_clearplot();
extern void com_reshape(); extern void com_reshape();
/* dimens.c */ /* dimens.c */
extern char *dimstring();
extern void dimstring();
extern int atodims(); extern int atodims();
extern char *indexstring();
extern void indexstring();
extern int incindex( ); extern int incindex( );
#endif /* FTEext_h */ #endif /* FTEext_h */

1
src/include/inpdefs.h

@ -96,6 +96,7 @@ int INPgetTok(char**,char**,int);
void INPgetTree(char**,INPparseTree**,void*,INPtables*); void INPgetTree(char**,INPparseTree**,void*,INPtables*);
IFvalue * INPgetValue(void*,char**,int,INPtables*); IFvalue * INPgetValue(void*,char**,int,INPtables*);
int INPgndInsert(void*,char**,INPtables*,void**); int INPgndInsert(void*,char**,INPtables*,void**);
int INPinsertNofree(char **token, INPtables *tab);
int INPinsert(char**,INPtables*); int INPinsert(char**,INPtables*);
int INPretrieve(char**,INPtables*); int INPretrieve(char**,INPtables*);
int INPremove(char*,INPtables*); int INPremove(char*,INPtables*);

Loading…
Cancel
Save