Give a couple of char to int functions better names.

- 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>
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index 6c48098..4702947 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -142,12 +142,12 @@
   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 @@
     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 51e7957..001e8ac 100644
--- a/core/fpdfapi/font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/font/fpdf_font_cid.cpp
@@ -441,7 +441,7 @@
   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 @@
   }
 
   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 @@
   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 @@
     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 76b58c9..e8116cf 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -500,7 +500,7 @@
         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 @@
       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 @@
       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 @@
     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 12ec81b..a3e5dba 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -144,13 +144,13 @@
     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 @@
           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 @@
 
         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 @@
           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 @@
 
         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 @@
             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 e41736d..5da696e 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -225,7 +225,7 @@
         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 @@
       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 @@
         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 @@
       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 306e6fe..c521c20 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -174,7 +174,7 @@
     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 d953d4c..1edf577 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -97,8 +97,8 @@
   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];
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp
index 08f4168..ef6aaad 100644
--- a/core/fxcrt/cfx_widestring.cpp
+++ b/core/fxcrt/cfx_widestring.cpp
@@ -1025,7 +1025,7 @@
     if (str[cc] == '.') {
       break;
     }
-    integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]);
+    integer = integer * 10 + FXSYS_DecimalCharToInt(str[cc]);
     cc++;
   }
   float fraction = 0;
@@ -1033,7 +1033,7 @@
     cc++;
     float scale = 0.1f;
     while (cc < len) {
-      fraction += scale * FXSYS_toDecimalDigit(str[cc]);
+      fraction += scale * FXSYS_DecimalCharToInt(str[cc]);
       scale *= 0.1f;
       cc++;
     }
diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp
index 8a65576..87c2533 100644
--- a/core/fxcrt/fx_basic_gcc.cpp
+++ b/core/fxcrt/fx_basic_gcc.cpp
@@ -23,7 +23,7 @@
 
   IntType num = 0;
   while (*str && FXSYS_isDecimalDigit(*str)) {
-    IntType val = FXSYS_toDecimalDigit(*str);
+    IntType val = FXSYS_DecimalCharToInt(*str);
     if (num > (std::numeric_limits<IntType>::max() - val) / 10) {
       if (neg && std::numeric_limits<IntType>::is_signed) {
         // Return MIN when the represented number is signed type and is smaller
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index ee3e9e7..aef623c 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -39,7 +39,7 @@
   }
 
   while (cc < strc.GetLength() && std::isdigit(strc[cc])) {
-    integer = integer * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc));
+    integer = integer * 10 + FXSYS_DecimalCharToInt(strc.CharAt(cc));
     if (!integer.IsValid())
       break;
     cc++;
@@ -105,7 +105,7 @@
   while (cc < len) {
     if (strc[cc] == '.')
       break;
-    value = value * 10 + FXSYS_toDecimalDigit(strc.CharAt(cc));
+    value = value * 10 + FXSYS_DecimalCharToInt(strc.CharAt(cc));
     cc++;
   }
   int scale = 0;
@@ -113,7 +113,7 @@
     cc++;
     while (cc < len) {
       value +=
-          FXSYS_FractionalScale(scale, FXSYS_toDecimalDigit(strc.CharAt(cc)));
+          FXSYS_FractionalScale(scale, FXSYS_DecimalCharToInt(strc.CharAt(cc)));
       scale++;
       if (scale == FXSYS_FractionalScaleCount())
         break;
diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
index beda105..f55153c 100644
--- a/core/fxcrt/fx_extension.h
+++ b/core/fxcrt/fx_extension.h
@@ -53,7 +53,7 @@
   return !((c & 0x80) || !std::isxdigit(c));
 }
 
-inline int FXSYS_toHexDigit(const char c) {
+inline int FXSYS_HexCharToInt(const char c) {
   if (!FXSYS_isHexDigit(c))
     return 0;
   char upchar = std::toupper(c);
@@ -68,11 +68,11 @@
   return !!std::iswdigit(c);
 }
 
-inline int FXSYS_toDecimalDigit(const char c) {
+inline int FXSYS_DecimalCharToInt(const char c) {
   return FXSYS_isDecimalDigit(c) ? c - '0' : 0;
 }
 
-inline int FXSYS_toDecimalDigit(const wchar_t c) {
+inline int FXSYS_DecimalCharToInt(const wchar_t c) {
   return std::iswdigit(c) ? c - L'0' : 0;
 }
 
diff --git a/core/fxcrt/fx_extension_unittest.cpp b/core/fxcrt/fx_extension_unittest.cpp
index 4e4294c..1bc3ec6 100644
--- a/core/fxcrt/fx_extension_unittest.cpp
+++ b/core/fxcrt/fx_extension_unittest.cpp
@@ -5,18 +5,18 @@
 #include "core/fxcrt/fx_extension.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
-TEST(fxcrt, FXSYS_toHexDigit) {
-  EXPECT_EQ(10, FXSYS_toHexDigit('a'));
-  EXPECT_EQ(10, FXSYS_toHexDigit('A'));
-  EXPECT_EQ(7, FXSYS_toHexDigit('7'));
-  EXPECT_EQ(0, FXSYS_toHexDigit('i'));
+TEST(fxcrt, FXSYS_HexCharToInt) {
+  EXPECT_EQ(10, FXSYS_HexCharToInt('a'));
+  EXPECT_EQ(10, FXSYS_HexCharToInt('A'));
+  EXPECT_EQ(7, FXSYS_HexCharToInt('7'));
+  EXPECT_EQ(0, FXSYS_HexCharToInt('i'));
 }
 
-TEST(fxcrt, FXSYS_toDecimalDigit) {
-  EXPECT_EQ(7, FXSYS_toDecimalDigit('7'));
-  EXPECT_EQ(0, FXSYS_toDecimalDigit('a'));
-  EXPECT_EQ(7, FXSYS_toDecimalDigit(L'7'));
-  EXPECT_EQ(0, FXSYS_toDecimalDigit(L'a'));
+TEST(fxcrt, FXSYS_DecimalCharToInt) {
+  EXPECT_EQ(7, FXSYS_DecimalCharToInt('7'));
+  EXPECT_EQ(0, FXSYS_DecimalCharToInt('a'));
+  EXPECT_EQ(7, FXSYS_DecimalCharToInt(L'7'));
+  EXPECT_EQ(0, FXSYS_DecimalCharToInt(L'a'));
 }
 
 TEST(fxcrt, FXSYS_isDecimalDigit) {
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index dc3978e..3c91d74 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -244,7 +244,7 @@
             break;
           }
           if (g_FXCRT_XML_IsDigital(ch))
-            code = code * 10 + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+            code = code * 10 + FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch));
           break;
         case 4:
           m_dwIndex++;
@@ -256,8 +256,8 @@
               g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar;
           if (nHex) {
             if (nHex == FXCRTM_XML_CHARTYPE_HexDigital) {
-              code =
-                  (code << 4) + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch));
+              code = (code << 4) +
+                     FXSYS_DecimalCharToInt(static_cast<wchar_t>(ch));
             } else if (nHex == FXCRTM_XML_CHARTYPE_HexLowerLetter) {
               code = (code << 4) + ch - 87;
             } else {
diff --git a/fpdfsdk/cpdfsdk_datetime.cpp b/fpdfsdk/cpdfsdk_datetime.cpp
index 47c764c..d2653fc 100644
--- a/fpdfsdk/cpdfsdk_datetime.cpp
+++ b/fpdfsdk/cpdfsdk_datetime.cpp
@@ -146,7 +146,7 @@
   char ch;
   while (i < strLength && j < 4) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -160,7 +160,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -174,7 +174,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -188,7 +188,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -202,7 +202,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -216,7 +216,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -237,7 +237,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
@@ -253,7 +253,7 @@
   k = 0;
   while (i < strLength && j < 2) {
     ch = dtStr[i];
-    k = k * 10 + FXSYS_toDecimalDigit(ch);
+    k = k * 10 + FXSYS_DecimalCharToInt(ch);
     j++;
     if (!std::isdigit(ch))
       break;
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 759fd91..2efcacd 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -238,7 +238,7 @@
     if (!std::iswdigit(c))
       break;
 
-    nRet = nRet * 10 + FXSYS_toDecimalDigit(c);
+    nRet = nRet * 10 + FXSYS_DecimalCharToInt(c);
     nSkip = i - nStart + 1;
     if (nSkip >= nMaxStep)
       break;
diff --git a/xfa/fde/css/cfde_cssdeclaration.cpp b/xfa/fde/css/cfde_cssdeclaration.cpp
index 4de8cb7..4179e61 100644
--- a/xfa/fde/css/cfde_cssdeclaration.cpp
+++ b/xfa/fde/css/cfde_cssdeclaration.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 uint8_t Hex2Dec(uint8_t hexHigh, uint8_t hexLow) {
-  return (FXSYS_toHexDigit(hexHigh) << 4) + FXSYS_toHexDigit(hexLow);
+  return (FXSYS_HexCharToInt(hexHigh) << 4) + FXSYS_HexCharToInt(hexLow);
 }
 
 bool ParseCSSNumber(const wchar_t* pszValue,