X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2F_PDCLIB%2Fatomax.c;h=f05a8af8e074e2337e1defdb5b1ada90c49093fb;hb=2040228f27d623585d339dec175c4e779ca9edb5;hp=84a0c08930b4f650867c10308a151c4f26808b5d;hpb=b08f4b52b1cd1f7a9553c0f357a7c90859fa3e73;p=pdclib diff --git a/functions/_PDCLIB/atomax.c b/functions/_PDCLIB/atomax.c index 84a0c08..f05a8af 100644 --- a/functions/_PDCLIB/atomax.c +++ b/functions/_PDCLIB/atomax.c @@ -1,16 +1,14 @@ -/* $Id$ */ - /* _PDCLIB_atomax( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ -#define _PDCLIB_INT_H _PDCLIB_INT_H -#include <_PDCLIB_int.h> #include #include +#ifndef REGTEST + _PDCLIB_intmax_t _PDCLIB_atomax( const char * s ) { _PDCLIB_intmax_t rc = 0; @@ -20,22 +18,27 @@ _PDCLIB_intmax_t _PDCLIB_atomax( const char * s ) while ( isspace( *s ) ) ++s; if ( *s == '+' ) ++s; else if ( *s == '-' ) sign = *(s++); - while ( ( x = memchr( _PDCLIB_digits, *(s++), 10 ) ) != NULL ) + /* TODO: Earlier version was missing tolower() but was not caught by tests */ + while ( ( x = memchr( _PDCLIB_digits, tolower(*(s++)), 10 ) ) != NULL ) { rc = rc * 10 + ( x - _PDCLIB_digits ); } return ( sign == '+' ) ? rc : -rc; } +#endif + #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" int main( void ) { +#ifndef REGTEST /* basic functionality */ TESTCASE( _PDCLIB_atomax( "123" ) == 123 ); /* testing skipping of leading whitespace and trailing garbage */ TESTCASE( _PDCLIB_atomax( " \n\v\t\f123xyz" ) == 123 ); +#endif return TEST_RESULTS; }