summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-04 12:13:55 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-04 22:39:39 +0000
commite8c1d4144e8407c0631116a954fa347dd39375ff (patch)
tree6a91c1197a5c183ce0cb7c792755d121dd1ca9b6 /core/fpdfapi
parent426b85af0f780e312221b061e2699c31821872f9 (diff)
downloadpdfium-e8c1d4144e8407c0631116a954fa347dd39375ff.tar.xz
Give a couple of char to int functions better names.chromium/3090
- FXSYS_toDecimalDigit() becomes FXSYS_DecimalCharToInt(). - FXSYS_toHexDigit() becomes FXSYS_HexCharToInt(). Change-Id: If4683e8f85f05124b92ff075056cbc295442087d Reviewed-on: https://pdfium-review.googlesource.com/4930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/fpdf_font.cpp6
-rw-r--r--core/fpdfapi/font/fpdf_font_cid.cpp11
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp18
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp8
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp2
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.cpp4
7 files changed, 30 insertions, 27 deletions
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index 6c48098c8a..4702947fd3 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -142,12 +142,12 @@ uint32_t CPDF_ToUnicodeMap::StringToCode(const CFX_ByteStringC& str) {
uint32_t result = 0;
if (str[0] == '<') {
for (int i = 1; i < len && std::isxdigit(str[i]); ++i)
- result = result * 16 + FXSYS_toHexDigit(str.CharAt(i));
+ result = result * 16 + FXSYS_HexCharToInt(str.CharAt(i));
return result;
}
for (int i = 0; i < len && std::isdigit(str[i]); ++i)
- result = result * 10 + FXSYS_toDecimalDigit(str.CharAt(i));
+ result = result * 10 + FXSYS_DecimalCharToInt(str.CharAt(i));
return result;
}
@@ -183,7 +183,7 @@ CFX_WideString CPDF_ToUnicodeMap::StringToWideString(
int byte_pos = 0;
wchar_t ch = 0;
for (int i = 1; i < len && std::isxdigit(str[i]); ++i) {
- ch = ch * 16 + FXSYS_toHexDigit(str[i]);
+ ch = ch * 16 + FXSYS_HexCharToInt(str[i]);
byte_pos++;
if (byte_pos == 4) {
result += ch;
diff --git a/core/fpdfapi/font/fpdf_font_cid.cpp b/core/fpdfapi/font/fpdf_font_cid.cpp
index 51e7957909..001e8acd57 100644
--- a/core/fpdfapi/font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/font/fpdf_font_cid.cpp
@@ -441,7 +441,7 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
pdfium::base::CheckedNumeric<uint32_t> num = 0;
if (word.GetAt(0) == '<') {
for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) {
- num = num * 16 + FXSYS_toHexDigit(word.GetAt(i));
+ num = num * 16 + FXSYS_HexCharToInt(word.GetAt(i));
if (!num.IsValid())
return 0;
}
@@ -449,7 +449,8 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
}
for (int i = 0; i < word.GetLength() && std::isdigit(word.GetAt(i)); ++i) {
- num = num * 10 + FXSYS_toDecimalDigit(static_cast<wchar_t>(word.GetAt(i)));
+ num =
+ num * 10 + FXSYS_DecimalCharToInt(static_cast<wchar_t>(word.GetAt(i)));
if (!num.IsValid())
return 0;
}
@@ -476,7 +477,8 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CMap_CodeRange& range,
for (i = 0; i < range.m_CharSize; ++i) {
uint8_t digit1 = first.GetAt(i * 2 + 1);
uint8_t digit2 = first.GetAt(i * 2 + 2);
- range.m_Lower[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2);
+ range.m_Lower[i] =
+ FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2);
}
uint32_t size = second.GetLength();
@@ -487,7 +489,8 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CMap_CodeRange& range,
uint8_t digit2 = ((uint32_t)i * 2 + 2 < size)
? second.GetAt((FX_STRSIZE)i * 2 + 2)
: '0';
- range.m_Upper[i] = FXSYS_toHexDigit(digit1) * 16 + FXSYS_toHexDigit(digit2);
+ range.m_Upper[i] =
+ FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2);
}
return true;
}
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index 76b58c9f4a..e8116cf980 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -500,7 +500,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
break;
case 1:
if (ch >= '0' && ch <= '7') {
- iEscCode = FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ iEscCode = FXSYS_DecimalCharToInt(static_cast<char>(ch));
status = 2;
break;
}
@@ -526,7 +526,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
case 2:
if (ch >= '0' && ch <= '7') {
iEscCode =
- iEscCode * 8 + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ iEscCode * 8 + FXSYS_DecimalCharToInt(static_cast<char>(ch));
status = 3;
} else {
buf.AppendChar(iEscCode);
@@ -537,7 +537,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() {
case 3:
if (ch >= '0' && ch <= '7') {
iEscCode =
- iEscCode * 8 + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ iEscCode * 8 + FXSYS_DecimalCharToInt(static_cast<char>(ch));
buf.AppendChar(iEscCode);
status = 0;
} else {
@@ -583,7 +583,7 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() {
if (!std::isxdigit(ch))
continue;
- int val = FXSYS_toHexDigit(ch);
+ int val = FXSYS_HexCharToInt(ch);
if (bFirst) {
code = val * 16;
} else {
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 12ec81bc07..a3e5dba40a 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -144,13 +144,13 @@ CPDF_Parser::Error CPDF_Parser::StartParse(
return FORMAT_ERROR;
if (std::isdigit(ch))
- m_FileVersion = FXSYS_toDecimalDigit(static_cast<wchar_t>(ch)) * 10;
+ m_FileVersion = FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch)) * 10;
if (!m_pSyntax->GetCharAt(7, ch))
return FORMAT_ERROR;
if (std::isdigit(ch))
- m_FileVersion += FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ m_FileVersion += FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch));
if (m_pSyntax->m_FileLen < m_pSyntax->m_HeaderOffset + 9)
return FORMAT_ERROR;
@@ -623,7 +623,7 @@ bool CPDF_Parser::RebuildCrossRef() {
if (std::isdigit(byte)) {
start_pos = pos + i;
state = ParserState::kObjNum;
- objnum = FXSYS_toDecimalDigit(static_cast<wchar_t>(byte));
+ objnum = FXSYS_DecimalCharToInt(static_cast<wchar_t>(byte));
} else if (byte == 't') {
state = ParserState::kTrailer;
inside_index = 1;
@@ -638,8 +638,8 @@ bool CPDF_Parser::RebuildCrossRef() {
case ParserState::kObjNum:
if (std::isdigit(byte)) {
- objnum =
- objnum * 10 + FXSYS_toDecimalDigit(static_cast<wchar_t>(byte));
+ objnum = objnum * 10 +
+ FXSYS_DecimalCharToInt(static_cast<wchar_t>(byte));
} else if (PDFCharIsWhitespace(byte)) {
state = ParserState::kPostObjNum;
} else {
@@ -653,7 +653,7 @@ bool CPDF_Parser::RebuildCrossRef() {
if (std::isdigit(byte)) {
start_pos1 = pos + i;
state = ParserState::kGenNum;
- gennum = FXSYS_toDecimalDigit(static_cast<wchar_t>(byte));
+ gennum = FXSYS_DecimalCharToInt(static_cast<wchar_t>(byte));
} else if (byte == 't') {
state = ParserState::kTrailer;
inside_index = 1;
@@ -665,8 +665,8 @@ bool CPDF_Parser::RebuildCrossRef() {
case ParserState::kGenNum:
if (std::isdigit(byte)) {
- gennum =
- gennum * 10 + FXSYS_toDecimalDigit(static_cast<wchar_t>(byte));
+ gennum = gennum * 10 +
+ FXSYS_DecimalCharToInt(static_cast<wchar_t>(byte));
} else if (PDFCharIsWhitespace(byte)) {
state = ParserState::kPostGenNum;
} else {
@@ -681,7 +681,7 @@ bool CPDF_Parser::RebuildCrossRef() {
inside_index = 1;
} else if (std::isdigit(byte)) {
objnum = gennum;
- gennum = FXSYS_toDecimalDigit(static_cast<wchar_t>(byte));
+ gennum = FXSYS_DecimalCharToInt(static_cast<wchar_t>(byte));
start_pos = start_pos1;
start_pos1 = pos + i;
state = ParserState::kGenNum;
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index e41736dd86..5da696e574 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -225,7 +225,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
break;
case ReadStatus::Backslash:
if (ch >= '0' && ch <= '7') {
- iEscCode = FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ iEscCode = FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch));
status = ReadStatus::Octal;
break;
}
@@ -251,7 +251,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
case ReadStatus::Octal:
if (ch >= '0' && ch <= '7') {
iEscCode =
- iEscCode * 8 + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ iEscCode * 8 + FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch));
status = ReadStatus::FinishOctal;
} else {
buf.AppendChar(iEscCode);
@@ -263,7 +263,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() {
status = ReadStatus::Normal;
if (ch >= '0' && ch <= '7') {
iEscCode =
- iEscCode * 8 + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+ iEscCode * 8 + FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch));
buf.AppendChar(iEscCode);
} else {
buf.AppendChar(iEscCode);
@@ -298,7 +298,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() {
break;
if (std::isxdigit(ch)) {
- int val = FXSYS_toHexDigit(ch);
+ int val = FXSYS_HexCharToInt(ch);
if (bFirst) {
code = val * 16;
} else {
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 306e6fe3ac..c521c20665 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -174,7 +174,7 @@ uint32_t HexDecode(const uint8_t* src_buf,
if (!std::isxdigit(ch))
continue;
- int digit = FXSYS_toHexDigit(ch);
+ int digit = FXSYS_HexCharToInt(ch);
if (bFirst)
dest_buf[dest_size] = digit * 16;
else
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index d953d4c3e8..1edf577c5b 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -97,8 +97,8 @@ CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
char* pDest = pDestStart;
for (int i = 0; i < size; i++) {
if (bstr[i] == '#' && i < size - 2) {
- *pDest++ =
- FXSYS_toHexDigit(bstr[i + 1]) * 16 + FXSYS_toHexDigit(bstr[i + 2]);
+ *pDest++ = FXSYS_HexCharToInt(bstr[i + 1]) * 16 +
+ FXSYS_HexCharToInt(bstr[i + 2]);
i += 2;
} else {
*pDest++ = bstr[i];