From 9606eabd82e6523ffb8ab8b3eeb405f24e3e2346 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 2 Dec 2024 09:23:45 -0500 Subject: bfstd: Add more strto*() wrappers --- src/bfstd.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/bfstd.h') diff --git a/src/bfstd.h b/src/bfstd.h index 97867fd..84f92ec 100644 --- a/src/bfstd.h +++ b/src/bfstd.h @@ -178,23 +178,26 @@ int open_cterm(int flags); */ const char *xgetprogname(void); +/** + * Wrapper for strtol() that forbids leading spaces. + */ +int xstrtol(const char *str, char **end, int base, long *value); + /** * Wrapper for strtoll() that forbids leading spaces. - * - * @str - * The string to parse. - * @end - * If non-NULL, will hold a pointer to the first invalid character. - * If NULL, the entire string must be valid. - * @base - * The base for the conversion, or 0 to auto-detect. - * @value - * Will hold the parsed integer value, on success. - * @return - * 0 on success, -1 on failure. */ int xstrtoll(const char *str, char **end, int base, long long *value); +/** + * Wrapper for strtof() that forbids leading spaces. + */ +int xstrtof(const char *str, char **end, float *value); + +/** + * Wrapper for strtod() that forbids leading spaces. + */ +int xstrtod(const char *str, char **end, double *value); + /** * Process a yes/no prompt. * -- cgit v1.2.3