core: simplify custom strtod() interface

The strtod_flags() function allowed for fine control of how to
parse strings. However, only two different modes were actually
used: ascii mode ("C" locale) and permissive mode (accept ","
and "." as decimal separator).

The former had already its own function name (ascii_strtod).
Make the latter a separatge function as well (permissive_strtod)
and remove all the flags rigmarole.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-04-23 15:06:28 +08:00 committed by bstoeger
parent 628e2fe933
commit 092035d883
8 changed files with 57 additions and 73 deletions

View file

@ -52,15 +52,8 @@ static inline char *copy_string(const char *s)
return (s && *s) ? strdup(s) : NULL;
}
#define STRTOD_NO_SIGN 0x01
#define STRTOD_NO_DOT 0x02
#define STRTOD_NO_COMMA 0x04
#define STRTOD_NO_EXPONENT 0x08
extern double strtod_flags(const char *str, const char **ptr, unsigned int flags);
#define STRTOD_ASCII (STRTOD_NO_COMMA)
#define ascii_strtod(str, ptr) strtod_flags(str, ptr, STRTOD_ASCII)
extern double permissive_strtod(const char *str, const char **ptr);
extern double ascii_strtod(const char *str, const char **ptr);
#ifdef __cplusplus
}