X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2F_PDCLIB%2Fstrtox_main.c;h=bc14811335c736c73eab4597f9f704559b0aefba;hb=7bcac73ac7bf61de3dd1bbeaf6071894c7805e7f;hp=59534d83809c3e00ef87116a6afed3e2da77c826;hpb=12e17136786afb1775c9dc946cbe41f5e230c24a;p=pdclib.old diff --git a/functions/_PDCLIB/strtox_main.c b/functions/_PDCLIB/strtox_main.c index 59534d8..bc14811 100644 --- a/functions/_PDCLIB/strtox_main.c +++ b/functions/_PDCLIB/strtox_main.c @@ -1,7 +1,5 @@ /* $Id$ */ -/* Release $Name$ */ - /* _PDCLIB_strtox_main( const char * *, int, _PDCLIB_uintmax_t, _PDCLIB_uintmax_t, int ) This file is part of the Public Domain C Library (PDCLib). @@ -20,19 +18,20 @@ _PDCLIB_uintmax_t _PDCLIB_strtox_main( const char ** p, unsigned int base, uintm _PDCLIB_uintmax_t rc = 0; int digit = -1; const char * x; - while ( ( x = memchr( _PDCLIB_digits, toupper(**p), base ) ) != NULL ) + while ( ( x = memchr( _PDCLIB_digits, tolower(**p), base ) ) != NULL ) { digit = x - _PDCLIB_digits; if ( ( rc < limval ) || ( ( rc == limval ) && ( digit <= limdigit ) ) ) { - rc = rc * base + ( x - _PDCLIB_digits ); + rc = rc * base + digit; ++(*p); } else { errno = ERANGE; /* TODO: Only if endptr != NULL - but do we really want *another* parameter? */ - while ( memchr( _PDCLIB_digits, **p, base ) != NULL ) ++(*p); + /* TODO: Earlier version was missing tolower() here but was not caught by tests */ + while ( memchr( _PDCLIB_digits, tolower(**p), base ) != NULL ) ++(*p); /* TODO: This is ugly, but keeps caller from negating the error value */ *sign = '+'; return error;