diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2008-11-24 21:27:33 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2008-11-24 21:27:33 +0000 |
commit | 0aca33c8236bec45e6acc238a1af0c5f2f6f8959 (patch) | |
tree | 11e45ea869c4aadf49a65449195e8c7733089321 /newlib/libc/stdlib/wcstoull_r.c | |
parent | 0ef912dfc442abcadcc8a6f01c6a6de86a8a2ea9 (diff) | |
download | cygnal-0aca33c8236bec45e6acc238a1af0c5f2f6f8959.tar.gz cygnal-0aca33c8236bec45e6acc238a1af0c5f2f6f8959.tar.bz2 cygnal-0aca33c8236bec45e6acc238a1af0c5f2f6f8959.zip |
2008-11-24 Craig Howland <howland@LGSInnovations.com>
* libc/stdlib/wcstoull_r.c: Add EINVAL return for bad base value,
include wchar.h for prototype, remove extraneous includes, use
C99/POSIX ULLONG_MAX (but allow for poor limits.h).
* libc/stdlib/wcstoull.c: Fix usage comments (mistakes and to add
base value check noted above), remove extraneous includes.
* libc/stdio/asnprintf.c: Add #include "local.h" to get function
prototype for _svfprintf_r().
* libc/stdio/vasnprintf.c: Ditto.
* libc/stdio/local.h: Add function prototype for __submore().
* libc/include/stdio.h: Add function prototypes for _fseeko_r and
_ftello_r.
* libc/posix/namespace.h: Commented out define for write to
eliminate write() prototype being missing for collate.c (which is
the only file that presently includes namespace.h).
* libc/include/reent.h: Added _rename_r.
* libc/reent/renamer.c: Corrected function prototypes in synopses.
* libc/locale/ldpart.c: Use struct stat64 when calling fstat64.
Diffstat (limited to 'newlib/libc/stdlib/wcstoull_r.c')
-rw-r--r-- | newlib/libc/stdlib/wcstoull_r.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/newlib/libc/stdlib/wcstoull_r.c b/newlib/libc/stdlib/wcstoull_r.c index 81dd320d1..abad681a3 100644 --- a/newlib/libc/stdlib/wcstoull_r.c +++ b/newlib/libc/stdlib/wcstoull_r.c @@ -45,11 +45,17 @@ #define _GNU_SOURCE #include <_ansi.h> #include <limits.h> +#include <wchar.h> #include <wctype.h> #include <errno.h> -#include <stdlib.h> #include <reent.h> +/* Make up for older non-compliant limits.h. (This is a C99/POSIX function, + * and both require ULLONG_MAX in limits.h.) */ +#if !defined(ULLONG_MAX) +# define ULLONG_MAX ULONG_LONG_MAX +#endif + /* * Convert a wide string to an unsigned long long integer. * @@ -69,6 +75,10 @@ _DEFUN (_wcstoull_r, (rptr, nptr, endptr, base), register unsigned long long cutoff; register int neg = 0, any, cutlim; + if(base < 0 || base == 1 || base > 36) { + rptr->_errno = EINVAL; + return(0ULL); + } /* * See strtol for comments as to the logic used. */ @@ -88,8 +98,8 @@ _DEFUN (_wcstoull_r, (rptr, nptr, endptr, base), } if (base == 0) base = c == L'0' ? 8 : 10; - cutoff = (unsigned long long)ULONG_LONG_MAX / (unsigned long long)base; - cutlim = (unsigned long long)ULONG_LONG_MAX % (unsigned long long)base; + cutoff = (unsigned long long)ULLONG_MAX / (unsigned long long)base; + cutlim = (unsigned long long)ULLONG_MAX % (unsigned long long)base; for (acc = 0, any = 0;; c = *s++) { if (iswdigit(c)) c -= L'0'; @@ -108,7 +118,7 @@ _DEFUN (_wcstoull_r, (rptr, nptr, endptr, base), } } if (any < 0) { - acc = ULONG_LONG_MAX; + acc = ULLONG_MAX; rptr->_errno = ERANGE; } else if (neg) acc = -acc; |