When it is detected that strtoll returns EINVAL not only in the case
that the base is not supported, HAVE_BSD_STRTOLL is declared and
strtoll is replaced. The current replacement code wraps strtoq in
order to replace strtoll and errors out when strtoq is missing.
In order to remove this possible error path, we can use strtoll instead
of strtoq since the code is only used when it is known that strtoll exists.
The fixes a compilation problem on linux systems using musl libc, which
has a BSD-like strtoll but no strtoq.
Signed-off-by: Felix Janda <felix.janda@posteo.de>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: "Stefan (metze) Metzmacher" <metze@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jun 22 12:49:10 CEST 2015 on sn-devel-104
}
#else
#ifdef HAVE_BSD_STRTOLL
-#ifdef HAVE_STRTOQ
long long int rep_strtoll(const char *str, char **endptr, int base)
{
- long long int nb = strtoq(str, endptr, base);
- /* In linux EINVAL is only returned if base is not ok */
+ long long int nb = strtoll(str, endptr, base);
+ /* With glibc EINVAL is only returned if base is not ok */
if (errno == EINVAL) {
if (base == 0 || (base >1 && base <37)) {
/* Base was ok so it's because we were not
}
return nb;
}
-#else
-#error "You need the strtoq function"
-#endif /* HAVE_STRTOQ */
#endif /* HAVE_BSD_STRTOLL */
#endif /* HAVE_STRTOLL */