diff --git a/Userland/Libraries/LibPDF/Reader.cpp b/Userland/Libraries/LibPDF/Reader.cpp index d36e9e1560..49886448fc 100644 --- a/Userland/Libraries/LibPDF/Reader.cpp +++ b/Userland/Libraries/LibPDF/Reader.cpp @@ -15,9 +15,14 @@ bool Reader::is_eol(char c) } bool Reader::is_whitespace(char c) +{ + return is_eol(c) || is_non_eol_whitespace(c); +} + +bool Reader::is_non_eol_whitespace(char c) { // 3.1.1 Character Set - return is_eol(c) || c == 0 || c == 0x9 || c == 0xc || c == ' '; + return c == 0 || c == 0x9 || c == 0xc || c == ' '; } bool Reader::matches_eol() const @@ -30,6 +35,11 @@ bool Reader::matches_whitespace() const return !done() && is_whitespace(peek()); } +bool Reader::matches_non_eol_whitespace() const +{ + return !done() && is_non_eol_whitespace(peek()); +} + bool Reader::matches_number() const { if (done()) @@ -74,6 +84,16 @@ bool Reader::consume_whitespace() return consumed; } +bool Reader::consume_non_eol_whitespace() +{ + bool consumed = false; + while (matches_non_eol_whitespace()) { + consumed = true; + consume(); + } + return consumed; +} + char Reader::consume() { return read(); diff --git a/Userland/Libraries/LibPDF/Reader.h b/Userland/Libraries/LibPDF/Reader.h index 17b9c9543f..886769775d 100644 --- a/Userland/Libraries/LibPDF/Reader.h +++ b/Userland/Libraries/LibPDF/Reader.h @@ -133,15 +133,18 @@ public: static bool is_eol(char); static bool is_whitespace(char); + static bool is_non_eol_whitespace(char); bool matches_eol() const; bool matches_whitespace() const; + bool matches_non_eol_whitespace() const; bool matches_number() const; bool matches_delimiter() const; bool matches_regular_character() const; bool consume_eol(); bool consume_whitespace(); + bool consume_non_eol_whitespace(); char consume(); void consume(int amount); bool consume(char);