From 9b70808ab562415e1ce1510fc27c003cc193213e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 11 Nov 2018 10:40:50 +0100 Subject: [PATCH] Add really cheap atol() since sizeof(int) == sizeof(long) here anyway. --- LibC/stdlib.cpp | 8 +++++++- LibC/stdlib.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp index 63583ab77b..7f323c204d 100644 --- a/LibC/stdlib.cpp +++ b/LibC/stdlib.cpp @@ -103,11 +103,17 @@ int atoi(const char* str) continue; } if (str[i] < '0' || str[i] > '9') - return 0; + return value; value = value * 10; value += str[i] - '0'; } return isNegative ? -value : value; } +long atol(const char* str) +{ + static_assert(sizeof(int) == sizeof(long)); + return atoi(str); +} + } diff --git a/LibC/stdlib.h b/LibC/stdlib.h index 0cd6a8e2c8..b8d4174dbd 100644 --- a/LibC/stdlib.h +++ b/LibC/stdlib.h @@ -11,6 +11,7 @@ void* calloc(size_t nmemb, size_t); void* realloc(void *ptr, size_t); char* getenv(const char* name); int atoi(const char*); +long atol(const char*); void exit(int status) __NORETURN; void abort() __NORETURN;