MIFget_boolean(), allow numeric values 0 and 1 too

This commit is contained in:
Calin Andrian 2013-12-05 19:12:02 +01:00 committed by rlar
parent 7a9abebfe7
commit c38f7236b1
1 changed files with 8 additions and 3 deletions

View File

@ -234,13 +234,18 @@ MIFgetValue (
static int MIFget_boolean(char *token, char **err)
{
int i;
*err = NULL;
if((strcmp(token, "t") == 0) || (strcmp(token, "true") == 0))
return(1);
else if((strcmp(token, "f") == 0) || (strcmp(token, "false") == 0))
if((strcmp(token, "f") == 0) || (strcmp(token, "false") == 0))
return(0);
else
i = MIFget_integer(token, err); // Try integer
if(!*err && (i == 1 || i == 0))
return i;
*err = "Bad boolean value";
return(-1);