Add strtoimax(3) and strtoumax(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2013-07-18 23:37:54 +02:00
parent d79808f85f
commit cdc5a9673e
2 changed files with 14 additions and 3 deletions

View File

@ -200,8 +200,8 @@ __BEGIN_DECLS
intmax_t imaxabs(intmax_t);
/* TODO: imaxdiv */
/* TODO: strtoimax */
/* TODO: strtoumax */
intmax_t strtoimax(const char* __restrict, char** __restrict, int);
uintmax_t strtoumax(const char* __restrict, char** __restrict, int);
/* TODO: wcstoimax */
/* TODO: wcstoumax */

View File

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2013.
This file is part of the Sortix C Library.
@ -23,6 +23,7 @@
*******************************************************************************/
#include <ctype.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdlib.h>
@ -79,6 +80,11 @@ extern "C" long long strtoll(const char* str, char** endptr, int base)
return ParseInteger<long long, false>(str, endptr, base);
}
extern "C" intmax_t strtoimax(const char* str, char** endptr, int base)
{
return ParseInteger<intmax_t, false>(str, endptr, base);
}
extern "C" unsigned long strtoul(const char* str, char** endptr, int base)
{
return ParseInteger<unsigned long, true>(str, endptr, base);
@ -88,3 +94,8 @@ extern "C" unsigned long long strtoull(const char* str, char** endptr, int base)
{
return ParseInteger<unsigned long long, true>(str, endptr, base);
}
extern "C" uintmax_t strtoumax(const char* str, char** endptr, int base)
{
return ParseInteger<uintmax_t, true>(str, endptr, base);
}