diff --git a/AK/Format.cpp b/AK/Format.cpp index 4c6d6c1ec1..a4823b8e75 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -71,12 +71,19 @@ static void write_escaped_literal(StringBuilder& builder, StringView literal) ++idx; } } + static size_t parse_number(StringView input) { - String null_terminated { input }; - char* endptr; - return strtoull(null_terminated.characters(), &endptr, 10); + size_t value = 0; + + for (char ch : input) { + value *= 10; + value += ch - '0'; + } + + return value; } + static bool parse_format_specifier(StringView input, FormatSpecifier& specifier) { specifier.index = NumericLimits::max(); diff --git a/AK/Format.h b/AK/Format.h index def205f3aa..f71f05ad1f 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -28,6 +28,7 @@ #include #include +#include namespace AK { diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 646cf406d1..0f3000cda2 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -209,6 +209,7 @@ set(AK_SOURCES ../AK/StringUtils.cpp ../AK/StringView.cpp ../AK/Time.cpp + ../AK/Format.cpp ) set(ELF_SOURCES