Hi,
is s/o interested in a working implementation of strtoull? I submitted a
patch 4 or 5 months ago but it wasn't added yet so I retry my submission.
Regards,
Mark
Index: crt.xml
===================================================================
--- crt.xml (revision 17794)
+++ crt.xml (working copy)
@@ -317,6 +317,7 @@
<file>senv.c</file>
<file>strtod.c</file>
<file>strtoul.c</file>
+ <file>strtoull.c</file>
<file>swab.c</file>
<file>wcstod.c</file>
<file>wcstombs.c</file>
Index: stdlib/strtoull.c
===================================================================
--- stdlib/strtoull.c (revision 17794)
+++ stdlib/strtoull.c (working copy)
@@ -1,24 +1,38 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <windows.h>
#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
-//#include <msvcrt/unconst.h>
+#include <internal/file.h>
+/*#include <msvcrt/unconst.h>*/
+#if defined(LONG_LONG_MAX)
+#define ULONGLONG_MAX ULONG_LONG_MAX
+#elif defined(_UI64_MAX)
+#define ULONGLONG_MAX _UI64_MAX
+#elif defined(ULLONG_MAX)
+#define ULONGLONG_MAX ULLONG_MAX
+#else
+/* FIXME: There must be a better way because LONGLONG might be defined as
+ * double. */
+#define ULONGLONG_MAX ((ULONGLONG) (LONGLONG) -1)
+#endif
+
/*
* Convert a string to an unsigned long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
-unsigned long
+ULONGLONG
strtoull(const char *nptr, char **endptr, int base)
{
const char *s = nptr;
- unsigned long acc;
+ ULONGLONG acc;
int c;
- unsigned long cutoff;
+ ULONGLONG cutoff;
int neg = 0, any, cutlim;
/*
@@ -43,8 +57,8 @@
}
if (base == 0)
base = c == '0' ? 8 : 10;
- cutoff = (unsigned long)ULONG_MAX / base;
- cutlim = (unsigned long)ULONG_MAX % base;
+ cutoff = ULONGLONG_MAX / base;
+ cutlim = (int) (ULONGLONG_MAX % base);
for (acc = 0, any = 0;; c = *s++)
{
if (isdigit(c))
@@ -65,7 +79,7 @@
}
if (any < 0)
{
- acc = ULONG_MAX;
+ acc = ULONGLONG_MAX;
__set_errno ( ERANGE );
}
else if (neg)