Code cleanup.

This commit is contained in:
pnenzi 2001-02-09 19:46:36 +00:00
parent 6f55975cc0
commit c68f3470e4
23 changed files with 70 additions and 57 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -15,14 +15,15 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group
/*
* 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;
char buf[BSIZE_SP];
if (!data || length < 1)
return NULL;
retstring = "";
buf[0] = '\0';
for (i=0; i < length; i++) {
@ -30,26 +31,27 @@ dimstring(int *data, int length)
(i < length - 1) ? "," : "");
}
/* 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]".
*/
char *
indexstring(int *data, int length)
void
indexstring(int *data, int length, char *retstring)
{
int i;
char buf[BSIZE_SP];
if (!data || length < 1)
return NULL;
retstring = "";
buf[0] = '\0';
for (i=0; i < length; i++) {
sprintf(buf + strlen(buf), "[%d]", data[i]);
}
return(buf);
strcpy(retstring, buf);
}
/*

View File

@ -6,8 +6,8 @@
#ifndef 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 emptydims(int *data, int length);
int atodims(char *p, int *data, int *outlength);

View File

@ -15,7 +15,7 @@ Copyright 1990 Regents of the University of California. All rights reserved.
/* static declarations */
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 nodev(void);
@ -51,7 +51,7 @@ DISPDEVICE device[] = {
nop, nop, nop, nop, nop,
nop, nop, nop,
nop, nop, nop, gen_Input,
nop,},
(void *)nop,},
#ifndef X_DISPLAY_MISSING
{"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, 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)
{
@ -297,6 +297,7 @@ gen_Input(REQUEST *request, RESPONSE *response)
response->option = error_option;
break;
}
return 0;
}
/* no operation, do nothing */

View File

@ -434,7 +434,8 @@ fixdotprint(wordlist *wl)
static char *
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, ',')) {
for (s = string; *s && (*s != ','); s++)

View File

@ -43,7 +43,7 @@ sig_matherr(void)
struct dvec *
ft_evaluate(struct pnode *node)
{
struct dvec *d;
struct dvec *d = NULL;
if (!node)
return (NULL);
@ -91,9 +91,9 @@ doop(char what,
struct pnode *arg2)
{
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;
bool free1 = FALSE, free2 = FALSE, relflag = FALSE;

View File

@ -16,7 +16,7 @@ static void dgen_next(dgen **dgx);
void
wl_forall(wordlist *wl, int (*fn) (/* ??? */), char *data)
wl_forall(wordlist *wl, void (*fn) (/* ??? */), void *data)
{
while (wl) {
(*fn)(wl, data);
@ -56,7 +56,7 @@ 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)
dgen_for_n(dgen *dg, int n, int (*fn) (/* ??? */), void *data, int subindex)
{
dgen dgx, *dgxp;
int dnum, i, j, k;

View File

@ -6,9 +6,9 @@
#ifndef 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);
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);

View File

@ -252,8 +252,8 @@ void
inp_spsource(FILE *fp, bool comfile, char *filename)
{
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;
wordlist *wl = NULL, *end = NULL, *wl_first = NULL;
wordlist *controls = NULL;

View File

@ -111,7 +111,7 @@ inp_pathopen(char *name, char *mode)
void
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;
int line = 1;
FILE *newfp;

View File

@ -29,8 +29,8 @@ void
inp_nutsource(FILE *fp, bool comfile, char *filename)
{
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;
wordlist *wl = NULL, *end = NULL;
wordlist *controls = NULL;

View File

@ -27,7 +27,7 @@ Modified: 2000 AlansFixes
#include <fcntl.h>
#include <time.h>
#include "cktdefs.h"
#include <inpdefs.h>
extern void gr_end_iplot(void);
extern char *spice_analysis_get_name(int index);
@ -114,9 +114,9 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
{
runDesc *run;
struct save_info *saves;
bool *savesused;
bool *savesused = NULL;
int numsaves;
int i, j, depind;
int i, j, depind = 0;
char namebuf[BSIZE_SP], parambuf[BSIZE_SP], depbuf[BSIZE_SP];
char *ch, tmpname[BSIZE_SP];
bool saveall = TRUE;
@ -149,9 +149,9 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
savesused = (bool *) tmalloc(sizeof (bool) * numsaves);
saveall = FALSE;
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 */
savesused[i] = TRUE;
savesused[i] = TRUE;
continue;
}
@ -323,8 +323,11 @@ beginPlot(void *analysisPtr, void *circuitPtr, char *cktName, char *analName, ch
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",
spice_analysis_get_description(((JOB *) analysisPtr)->JOBtype));

View File

@ -8,7 +8,7 @@
void
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",
d->v_name,
@ -72,7 +72,8 @@ pvec(struct dvec *d)
strcat(buf, buf2);
}
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);
}
if (d->v_plot->pl_scale == d) {

View File

@ -38,6 +38,7 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
wordlist *wl;
struct variable *vv;
double dd;
char *buf[BSIZE_SP];
if (!cp_getvar("nopadding", VT_BOOL, (char *) &raw_padding))
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. Points: %d\n", length);
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)
@ -147,7 +149,8 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
writedims = TRUE;
}
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);
}
@ -242,7 +245,7 @@ raw_read(char *name)
char *date = 0;
struct plot *plots = NULL, *curpl = NULL;
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];
bool raw_padded = TRUE;
double junk;

View File

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

View File

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

View File

@ -341,7 +341,7 @@ cp_setparse(wordlist *wl)
continue;
}
ss = cp_unquote(val);
copyval = ss = cp_unquote(val);
td = ft_numparse(&ss, FALSE);
vv = alloc(struct variable);
vv->va_name = copy(name);
@ -355,7 +355,7 @@ cp_setparse(wordlist *wl)
vv->va_type = VT_STRING;
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);
}

View File

@ -807,7 +807,7 @@ vec_mkfamily(struct dvec *v)
int size, numvecs, i, j, count[MAXDIMS];
int totalsize;
struct dvec *vecs, *d;
char buf[BSIZE_SP];
char buf[BSIZE_SP], buf2[BSIZE_SP];
if (v->v_numdims < 2)
return (v);
@ -827,8 +827,8 @@ vec_mkfamily(struct dvec *v)
for (i = 0; i < MAXDIMS; i++)
count[i] = 0;
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_type = v->v_type;
d->v_flags = v->v_flags;

View File

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

View File

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