From 34f0e76ca0135b2b302e2b079482a4038149b079 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 19 Jul 2019 12:34:44 +0000 Subject: bits-fmtscan refactor, part two --- src/libstddjb/uint640_scan_base_max.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/libstddjb/uint640_scan_base_max.c (limited to 'src/libstddjb/uint640_scan_base_max.c') diff --git a/src/libstddjb/uint640_scan_base_max.c b/src/libstddjb/uint640_scan_base_max.c new file mode 100644 index 0000000..5487f98 --- /dev/null +++ b/src/libstddjb/uint640_scan_base_max.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include + +#include +#include + +size_t uint640_scan_base_max (char const *s, uint64_t *u, uint8_t base, uint64_t max) +{ + size_t pos = uint640_scan_base_max(s, u, base, max) ; + if (!pos) return (errno = EINVAL, 0) ; + if (!s[pos]) return pos ; + errno = fmtscan_num(s[pos], base) < base ? ERANGE : EINVAL ; + return 0 ; +} -- cgit v1.2.3