rrd_set_error("Invalid row count %s: %s", token, parsetime_error);
break;
default:
- rra_def->par[RRA_cdp_xff_val].u_val = atof(token);
- if (rra_def->par[RRA_cdp_xff_val].u_val < 0.0
- || rra_def->par[RRA_cdp_xff_val].u_val >= 1.0)
- rrd_set_error
+ double xff;
+ if (rrd_strtodbl(token, NULL, &xff, NULL) != 2
+ || xff < 0.0 || xff >= 1.0 ){
+ rrd_set_error
("Invalid xff: must be between 0 and 1");
+ }
+ rra_def->par[RRA_cdp_xff_val].u_val = xff;
break;
}
break;
(rra_def->cf_nam)) {
case CF_HWPREDICT:
case CF_MHWPREDICT:
- rra_def->par[RRA_hw_alpha].
- u_val = atof(token);
- if (atof(token) <= 0.0 || atof(token) >= 1.0)
+ double hw_alpha;
+ if (rrd_strtodbl(token, NULL, &hw_alpha, NULL) != 2
+ || hw_alpha <= 0.0 || hw_alpha >= 1.0){
rrd_set_error
("Invalid alpha: must be between 0 and 1");
+ }
+ rra_def->par[RRA_hw_alpha].u_val = hw_alpha;
break;
case CF_DEVSEASONAL:
case CF_SEASONAL:
- rra_def->par[RRA_seasonal_gamma].u_val = atof(token);
- if (atof(token) <= 0.0 || atof(token) >= 1.0)
+ double gamma;
+ if (rrd_strtodbl(token, NULL, &gamma, NULL) != 2
+ || gamma <= 0.0 || gamma >= 1.0){
rrd_set_error
("Invalid gamma: must be between 0 and 1");
+ }
+ rra_def->par[RRA_seasonal_gamma].u_val = gamma;
rra_def->par[RRA_seasonal_smooth_idx].u_cnt =
hash % rra_def->row_cnt;
break;
switch (cf_conv(rra_def->cf_nam)) {
case CF_HWPREDICT:
case CF_MHWPREDICT:
- rra_def->par[RRA_hw_beta].u_val = atof(token);
- if (atof(token) < 0.0 || atof(token) > 1.0)
+ double beta;
+ if (rrd_strtodbl(token, NULL, &beta, NULL) != 2
+ || beta < 0.0 || beta > 1.0){
rrd_set_error
("Invalid beta: must be between 0 and 1");
+ }
+ rra_def->par[RRA_hw_beta].u_val = beta;
break;
case CF_DEVSEASONAL:
case CF_SEASONAL:
#include <ctype.h>
#include "rrd_tool.h"
+#include "rrd_strtodbl.h"
double rrd_diff(
char *a,
c = 0;
}
}
- result = -atof(res);
- } else
- result = atof(res);
-
+ if (rrd_strtodbl(res, NULL, &result, 'expected a number') != 2){
+ result = DNAN;
+ }
+ else {
+ result = -result;
+ }
+ } else {
+ if (rrd_strtodbl(res, NULL, &result, 'expected a number') != 2){
+ result = DNAN;
+ }
+ }
if (a_neg + b_neg == 2) /* both are negatives, reverse sign */
result = -result;