diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-01-27 09:47:45 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-01-27 09:47:45 -0800 |
commit | eef005055d6aafc2cc6066af37ce47d8b15ec7cd (patch) | |
tree | ab47aecac44e920d06b0d5e5aac6e15ad316a827 /core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | |
parent | a03932372b0906a340a6e3860c87e45f9ec79042 (diff) | |
download | pdfium-eef005055d6aafc2cc6066af37ce47d8b15ec7cd.tar.xz |
Kill scattered extern _PDF_CharType declarations.chromium/2292chromium/2291chromium/2290
While we're at it, avoid an indirection through a pointer, and
use a name that isn't reserved for the compiler (leading _ CAP).
This is a small portion of the associated bug:
BUG=https://code.google.com/p/pdfium/issues/detail?id=112
R=brucedawson@chromium.org
Review URL: https://codereview.chromium.org/880663003
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp')
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index e5e68c2f5c..bbfd4cc680 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -5,15 +5,41 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fpdfapi/fpdf_parser.h" -extern const FX_LPCSTR _PDF_CharType = - "WRRRRRRRRWWRWWRRRRRRRRRRRRRRRRRR" - "WRRRRDRRDDRNRNNDNNNNNNNNNNRRDRDR" - "RRRRRRRRRRRRRRRRRRRRRRRRRRRDRDRR" - "RRRRRRRRRRRRRRRRRRRRRRRRRRRDRDRR" - "WRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR" - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRW"; +const char PDF_CharType[256] = { + //NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI + 'W', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W', 'W', 'R', 'W', 'W', 'R', 'R', + + //DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + + //SP ! " # $ % & ยด ( ) * + , - . / + 'W', 'R', 'R', 'R', 'R', 'D', 'R', 'R', 'D', 'D', 'R', 'N', 'R', 'N', 'N', 'D', + + // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? + 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'R', 'R', 'D', 'R', 'D', 'R', + + // @ A B C D E F G H I J K L M N O + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + + // P Q R S T U V W X Y Z [ \ ] ^ _ + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'D', 'R', 'D', 'R', 'R', + + // ` a b c d e f g h i j k l m n o + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + + // p q r s t u v w x y z { | } ~ DEL + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'D', 'R', 'D', 'R', 'R', + + 'W', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W' +}; + #ifndef MAX_PATH #define MAX_PATH 4096 #endif @@ -41,13 +67,13 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ return; } ch = m_pData[m_dwCurPos++]; - chartype = _PDF_CharType[ch]; + chartype = PDF_CharType[ch]; while (chartype == 'W') { if (m_dwSize <= m_dwCurPos) { return; } ch = m_pData[m_dwCurPos++]; - chartype = _PDF_CharType[ch]; + chartype = PDF_CharType[ch]; } if (ch != '%') { break; @@ -61,7 +87,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ break; } } - chartype = _PDF_CharType[ch]; + chartype = PDF_CharType[ch]; } FX_DWORD start_pos = m_dwCurPos - 1; pStart = m_pData + start_pos; @@ -72,7 +98,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ return; } ch = m_pData[m_dwCurPos++]; - chartype = _PDF_CharType[ch]; + chartype = PDF_CharType[ch]; if (chartype != 'R' && chartype != 'N') { m_dwCurPos --; dwSize = m_dwCurPos - start_pos; @@ -117,7 +143,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ return; } ch = m_pData[m_dwCurPos++]; - chartype = _PDF_CharType[ch]; + chartype = PDF_CharType[ch]; if (chartype == 'D' || chartype == 'W') { m_dwCurPos --; break; @@ -297,8 +323,8 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) int i; for (i = 0; i < src_len; i ++) { FX_BYTE ch = src_buf[i]; - if (ch >= 0x80 || _PDF_CharType[ch] == 'W' || ch == '#' || - _PDF_CharType[ch] == 'D') { + if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' || + PDF_CharType[ch] == 'D') { dest_len += 3; } else { dest_len ++; @@ -312,8 +338,8 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) dest_len = 0; for (i = 0; i < src_len; i ++) { FX_BYTE ch = src_buf[i]; - if (ch >= 0x80 || _PDF_CharType[ch] == 'W' || ch == '#' || - _PDF_CharType[ch] == 'D') { + if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' || + PDF_CharType[ch] == 'D') { dest_buf[dest_len++] = '#'; dest_buf[dest_len++] = "0123456789ABCDEF"[ch / 16]; dest_buf[dest_len++] = "0123456789ABCDEF"[ch % 16]; |