procps/include/strutils.h
Craig Small 32e1b2e297 A locale-independent strtod
There is a need in some utilities to have a way of accepting both
types of decimal points "." and ",". The only way seems to be to
rebuild strtod().

This new function will accept "123.456" and "123,456" as 123.456
and considers them the same number. It means we lose thousands
separator, but this is rarely used.

test scripts are added to check the function returns the proper
values. There was simpler predecessor that got stuck on negative
0 or -0.123 which these tests flushed out.

References:
2016-03-03 21:24:08 +11:00

13 lines
317 B
C

/*
* This header was copied from util-linux at fall 2011.
*/
#ifndef PROCPS_NG_STRUTILS
#define PROCPS_NG_STRUTILS
extern long strtol_or_err(const char *str, const char *errmesg);
extern double strtod_or_err(const char *str, const char *errmesg);
double strtod_nol_or_err(char *str, const char *errmesg);
#endif