diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-28 17:24:07 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-28 17:24:07 -0400 |
commit | 806af3a576ac4ce4d1979a225dcb49ae385000d3 (patch) | |
tree | 7fbb98d61c9b371f9bb48357d7cbfe22e3969713 /core/src | |
parent | 456b923e60071b10c5cd9a2a907f7c190d548942 (diff) | |
download | pdfium-806af3a576ac4ce4d1979a225dcb49ae385000d3.tar.xz |
Merge to XFA: Add PDFCharIsLineEnding helper
This CL adds a helper to check if a given character is a \n or \r.
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1418073006 .
(cherry picked from commit 4b38229b004b7b6493cb4c4507df450adc6085f6)
Review URL: https://codereview.chromium.org/1428763002 .
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 4 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 8 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 0e059f3fc5..1fa27e3805 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -490,7 +490,7 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() { return EndOfData; ch = m_pBuf[m_Pos++]; - if (ch == '\r' || ch == '\n') + if (PDFCharIsLineEnding(ch)) break; } } @@ -714,7 +714,7 @@ void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) { if (!PositionIsInBounds()) return; ch = m_pBuf[m_Pos++]; - if (ch == '\r' || ch == '\n') + if (PDFCharIsLineEnding(ch)) break; } } diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 1815d40194..255d0ce29c 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -80,9 +80,9 @@ FX_DWORD _A85Decode(const uint8_t* src_buf, pos = dest_size = 0; while (pos < src_size) { uint8_t ch = src_buf[pos++]; - if (ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t') { + if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t') continue; - } + if (ch == 'z') { FXSYS_memset(dest_buf + dest_size, 0, 4); state = 0; @@ -131,9 +131,9 @@ FX_DWORD _HexDecode(const uint8_t* src_buf, FX_BOOL bFirstDigit = TRUE; for (i = 0; i < src_size; i++) { uint8_t ch = src_buf[i]; - if (ch == ' ' || ch == '\n' || ch == '\t' || ch == '\r') { + if (PDFCharIsLineEnding(ch) || ch == ' ' || ch == '\t') continue; - } + int digit; if (ch <= '9' && ch >= '0') { digit = ch - '0'; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index e8842888c8..4ce196e90d 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -1780,7 +1780,7 @@ void CPDF_SyntaxParser::GetNextWord() { while (1) { if (!GetNextChar(ch)) return; - if (ch == '\r' || ch == '\n') + if (PDFCharIsLineEnding(ch)) break; } } @@ -1999,7 +1999,7 @@ void CPDF_SyntaxParser::ToNextWord() { while (1) { if (!GetNextChar(ch)) return; - if (ch == '\r' || ch == '\n') + if (PDFCharIsLineEnding(ch)) break; } } @@ -3767,7 +3767,7 @@ FX_BOOL CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { while (1) { if (!GetNextChar(ch)) return FALSE; - if (ch == '\r' || ch == '\n') + if (PDFCharIsLineEnding(ch)) break; } } |