diff --git a/Userland/Libraries/LibPDF/Reader.cpp b/Userland/Libraries/LibPDF/Reader.cpp index c9fc720384..d36e9e1560 100644 --- a/Userland/Libraries/LibPDF/Reader.cpp +++ b/Userland/Libraries/LibPDF/Reader.cpp @@ -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 diff --git a/Userland/Libraries/LibPDF/Reader.h b/Userland/Libraries/LibPDF/Reader.h index 97e6a21bd8..3df2d0e5d7 100644 --- a/Userland/Libraries/LibPDF/Reader.h +++ b/Userland/Libraries/LibPDF/Reader.h @@ -131,6 +131,9 @@ public: move_until([&predicate](char t) { return !predicate(t); }); } + static bool is_eol(char); + static bool is_whitespace(char); + bool matches_eol() const; bool matches_whitespace() const; bool matches_number() const;