mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:42:57 +00:00
Fix strtoull implementation and add it to build files. Based on patch by Mark Junker <mjscod@gmx.de>.
svn path=/trunk/; revision=17797
This commit is contained in:
parent
a43952c66b
commit
c25a8a58af
2 changed files with 9 additions and 7 deletions
|
@ -317,6 +317,7 @@
|
||||||
<file>senv.c</file>
|
<file>senv.c</file>
|
||||||
<file>strtod.c</file>
|
<file>strtod.c</file>
|
||||||
<file>strtoul.c</file>
|
<file>strtoul.c</file>
|
||||||
|
<file>strtoull.c</file>
|
||||||
<file>swab.c</file>
|
<file>swab.c</file>
|
||||||
<file>wcstod.c</file>
|
<file>wcstod.c</file>
|
||||||
<file>wcstombs.c</file>
|
<file>wcstombs.c</file>
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
//#include <msvcrt/unconst.h>
|
#include <stdint.h>
|
||||||
|
#include <internal/file.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a string to an unsigned long integer.
|
* Convert a string to an unsigned long integer.
|
||||||
|
@ -12,13 +13,13 @@
|
||||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||||
* alphabets and digits are each contiguous.
|
* alphabets and digits are each contiguous.
|
||||||
*/
|
*/
|
||||||
unsigned long
|
uint64_t
|
||||||
strtoull(const char *nptr, char **endptr, int base)
|
strtoull(const char *nptr, char **endptr, int base)
|
||||||
{
|
{
|
||||||
const char *s = nptr;
|
const char *s = nptr;
|
||||||
unsigned long acc;
|
uint64_t acc;
|
||||||
int c;
|
int c;
|
||||||
unsigned long cutoff;
|
uint64_t cutoff;
|
||||||
int neg = 0, any, cutlim;
|
int neg = 0, any, cutlim;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,8 +44,8 @@ strtoull(const char *nptr, char **endptr, int base)
|
||||||
}
|
}
|
||||||
if (base == 0)
|
if (base == 0)
|
||||||
base = c == '0' ? 8 : 10;
|
base = c == '0' ? 8 : 10;
|
||||||
cutoff = (unsigned long)ULONG_MAX / base;
|
cutoff = UINT64_MAX / base;
|
||||||
cutlim = (unsigned long)ULONG_MAX % base;
|
cutlim = (int)(UINT64_MAX % base);
|
||||||
for (acc = 0, any = 0;; c = *s++)
|
for (acc = 0, any = 0;; c = *s++)
|
||||||
{
|
{
|
||||||
if (isdigit(c))
|
if (isdigit(c))
|
||||||
|
@ -65,7 +66,7 @@ strtoull(const char *nptr, char **endptr, int base)
|
||||||
}
|
}
|
||||||
if (any < 0)
|
if (any < 0)
|
||||||
{
|
{
|
||||||
acc = ULONG_MAX;
|
acc = UINT64_MAX;
|
||||||
__set_errno ( ERANGE );
|
__set_errno ( ERANGE );
|
||||||
}
|
}
|
||||||
else if (neg)
|
else if (neg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue