Skip to content
Browse files

Allow parsing of 'float64' in configuration files

This small patch adds support of type 'float64' in configuration file.

Rationale: precision of float32 is not always sufficient, even for what would seem to be very simple numbers.
For example: "88.005" when printed with the default precision shows "88.004997".
  • Loading branch information
nchaigne authored and alandekok committed Aug 22, 2019
1 parent f3990ab commit b7c6b98012faced15be31c49751d98c03fb7806d
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/lib/server/cf_parse.c
@@ -424,6 +424,20 @@ int cf_pair_parse_value(TALLOC_CTX *ctx, void *out, UNUSED void *base, CONF_ITEM

double num;

if (sscanf(cp->value, "%lf", &num) != 1) {
cf_log_err(cp, "Failed parsing floating point number");
rcode = -1;
goto error;
cf_log_debug(cs, "%.*s%s = %f", PAIR_SPACE(cs), parse_spaces, cf_pair_attr(cp), num);
memcpy(out, &num, sizeof(num));

* If we get here, it's a sanity check error.

0 comments on commit b7c6b98

Please sign in to comment.
You can’t perform that action at this time.