From a32b1e9e3557393d60fb4805cd74d8ba357b66cb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 19 Feb 2015 16:00:01 +0000 Subject: [libc] Rewrite strtoul() The implementation of strtoul() has a partially unknown provenance. Rewrite this code to avoid potential licensing uncertainty. Since we now use -ffunction-sections, there is no need to place strtoull() in a separate file from strtoul(). Signed-off-by: Michael Brown --- src/core/misc.c | 62 --------------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/core/misc.c (limited to 'src/core/misc.c') diff --git a/src/core/misc.c b/src/core/misc.c deleted file mode 100644 index 84cfcd803..000000000 --- a/src/core/misc.c +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -MISC Support Routines -**************************************************************************/ - -FILE_LICENCE ( GPL2_OR_LATER ); - -#include -#include -#include -#include -#include - -unsigned int strtoul_charval ( unsigned int charval ) { - - if ( charval >= 'a' ) { - charval = ( charval - 'a' + 10 ); - } else if ( charval >= 'A' ) { - charval = ( charval - 'A' + 10 ); - } else if ( charval <= '9' ) { - charval = ( charval - '0' ); - } - - return charval; -} - -unsigned long strtoul ( const char *p, char **endp, int base ) { - unsigned long ret = 0; - int negative = 0; - unsigned int charval; - - while ( isspace ( *p ) ) - p++; - - if ( *p == '-' ) { - negative = 1; - p++; - } - - base = strtoul_base ( &p, base ); - - while ( 1 ) { - charval = strtoul_charval ( *p ); - if ( charval >= ( unsigned int ) base ) - break; - ret = ( ( ret * base ) + charval ); - p++; - } - - if ( negative ) - ret = -ret; - - if ( endp ) - *endp = ( char * ) p; - - return ( ret ); -} - -/* - * Local variables: - * c-basic-offset: 8 - * End: - */ -- cgit v1.2.3-55-g7522