diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-09-07 18:19:27 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-07 15:43:59 +0000 |
commit | 6f9b1d7eff38d503de231fc7260f012af774ce62 (patch) | |
tree | e17003d606d69a7dd1679910bf0e36156405f733 /core/fpdfapi/parser | |
parent | 38371fe908e14a1362d6e5a5bfa38bc5ea92daec (diff) | |
download | pdfium-6f9b1d7eff38d503de231fc7260f012af774ce62.tar.xz |
Implement CPDF_SyntaxParser::PeekNextWord.
Change-Id: I92c0bd417d9c5be59c36401efae89406e482756a
Reviewed-on: https://pdfium-review.googlesource.com/12650
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 5 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp | 9 |
3 files changed, 15 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index f7c79bc950..4a7810fc43 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -352,6 +352,11 @@ CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) { : CFX_ByteString((const char*)m_WordBuffer, m_WordSize); } +CFX_ByteString CPDF_SyntaxParser::PeekNextWord(bool* bIsNumber) { + const CFX_AutoRestorer<FX_FILESIZE> save_pos(&m_Pos); + return GetNextWord(bIsNumber); +} + CFX_ByteString CPDF_SyntaxParser::GetKeyword() { return GetNextWord(nullptr); } diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 88bbc5c9fa..179058edf8 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -65,6 +65,7 @@ class CPDF_SyntaxParser { bool ReadBlock(uint8_t* pBuf, uint32_t size); bool GetCharAt(FX_FILESIZE pos, uint8_t& ch); CFX_ByteString GetNextWord(bool* bIsNumber); + CFX_ByteString PeekNextWord(bool* bIsNumber); CFX_RetainPtr<IFX_SeekableReadStream> GetFileAccess() const; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp index ac7a875af6..6b54c70db6 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp @@ -155,3 +155,12 @@ TEST(cpdf_syntax_parser, GetInvalidReference) { parser.GetObject(nullptr, CPDF_Object::kInvalidObjNum, 0, false); EXPECT_FALSE(ref); } + +TEST(cpdf_syntax_parser, PeekNextWord) { + CPDF_SyntaxParser parser; + uint8_t data[] = " WORD "; + parser.InitParser( + pdfium::MakeRetain<CFX_MemoryStream>(data, sizeof(data), false), 0); + EXPECT_EQ("WORD", parser.PeekNextWord(nullptr)); + EXPECT_EQ("WORD", parser.GetNextWord(nullptr)); +} |