1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

AK: Standardize the behaviour of GenericLexer::consume_until overloads

Before this commit all consume_until overloads aside from the Predicate
one would consume (and ignore) the stop char/string, while the
Predicate overload would not, in order to keep behaviour consistent,
the other overloads no longer consume the stop char/string as well.
This commit is contained in:
Idan Horowitz 2022-01-24 23:47:22 +02:00 committed by Ali Mohammad Pur
parent d49d2c7ec4
commit 67ce9e28a5
7 changed files with 18 additions and 14 deletions

View file

@ -53,7 +53,6 @@ StringView GenericLexer::consume_line()
}
// Consume and return characters until `stop` is peek'd
// The `stop` character is ignored, as it is user-defined
StringView GenericLexer::consume_until(char stop)
{
size_t start = m_index;
@ -61,15 +60,12 @@ StringView GenericLexer::consume_until(char stop)
m_index++;
size_t length = m_index - start;
ignore();
if (length == 0)
return {};
return m_input.substring_view(start, length);
}
// Consume and return characters until the string `stop` is found
// The `stop` string is ignored, as it is user-defined
StringView GenericLexer::consume_until(const char* stop)
{
size_t start = m_index;
@ -77,15 +73,12 @@ StringView GenericLexer::consume_until(const char* stop)
m_index++;
size_t length = m_index - start;
ignore(__builtin_strlen(stop));
if (length == 0)
return {};
return m_input.substring_view(start, length);
}
// Consume and return characters until the string `stop` is found
// The `stop` string is ignored, as it is user-defined
StringView GenericLexer::consume_until(StringView stop)
{
size_t start = m_index;
@ -93,8 +86,6 @@ StringView GenericLexer::consume_until(StringView stop)
m_index++;
size_t length = m_index - start;
ignore(stop.length());
if (length == 0)
return {};
return m_input.substring_view(start, length);