mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibIMAP: Rename IMAP::Parser::{parse => consume}_while()
This isn't parsing anything.
This commit is contained in:
parent
6502d79240
commit
8c05b4e137
2 changed files with 14 additions and 14 deletions
|
@ -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<String>() : Optional<String>(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<unsigned>(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<T> 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<bool(u8)> should_consume)
|
||||
StringView Parser::consume_while(Function<bool(u8)> should_consume)
|
||||
{
|
||||
int chars = 0;
|
||||
while (!at_end() && should_consume(m_buffer[position])) {
|
||||
|
@ -689,13 +689,13 @@ StringView Parser::parse_while(Function<bool(u8)> 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<String>();
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
void parse_response_done();
|
||||
|
||||
void consume(StringView x);
|
||||
StringView consume_while(Function<bool(u8)> should_consume);
|
||||
|
||||
unsigned parse_number();
|
||||
Optional<unsigned> try_parse_number();
|
||||
|
@ -54,7 +55,6 @@ private:
|
|||
|
||||
static MailboxFlag parse_mailbox_flag(StringView s);
|
||||
|
||||
StringView parse_while(Function<bool(u8)> should_consume);
|
||||
|
||||
void parse_capability_response();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue