summaryrefslogtreecommitdiff
path: root/core/include/fxcrt/fx_string.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-05-06 16:17:06 -0700
committerTom Sepez <tsepez@chromium.org>2015-05-06 16:17:06 -0700
commitdd995a3d20de128ff1e3143a531beed0c90d65c1 (patch)
tree07a5b3671a640b40673b6a7fb619eafeba47b211 /core/include/fxcrt/fx_string.h
parent996bf1f2ba1bf89c53fca14cf2d171a5528f6183 (diff)
downloadpdfium-dd995a3d20de128ff1e3143a531beed0c90d65c1.tar.xz
Merge to XFA:Remove FX_STRSIZE casts, use safe conversions
Original Review URL: https://codereview.chromium.org/1124043003 BUG=pdfium:153 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1132443002
Diffstat (limited to 'core/include/fxcrt/fx_string.h')
-rw-r--r--core/include/fxcrt/fx_string.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index fe0985772d..8bb29dabd6 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -11,12 +11,12 @@
#include <algorithm>
#include "fx_memory.h"
+#include "fx_system.h"
class CFX_BinaryBuf;
class CFX_ByteString;
class CFX_WideString;
struct CFX_CharMap;
-typedef int FX_STRSIZE;
// An immutable string with caller-provided storage which must outlive the
// string itself.
@@ -40,7 +40,7 @@ public:
CFX_ByteStringC(FX_LPCSTR ptr)
{
m_Ptr = (FX_LPCBYTE)ptr;
- m_Length = ptr ? (FX_STRSIZE)FXSYS_strlen(ptr) : 0;
+ m_Length = ptr ? FXSYS_strlen(ptr) : 0;
}
// |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
@@ -59,11 +59,7 @@ public:
CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
{
m_Ptr = (FX_LPCBYTE)ptr;
- if (len == -1) {
- m_Length = (FX_STRSIZE)FXSYS_strlen(ptr);
- } else {
- m_Length = len;
- }
+ m_Length = (len == -1) ? FXSYS_strlen(ptr) : len;
}
CFX_ByteStringC(const CFX_ByteStringC& src)
@@ -77,7 +73,7 @@ public:
CFX_ByteStringC& operator = (FX_LPCSTR src)
{
m_Ptr = (FX_LPCBYTE)src;
- m_Length = m_Ptr ? (FX_STRSIZE)FXSYS_strlen(src) : 0;
+ m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
return *this;
}
@@ -91,7 +87,7 @@ public:
CFX_ByteStringC& operator = (const CFX_ByteString& src);
bool operator== (const char* ptr) const {
- return (FX_STRSIZE)FXSYS_strlen(ptr) == m_Length &&
+ return FXSYS_strlen(ptr) == m_Length &&
FXSYS_memcmp32(ptr, m_Ptr, m_Length) == 0;
}
bool operator== (const CFX_ByteStringC& other) const {
@@ -466,7 +462,7 @@ public:
CFX_WideStringC(FX_LPCWSTR ptr)
{
m_Ptr = ptr;
- m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
+ m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
}
CFX_WideStringC(FX_WCHAR& ch)
@@ -478,11 +474,7 @@ public:
CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
{
m_Ptr = ptr;
- if (len == -1) {
- m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
- } else {
- m_Length = len;
- }
+ m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len;
}
CFX_WideStringC(const CFX_WideStringC& src)
@@ -496,7 +488,7 @@ public:
CFX_WideStringC& operator = (FX_LPCWSTR src)
{
m_Ptr = src;
- m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
+ m_Length = FXSYS_wcslen(src);
return *this;
}
@@ -510,7 +502,7 @@ public:
CFX_WideStringC& operator = (const CFX_WideString& src);
bool operator== (const wchar_t* ptr) const {
- return (FX_STRSIZE)FXSYS_wcslen(ptr) == m_Length &&
+ return FXSYS_wcslen(ptr) == m_Length &&
wmemcmp(ptr, m_Ptr, m_Length) == 0;
}
bool operator== (const CFX_WideStringC& str) const {