diff options
author | Lei Zhang <thestig@chromium.org> | 2017-05-04 12:13:55 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-04 22:39:39 +0000 |
commit | e8c1d4144e8407c0631116a954fa347dd39375ff (patch) | |
tree | 6a91c1197a5c183ce0cb7c792755d121dd1ca9b6 /core/fxcrt | |
parent | 426b85af0f780e312221b061e2699c31821872f9 (diff) | |
download | pdfium-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/fxcrt')
-rw-r--r-- | core/fxcrt/cfx_widestring.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_gcc.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_util.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.h | 6 | ||||
-rw-r--r-- | core/fxcrt/fx_extension_unittest.cpp | 20 | ||||
-rw-r--r-- | core/fxcrt/xml/cxml_parser.cpp | 6 |
6 files changed, 22 insertions, 22 deletions
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp index 08f41681a4..ef6aaad931 100644 --- a/core/fxcrt/cfx_widestring.cpp +++ b/core/fxcrt/cfx_widestring.cpp @@ -1025,7 +1025,7 @@ float FX_wtof(const wchar_t* str, int len) { 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 @@ float FX_wtof(const wchar_t* str, int len) { 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 8a65576b39..87c2533ab8 100644 --- a/core/fxcrt/fx_basic_gcc.cpp +++ b/core/fxcrt/fx_basic_gcc.cpp @@ -23,7 +23,7 @@ IntType FXSYS_StrToInt(const CharType* str) { 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 ee3e9e7fd5..aef623ce92 100644 --- a/core/fxcrt/fx_basic_util.cpp +++ b/core/fxcrt/fx_basic_util.cpp @@ -39,7 +39,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) { } 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 @@ float FX_atof(const CFX_ByteStringC& strc) { 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 @@ float FX_atof(const CFX_ByteStringC& strc) { 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 beda105909..f55153c0ad 100644 --- a/core/fxcrt/fx_extension.h +++ b/core/fxcrt/fx_extension.h @@ -53,7 +53,7 @@ inline bool FXSYS_isHexDigit(const char c) { 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 @@ inline bool FXSYS_isDecimalDigit(const wchar_t c) { 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 4e4294c7ce..1bc3ec6298 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 dc3978e2d2..3c91d744ec 100644 --- a/core/fxcrt/xml/cxml_parser.cpp +++ b/core/fxcrt/xml/cxml_parser.cpp @@ -244,7 +244,7 @@ uint32_t CXML_Parser::GetCharRef() { 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 @@ uint32_t CXML_Parser::GetCharRef() { 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 { |