]> pd.if.org Git - pdclib/blobdiff - functions/stdlib/strtoll.c
Merged branch stdio_rewrite back into trunk.
[pdclib] / functions / stdlib / strtoll.c
index b9b6627b6ed322cdacc689b4c4f3d43afbf20e22..aa91163842a09bc4923a64c95a1e65333d9c49d2 100644 (file)
@@ -1,7 +1,5 @@
 /* $Id$ */
 
-/* Release $Name$ */
-
 /* strtoll( const char *, char * *, int )
 
    This file is part of the Public Domain C Library (PDCLib).
@@ -23,12 +21,13 @@ long long int strtoll( const char * s, char ** endptr, int base )
     if ( base < 2 || base > 36 ) return 0;
     if ( sign == '+' )
     {
-        rc = _PDCLIB_strtox_main( &p, (unsigned)base, (uintmax_t)LLONG_MAX, (uintmax_t)( LLONG_MAX / base ), (uintmax_t)( LLONG_MAX % base ), &sign );
+        rc = (long long int)_PDCLIB_strtox_main( &p, (unsigned)base, (uintmax_t)LLONG_MAX, (uintmax_t)( LLONG_MAX / base ), (int)( LLONG_MAX % base ), &sign );
     }
     else
     {
         /* FIXME: This breaks on some machines that round negatives wrongly */
-        rc = _PDCLIB_strtox_main( &p, (unsigned)base, (uintmax_t)LLONG_MIN, (uintmax_t)( LLONG_MIN / -base ), (uintmax_t)( -( LLONG_MIN % base ) ), &sign );
+        /* FIXME: Sign error not caught by testdriver */
+        rc = (long long int)_PDCLIB_strtox_main( &p, (unsigned)base, (uintmax_t)LLONG_MIN, (uintmax_t)( LLONG_MIN / -base ), (int)( -( LLONG_MIN % base ) ), &sign );
     }
     if ( endptr != NULL ) *endptr = ( p != NULL ) ? (char *) p : (char *) s;
     return ( sign == '+' ) ? rc : -rc;
@@ -94,7 +93,7 @@ int main( void )
     TESTCASE( strtoll( "0x8000000000000000", NULL, 0 ) == LLONG_MAX );
     TESTCASE( errno == ERANGE );
     errno = 0;
-    TESTCASE( strtoll( "-0x7FFFFFFFFFFFFFFF", NULL, 0 ) == 0x8000000000000001 );
+    TESTCASE( strtoll( "-0x7FFFFFFFFFFFFFFF", NULL, 0 ) == (long long)0x8000000000000001 );
     TESTCASE( errno == 0 );
     TESTCASE( strtoll( "-0x8000000000000000", NULL, 0 ) == LLONG_MIN );
     TESTCASE( errno == 0 );