Skip to content

Commit

Permalink
Allow to specify floats as "1.0" and "1"
Browse files Browse the repository at this point in the history
  • Loading branch information
cfnptr committed Jun 9, 2024
1 parent d9dfff2 commit cec562b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions source/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,20 @@ bool getConfReaderFloat(ConfReader confReader, const char* key, double* value)
ConfItem* foundItem = bsearch(&item, confReader->items,
confReader->itemCount, sizeof(struct ConfItem), compareConfItems);

if (!foundItem || foundItem->type != FLOATING_CONF_DATA_TYPE)
if (!foundItem)
return false;

*value = foundItem->value.floating;
return true;
if (foundItem->type == FLOATING_CONF_DATA_TYPE)
{
*value = foundItem->value.floating;
return true;
}
else if (foundItem->type == INTEGER_CONF_DATA_TYPE)
{
*value = foundItem->value.integer;
return true;
}
return false;
}

bool getConfReaderBool(ConfReader confReader, const char* key, bool* value)
Expand Down

0 comments on commit cec562b

Please sign in to comment.