Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
Copyright (C) James J Myers 2003
Copyright (C) Volker Lendecke 2010
-
+ Copyright (C) Swen Schillig 2019
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
* - wrong base
* - value overflow
* - string with a leading "-" indicating a negative number
+ * - no conversion due to empty string or not representing a number
*/
unsigned long int
strtoul_err(const char *nptr, char **endptr, int base, int *err)
return val;
}
+ /* got an invalid number-string resulting in no conversion */
+ if (nptr == tmp_endptr) {
+ *err = EINVAL;
+ errno = saved_errno;
+ return val;
+ }
+
/* did we convert a negative "number" ? */
needle = strchr(nptr, '-');
if (needle != NULL && needle < tmp_endptr) {
* - wrong base
* - value overflow
* - string with a leading "-" indicating a negative number
+ * - no conversion due to empty string or not representing a number
*/
unsigned long long int
strtoull_err(const char *nptr, char **endptr, int base, int *err)
return val;
}
+ /* got an invalid number-string resulting in no conversion */
+ if (nptr == tmp_endptr) {
+ *err = EINVAL;
+ errno = saved_errno;
+ return val;
+ }
+
/* did we convert a negative "number" ? */
needle = strchr(nptr, '-');
if (needle != NULL && needle < tmp_endptr) {