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

LibPDF: Implement Reader::is_[eol, whitespace](char)

These two static members are now used to implement respective `matches_`
methods but will also be useful to provide a global implementation of
the specified concept of whitespace.
This commit is contained in:
Lucas CHOLLET 2023-11-13 22:46:42 -05:00 committed by Andreas Kling
parent dac703a0b8
commit db08fe12ec
2 changed files with 16 additions and 2 deletions

View file

@ -9,14 +9,25 @@
namespace PDF {
bool Reader::is_eol(char c)
{
return c == 0xa || c == 0xd;
}
bool Reader::is_whitespace(char c)
{
// 3.1.1 Character Set
return is_eol(c) || c == 0 || c == 0x9 || c == 0xc || c == ' ';
}
bool Reader::matches_eol() const
{
return matches_any(0xa, 0xd);
return !done() && is_eol(peek());
}
bool Reader::matches_whitespace() const
{
return matches_eol() || matches_any(0, 0x9, 0xc, ' ');
return !done() && is_whitespace(peek());
}
bool Reader::matches_number() const