use a void * for the third argument (&value) of the cp_vset() function

This commit is contained in:
rlar 2010-07-20 19:19:51 +00:00
parent 3942bc2ade
commit 73cf2a8ea5
12 changed files with 40 additions and 27 deletions

View File

@ -1,3 +1,18 @@
2010-07-20 Robert Larice
* src/frontend/com_option.c ,
* src/frontend/com_set.c ,
* src/frontend/com_strcmp.c ,
* src/frontend/cpitf.c ,
* src/frontend/dotcards.c ,
* src/frontend/init.c ,
* src/frontend/inp.c ,
* src/frontend/variable.c ,
* src/frontend/variable.h ,
* src/frontend/wdisp/windisp.c ,
* src/include/cpextern.h :
use a void * for the third argument (&value) of the cp_vset() function
(polymorphic, has been claimed to be char *)
2010-07-20 Robert Larice
* src/tclspice.c :
drop #include <frontend/variable.h>, (even for non MSC_VER)

View File

@ -16,7 +16,6 @@ com_option(wordlist *wl)
{
struct variable *vars;
char *s;
CKTcircuit *circuit = NULL;
@ -88,24 +87,25 @@ struct variable *vars;
/* This is sort of a hassle... */
while (vars) {
void *s;
switch (vars->va_type) {
case CP_BOOL:
s = (char *) &vars->va_bool;
s = &vars->va_bool;
break;
case CP_NUM:
s = (char *) &vars->va_num;
s = &vars->va_num;
break;
case CP_REAL:
s = (char *) &vars->va_real;
s = &vars->va_real;
break;
case CP_STRING:
s = vars->va_string;
break;
case CP_LIST:
s = (char *) vars->va_vlist;
s = vars->va_vlist;
break;
default:
s = (char *) NULL;
s = NULL;
}
/* qui deve settare le opzioni di simulazione */

View File

@ -14,7 +14,6 @@ void
com_set(wordlist *wl)
{
struct variable *vars, *oldvar;
char *s;
if (wl == NULL) {
cp_vprint();
@ -24,24 +23,25 @@ com_set(wordlist *wl)
/* This is sort of a hassle... */
while (vars) {
void *s;
switch (vars->va_type) {
case CP_BOOL:
s = (char *) &vars->va_bool;
s = &vars->va_bool;
break;
case CP_NUM:
s = (char *) &vars->va_num;
s = &vars->va_num;
break;
case CP_REAL:
s = (char *) &vars->va_real;
s = &vars->va_real;
break;
case CP_STRING:
s = vars->va_string;
break;
case CP_LIST:
s = (char *) vars->va_vlist;
s = vars->va_vlist;
break;
default:
s = (char *) NULL;
s = NULL;
}
cp_vset(vars->va_name, vars->va_type, s);
oldvar = vars;

View File

@ -23,6 +23,6 @@ com_strcmp(wordlist *wl)
i = strcmp(s1, s2);
tfree(s1);/*DG cp_unquote memory leak*/
tfree(s2);
cp_vset(var, CP_NUM, (char *) &i);
cp_vset(var, CP_NUM, &i);
return;
}

View File

@ -167,8 +167,8 @@ ft_cpinit(void)
(void) sprintf(buf, "%s ! -> ", cp_program);
cp_vset("prompt", CP_STRING, buf);
cp_vset("noglob", CP_BOOL, (char *) &t);
cp_vset("brief", CP_BOOL, (char *) &t);
cp_vset("noglob", CP_BOOL, &t);
cp_vset("brief", CP_BOOL, &t);
/* Make vectors from values in predefs[] for the current plot.
Define functions from entries in udfs[] (like user defined functions).

View File

@ -284,7 +284,7 @@ ft_cktcoms(bool terse)
continue;
}
i = atoi(++s);
cp_vset("width", CP_NUM, (char *) &i);
cp_vset("width", CP_NUM, &i);
}
} else if (eq(command->wl_word, ".print")) {
if (terse) {

View File

@ -32,7 +32,7 @@ cp_init(void)
/* break word to right or left of characters <>;&*/
cp_chars[(int) *s] = (CPC_BRR | CPC_BRL);
cp_vset("history", CP_NUM, (char *) &cp_maxhistlength);
cp_vset("history", CP_NUM, &cp_maxhistlength);
cp_curin = stdin;
cp_curout = stdout;

View File

@ -510,8 +510,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
in numparam evaluation */
if ( temperature != NULL ) {
temperature_value = atof(temperature);
s = (char *) &temperature_value;
cp_vset("pretemp", CP_REAL, s );
cp_vset("pretemp", CP_REAL, &temperature_value );
}
if (ft_ngdebug) {
cp_getvar( "pretemp", CP_REAL, (double *) &testemp );
@ -623,8 +622,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
/* set temperature if defined */
if ( temperature != NULL ) {
temperature_value = atof(temperature);
s = (char *) &temperature_value;
cp_vset("temp", CP_REAL, s );
cp_vset("temp", CP_REAL, &temperature_value );
txfree(temperature);
}
@ -754,7 +752,7 @@ inp_dodeck(
break;
case CP_REAL:
if ( strcmp("scale",eev->va_name)==0 ){
cp_vset("scale", CP_REAL, (char*) &eev->va_real );
cp_vset("scale", CP_REAL, &eev->va_real );
printf("Scale set\n");
}
break;

View File

@ -85,7 +85,7 @@ cp_varwl(struct variable *var)
/* Set a variable. */
void
cp_vset(char *varname, enum cp_types type, char *value)
cp_vset(char *varname, enum cp_types type, void *value)
{
struct variable *v, *u, *w;
int i;
@ -133,7 +133,7 @@ cp_vset(char *varname, enum cp_types type, char *value)
break;
case CP_STRING:
v->va_string = copy(value);
v->va_string = copy((char*) value);
break;
case CP_LIST:

View File

@ -45,7 +45,7 @@ extern bool cp_echo;
/* extern struct variable *variables; */
wordlist * cp_varwl(struct variable *var);
void cp_vset(char *varname, enum cp_types type, char *value);
void cp_vset(char *varname, enum cp_types type, void *value);
struct variable * cp_setparse(wordlist *wl);
void cp_remvar(char *varname);
bool cp_getvar(char *name, enum cp_types type, void *retval);

View File

@ -232,7 +232,7 @@ static int LType( int ColorIndex)
LRESULT HcpyPlot( HWND hwnd)
{
int colorval = isblack? 0 : 1;
cp_vset("hcopypscolor", CP_NUM, (char*)(&colorval));
cp_vset("hcopypscolor", CP_NUM, &colorval);
com_hardcopy(NULL);
return 0;
}

View File

@ -174,7 +174,7 @@ extern bool cp_noglob;
extern bool cp_nonomatch;
extern char cp_dol;
extern void cp_remvar(char *varname);
extern void cp_vset(char *varname, enum cp_types type, char *value);
extern void cp_vset(char *varname, enum cp_types type, void *value);
extern struct variable *cp_setparse(wordlist *wl);
extern wordlist *vareval(char *string);