Added atoi(3).
This commit is contained in:
parent
ae599b6d67
commit
33c0a9586e
|
@ -45,6 +45,7 @@ typedef int div_t, ldiv_t, lldiv_t;
|
||||||
|
|
||||||
/* TODO: WEXITSTATUS, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED is missing here */
|
/* TODO: WEXITSTATUS, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED is missing here */
|
||||||
|
|
||||||
|
int atoi(const char*);
|
||||||
void exit(int);
|
void exit(int);
|
||||||
void _Exit(int status);
|
void _Exit(int status);
|
||||||
void free(void*);
|
void free(void*);
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Maxsi
|
||||||
int Compare(const char* A, const char* B);
|
int Compare(const char* A, const char* B);
|
||||||
int CompareN(const char* A, const char* B, size_t MaxLength);
|
int CompareN(const char* A, const char* B, size_t MaxLength);
|
||||||
int StartsWith(const char* Haystack, const char* Needle);
|
int StartsWith(const char* Haystack, const char* Needle);
|
||||||
|
int ToInt(const char* str);
|
||||||
|
|
||||||
int ConvertUInt8T(uint8_t num, char* dest);
|
int ConvertUInt8T(uint8_t num, char* dest);
|
||||||
int ConvertUInt16(uint16_t num, char* dest);
|
int ConvertUInt16(uint16_t num, char* dest);
|
||||||
|
|
|
@ -90,6 +90,20 @@ namespace Maxsi
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DUAL_FUNCTION(int, atoi, ToInt, (const char* str))
|
||||||
|
{
|
||||||
|
bool negative = ( *str == '-' );
|
||||||
|
if ( negative ) { str++; }
|
||||||
|
int result = 0;
|
||||||
|
int c;
|
||||||
|
while ( (c = *str++) != 0 )
|
||||||
|
{
|
||||||
|
if ( c < '0' || '9' < c ) { return result; }
|
||||||
|
result = result * 10 + c - '0';
|
||||||
|
}
|
||||||
|
return (negative) ? -result : result;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
char* Combine(size_t NumParameters, ...)
|
char* Combine(size_t NumParameters, ...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue