mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibGfx/PortableFormat: Make read_comment
return an ErrorOr
This commit is contained in:
parent
964172754e
commit
74f893e9f4
1 changed files with 5 additions and 4 deletions
|
@ -53,7 +53,7 @@ static inline ErrorOr<u16> read_number(Streamer& streamer)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TContext>
|
template<typename TContext>
|
||||||
static bool read_comment([[maybe_unused]] TContext& context, Streamer& streamer)
|
static ErrorOr<void> read_comment([[maybe_unused]] TContext& context, Streamer& streamer)
|
||||||
{
|
{
|
||||||
bool is_first_char = true;
|
bool is_first_char = true;
|
||||||
u8 byte {};
|
u8 byte {};
|
||||||
|
@ -61,14 +61,14 @@ static bool read_comment([[maybe_unused]] TContext& context, Streamer& streamer)
|
||||||
while (streamer.read(byte)) {
|
while (streamer.read(byte)) {
|
||||||
if (is_first_char) {
|
if (is_first_char) {
|
||||||
if (byte != '#')
|
if (byte != '#')
|
||||||
return false;
|
return Error::from_string_literal("Can't read comment from stream");
|
||||||
is_first_char = false;
|
is_first_char = false;
|
||||||
} else if (byte == '\t' || byte == '\n') {
|
} else if (byte == '\t' || byte == '\n') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TContext>
|
template<typename TContext>
|
||||||
|
@ -119,7 +119,8 @@ static bool read_whitespace(TContext& context, Streamer& streamer)
|
||||||
exist = true;
|
exist = true;
|
||||||
} else if (byte == '#') {
|
} else if (byte == '#') {
|
||||||
streamer.step_back();
|
streamer.step_back();
|
||||||
read_comment(context, streamer);
|
if (read_comment(context, streamer).is_error())
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
streamer.step_back();
|
streamer.step_back();
|
||||||
return exist;
|
return exist;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue