diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-09-27 11:07:51 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-27 16:18:11 +0000 |
commit | 8b1408e7053247def45659515cda19a64a7fccd5 (patch) | |
tree | f3dfb5ebd24fb4993c6b915917b97250b3739555 /core/fxcrt | |
parent | bacf75eeeb5d89fe60b2c77584350ca1b1432bd5 (diff) | |
download | pdfium-8b1408e7053247def45659515cda19a64a7fccd5.tar.xz |
Remove FXSYS_strlen and FXSYS_wcslenchromium/3226
With the conversion of internal string sizes to size_t, these wrappers
are no longer needed. Replacing them with strlen and wcslen
respectively.
BUG=pdfium:828
Change-Id: Ia087ca2ddaf688a57ec9bd9ddfb8533cbe41510d
Reviewed-on: https://pdfium-review.googlesource.com/14890
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/bytestring.cpp | 8 | ||||
-rw-r--r-- | core/fxcrt/bytestring.h | 2 | ||||
-rw-r--r-- | core/fxcrt/bytestring_unittest.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/cfx_widetextbuf.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/css/cfx_cssstylesheet_unittest.cpp | 14 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_string.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_system.h | 10 | ||||
-rw-r--r-- | core/fxcrt/widestring.cpp | 16 | ||||
-rw-r--r-- | core/fxcrt/widestring.h | 2 | ||||
-rw-r--r-- | core/fxcrt/widestring_unittest.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlnode.cpp | 2 |
12 files changed, 30 insertions, 36 deletions
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index 3079eb7b72..37121a7da9 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -116,7 +116,7 @@ ByteString::ByteString(char ch) { } ByteString::ByteString(const char* ptr) - : ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {} + : ByteString(ptr, ptr ? strlen(ptr) : 0) {} ByteString::ByteString(const ByteStringView& stringSrc) { if (!stringSrc.IsEmpty()) @@ -169,7 +169,7 @@ const ByteString& ByteString::operator=(const char* pStr) { if (!pStr || !pStr[0]) clear(); else - AssignCopy(pStr, FXSYS_strlen(pStr)); + AssignCopy(pStr, strlen(pStr)); return *this; } @@ -192,7 +192,7 @@ const ByteString& ByteString::operator=(const ByteString& stringSrc) { const ByteString& ByteString::operator+=(const char* pStr) { if (pStr) - Concat(pStr, FXSYS_strlen(pStr)); + Concat(pStr, strlen(pStr)); return *this; } @@ -223,7 +223,7 @@ bool ByteString::operator==(const char* ptr) const { if (!ptr) return m_pData->m_nDataLength == 0; - return FXSYS_strlen(ptr) == m_pData->m_nDataLength && + return strlen(ptr) == m_pData->m_nDataLength && memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; } diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index 2b01bc19aa..67fdd1d9ac 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -93,7 +93,7 @@ class ByteString { size_t GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } size_t GetStringLength() const { - return m_pData ? FXSYS_strlen(m_pData->m_String) : 0; + return m_pData ? strlen(m_pData->m_String) : 0; } bool IsEmpty() const { return !GetLength(); } bool IsValidIndex(size_t index) const { return index < GetLength(); } diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index d3597ad421..ed20abcc8e 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -1421,7 +1421,7 @@ TEST(ByteString, Empty) { EXPECT_TRUE(empty_str.IsEmpty()); EXPECT_EQ(0u, empty_str.GetLength()); const char* cstr = empty_str.c_str(); - EXPECT_EQ(0u, FXSYS_strlen(cstr)); + EXPECT_EQ(0u, strlen(cstr)); } TEST(ByteString, InitializerList) { diff --git a/core/fxcrt/cfx_widetextbuf.cpp b/core/fxcrt/cfx_widetextbuf.cpp index 08e4921560..a9b59b5ff8 100644 --- a/core/fxcrt/cfx_widetextbuf.cpp +++ b/core/fxcrt/cfx_widetextbuf.cpp @@ -29,7 +29,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const WideString& str) { CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) { char buf[32]; FXSYS_itoa(i, buf, 10); - size_t len = FXSYS_strlen(buf); + size_t len = strlen(buf); ExpandBuf(len * sizeof(wchar_t)); wchar_t* str = (wchar_t*)(m_pBuffer.get() + m_DataSize); for (size_t j = 0; j < len; j++) { @@ -52,7 +52,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) { } CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const wchar_t* lpsz) { - AppendBlock(lpsz, FXSYS_wcslen(lpsz) * sizeof(wchar_t)); + AppendBlock(lpsz, wcslen(lpsz) * sizeof(wchar_t)); return *this; } diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp index 30298243bc..baa002b05c 100644 --- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp +++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp @@ -32,7 +32,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { size_t decl_count) { ASSERT(sheet_); - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(sheet_->CountRules(), 1); CFX_CSSStyleRule* style = sheet_->GetRule(0); @@ -89,7 +89,7 @@ class CFX_CSSStyleSheetTest : public testing::Test { TEST_F(CFX_CSSStyleSheetTest, ParseMultipleSelectors) { const wchar_t* buf = L"a { border: 10px; }\nb { text-decoration: underline; }"; - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(2, sheet_->CountRules()); CFX_CSSStyleRule* style = sheet_->GetRule(0); @@ -137,7 +137,7 @@ TEST_F(CFX_CSSStyleSheetTest, ParseMultipleSelectors) { TEST_F(CFX_CSSStyleSheetTest, ParseChildSelectors) { const wchar_t* buf = L"a b c { border: 10px; }"; - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(1, sheet_->CountRules()); CFX_CSSStyleRule* style = sheet_->GetRule(0); @@ -172,19 +172,19 @@ TEST_F(CFX_CSSStyleSheetTest, ParseChildSelectors) { TEST_F(CFX_CSSStyleSheetTest, ParseUnhandledSelectors) { const wchar_t* buf = L"a > b { padding: 0; }"; - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(0, sheet_->CountRules()); buf = L"a[first] { padding: 0; }"; - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(0, sheet_->CountRules()); buf = L"a+b { padding: 0; }"; - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(0, sheet_->CountRules()); buf = L"a ^ b { padding: 0; }"; - EXPECT_TRUE(sheet_->LoadBuffer(buf, FXSYS_wcslen(buf))); + EXPECT_TRUE(sheet_->LoadBuffer(buf, wcslen(buf))); EXPECT_EQ(0, sheet_->CountRules()); } diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 4d0adb86ca..62cf8a0e04 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -12,7 +12,7 @@ float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pwsStr); if (iLength < 0) - iLength = static_cast<int32_t>(FXSYS_wcslen(pwsStr)); + iLength = static_cast<int32_t>(wcslen(pwsStr)); if (iLength == 0) return 0.0f; diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp index 233c5e64b7..13eb3a5bdd 100644 --- a/core/fxcrt/fx_string.cpp +++ b/core/fxcrt/fx_string.cpp @@ -214,7 +214,7 @@ size_t FX_ftoa(float d, char* buf) { } int i = scaled / scale; FXSYS_itoa(i, buf2, 10); - size_t len = FXSYS_strlen(buf2); + size_t len = strlen(buf2); memcpy(buf + buf_size, buf2, len); buf_size += len; int fraction = scaled % scale; diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h index 2c84b02238..aa9b8490f9 100644 --- a/core/fxcrt/fx_system.h +++ b/core/fxcrt/fx_system.h @@ -116,16 +116,13 @@ extern "C" { #include "third_party/base/numerics/safe_conversions.h" -#define FXSYS_strlen(ptr) (strlen(ptr)) -#define FXSYS_wcslen(ptr) (wcslen(ptr)) - // Overloaded functions for C++ templates inline size_t FXSYS_len(const char* ptr) { - return FXSYS_strlen(ptr); + return strlen(ptr); } inline size_t FXSYS_len(const wchar_t* ptr) { - return FXSYS_wcslen(ptr); + return wcslen(ptr); } inline int FXSYS_cmp(const char* ptr1, const char* ptr2, size_t len) { @@ -145,9 +142,6 @@ inline const wchar_t* FXSYS_chr(const wchar_t* ptr, wchar_t ch, size_t len) { } extern "C" { -#else -#define FXSYS_strlen(ptr) (strlen(ptr)) -#define FXSYS_wcslen(ptr) (wcslen(ptr)) #endif // __cplusplus #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index b9d6dc2080..adeb28cc16 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -135,7 +135,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat, case 's': { const wchar_t* pstrNextArg = va_arg(argList, const wchar_t*); if (pstrNextArg) { - nItemLen = FXSYS_wcslen(pstrNextArg); + nItemLen = wcslen(pstrNextArg); if (nItemLen < 1) { nItemLen = 1; } @@ -146,7 +146,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat, case 'S': { const char* pstrNextArg = va_arg(argList, const char*); if (pstrNextArg) { - nItemLen = FXSYS_strlen(pstrNextArg); + nItemLen = strlen(pstrNextArg); if (nItemLen < 1) { nItemLen = 1; } @@ -158,7 +158,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat, case 'S' | FORCE_ANSI: { const char* pstrNextArg = va_arg(argList, const char*); if (pstrNextArg) { - nItemLen = FXSYS_strlen(pstrNextArg); + nItemLen = strlen(pstrNextArg); if (nItemLen < 1) { nItemLen = 1; } @@ -170,7 +170,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat, case 'S' | FORCE_UNICODE: { const wchar_t* pstrNextArg = va_arg(argList, wchar_t*); if (pstrNextArg) { - nItemLen = FXSYS_wcslen(pstrNextArg); + nItemLen = wcslen(pstrNextArg); if (nItemLen < 1) { nItemLen = 1; } @@ -225,7 +225,7 @@ pdfium::Optional<size_t> GuessSizeForVSWPrintf(const wchar_t* pFormat, f = va_arg(argList, double); FXSYS_snprintf(pszTemp, sizeof(pszTemp), "%*.*f", nWidth, nPrecision + 6, f); - nItemLen = FXSYS_strlen(pszTemp); + nItemLen = strlen(pszTemp); } break; case 'p': @@ -304,7 +304,7 @@ WideString::WideString(wchar_t ch) { } WideString::WideString(const wchar_t* ptr) - : WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {} + : WideString(ptr, ptr ? wcslen(ptr) : 0) {} WideString::WideString(const WideStringView& stringSrc) { if (!stringSrc.IsEmpty()) { @@ -352,7 +352,7 @@ const WideString& WideString::operator=(const wchar_t* pStr) { if (!pStr || !pStr[0]) clear(); else - AssignCopy(pStr, FXSYS_wcslen(pStr)); + AssignCopy(pStr, wcslen(pStr)); return *this; } @@ -375,7 +375,7 @@ const WideString& WideString::operator=(const WideString& stringSrc) { const WideString& WideString::operator+=(const wchar_t* pStr) { if (pStr) - Concat(pStr, FXSYS_wcslen(pStr)); + Concat(pStr, wcslen(pStr)); return *this; } diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h index 73846e1be0..745fa5b2ab 100644 --- a/core/fxcrt/widestring.h +++ b/core/fxcrt/widestring.h @@ -91,7 +91,7 @@ class WideString { size_t GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } size_t GetStringLength() const { - return m_pData ? FXSYS_wcslen(m_pData->m_String) : 0; + return m_pData ? wcslen(m_pData->m_String) : 0; } bool IsEmpty() const { return !GetLength(); } bool IsValidIndex(size_t index) const { return index < GetLength(); } diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index 1f7219616d..7824c2bd72 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -1268,7 +1268,7 @@ TEST(WideString, Empty) { EXPECT_TRUE(empty_str.IsEmpty()); EXPECT_EQ(0u, empty_str.GetLength()); const wchar_t* cstr = empty_str.c_str(); - EXPECT_EQ(0u, FXSYS_wcslen(cstr)); + EXPECT_EQ(0u, wcslen(cstr)); } TEST(CFX_WidString, InitializerList) { diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index a1e3ac2740..4550d5b4ae 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -79,7 +79,7 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath, bool bQualifiedName) const { ASSERT(pPath); if (iLength < 0) { - iLength = FXSYS_wcslen(pPath); + iLength = wcslen(pPath); } if (iLength == 0) { return nullptr; |