From b22cb40565b118632b635bce0028d6a037d906d1 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 15 Feb 2022 23:32:59 +0200 Subject: [PATCH] AK: Exclude GenericLexer String APIs from the Kernel These APIs are only used by userland, and String is OOM-infallible, so let's just ifdef it out of the Kernel. --- AK/GenericLexer.cpp | 9 +++++++-- AK/GenericLexer.h | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/AK/GenericLexer.cpp b/AK/GenericLexer.cpp index 8a55451dafa..d6e977a0074 100644 --- a/AK/GenericLexer.cpp +++ b/AK/GenericLexer.cpp @@ -7,9 +7,12 @@ #include #include #include -#include #include -#include + +#ifndef KERNEL +# include +# include +#endif namespace AK { // Consume a number of characters @@ -125,6 +128,7 @@ StringView GenericLexer::consume_quoted_string(char escape_char) return m_input.substring_view(start, length); } +#ifndef KERNEL String GenericLexer::consume_and_unescape_string(char escape_char) { auto view = consume_quoted_string(escape_char); @@ -206,5 +210,6 @@ auto GenericLexer::decode_single_or_paired_surrogate(bool combine_surrogate_pair retreat(6); return *high_surrogate; } +#endif } diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index 37604d2bd54..3c317782d43 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -83,10 +83,12 @@ public: return true; } +#ifndef KERNEL bool consume_specific(const String& next) { return consume_specific(StringView { next }); } +#endif constexpr bool consume_specific(const char* next) { @@ -115,14 +117,18 @@ public: StringView consume_until(const char*); StringView consume_until(StringView); StringView consume_quoted_string(char escape_char = 0); +#ifndef KERNEL String consume_and_unescape_string(char escape_char = '\\'); +#endif enum class UnicodeEscapeError { MalformedUnicodeEscape, UnicodeEscapeOverflow, }; +#ifndef KERNEL Result consume_escaped_code_point(bool combine_surrogate_pairs = true); +#endif constexpr void ignore(size_t count = 1) { @@ -212,8 +218,10 @@ protected: size_t m_index { 0 }; private: +#ifndef KERNEL Result decode_code_point(); Result decode_single_or_paired_surrogate(bool combine_surrogate_pairs); +#endif }; constexpr auto is_any_of(StringView values)