Fixed wrong way last time - NILs are valid, ints now passed as pointers like everything else so we can detect them - sorry

SVN revision: 9718
This commit is contained in:
handyande 2004-04-13 23:36:40 +00:00 committed by handyande
parent dfaa029de0
commit e909f1794a
1 changed files with 12 additions and 8 deletions

View File

@ -201,17 +201,19 @@ int ecore_config_guess_type(char *val) {
static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) { static int ecore_config_val_typed(Ecore_Config_Prop *e,void *val,int type) {
char *l; char *l;
long v; long v;
int *i;
float *f; float *f;
l=NULL; l=NULL;
v=0; v=0;
e->type=PT_NIL; e->type=PT_NIL;
if(!(val || type==PT_INT)) if(!(val))
e->ptr=NULL; e->ptr=NULL;
else { else {
if (type==PT_INT) { if (type==PT_INT) {
e->val=(int)val; i = (int *)val;
e->val=(long)*i;
e->type=PT_INT; e->type=PT_INT;
} else if (type==PT_STR) { } else if (type==PT_STR) {
if(!(e->ptr=strdup(val))) if(!(e->ptr=strdup(val)))
@ -314,11 +316,13 @@ int ecore_config_set_typed(Ecore_Config_Bundle *t,const char *key,void *val,int
int ecore_config_set(Ecore_Config_Bundle *t,const char *key,char *val) { int ecore_config_set(Ecore_Config_Bundle *t,const char *key,char *val) {
int type; int type;
int tmpi;
float tmpf; float tmpf;
type=ecore_config_guess_type(val); type=ecore_config_guess_type(val);
if (type == PT_INT) if (type == PT_INT) {
return ecore_config_set_typed(t,key,(void*) atoi(val),type); tmpi = atoi(val);
else if (type == PT_FLT) { return ecore_config_set_typed(t,key,(void*) &tmpi,type);
} else if (type == PT_FLT) {
tmpf = atof(val); tmpf = atof(val);
return ecore_config_set_typed(t,key,(void*) &tmpf,type); return ecore_config_set_typed(t,key,(void*) &tmpf,type);
} else } else
@ -328,7 +332,7 @@ int ecore_config_set_as_string(const char *key,char *val) {
return ecore_config_set(__ecore_config_bundle_local,key,val); } return ecore_config_set(__ecore_config_bundle_local,key,val); }
int ecore_config_set_int(const char *key, int val) { int ecore_config_set_int(const char *key, int val) {
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_INT); } return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)&val,PT_INT); }
int ecore_config_set_string(const char *key, char* val) { int ecore_config_set_string(const char *key, char* val) {
return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_STR); } return ecore_config_set_typed(__ecore_config_bundle_local,key,(void *)val,PT_STR); }
@ -383,7 +387,7 @@ int ecore_config_default(const char *key,char *val,float lo,float hi,float step)
} }
int ecore_config_default_int(const char *key,int val) { int ecore_config_default_int(const char *key,int val) {
return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) val, PT_INT); return ecore_config_default_typed(__ecore_config_bundle_local, key, (void *) &val, PT_INT);
} }
int ecore_config_default_int_bound(const char *key,int val,int low,int high,int step) { int ecore_config_default_int_bound(const char *key,int val,int low,int high,int step) {
@ -392,7 +396,7 @@ int ecore_config_default_int_bound(const char *key,int val,int low,int high,int
int ret; int ret;
t = __ecore_config_bundle_local; t = __ecore_config_bundle_local;
ret=ecore_config_default_typed(t, key, (void *) val, PT_INT); ret=ecore_config_default_typed(t, key, (void *) &val, PT_INT);
e=ecore_config_get(t,key); e=ecore_config_get(t,key);
if (e) { if (e) {
e->step=step; e->step=step;