From 8c05b4e13778dfd908c9b65ed39f17604eb34e89 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 24 Jul 2021 20:45:27 +0100 Subject: LibIMAP: Rename IMAP::Parser::{parse => consume}_while() This isn't parsing anything. --- Userland/Libraries/LibIMAP/Parser.cpp | 26 +++++++++++++------------- Userland/Libraries/LibIMAP/Parser.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Userland/Libraries/LibIMAP/Parser.cpp b/Userland/Libraries/LibIMAP/Parser.cpp index 183d0d94a2..e7a5840858 100644 --- a/Userland/Libraries/LibIMAP/Parser.cpp +++ b/Userland/Libraries/LibIMAP/Parser.cpp @@ -22,7 +22,7 @@ ParseStatus Parser::parse(ByteBuffer&& buffer, bool expecting_tag) if (try_consume("+")) { consume(" "); - auto data = parse_while([](u8 x) { return x != '\r'; }); + auto data = consume_while([](u8 x) { return x != '\r'; }); consume("\r\n"); return { true, { ContinueRequest { data } } }; } @@ -179,13 +179,13 @@ void Parser::parse_untagged() m_response.data().set_permanent_flags(move(flags)); } else { dbgln("Unknown: {}", actual_type); - parse_while([](u8 x) { return x != ']'; }); + consume_while([](u8 x) { return x != ']'; }); } consume("]"); - parse_while([](u8 x) { return x != '\r'; }); + consume_while([](u8 x) { return x != '\r'; }); consume("\r\n"); } else { - parse_while([](u8 x) { return x != '\r'; }); + consume_while([](u8 x) { return x != '\r'; }); consume("\r\n"); } } else if (try_consume("SEARCH")) { @@ -197,7 +197,7 @@ void Parser::parse_untagged() } m_response.data().set_search_results(move(ids)); } else if (try_consume("BYE")) { - auto message = parse_while([](u8 x) { return x != '\r'; }); + auto message = consume_while([](u8 x) { return x != '\r'; }); consume("\r\n"); m_response.data().set_bye(message.is_empty() ? Optional() : Optional(message)); } else if (try_consume("STATUS")) { @@ -236,7 +236,7 @@ void Parser::parse_untagged() try_consume(" "); // Not in the spec but the Outlook server sends a space for some reason. consume("\r\n"); } else { - auto x = parse_while([](u8 x) { return x != '\r'; }); + auto x = consume_while([](u8 x) { return x != '\r'; }); consume("\r\n"); dbgln("ignored {}", x); } @@ -244,7 +244,7 @@ void Parser::parse_untagged() StringView Parser::parse_quoted_string() { - auto str = parse_while([](u8 x) { return x != '"'; }); + auto str = consume_while([](u8 x) { return x != '"'; }); consume("\""); return str; } @@ -292,7 +292,7 @@ FetchResponseData Parser::parse_fetch_response() } case FetchCommand::DataItemType::InternalDate: { consume(" \""); - auto date_view = parse_while([](u8 x) { return x != '"'; }); + auto date_view = consume_while([](u8 x) { return x != '"'; }); consume("\""); auto date = Core::DateTime::parse("%d-%b-%Y %H:%M:%S %z", date_view).value(); fetch_response.set_internal_date(date); @@ -574,7 +574,7 @@ ListItem Parser::parse_list_item() flags |= static_cast(flag); } consume(" \""); - auto reference = parse_while([](u8 x) { return x != '"'; }); + auto reference = consume_while([](u8 x) { return x != '"'; }); consume("\" "); auto mailbox = parse_astring(); consume("\r\n"); @@ -634,7 +634,7 @@ Vector Parser::parse_list(T converter(StringView)) while (!try_consume(")")) { if (!first) consume(" "); - auto item = parse_while([](u8 x) { + auto item = consume_while([](u8 x) { return x != ' ' && x != ')'; }); x.append(converter(item)); @@ -677,7 +677,7 @@ MailboxFlag Parser::parse_mailbox_flag(StringView s) return MailboxFlag::Unknown; } -StringView Parser::parse_while(Function should_consume) +StringView Parser::consume_while(Function should_consume) { int chars = 0; while (!at_end() && should_consume(m_buffer[position])) { @@ -689,13 +689,13 @@ StringView Parser::parse_while(Function should_consume) FetchCommand::DataItem Parser::parse_fetch_data_item() { - auto msg_attr = parse_while([](u8 x) { return is_ascii_alpha(x) != 0; }); + auto msg_attr = consume_while([](u8 x) { return is_ascii_alpha(x) != 0; }); if (msg_attr.equals_ignoring_case("BODY") && try_consume("[")) { auto data_item = FetchCommand::DataItem { .type = FetchCommand::DataItemType::BodySection, .section = { {} } }; - auto section_type = parse_while([](u8 x) { return x != ']' && x != ' '; }); + auto section_type = consume_while([](u8 x) { return x != ']' && x != ' '; }); if (section_type.equals_ignoring_case("HEADER.FIELDS")) { data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFields; data_item.section->headers = Vector(); diff --git a/Userland/Libraries/LibIMAP/Parser.h b/Userland/Libraries/LibIMAP/Parser.h index b55e917e67..de739f819f 100644 --- a/Userland/Libraries/LibIMAP/Parser.h +++ b/Userland/Libraries/LibIMAP/Parser.h @@ -36,6 +36,7 @@ private: void parse_response_done(); void consume(StringView x); + StringView consume_while(Function should_consume); unsigned parse_number(); Optional try_parse_number(); @@ -54,7 +55,6 @@ private: static MailboxFlag parse_mailbox_flag(StringView s); - StringView parse_while(Function should_consume); void parse_capability_response(); -- cgit v1.2.3