Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401//// strtox.cpp//// Copyright (c) Microsoft Corporation. All rights reserved.//// The many string-to-integer conversion functions, including strtol, strtoul,// strtoll, strtoull, wcstol, wcstoul, wcstoll, wcstoull, and various variations// of these functions. All of these share a common implementation that converts// a narrow or wide character string to a 32-bit or 64-bit signed or unsigned// integer.//// The base must be zero or in the range [2,36]. If the base zero is passed,// the functions attempt to determine the base from the prefix of the string: a// prefix of "0" indicates an octal string, a prefix of "0x" or "0X" indicates a// hexadecimal string, and any other character indicates base 10.//// If the end_ptr is non-null, then if the number is successfully parsed, the// *end_ptr is set to point to the last digit of the number (note: it does NOT// point one-past-the-end, STL style).//// The string format must be://// [whitespace] [sign] [0|0x] [digits/letters]//// If the string does not start with a valid number, zero is returned and end_ptr// is set to point to the initial character in the string.//// If the string starts with a valid number that is representable in the target// integer type, the number is returned and end_ptr is set to point to the last// character of the number.//// If the string starts with a valid number that is not representable in the// target integer type, end_ptr is set to point to the last character of the// number and a sentinel value is returned://// 32-bit 64-bit// Unsigned / too large: UINT_MAX _UI64_MAX// Signed / too large: INT_MAX _I64_MAX// Signed / too small: INT_MIN _I64_MIN//// See also atox.cpp, which defines the "simple" functions--the atox and wtox// families of functions.//#define _ALLOW_OLD_VALIDATE_MACROS#include <corecrt_internal.h>#include <corecrt_internal_strtox.h>#include <corecrt_wstdlib.h>#include <ctype.h>#include <errno.h>#include <limits.h>#include <locale.h>#include <stdint.h>#include <stdlib.h>#include <inttypes.h>
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+//// Narrow Strings => 32-bit Integers////-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+extern "C" long __cdecl strtol( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<long>(string, end_ptr, base, nullptr);}
extern "C" long __cdecl _strtol_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<long>(string, end_ptr, base, locale);}
extern "C" unsigned long __cdecl strtoul( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<unsigned long>(string, end_ptr, base, nullptr);}
extern "C" unsigned long __cdecl _strtoul_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<unsigned long>(string, end_ptr, base, locale);}
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+//// Narrow Strings => 64-bit Integers////-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+extern "C" __int64 __cdecl _strtoi64( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<__int64>(string, end_ptr, base, nullptr);}
extern "C" long long __cdecl strtoll( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<long long>(string, end_ptr, base, nullptr);}
extern "C" intmax_t __cdecl strtoimax( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<intmax_t>(string, end_ptr, base, nullptr);}
extern "C" __int64 __cdecl _strtoi64_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<__int64>(string, end_ptr, base, locale);}
extern "C" long long __cdecl _strtoll_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<long long>(string, end_ptr, base, locale);}
extern "C" intmax_t __cdecl _strtoimax_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<intmax_t>(string, end_ptr, base, locale);}
extern "C" unsigned __int64 __cdecl _strtoui64( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<unsigned __int64>(string, end_ptr, base, nullptr);}
extern "C" unsigned long long __cdecl strtoull( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<unsigned long long>(string, end_ptr, base, nullptr);}
extern "C" uintmax_t __cdecl strtoumax( char const* const string, char** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<uintmax_t>(string, end_ptr, base, nullptr);}
extern "C" unsigned __int64 __cdecl _strtoui64_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<unsigned __int64>(string, end_ptr, base, locale);}
extern "C" unsigned long long __cdecl _strtoull_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<unsigned long long>(string, end_ptr, base, locale);}
extern "C" uintmax_t __cdecl _strtoumax_l( char const* const string, char** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<uintmax_t>(string, end_ptr, base, locale);}
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+//// Wide Strings => 32-bit Integers////-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+extern "C" long __cdecl wcstol( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<long>(string, end_ptr, base, nullptr);}
extern "C" long __cdecl _wcstol_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<long>(string, end_ptr, base, locale);}
extern "C" unsigned long __cdecl wcstoul( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<unsigned long>(string, end_ptr, base, nullptr);}
extern "C" unsigned long __cdecl _wcstoul_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<unsigned long>(string, end_ptr, base, locale);}
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+//// Wide Strings => 64-bit Integers////-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+extern "C" __int64 __cdecl _wcstoi64( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<__int64>(string, end_ptr, base, nullptr);}
extern "C" long long __cdecl wcstoll( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<long long>(string, end_ptr, base, nullptr);}
extern "C" intmax_t __cdecl wcstoimax( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<intmax_t>(string, end_ptr, base, nullptr);}
extern "C" __int64 __cdecl _wcstoi64_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<__int64>(string, end_ptr, base, locale);}
extern "C" long long __cdecl _wcstoll_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<long long>(string, end_ptr, base, locale);}
extern "C" intmax_t __cdecl _wcstoimax_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<intmax_t>(string, end_ptr, base, locale);}
extern "C" unsigned __int64 __cdecl _wcstoui64( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<unsigned __int64>(string, end_ptr, base, nullptr);}
extern "C" unsigned long long __cdecl wcstoull( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<unsigned long long>(string, end_ptr, base, nullptr);}
extern "C" uintmax_t __cdecl wcstoumax( wchar_t const* const string, wchar_t** const end_ptr, int const base ){ return __crt_strtox::parse_integer_from_string<uintmax_t>(string, end_ptr, base, nullptr);}
extern "C" unsigned __int64 __cdecl _wcstoui64_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<unsigned __int64>(string, end_ptr, base, locale);}
extern "C" unsigned long long __cdecl _wcstoull_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<unsigned long long>(string, end_ptr, base, locale);}
extern "C" uintmax_t __cdecl _wcstoumax_l( wchar_t const* const string, wchar_t** const end_ptr, int const base, _locale_t const locale ){ return __crt_strtox::parse_integer_from_string<uintmax_t>(string, end_ptr, base, locale);}