diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-13 16:43:37 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-14 14:14:51 +0000 |
commit | 812e96c2b4c5908a1979da5e27cdcecda0d1dfc9 (patch) | |
tree | f0b0607f6b757eb22237527215094bd87b5d03ba /core/fxcrt | |
parent | 893822aa5b6254591f8e80fbffcbb4fa6ad849aa (diff) | |
download | pdfium-812e96c2b4c5908a1979da5e27cdcecda0d1dfc9.tar.xz |
Replace FX_CHAR and FX_WCHAR with underlying types.
Change-Id: I96e0a20d66b9184d22f64d8e4ce0dadd5a78c1e8
Reviewed-on: https://pdfium-review.googlesource.com/2967
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt')
25 files changed, 371 insertions, 382 deletions
diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h index 3bfcc915fb..3e3972ca92 100644 --- a/core/fxcrt/cfx_string_c_template.h +++ b/core/fxcrt/cfx_string_c_template.h @@ -164,7 +164,7 @@ inline bool operator!=(const T* lhs, const CFX_StringCTemplate<T>& rhs) { return rhs != lhs; } -extern template class CFX_StringCTemplate<FX_CHAR>; -extern template class CFX_StringCTemplate<FX_WCHAR>; +extern template class CFX_StringCTemplate<char>; +extern template class CFX_StringCTemplate<wchar_t>; #endif // CORE_FXCRT_CFX_STRING_C_TEMPLATE_H_ diff --git a/core/fxcrt/cfx_string_data_template.h b/core/fxcrt/cfx_string_data_template.h index c3e090fef0..2e87a811a5 100644 --- a/core/fxcrt/cfx_string_data_template.h +++ b/core/fxcrt/cfx_string_data_template.h @@ -110,7 +110,7 @@ class CFX_StringDataTemplate { ~CFX_StringDataTemplate() = delete; }; -extern template class CFX_StringDataTemplate<FX_CHAR>; -extern template class CFX_StringDataTemplate<FX_WCHAR>; +extern template class CFX_StringDataTemplate<char>; +extern template class CFX_StringDataTemplate<wchar_t>; #endif // CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_ diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp index 11743e41ad..103271cd02 100644 --- a/core/fxcrt/fx_arabic.cpp +++ b/core/fxcrt/fx_arabic.cpp @@ -236,7 +236,7 @@ const int32_t gc_FX_BidiAddLevel[][4] = { }; const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC, - FX_WCHAR& wChar, + wchar_t& wChar, FX_CHARTYPE& eType) { if (!pTC) { eType = FX_CHARTYPE_Unknown; @@ -244,7 +244,7 @@ const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC, return nullptr; } eType = pTC->GetCharType(); - wChar = (FX_WCHAR)pTC->m_wCharCode; + wChar = (wchar_t)pTC->m_wCharCode; const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar); if (!pFT || eType >= FX_CHARTYPE_ArabicNormal) eType = FX_CHARTYPE_Unknown; @@ -254,13 +254,13 @@ const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC, } // namespace -const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode) { +const FX_ARBFORMTABLE* FX_GetArabicFormTable(wchar_t unicode) { if (unicode < 0x622 || unicode > 0x6d5) { return nullptr; } return g_FX_ArabicFormTables + unicode - 0x622; } -FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef) { +wchar_t FX_GetArabicFromAlefTable(wchar_t alef) { static const int32_t s_iAlefCount = sizeof(gs_FX_AlefTable) / sizeof(FX_ARAALEF); for (int32_t iStart = 0; iStart < s_iAlefCount; iStart++) { @@ -271,7 +271,7 @@ FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef) { } return alef; } -FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda) { +wchar_t FX_GetArabicFromShaddaTable(wchar_t shadda) { static const int32_t s_iShaddaCount = sizeof(gs_FX_ShaddaTable) / sizeof(FX_ARASHADDA); for (int32_t iStart = 0; iStart < s_iShaddaCount; iStart++) { @@ -286,30 +286,30 @@ FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda) { namespace pdfium { namespace arabic { -FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next) { +wchar_t GetFormChar(wchar_t wch, wchar_t prev, wchar_t next) { CFX_Char c(wch, kTextLayoutCodeProperties[(uint16_t)wch]); CFX_Char p(prev, kTextLayoutCodeProperties[(uint16_t)prev]); CFX_Char n(next, kTextLayoutCodeProperties[(uint16_t)next]); return GetFormChar(&c, &p, &n); } -FX_WCHAR GetFormChar(const CFX_Char* cur, - const CFX_Char* prev, - const CFX_Char* next) { +wchar_t GetFormChar(const CFX_Char* cur, + const CFX_Char* prev, + const CFX_Char* next) { FX_CHARTYPE eCur; - FX_WCHAR wCur; + wchar_t wCur; const FX_ARBFORMTABLE* ft = ParseChar(cur, wCur, eCur); if (eCur < FX_CHARTYPE_ArabicAlef || eCur >= FX_CHARTYPE_ArabicNormal) { return wCur; } FX_CHARTYPE ePrev; - FX_WCHAR wPrev; + wchar_t wPrev; ParseChar(prev, wPrev, ePrev); if (wPrev == 0x0644 && eCur == FX_CHARTYPE_ArabicAlef) { return 0xFEFF; } FX_CHARTYPE eNext; - FX_WCHAR wNext; + wchar_t wNext; ParseChar(next, wNext, eNext); bool bAlef = (eNext == FX_CHARTYPE_ArabicAlef && wCur == 0x644); if (ePrev < FX_CHARTYPE_ArabicAlef) { @@ -336,10 +336,10 @@ void FX_BidiReverseString(CFX_WideString& wsText, int32_t iCount) { ASSERT(iStart > -1 && iStart < wsText.GetLength()); ASSERT(iCount >= 0 && iStart + iCount <= wsText.GetLength()); - FX_WCHAR wch; - FX_WCHAR* pStart = const_cast<FX_WCHAR*>(wsText.c_str()); + wchar_t wch; + wchar_t* pStart = const_cast<wchar_t*>(wsText.c_str()); pStart += iStart; - FX_WCHAR* pEnd = pStart + iCount - 1; + wchar_t* pEnd = pStart + iCount - 1; while (pStart < pEnd) { wch = *pStart; *pStart++ = *pEnd; diff --git a/core/fxcrt/fx_arabic.h b/core/fxcrt/fx_arabic.h index 1856f106c2..8adb419f01 100644 --- a/core/fxcrt/fx_arabic.h +++ b/core/fxcrt/fx_arabic.h @@ -20,10 +20,10 @@ namespace pdfium { namespace arabic { -FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next); -FX_WCHAR GetFormChar(const CFX_Char* cur, - const CFX_Char* prev, - const CFX_Char* next); +wchar_t GetFormChar(wchar_t wch, wchar_t prev, wchar_t next); +wchar_t GetFormChar(const CFX_Char* cur, + const CFX_Char* prev, + const CFX_Char* next); } // namespace arabic } // namespace pdfium @@ -160,9 +160,9 @@ struct FX_ARASHADDA { uint16_t wIsolated; }; -const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode); -FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef); -FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda); +const FX_ARBFORMTABLE* FX_GetArabicFormTable(wchar_t unicode); +wchar_t FX_GetArabicFromAlefTable(wchar_t alef); +wchar_t FX_GetArabicFromShaddaTable(wchar_t shadda); void FX_BidiLine(std::vector<CFX_Char>& chars, int32_t iCount, diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h index 18413b2e70..007c362ad6 100644 --- a/core/fxcrt/fx_basic.h +++ b/core/fxcrt/fx_basic.h @@ -70,7 +70,7 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf { CFX_ByteTextBuf& operator<<(int i); CFX_ByteTextBuf& operator<<(uint32_t i); CFX_ByteTextBuf& operator<<(double f); - CFX_ByteTextBuf& operator<<(const FX_CHAR* pStr) { + CFX_ByteTextBuf& operator<<(const char* pStr) { return *this << CFX_ByteStringC(pStr); } CFX_ByteTextBuf& operator<<(const CFX_ByteString& str) { @@ -82,29 +82,29 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf { class CFX_WideTextBuf : public CFX_BinaryBuf { public: - void AppendChar(FX_WCHAR wch); - FX_STRSIZE GetLength() const { return m_DataSize / sizeof(FX_WCHAR); } - FX_WCHAR* GetBuffer() const { - return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get()); + void AppendChar(wchar_t wch); + FX_STRSIZE GetLength() const { return m_DataSize / sizeof(wchar_t); } + wchar_t* GetBuffer() const { + return reinterpret_cast<wchar_t*>(m_pBuffer.get()); } CFX_WideStringC AsStringC() const { - return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()), - m_DataSize / sizeof(FX_WCHAR)); + return CFX_WideStringC(reinterpret_cast<const wchar_t*>(m_pBuffer.get()), + m_DataSize / sizeof(wchar_t)); } CFX_WideString MakeString() const { - return CFX_WideString(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()), - m_DataSize / sizeof(FX_WCHAR)); + return CFX_WideString(reinterpret_cast<const wchar_t*>(m_pBuffer.get()), + m_DataSize / sizeof(wchar_t)); } void Delete(int start_index, int count) { - CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), - count * sizeof(FX_WCHAR)); + CFX_BinaryBuf::Delete(start_index * sizeof(wchar_t), + count * sizeof(wchar_t)); } CFX_WideTextBuf& operator<<(int i); CFX_WideTextBuf& operator<<(double f); - CFX_WideTextBuf& operator<<(const FX_WCHAR* lpsz); + CFX_WideTextBuf& operator<<(const wchar_t* lpsz); CFX_WideTextBuf& operator<<(const CFX_WideStringC& str); CFX_WideTextBuf& operator<<(const CFX_WideString& str); CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf); @@ -168,7 +168,7 @@ class CFX_UTF8Encoder { public: CFX_UTF8Encoder() {} - void Input(FX_WCHAR unicode); + void Input(wchar_t unicode); void AppendStr(const CFX_ByteStringC& str) { m_Buffer << str; } CFX_ByteStringC GetResult() const { return m_Buffer.AsStringC(); } diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index 2669474f00..cbd8b379b9 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -13,8 +13,8 @@ #include "core/fxcrt/fx_basic.h" #include "third_party/base/numerics/safe_math.h" -template class CFX_StringDataTemplate<FX_CHAR>; -template class CFX_StringCTemplate<FX_CHAR>; +template class CFX_StringDataTemplate<char>; +template class CFX_StringCTemplate<char>; template class CFX_StringPoolTemplate<CFX_ByteString>; template struct std::hash<CFX_ByteString>; @@ -32,7 +32,7 @@ int Buffer_itoa(char* buf, int i, uint32_t flags) { u = -i; } int base = 10; - const FX_CHAR* str = "0123456789abcdef"; + const char* str = "0123456789abcdef"; if (flags & FXFORMAT_HEX) { base = 16; if (flags & FXFORMAT_CAPITAL) { @@ -53,14 +53,14 @@ int Buffer_itoa(char* buf, int i, uint32_t flags) { return len; } -const FX_CHAR* FX_strstr(const FX_CHAR* haystack, - int haystack_len, - const FX_CHAR* needle, - int needle_len) { +const char* FX_strstr(const char* haystack, + int haystack_len, + const char* needle, + int needle_len) { if (needle_len > haystack_len || needle_len == 0) { return nullptr; } - const FX_CHAR* end_ptr = haystack + haystack_len - needle_len; + const char* end_ptr = haystack + haystack_len - needle_len; while (haystack <= end_ptr) { int i = 0; while (1) { @@ -79,10 +79,10 @@ const FX_CHAR* FX_strstr(const FX_CHAR* haystack, } // namespace -static_assert(sizeof(CFX_ByteString) <= sizeof(FX_CHAR*), +static_assert(sizeof(CFX_ByteString) <= sizeof(char*), "Strings must not require more space than pointers"); -CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) { +CFX_ByteString::CFX_ByteString(const char* pStr, FX_STRSIZE nLen) { if (nLen < 0) nLen = pStr ? FXSYS_strlen(pStr) : 0; @@ -93,7 +93,7 @@ CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) { CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) { if (nLen > 0) { m_pData.Reset( - StringData::Create(reinterpret_cast<const FX_CHAR*>(pStr), nLen)); + StringData::Create(reinterpret_cast<const char*>(pStr), nLen)); } } @@ -111,7 +111,7 @@ CFX_ByteString::CFX_ByteString(char ch) { m_pData->m_String[0] = ch; } -CFX_ByteString::CFX_ByteString(const FX_CHAR* ptr) +CFX_ByteString::CFX_ByteString(const char* ptr) : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {} CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) { @@ -132,7 +132,7 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1, CFX_ByteString::~CFX_ByteString() {} -const CFX_ByteString& CFX_ByteString::operator=(const FX_CHAR* pStr) { +const CFX_ByteString& CFX_ByteString::operator=(const char* pStr) { if (!pStr || !pStr[0]) clear(); else @@ -159,7 +159,7 @@ const CFX_ByteString& CFX_ByteString::operator=( return *this; } -const CFX_ByteString& CFX_ByteString::operator+=(const FX_CHAR* pStr) { +const CFX_ByteString& CFX_ByteString::operator+=(const char* pStr) { if (pStr) Concat(pStr, FXSYS_strlen(pStr)); @@ -257,7 +257,7 @@ bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const { return true; } -void CFX_ByteString::AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen) { +void CFX_ByteString::AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen) { AllocBeforeWrite(nSrcLen); m_pData->CopyContents(pSrcData, nSrcLen); m_pData->m_nDataLength = nSrcLen; @@ -324,7 +324,7 @@ void CFX_ByteString::Reserve(FX_STRSIZE len) { GetBuffer(len); } -FX_CHAR* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) { +char* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) { if (!m_pData) { if (nMinBufLength == 0) return nullptr; @@ -372,7 +372,7 @@ FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) { return m_pData->m_nDataLength; } -void CFX_ByteString::Concat(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen) { +void CFX_ByteString::Concat(const char* pSrcData, FX_STRSIZE nSrcLen) { if (!pSrcData || nSrcLen <= 0) return; @@ -438,7 +438,7 @@ CFX_ByteString CFX_ByteString::FormatInteger(int i, uint32_t flags) { return CFX_ByteString(buf, Buffer_itoa(buf, i, flags)); } -void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { +void CFX_ByteString::FormatV(const char* pFormat, va_list argList) { va_list argListSave; #if defined(__ARMCC_VERSION) || \ (!defined(_MSC_VER) && (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || \ @@ -449,7 +449,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { argListSave = argList; #endif int nMaxLen = 0; - for (const FX_CHAR* pStr = pFormat; *pStr != 0; pStr++) { + for (const char* pStr = pFormat; *pStr != 0; pStr++) { if (*pStr != '%' || *(pStr = pStr + 1) == '%') { nMaxLen += FXSYS_strlen(pStr); continue; @@ -530,7 +530,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { va_arg(argList, int); break; case 's': { - const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); + const char* pstrNextArg = va_arg(argList, const char*); if (pstrNextArg) { nItemLen = FXSYS_strlen(pstrNextArg); if (nItemLen < 1) { @@ -541,7 +541,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { } } break; case 'S': { - FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*); + wchar_t* pstrNextArg = va_arg(argList, wchar_t*); if (pstrNextArg) { nItemLen = FXSYS_wcslen(pstrNextArg); if (nItemLen < 1) { @@ -553,7 +553,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { } break; case 's' | FORCE_ANSI: case 'S' | FORCE_ANSI: { - const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); + const char* pstrNextArg = va_arg(argList, const char*); if (pstrNextArg) { nItemLen = FXSYS_strlen(pstrNextArg); if (nItemLen < 1) { @@ -565,7 +565,7 @@ void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { } break; case 's' | FORCE_UNICODE: case 'S' | FORCE_UNICODE: { - FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*); + wchar_t* pstrNextArg = va_arg(argList, wchar_t*); if (pstrNextArg) { nItemLen = FXSYS_wcslen(pstrNextArg); if (nItemLen < 1) { @@ -649,14 +649,14 @@ void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) { va_end(argListSave); } -void CFX_ByteString::Format(const FX_CHAR* pFormat, ...) { +void CFX_ByteString::Format(const char* pFormat, ...) { va_list argList; va_start(argList, pFormat); FormatV(pFormat, argList); va_end(argList); } -FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE nIndex, FX_CHAR ch) { +FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE nIndex, char ch) { FX_STRSIZE nNewLength = m_pData ? m_pData->m_nDataLength : 0; nIndex = std::max(nIndex, 0); nIndex = std::min(nIndex, nNewLength); @@ -696,19 +696,19 @@ CFX_ByteString CFX_ByteString::Left(FX_STRSIZE nCount) const { return dest; } -FX_STRSIZE CFX_ByteString::Find(FX_CHAR ch, FX_STRSIZE nStart) const { +FX_STRSIZE CFX_ByteString::Find(char ch, FX_STRSIZE nStart) const { if (!m_pData) return -1; if (nStart < 0 || nStart >= m_pData->m_nDataLength) return -1; - const FX_CHAR* pStr = static_cast<const FX_CHAR*>( + const char* pStr = static_cast<const char*>( memchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart)); return pStr ? pStr - m_pData->m_String : -1; } -FX_STRSIZE CFX_ByteString::ReverseFind(FX_CHAR ch) const { +FX_STRSIZE CFX_ByteString::ReverseFind(char ch) const { if (!m_pData) return -1; @@ -729,7 +729,7 @@ FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& pSub, if (nStart > nLength) return -1; - const FX_CHAR* pStr = + const char* pStr = FX_strstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart, pSub.c_str(), pSub.GetLength()); return pStr ? (int)(pStr - m_pData->m_String) : -1; @@ -751,12 +751,12 @@ void CFX_ByteString::MakeUpper() { FXSYS_strupr(m_pData->m_String); } -FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) { +FX_STRSIZE CFX_ByteString::Remove(char chRemove) { if (!m_pData || m_pData->m_nDataLength < 1) return 0; - FX_CHAR* pstrSource = m_pData->m_String; - FX_CHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; + char* pstrSource = m_pData->m_String; + char* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; while (pstrSource < pstrEnd) { if (*pstrSource == chRemove) break; @@ -770,7 +770,7 @@ FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) { pstrSource = m_pData->m_String + copied; pstrEnd = m_pData->m_String + m_pData->m_nDataLength; - FX_CHAR* pstrDest = pstrSource; + char* pstrDest = pstrSource; while (pstrSource < pstrEnd) { if (*pstrSource != chRemove) { *pstrDest = *pstrSource; @@ -793,11 +793,11 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, FX_STRSIZE nSourceLen = pOld.GetLength(); FX_STRSIZE nReplacementLen = pNew.GetLength(); FX_STRSIZE nCount = 0; - const FX_CHAR* pStart = m_pData->m_String; - FX_CHAR* pEnd = m_pData->m_String + m_pData->m_nDataLength; + const char* pStart = m_pData->m_String; + char* pEnd = m_pData->m_String + m_pData->m_nDataLength; while (1) { - const FX_CHAR* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart), - pOld.c_str(), nSourceLen); + const char* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart), + pOld.c_str(), nSourceLen); if (!pTarget) break; @@ -817,10 +817,10 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); pStart = m_pData->m_String; - FX_CHAR* pDest = pNewData->m_String; + char* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < nCount; i++) { - const FX_CHAR* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart), - pOld.c_str(), nSourceLen); + const char* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart), + pOld.c_str(), nSourceLen); FXSYS_memcpy(pDest, pStart, pTarget - pStart); pDest += pTarget - pStart; FXSYS_memcpy(pDest, pNew.c_str(), pNew.GetLength()); @@ -832,7 +832,7 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, return nCount; } -void CFX_ByteString::SetAt(FX_STRSIZE nIndex, FX_CHAR ch) { +void CFX_ByteString::SetAt(FX_STRSIZE nIndex, char ch) { if (!m_pData) { return; } @@ -851,8 +851,7 @@ CFX_WideString CFX_ByteString::UTF8Decode() const { } // static -CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, - FX_STRSIZE len) { +CFX_ByteString CFX_ByteString::FromUnicode(const wchar_t* str, FX_STRSIZE len) { FX_STRSIZE str_len = len >= 0 ? len : FXSYS_wcslen(str); return FromUnicode(CFX_WideString(str, str_len)); } @@ -912,7 +911,7 @@ void CFX_ByteString::TrimRight(const CFX_ByteStringC& pTargets) { } } -void CFX_ByteString::TrimRight(FX_CHAR chTarget) { +void CFX_ByteString::TrimRight(char chTarget) { TrimRight(CFX_ByteStringC(chTarget)); } @@ -943,12 +942,12 @@ void CFX_ByteString::TrimLeft(const CFX_ByteStringC& pTargets) { ReallocBeforeWrite(len); FX_STRSIZE nDataLength = len - pos; FXSYS_memmove(m_pData->m_String, m_pData->m_String + pos, - (nDataLength + 1) * sizeof(FX_CHAR)); + (nDataLength + 1) * sizeof(char)); m_pData->m_nDataLength = nDataLength; } } -void CFX_ByteString::TrimLeft(FX_CHAR chTarget) { +void CFX_ByteString::TrimLeft(char chTarget) { TrimLeft(CFX_ByteStringC(chTarget)); } @@ -959,7 +958,7 @@ void CFX_ByteString::TrimLeft() { uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const { return AsStringC().GetID(start_pos); } -FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) { +FX_STRSIZE FX_ftoa(FX_FLOAT d, char* buf) { buf[0] = '0'; buf[1] = '\0'; if (d == 0.0f) { @@ -1006,7 +1005,7 @@ FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) { return buf_size; } CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { - FX_CHAR buf[32]; + char buf[32]; FX_STRSIZE len = FX_ftoa(d, buf); return CFX_ByteString(buf, len); } diff --git a/core/fxcrt/fx_basic_bstring_unittest.cpp b/core/fxcrt/fx_basic_bstring_unittest.cpp index 503e68458a..a58169d039 100644 --- a/core/fxcrt/fx_basic_bstring_unittest.cpp +++ b/core/fxcrt/fx_basic_bstring_unittest.cpp @@ -278,7 +278,7 @@ TEST(fxcrt, ByteStringCNull) { EXPECT_EQ(null_string, assigned_null_string); CFX_ByteStringC assigned_nullptr_string("initially not nullptr"); - assigned_nullptr_string = (const FX_CHAR*)nullptr; + assigned_nullptr_string = (const char*)nullptr; EXPECT_FALSE(assigned_nullptr_string.raw_str()); EXPECT_EQ(assigned_nullptr_string.GetLength(), 0); EXPECT_TRUE(assigned_nullptr_string.IsEmpty()); @@ -335,7 +335,7 @@ TEST(fxcrt, ByteStringRemove) { TEST(fxcrt, ByteStringRemoveCopies) { CFX_ByteString freed("FREED"); - const FX_CHAR* old_buffer = freed.c_str(); + const char* old_buffer = freed.c_str(); // No change with single reference - no copy. freed.Remove('Q'); @@ -538,7 +538,7 @@ TEST(fxcrt, ByteStringTrimRightCopies) { { // With a single reference, no copy takes place. CFX_ByteString fred(" FRED "); - const FX_CHAR* old_buffer = fred.c_str(); + const char* old_buffer = fred.c_str(); fred.TrimRight(); EXPECT_EQ(" FRED", fred); EXPECT_EQ(old_buffer, fred.c_str()); @@ -547,7 +547,7 @@ TEST(fxcrt, ByteStringTrimRightCopies) { // With multiple references, we must copy. CFX_ByteString fred(" FRED "); CFX_ByteString other_fred = fred; - const FX_CHAR* old_buffer = fred.c_str(); + const char* old_buffer = fred.c_str(); fred.TrimRight(); EXPECT_EQ(" FRED", fred); EXPECT_EQ(" FRED ", other_fred); @@ -557,7 +557,7 @@ TEST(fxcrt, ByteStringTrimRightCopies) { // With multiple references, but no modifications, no copy. CFX_ByteString fred("FRED"); CFX_ByteString other_fred = fred; - const FX_CHAR* old_buffer = fred.c_str(); + const char* old_buffer = fred.c_str(); fred.TrimRight(); EXPECT_EQ("FRED", fred); EXPECT_EQ("FRED", other_fred); @@ -597,7 +597,7 @@ TEST(fxcrt, ByteStringTrimLeftCopies) { { // With a single reference, no copy takes place. CFX_ByteString fred(" FRED "); - const FX_CHAR* old_buffer = fred.c_str(); + const char* old_buffer = fred.c_str(); fred.TrimLeft(); EXPECT_EQ("FRED ", fred); EXPECT_EQ(old_buffer, fred.c_str()); @@ -606,7 +606,7 @@ TEST(fxcrt, ByteStringTrimLeftCopies) { // With multiple references, we must copy. CFX_ByteString fred(" FRED "); CFX_ByteString other_fred = fred; - const FX_CHAR* old_buffer = fred.c_str(); + const char* old_buffer = fred.c_str(); fred.TrimLeft(); EXPECT_EQ("FRED ", fred); EXPECT_EQ(" FRED ", other_fred); @@ -616,7 +616,7 @@ TEST(fxcrt, ByteStringTrimLeftCopies) { // With multiple references, but no modifications, no copy. CFX_ByteString fred("FRED"); CFX_ByteString other_fred = fred; - const FX_CHAR* old_buffer = fred.c_str(); + const char* old_buffer = fred.c_str(); fred.TrimLeft(); EXPECT_EQ("FRED", fred); EXPECT_EQ("FRED", other_fred); @@ -628,7 +628,7 @@ TEST(fxcrt, ByteStringReserve) { { CFX_ByteString str; str.Reserve(6); - const FX_CHAR* old_buffer = str.c_str(); + const char* old_buffer = str.c_str(); str += "ABCDEF"; EXPECT_EQ(old_buffer, str.c_str()); str += "Blah Blah Blah Blah Blah Blah"; @@ -637,7 +637,7 @@ TEST(fxcrt, ByteStringReserve) { { CFX_ByteString str("A"); str.Reserve(6); - const FX_CHAR* old_buffer = str.c_str(); + const char* old_buffer = str.c_str(); str += "BCDEF"; EXPECT_EQ(old_buffer, str.c_str()); str += "Blah Blah Blah Blah Blah Blah"; @@ -648,7 +648,7 @@ TEST(fxcrt, ByteStringReserve) { TEST(fxcrt, ByteStringGetBuffer) { { CFX_ByteString str; - FX_CHAR* buffer = str.GetBuffer(12); + char* buffer = str.GetBuffer(12); // NOLINTNEXTLINE(runtime/printf) strcpy(buffer, "clams"); str.ReleaseBuffer(); @@ -656,7 +656,7 @@ TEST(fxcrt, ByteStringGetBuffer) { } { CFX_ByteString str("cl"); - FX_CHAR* buffer = str.GetBuffer(12); + char* buffer = str.GetBuffer(12); // NOLINTNEXTLINE(runtime/printf) strcpy(buffer + 2, "ams"); str.ReleaseBuffer(); @@ -669,7 +669,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) { CFX_ByteString str; str.Reserve(12); str += "clams"; - const FX_CHAR* old_buffer = str.c_str(); + const char* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_EQ(old_buffer, str.c_str()); EXPECT_EQ("clam", str); @@ -678,7 +678,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) { CFX_ByteString str("c"); str.Reserve(12); str += "lams"; - const FX_CHAR* old_buffer = str.c_str(); + const char* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_EQ(old_buffer, str.c_str()); EXPECT_EQ("clam", str); @@ -687,7 +687,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) { CFX_ByteString str; str.Reserve(200); str += "clams"; - const FX_CHAR* old_buffer = str.c_str(); + const char* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_NE(old_buffer, str.c_str()); EXPECT_EQ("clam", str); @@ -696,7 +696,7 @@ TEST(fxcrt, ByteStringReleaseBuffer) { CFX_ByteString str("c"); str.Reserve(200); str += "lams"; - const FX_CHAR* old_buffer = str.c_str(); + const char* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_NE(old_buffer, str.c_str()); EXPECT_EQ("clam", str); @@ -1097,6 +1097,6 @@ TEST(fxcrt, EmptyByteString) { CFX_ByteString empty_str; EXPECT_TRUE(empty_str.IsEmpty()); EXPECT_EQ(0, empty_str.GetLength()); - const FX_CHAR* cstr = empty_str.c_str(); + const char* cstr = empty_str.c_str(); EXPECT_EQ(0, FXSYS_strlen(cstr)); } diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index 14a85c2ee5..eaa79c9af1 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -127,19 +127,19 @@ CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(const CFX_ByteTextBuf& buf) { return *this; } -void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) { - ExpandBuf(sizeof(FX_WCHAR)); - *(FX_WCHAR*)(m_pBuffer.get() + m_DataSize) = ch; - m_DataSize += sizeof(FX_WCHAR); +void CFX_WideTextBuf::AppendChar(wchar_t ch) { + ExpandBuf(sizeof(wchar_t)); + *(wchar_t*)(m_pBuffer.get() + m_DataSize) = ch; + m_DataSize += sizeof(wchar_t); } CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideStringC& str) { - AppendBlock(str.c_str(), str.GetLength() * sizeof(FX_WCHAR)); + AppendBlock(str.c_str(), str.GetLength() * sizeof(wchar_t)); return *this; } CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideString& str) { - AppendBlock(str.c_str(), str.GetLength() * sizeof(FX_WCHAR)); + AppendBlock(str.c_str(), str.GetLength() * sizeof(wchar_t)); return *this; } @@ -147,29 +147,29 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) { char buf[32]; FXSYS_itoa(i, buf, 10); FX_STRSIZE len = FXSYS_strlen(buf); - ExpandBuf(len * sizeof(FX_WCHAR)); - FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer.get() + m_DataSize); + ExpandBuf(len * sizeof(wchar_t)); + wchar_t* str = (wchar_t*)(m_pBuffer.get() + m_DataSize); for (FX_STRSIZE j = 0; j < len; j++) { *str++ = buf[j]; } - m_DataSize += len * sizeof(FX_WCHAR); + m_DataSize += len * sizeof(wchar_t); return *this; } CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) { char buf[32]; FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf); - ExpandBuf(len * sizeof(FX_WCHAR)); - FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer.get() + m_DataSize); + ExpandBuf(len * sizeof(wchar_t)); + wchar_t* str = (wchar_t*)(m_pBuffer.get() + m_DataSize); for (FX_STRSIZE i = 0; i < len; i++) { *str++ = buf[i]; } - m_DataSize += len * sizeof(FX_WCHAR); + m_DataSize += len * sizeof(wchar_t); return *this; } -CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const FX_WCHAR* lpsz) { - AppendBlock(lpsz, FXSYS_wcslen(lpsz) * sizeof(FX_WCHAR)); +CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const wchar_t* lpsz) { + AppendBlock(lpsz, FXSYS_wcslen(lpsz) * sizeof(wchar_t)); return *this; } diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp index 42fb2a17f7..4960dc8432 100644 --- a/core/fxcrt/fx_basic_gcc.cpp +++ b/core/fxcrt/fx_basic_gcc.cpp @@ -82,23 +82,23 @@ STR_T FXSYS_IntToStr(T value, STR_T str, int radix) { #ifdef __cplusplus extern "C" { #endif -int32_t FXSYS_atoi(const FX_CHAR* str) { - return FXSYS_StrToInt<int32_t, FX_CHAR>(str); +int32_t FXSYS_atoi(const char* str) { + return FXSYS_StrToInt<int32_t, char>(str); } -uint32_t FXSYS_atoui(const FX_CHAR* str) { +uint32_t FXSYS_atoui(const char* str) { return FXSYS_StrToInt<uint32_t>(str); } -int32_t FXSYS_wtoi(const FX_WCHAR* str) { - return FXSYS_StrToInt<int32_t, FX_WCHAR>(str); +int32_t FXSYS_wtoi(const wchar_t* str) { + return FXSYS_StrToInt<int32_t, wchar_t>(str); } -int64_t FXSYS_atoi64(const FX_CHAR* str) { - return FXSYS_StrToInt<int64_t, FX_CHAR>(str); +int64_t FXSYS_atoi64(const char* str) { + return FXSYS_StrToInt<int64_t, char>(str); } -int64_t FXSYS_wtoi64(const FX_WCHAR* str) { - return FXSYS_StrToInt<int64_t, FX_WCHAR>(str); +int64_t FXSYS_wtoi64(const wchar_t* str) { + return FXSYS_StrToInt<int64_t, wchar_t>(str); } -const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix) { - return FXSYS_IntToStr<int64_t, uint64_t, FX_CHAR*>(value, str, radix); +const char* FXSYS_i64toa(int64_t value, char* str, int radix) { + return FXSYS_IntToStr<int64_t, uint64_t, char*>(value, str, radix); } #ifdef __cplusplus } @@ -110,10 +110,10 @@ extern "C" { int FXSYS_GetACP() { return 0; } -uint32_t FXSYS_GetFullPathName(const FX_CHAR* filename, +uint32_t FXSYS_GetFullPathName(const char* filename, uint32_t buflen, - FX_CHAR* buf, - FX_CHAR** filepart) { + char* buf, + char** filepart) { int srclen = FXSYS_strlen(filename); if (!buf || (int)buflen < srclen + 1) { return srclen + 1; @@ -132,7 +132,7 @@ uint32_t FXSYS_GetModuleFileName(void* hModule, char* buf, uint32_t bufsize) { #ifdef __cplusplus extern "C" { #endif -FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode) { +FXSYS_FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode) { return FXSYS_fopen(CFX_ByteString::FromUnicode(filename).c_str(), CFX_ByteString::FromUnicode(mode).c_str()); } @@ -158,22 +158,22 @@ char* FXSYS_strupr(char* str) { } return s; } -FX_WCHAR* FXSYS_wcslwr(FX_WCHAR* str) { +wchar_t* FXSYS_wcslwr(wchar_t* str) { if (!str) { return nullptr; } - FX_WCHAR* s = str; + wchar_t* s = str; while (*str) { *str = FXSYS_tolower(*str); str++; } return s; } -FX_WCHAR* FXSYS_wcsupr(FX_WCHAR* str) { +wchar_t* FXSYS_wcsupr(wchar_t* str) { if (!str) { return nullptr; } - FX_WCHAR* s = str; + wchar_t* s = str; while (*str) { *str = FXSYS_toupper(*str); str++; @@ -192,20 +192,20 @@ int FXSYS_stricmp(const char* dst, const char* src) { } while (f && (f == l)); return (f - l); } -int FXSYS_wcsicmp(const FX_WCHAR* dst, const FX_WCHAR* src) { - FX_WCHAR f, l; +int FXSYS_wcsicmp(const wchar_t* dst, const wchar_t* src) { + wchar_t f, l; do { - if (((f = (FX_WCHAR)(*(dst++))) >= 'A') && (f <= 'Z')) { + if (((f = (wchar_t)(*(dst++))) >= 'A') && (f <= 'Z')) { f -= ('A' - 'a'); } - if (((l = (FX_WCHAR)(*(src++))) >= 'A') && (l <= 'Z')) { + if (((l = (wchar_t)(*(src++))) >= 'A') && (l <= 'Z')) { l -= ('A' - 'a'); } } while (f && (f == l)); return (f - l); } char* FXSYS_itoa(int value, char* str, int radix) { - return FXSYS_IntToStr<int32_t, uint32_t, FX_CHAR*>(value, str, radix); + return FXSYS_IntToStr<int32_t, uint32_t, char*>(value, str, radix); } #ifdef __cplusplus } @@ -217,17 +217,17 @@ extern "C" { #endif int FXSYS_WideCharToMultiByte(uint32_t codepage, uint32_t dwFlags, - const FX_WCHAR* wstr, + const wchar_t* wstr, int wlen, - FX_CHAR* buf, + char* buf, int buflen, - const FX_CHAR* default_str, + const char* default_str, int* pUseDefault) { int len = 0; for (int i = 0; i < wlen; i++) { if (wstr[i] < 0x100) { if (buf && len < buflen) - buf[len] = static_cast<FX_CHAR>(wstr[i]); + buf[len] = static_cast<char>(wstr[i]); len++; } } @@ -235,9 +235,9 @@ int FXSYS_WideCharToMultiByte(uint32_t codepage, } int FXSYS_MultiByteToWideChar(uint32_t codepage, uint32_t dwFlags, - const FX_CHAR* bstr, + const char* bstr, int blen, - FX_WCHAR* buf, + wchar_t* buf, int buflen) { int wlen = 0; for (int i = 0; i < blen; i++) { diff --git a/core/fxcrt/fx_basic_utf.cpp b/core/fxcrt/fx_basic_utf.cpp index c0f14c8178..10aa918962 100644 --- a/core/fxcrt/fx_basic_utf.cpp +++ b/core/fxcrt/fx_basic_utf.cpp @@ -11,7 +11,7 @@ void CFX_UTF8Decoder::Clear() { m_PendingBytes = 0; } void CFX_UTF8Decoder::AppendChar(uint32_t ch) { - m_Buffer.AppendChar((FX_WCHAR)ch); + m_Buffer.AppendChar((wchar_t)ch); } void CFX_UTF8Decoder::Input(uint8_t byte) { if (byte < 0x80) { @@ -43,7 +43,7 @@ void CFX_UTF8Decoder::Input(uint8_t byte) { m_PendingChar = (byte & 0x01) << 30; } } -void CFX_UTF8Encoder::Input(FX_WCHAR unicode) { +void CFX_UTF8Encoder::Input(wchar_t unicode) { if ((uint32_t)unicode < 0x80) { m_Buffer.AppendChar(unicode); } else { @@ -76,7 +76,7 @@ void CFX_UTF8Encoder::Input(FX_WCHAR unicode) { CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) { FX_STRSIZE len = wsStr.GetLength(); - const FX_WCHAR* pStr = wsStr.c_str(); + const wchar_t* pStr = wsStr.c_str(); CFX_UTF8Encoder encoder; while (len-- > 0) encoder.Input(*pStr++); diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp index f608e290a2..45543dc317 100644 --- a/core/fxcrt/fx_basic_util.cpp +++ b/core/fxcrt/fx_basic_util.cpp @@ -140,7 +140,7 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap) { } #endif // _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 -FX_FileHandle* FX_OpenFolder(const FX_CHAR* path) { +FX_FileHandle* FX_OpenFolder(const char* path) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ std::unique_ptr<CFindFileDataA> pData(new CFindFileDataA); pData->m_Handle = FindFirstFileExA((CFX_ByteString(path) + "/*.*").c_str(), @@ -197,7 +197,7 @@ void FX_CloseFolder(FX_FileHandle* handle) { #endif } -FX_WCHAR FX_GetFolderSeparator() { +wchar_t FX_GetFolderSeparator() { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ return '\\'; #else diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 93b9ba7c25..3b9fa2435c 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -14,8 +14,8 @@ #include "core/fxcrt/fx_ext.h" #include "third_party/base/numerics/safe_math.h" -template class CFX_StringDataTemplate<FX_WCHAR>; -template class CFX_StringCTemplate<FX_WCHAR>; +template class CFX_StringDataTemplate<wchar_t>; +template class CFX_StringCTemplate<wchar_t>; template class CFX_StringPoolTemplate<CFX_WideString>; template struct std::hash<CFX_WideString>; @@ -37,14 +37,14 @@ bool IsValidCodePage(uint16_t codepage) { } #endif -const FX_WCHAR* FX_wcsstr(const FX_WCHAR* haystack, - int haystack_len, - const FX_WCHAR* needle, - int needle_len) { +const wchar_t* FX_wcsstr(const wchar_t* haystack, + int haystack_len, + const wchar_t* needle, + int needle_len) { if (needle_len > haystack_len || needle_len == 0) { return nullptr; } - const FX_WCHAR* end_ptr = haystack + haystack_len - needle_len; + const wchar_t* end_ptr = haystack + haystack_len - needle_len; while (haystack <= end_ptr) { int i = 0; while (1) { @@ -63,7 +63,7 @@ const FX_WCHAR* FX_wcsstr(const FX_WCHAR* haystack, } // namespace -static_assert(sizeof(CFX_WideString) <= sizeof(FX_WCHAR*), +static_assert(sizeof(CFX_WideString) <= sizeof(wchar_t*), "Strings must not require more space than pointers"); CFX_WideString::CFX_WideString() {} @@ -75,7 +75,7 @@ CFX_WideString::CFX_WideString(CFX_WideString&& other) { m_pData.Swap(other.m_pData); } -CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { +CFX_WideString::CFX_WideString(const wchar_t* pStr, FX_STRSIZE nLen) { if (nLen < 0) nLen = pStr ? FXSYS_wcslen(pStr) : 0; @@ -83,12 +83,12 @@ CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { m_pData.Reset(StringData::Create(pStr, nLen)); } -CFX_WideString::CFX_WideString(FX_WCHAR ch) { +CFX_WideString::CFX_WideString(wchar_t ch) { m_pData.Reset(StringData::Create(1)); m_pData->m_String[0] = ch; } -CFX_WideString::CFX_WideString(const FX_WCHAR* ptr) +CFX_WideString::CFX_WideString(const wchar_t* ptr) : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {} CFX_WideString::CFX_WideString(const CFX_WideStringC& stringSrc) { @@ -110,7 +110,7 @@ CFX_WideString::CFX_WideString(const CFX_WideStringC& str1, CFX_WideString::~CFX_WideString() {} -const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* pStr) { +const CFX_WideString& CFX_WideString::operator=(const wchar_t* pStr) { if (!pStr || !pStr[0]) clear(); else @@ -137,14 +137,14 @@ const CFX_WideString& CFX_WideString::operator=( return *this; } -const CFX_WideString& CFX_WideString::operator+=(const FX_WCHAR* pStr) { +const CFX_WideString& CFX_WideString::operator+=(const wchar_t* pStr) { if (pStr) Concat(pStr, FXSYS_wcslen(pStr)); return *this; } -const CFX_WideString& CFX_WideString::operator+=(FX_WCHAR ch) { +const CFX_WideString& CFX_WideString::operator+=(wchar_t ch) { Concat(&ch, 1); return *this; } @@ -206,7 +206,7 @@ bool CFX_WideString::operator<(const CFX_WideString& str) const { return result < 0 || (result == 0 && GetLength() < str.GetLength()); } -void CFX_WideString::AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) { +void CFX_WideString::AssignCopy(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) { AllocBeforeWrite(nSrcLen); m_pData->CopyContents(pSrcData, nSrcLen); m_pData->m_nDataLength = nSrcLen; @@ -273,7 +273,7 @@ void CFX_WideString::Reserve(FX_STRSIZE len) { GetBuffer(len); } -FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) { +wchar_t* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) { if (!m_pData) { if (nMinBufLength == 0) return nullptr; @@ -321,7 +321,7 @@ FX_STRSIZE CFX_WideString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) { return m_pData->m_nDataLength; } -void CFX_WideString::Concat(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) { +void CFX_WideString::Concat(const wchar_t* pSrcData, FX_STRSIZE nSrcLen) { if (!pSrcData || nSrcLen <= 0) return; @@ -353,7 +353,7 @@ CFX_ByteString CFX_WideString::UTF16LE_Encode() const { } int len = m_pData->m_nDataLength; CFX_ByteString result; - FX_CHAR* buffer = result.GetBuffer(len * 2 + 2); + char* buffer = result.GetBuffer(len * 2 + 2); for (int i = 0; i < len; i++) { buffer[i * 2] = m_pData->m_String[i] & 0xff; buffer[i * 2 + 1] = m_pData->m_String[i] >> 8; @@ -403,7 +403,7 @@ void CFX_WideString::AllocCopy(CFX_WideString& dest, #define FORCE_UNICODE 0x20000 #define FORCE_INT64 0x40000 -void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { +void CFX_WideString::FormatV(const wchar_t* pFormat, va_list argList) { va_list argListSave; #if defined(__ARMCC_VERSION) || \ (!defined(_MSC_VER) && (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || \ @@ -414,7 +414,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { argListSave = argList; #endif int nMaxLen = 0; - for (const FX_WCHAR* pStr = pFormat; *pStr != 0; pStr++) { + for (const wchar_t* pStr = pFormat; *pStr != 0; pStr++) { if (*pStr != '%' || *(pStr = pStr + 1) == '%') { nMaxLen += FXSYS_wcslen(pStr); continue; @@ -495,7 +495,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { va_arg(argList, int); break; case 's': { - const FX_WCHAR* pstrNextArg = va_arg(argList, const FX_WCHAR*); + const wchar_t* pstrNextArg = va_arg(argList, const wchar_t*); if (pstrNextArg) { nItemLen = FXSYS_wcslen(pstrNextArg); if (nItemLen < 1) { @@ -506,7 +506,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { } } break; case 'S': { - const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); + const char* pstrNextArg = va_arg(argList, const char*); if (pstrNextArg) { nItemLen = FXSYS_strlen(pstrNextArg); if (nItemLen < 1) { @@ -518,7 +518,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { } break; case 's' | FORCE_ANSI: case 'S' | FORCE_ANSI: { - const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); + const char* pstrNextArg = va_arg(argList, const char*); if (pstrNextArg) { nItemLen = FXSYS_strlen(pstrNextArg); if (nItemLen < 1) { @@ -530,7 +530,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { } break; case 's' | FORCE_UNICODE: case 'S' | FORCE_UNICODE: { - const FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*); + const wchar_t* pstrNextArg = va_arg(argList, wchar_t*); if (pstrNextArg) { nItemLen = FXSYS_wcslen(pstrNextArg); if (nItemLen < 1) { @@ -613,14 +613,14 @@ void CFX_WideString::FormatV(const FX_WCHAR* pFormat, va_list argList) { va_end(argListSave); } -void CFX_WideString::Format(const FX_WCHAR* pFormat, ...) { +void CFX_WideString::Format(const wchar_t* pFormat, ...) { va_list argList; va_start(argList, pFormat); FormatV(pFormat, argList); va_end(argList); } -FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) { +FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, wchar_t ch) { FX_STRSIZE nNewLength = m_pData ? m_pData->m_nDataLength : 0; nIndex = std::max(nIndex, 0); nIndex = std::min(nIndex, nNewLength); @@ -660,14 +660,14 @@ CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const { return dest; } -FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const { +FX_STRSIZE CFX_WideString::Find(wchar_t ch, FX_STRSIZE nStart) const { if (!m_pData) return -1; if (nStart < 0 || nStart >= m_pData->m_nDataLength) return -1; - const FX_WCHAR* pStr = + const wchar_t* pStr = wmemchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart); return pStr ? pStr - m_pData->m_String : -1; } @@ -681,7 +681,7 @@ FX_STRSIZE CFX_WideString::Find(const CFX_WideStringC& pSub, if (nStart > nLength) return -1; - const FX_WCHAR* pStr = + const wchar_t* pStr = FX_wcsstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart, pSub.c_str(), pSub.GetLength()); return pStr ? (int)(pStr - m_pData->m_String) : -1; @@ -703,12 +703,12 @@ void CFX_WideString::MakeUpper() { FXSYS_wcsupr(m_pData->m_String); } -FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { +FX_STRSIZE CFX_WideString::Remove(wchar_t chRemove) { if (!m_pData || m_pData->m_nDataLength < 1) return 0; - FX_WCHAR* pstrSource = m_pData->m_String; - FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; + wchar_t* pstrSource = m_pData->m_String; + wchar_t* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; while (pstrSource < pstrEnd) { if (*pstrSource == chRemove) break; @@ -722,7 +722,7 @@ FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { pstrSource = m_pData->m_String + copied; pstrEnd = m_pData->m_String + m_pData->m_nDataLength; - FX_WCHAR* pstrDest = pstrSource; + wchar_t* pstrDest = pstrSource; while (pstrSource < pstrEnd) { if (*pstrSource != chRemove) { *pstrDest = *pstrSource; @@ -745,11 +745,11 @@ FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld, FX_STRSIZE nSourceLen = pOld.GetLength(); FX_STRSIZE nReplacementLen = pNew.GetLength(); FX_STRSIZE nCount = 0; - const FX_WCHAR* pStart = m_pData->m_String; - FX_WCHAR* pEnd = m_pData->m_String + m_pData->m_nDataLength; + const wchar_t* pStart = m_pData->m_String; + wchar_t* pEnd = m_pData->m_String + m_pData->m_nDataLength; while (1) { - const FX_WCHAR* pTarget = FX_wcsstr(pStart, (FX_STRSIZE)(pEnd - pStart), - pOld.c_str(), nSourceLen); + const wchar_t* pTarget = FX_wcsstr(pStart, (FX_STRSIZE)(pEnd - pStart), + pOld.c_str(), nSourceLen); if (!pTarget) break; @@ -769,10 +769,10 @@ FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld, CFX_RetainPtr<StringData> pNewData(StringData::Create(nNewLength)); pStart = m_pData->m_String; - FX_WCHAR* pDest = pNewData->m_String; + wchar_t* pDest = pNewData->m_String; for (FX_STRSIZE i = 0; i < nCount; i++) { - const FX_WCHAR* pTarget = FX_wcsstr(pStart, (FX_STRSIZE)(pEnd - pStart), - pOld.c_str(), nSourceLen); + const wchar_t* pTarget = FX_wcsstr(pStart, (FX_STRSIZE)(pEnd - pStart), + pOld.c_str(), nSourceLen); wmemcpy(pDest, pStart, pTarget - pStart); pDest += pTarget - pStart; wmemcpy(pDest, pNew.c_str(), pNew.GetLength()); @@ -784,7 +784,7 @@ FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld, return nCount; } -void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) { +void CFX_WideString::SetAt(FX_STRSIZE nIndex, wchar_t ch) { if (!m_pData) { return; } @@ -825,7 +825,7 @@ CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, } CFX_WideString result; - FX_WCHAR* buf = result.GetBuffer(wlen); + wchar_t* buf = result.GetBuffer(wlen); for (int i = 0; i < wlen; i++) { buf[i] = wstr[i]; } @@ -833,7 +833,7 @@ CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, return result; } -int CFX_WideString::Compare(const FX_WCHAR* lpsz) const { +int CFX_WideString::Compare(const wchar_t* lpsz) const { if (m_pData) return FXSYS_wcscmp(m_pData->m_String, lpsz); return (!lpsz || lpsz[0] == 0) ? 0 : -1; @@ -869,7 +869,7 @@ int CFX_WideString::Compare(const CFX_WideString& str) const { return 0; } -int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const { +int CFX_WideString::CompareNoCase(const wchar_t* lpsz) const { if (!m_pData) { return (!lpsz || lpsz[0] == 0) ? 0 : -1; } @@ -899,8 +899,8 @@ void CFX_WideString::TrimRight(const CFX_WideStringC& pTargets) { } } -void CFX_WideString::TrimRight(FX_WCHAR chTarget) { - FX_WCHAR str[2] = {chTarget, 0}; +void CFX_WideString::TrimRight(wchar_t chTarget) { + wchar_t str[2] = {chTarget, 0}; TrimRight(str); } @@ -932,20 +932,20 @@ void CFX_WideString::TrimLeft(const CFX_WideStringC& pTargets) { ReallocBeforeWrite(len); FX_STRSIZE nDataLength = len - pos; FXSYS_memmove(m_pData->m_String, m_pData->m_String + pos, - (nDataLength + 1) * sizeof(FX_WCHAR)); + (nDataLength + 1) * sizeof(wchar_t)); m_pData->m_nDataLength = nDataLength; } } -void CFX_WideString::TrimLeft(FX_WCHAR chTarget) { - FX_WCHAR str[2] = {chTarget, 0}; +void CFX_WideString::TrimLeft(wchar_t chTarget) { + wchar_t str[2] = {chTarget, 0}; TrimLeft(str); } void CFX_WideString::TrimLeft() { TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20"); } -FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) { +FX_FLOAT FX_wtof(const wchar_t* str, int len) { if (len == 0) { return 0.0; } @@ -996,7 +996,7 @@ CFX_ByteString CFX_CharMap::GetByteString(uint16_t codepage, nullptr, 0, nullptr, nullptr); CFX_ByteString bstr; if (dest_len) { - FX_CHAR* dest_buf = bstr.GetBuffer(dest_len); + char* dest_buf = bstr.GetBuffer(dest_len); FXSYS_WideCharToMultiByte(codepage, 0, wstr.c_str(), src_len, dest_buf, dest_len, nullptr, nullptr); bstr.ReleaseBuffer(dest_len); @@ -1013,7 +1013,7 @@ CFX_WideString CFX_CharMap::GetWideString(uint16_t codepage, FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); CFX_WideString wstr; if (dest_len) { - FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); + wchar_t* dest_buf = wstr.GetBuffer(dest_len); FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, dest_len); wstr.ReleaseBuffer(dest_len); diff --git a/core/fxcrt/fx_basic_wstring_unittest.cpp b/core/fxcrt/fx_basic_wstring_unittest.cpp index 07b5aaf13c..ceb4616b8a 100644 --- a/core/fxcrt/fx_basic_wstring_unittest.cpp +++ b/core/fxcrt/fx_basic_wstring_unittest.cpp @@ -296,7 +296,7 @@ TEST(fxcrt, WideStringRemove) { TEST(fxcrt, WideStringRemoveCopies) { CFX_WideString freed(L"FREED"); - const FX_WCHAR* old_buffer = freed.c_str(); + const wchar_t* old_buffer = freed.c_str(); // No change with single reference - no copy. freed.Remove(L'Q'); @@ -505,7 +505,7 @@ TEST(fxcrt, WideStringTrimRightCopies) { { // With a single reference, no copy takes place. CFX_WideString fred(L" FRED "); - const FX_WCHAR* old_buffer = fred.c_str(); + const wchar_t* old_buffer = fred.c_str(); fred.TrimRight(); EXPECT_EQ(L" FRED", fred); EXPECT_EQ(old_buffer, fred.c_str()); @@ -514,7 +514,7 @@ TEST(fxcrt, WideStringTrimRightCopies) { // With multiple references, we must copy. CFX_WideString fred(L" FRED "); CFX_WideString other_fred = fred; - const FX_WCHAR* old_buffer = fred.c_str(); + const wchar_t* old_buffer = fred.c_str(); fred.TrimRight(); EXPECT_EQ(L" FRED", fred); EXPECT_EQ(L" FRED ", other_fred); @@ -524,7 +524,7 @@ TEST(fxcrt, WideStringTrimRightCopies) { // With multiple references, but no modifications, no copy. CFX_WideString fred(L"FRED"); CFX_WideString other_fred = fred; - const FX_WCHAR* old_buffer = fred.c_str(); + const wchar_t* old_buffer = fred.c_str(); fred.TrimRight(); EXPECT_EQ(L"FRED", fred); EXPECT_EQ(L"FRED", other_fred); @@ -564,7 +564,7 @@ TEST(fxcrt, WideStringTrimLeftCopies) { { // With a single reference, no copy takes place. CFX_WideString fred(L" FRED "); - const FX_WCHAR* old_buffer = fred.c_str(); + const wchar_t* old_buffer = fred.c_str(); fred.TrimLeft(); EXPECT_EQ(L"FRED ", fred); EXPECT_EQ(old_buffer, fred.c_str()); @@ -573,7 +573,7 @@ TEST(fxcrt, WideStringTrimLeftCopies) { // With multiple references, we must copy. CFX_WideString fred(L" FRED "); CFX_WideString other_fred = fred; - const FX_WCHAR* old_buffer = fred.c_str(); + const wchar_t* old_buffer = fred.c_str(); fred.TrimLeft(); EXPECT_EQ(L"FRED ", fred); EXPECT_EQ(L" FRED ", other_fred); @@ -583,7 +583,7 @@ TEST(fxcrt, WideStringTrimLeftCopies) { // With multiple references, but no modifications, no copy. CFX_WideString fred(L"FRED"); CFX_WideString other_fred = fred; - const FX_WCHAR* old_buffer = fred.c_str(); + const wchar_t* old_buffer = fred.c_str(); fred.TrimLeft(); EXPECT_EQ(L"FRED", fred); EXPECT_EQ(L"FRED", other_fred); @@ -595,7 +595,7 @@ TEST(fxcrt, WideStringReserve) { { CFX_WideString str; str.Reserve(6); - const FX_WCHAR* old_buffer = str.c_str(); + const wchar_t* old_buffer = str.c_str(); str += L"ABCDEF"; EXPECT_EQ(old_buffer, str.c_str()); str += L"Blah Blah Blah Blah Blah Blah"; @@ -604,7 +604,7 @@ TEST(fxcrt, WideStringReserve) { { CFX_WideString str(L"A"); str.Reserve(6); - const FX_WCHAR* old_buffer = str.c_str(); + const wchar_t* old_buffer = str.c_str(); str += L"BCDEF"; EXPECT_EQ(old_buffer, str.c_str()); str += L"Blah Blah Blah Blah Blah Blah"; @@ -615,14 +615,14 @@ TEST(fxcrt, WideStringReserve) { TEST(fxcrt, WideStringGetBuffer) { { CFX_WideString str; - FX_WCHAR* buffer = str.GetBuffer(12); + wchar_t* buffer = str.GetBuffer(12); wcscpy(buffer, L"clams"); str.ReleaseBuffer(); EXPECT_EQ(L"clams", str); } { CFX_WideString str(L"cl"); - FX_WCHAR* buffer = str.GetBuffer(12); + wchar_t* buffer = str.GetBuffer(12); wcscpy(buffer + 2, L"ams"); str.ReleaseBuffer(); EXPECT_EQ(L"clams", str); @@ -634,7 +634,7 @@ TEST(fxcrt, WideStringReleaseBuffer) { CFX_WideString str; str.Reserve(12); str += L"clams"; - const FX_WCHAR* old_buffer = str.c_str(); + const wchar_t* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_EQ(old_buffer, str.c_str()); EXPECT_EQ(L"clam", str); @@ -643,7 +643,7 @@ TEST(fxcrt, WideStringReleaseBuffer) { CFX_WideString str(L"c"); str.Reserve(12); str += L"lams"; - const FX_WCHAR* old_buffer = str.c_str(); + const wchar_t* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_EQ(old_buffer, str.c_str()); EXPECT_EQ(L"clam", str); @@ -652,7 +652,7 @@ TEST(fxcrt, WideStringReleaseBuffer) { CFX_WideString str; str.Reserve(200); str += L"clams"; - const FX_WCHAR* old_buffer = str.c_str(); + const wchar_t* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_NE(old_buffer, str.c_str()); EXPECT_EQ(L"clam", str); @@ -661,7 +661,7 @@ TEST(fxcrt, WideStringReleaseBuffer) { CFX_WideString str(L"c"); str.Reserve(200); str += L"lams"; - const FX_WCHAR* old_buffer = str.c_str(); + const wchar_t* old_buffer = str.c_str(); str.ReleaseBuffer(4); EXPECT_NE(old_buffer, str.c_str()); EXPECT_EQ(L"clam", str); @@ -936,6 +936,6 @@ TEST(fxcrt, EmptyWideString) { CFX_WideString empty_str; EXPECT_TRUE(empty_str.IsEmpty()); EXPECT_EQ(0, empty_str.GetLength()); - const FX_WCHAR* cstr = empty_str.c_str(); + const wchar_t* cstr = empty_str.c_str(); EXPECT_EQ(0, FXSYS_wcslen(cstr)); } diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp index e82b3e7284..5ad6439e07 100644 --- a/core/fxcrt/fx_bidi.cpp +++ b/core/fxcrt/fx_bidi.cpp @@ -12,7 +12,7 @@ CFX_BidiChar::CFX_BidiChar() : m_CurrentSegment({0, 0, NEUTRAL}), m_LastSegment({0, 0, NEUTRAL}) {} -bool CFX_BidiChar::AppendChar(FX_WCHAR wch) { +bool CFX_BidiChar::AppendChar(wchar_t wch) { uint32_t dwProps = FX_GetUnicodeProperties(wch); int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; Direction direction = NEUTRAL; diff --git a/core/fxcrt/fx_bidi.h b/core/fxcrt/fx_bidi.h index 8d12cc8997..d5e0bd3f62 100644 --- a/core/fxcrt/fx_bidi.h +++ b/core/fxcrt/fx_bidi.h @@ -28,7 +28,7 @@ class CFX_BidiChar { // Append a character and classify it as left, right, or neutral. // Returns true if the character has a different direction than the // existing direction to indicate there is a segment to process. - bool AppendChar(FX_WCHAR wch); + bool AppendChar(wchar_t wch); // Call this after the last character has been appended. AppendChar() // must not be called after this. @@ -61,7 +61,7 @@ class CFX_BidiString { // Force the overall direction to be R2L regardless of what was detected. void SetOverallDirectionRight(); - FX_WCHAR CharAt(size_t x) const { return m_Str[x]; } + wchar_t CharAt(size_t x) const { return m_Str[x]; } const_iterator begin() const { return m_Order.begin(); } const_iterator end() const { return m_Order.end(); } diff --git a/core/fxcrt/fx_bidi_unittest.cpp b/core/fxcrt/fx_bidi_unittest.cpp index 2c1996be46..ad598a6741 100644 --- a/core/fxcrt/fx_bidi_unittest.cpp +++ b/core/fxcrt/fx_bidi_unittest.cpp @@ -7,9 +7,9 @@ namespace { -const FX_WCHAR kNeutralChar = 32; -const FX_WCHAR kLeftChar = 65; -const FX_WCHAR kRightChar = 1424; +const wchar_t kNeutralChar = 32; +const wchar_t kLeftChar = 65; +const wchar_t kRightChar = 1424; } // namespace @@ -126,7 +126,7 @@ TEST(fxcrt, BidiStringEmpty) { TEST(fxcrt, BidiStringAllNeutral) { { - const FX_WCHAR str[] = {kNeutralChar, 0}; + const wchar_t str[] = {kNeutralChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::LEFT, bidi.OverallDirection()); @@ -139,7 +139,7 @@ TEST(fxcrt, BidiStringAllNeutral) { EXPECT_TRUE(it == bidi.end()); } { - const FX_WCHAR str[] = {kNeutralChar, kNeutralChar, kNeutralChar, 0}; + const wchar_t str[] = {kNeutralChar, kNeutralChar, kNeutralChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::LEFT, bidi.OverallDirection()); @@ -155,7 +155,7 @@ TEST(fxcrt, BidiStringAllNeutral) { TEST(fxcrt, BidiStringAllLeft) { { - const FX_WCHAR str[] = {kLeftChar, 0}; + const wchar_t str[] = {kLeftChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::LEFT, bidi.OverallDirection()); @@ -176,7 +176,7 @@ TEST(fxcrt, BidiStringAllLeft) { EXPECT_TRUE(it == bidi.end()); } { - const FX_WCHAR str[] = {kLeftChar, kLeftChar, kLeftChar, 0}; + const wchar_t str[] = {kLeftChar, kLeftChar, kLeftChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::LEFT, bidi.OverallDirection()); @@ -200,7 +200,7 @@ TEST(fxcrt, BidiStringAllLeft) { TEST(fxcrt, BidiStringAllRight) { { - const FX_WCHAR str[] = {kRightChar, 0}; + const wchar_t str[] = {kRightChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::RIGHT, bidi.OverallDirection()); @@ -221,7 +221,7 @@ TEST(fxcrt, BidiStringAllRight) { EXPECT_TRUE(it == bidi.end()); } { - const FX_WCHAR str[] = {kRightChar, kRightChar, kRightChar, 0}; + const wchar_t str[] = {kRightChar, kRightChar, kRightChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::RIGHT, bidi.OverallDirection()); @@ -244,7 +244,7 @@ TEST(fxcrt, BidiStringAllRight) { } TEST(fxcrt, BidiStringLeftNeutralLeftRight) { - const FX_WCHAR str[] = {kLeftChar, kNeutralChar, kLeftChar, kRightChar, 0}; + const wchar_t str[] = {kLeftChar, kNeutralChar, kLeftChar, kRightChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::LEFT, bidi.OverallDirection()); @@ -284,7 +284,7 @@ TEST(fxcrt, BidiStringLeftNeutralLeftRight) { } TEST(fxcrt, BidiStringRightNeutralLeftRight) { - const FX_WCHAR str[] = {kRightChar, kNeutralChar, kLeftChar, kRightChar, 0}; + const wchar_t str[] = {kRightChar, kNeutralChar, kLeftChar, kRightChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::RIGHT, bidi.OverallDirection()); @@ -324,7 +324,7 @@ TEST(fxcrt, BidiStringRightNeutralLeftRight) { } TEST(fxcrt, BidiStringReverse) { - const FX_WCHAR str[] = {kLeftChar, kNeutralChar, kRightChar, kLeftChar, 0}; + const wchar_t str[] = {kLeftChar, kNeutralChar, kRightChar, kLeftChar, 0}; CFX_BidiString bidi(str); EXPECT_EQ(CFX_BidiChar::LEFT, bidi.OverallDirection()); bidi.SetOverallDirectionRight(); diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h index 9203938c2c..3ee5a4f91f 100644 --- a/core/fxcrt/fx_ext.h +++ b/core/fxcrt/fx_ext.h @@ -17,15 +17,15 @@ FX_FLOAT FXSYS_tan(FX_FLOAT a); FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x); -FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, +FX_FLOAT FXSYS_strtof(const char* pcsStr, int32_t iLength = -1, int32_t* pUsedLen = nullptr); -FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, +FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength = -1, int32_t* pUsedLen = nullptr); -FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count); -int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); -int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count); +wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count); +int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count); +int32_t FXSYS_strnicmp(const char* s1, const char* s2, size_t count); inline bool FXSYS_islower(int32_t ch) { return ch >= 'a' && ch <= 'z'; @@ -48,30 +48,30 @@ inline bool FXSYS_iswdigit(wchar_t wch) { inline bool FXSYS_iswalnum(wchar_t wch) { return FXSYS_iswalpha(wch) || FXSYS_iswdigit(wch); } -inline bool FXSYS_iswspace(FX_WCHAR c) { +inline bool FXSYS_iswspace(wchar_t c) { return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09); } -inline int FXSYS_toHexDigit(const FX_CHAR c) { +inline int FXSYS_toHexDigit(const char c) { if (!std::isxdigit(c)) return 0; char upchar = std::toupper(c); return upchar > '9' ? upchar - 'A' + 10 : upchar - '0'; } -inline bool FXSYS_isDecimalDigit(const FX_CHAR c) { +inline bool FXSYS_isDecimalDigit(const char c) { return !!std::isdigit(c); } -inline bool FXSYS_isDecimalDigit(const FX_WCHAR c) { +inline bool FXSYS_isDecimalDigit(const wchar_t c) { return !!std::iswdigit(c); } -inline int FXSYS_toDecimalDigit(const FX_CHAR c) { +inline int FXSYS_toDecimalDigit(const char c) { return std::isdigit(c) ? c - '0' : 0; } -inline int FXSYS_toDecimalDigit(const FX_WCHAR c) { +inline int FXSYS_toDecimalDigit(const wchar_t c) { return std::iswdigit(c) ? c - L'0' : 0; } diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 5b577f745c..0b7197ec7c 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -387,7 +387,7 @@ CFX_RetainPtr<IFX_FileAccess> IFX_FileAccess::CreateDefault( // static CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( - const FX_CHAR* filename, + const char* filename, uint32_t dwModes) { std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); if (!pFA->Open(filename, dwModes)) @@ -397,7 +397,7 @@ CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( // static CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( - const FX_WCHAR* filename, + const wchar_t* filename, uint32_t dwModes) { std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); if (!pFA->Open(filename, dwModes)) @@ -407,7 +407,7 @@ CFX_RetainPtr<IFX_SeekableStream> IFX_SeekableStream::CreateFromFilename( // static CFX_RetainPtr<IFX_SeekableReadStream> -IFX_SeekableReadStream::CreateFromFilename(const FX_CHAR* filename) { +IFX_SeekableReadStream::CreateFromFilename(const char* filename) { return IFX_SeekableStream::CreateFromFilename(filename, FX_FILEMODE_ReadOnly); } @@ -429,9 +429,7 @@ FX_FLOAT FXSYS_tan(FX_FLOAT a) { FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { return FXSYS_log(x) / FXSYS_log(b); } -FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, - int32_t iLength, - int32_t* pUsedLen) { +FX_FLOAT FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pcsStr); if (iLength < 0) { iLength = (int32_t)FXSYS_strlen(pcsStr); @@ -440,7 +438,7 @@ FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, CFX_WideString::FromLocal(CFX_ByteStringC(pcsStr, iLength)); return FXSYS_wcstof(ws.c_str(), iLength, pUsedLen); } -FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, +FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pwsStr); @@ -461,7 +459,7 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, } FX_FLOAT fValue = 0.0f; while (iUsedLen < iLength) { - FX_WCHAR wch = pwsStr[iUsedLen]; + wchar_t wch = pwsStr[iUsedLen]; if (wch >= L'0' && wch <= L'9') { fValue = fValue * 10.0f + (wch - L'0'); } else { @@ -472,7 +470,7 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, if (iUsedLen < iLength && pwsStr[iUsedLen] == L'.') { FX_FLOAT fPrecise = 0.1f; while (++iUsedLen < iLength) { - FX_WCHAR wch = pwsStr[iUsedLen]; + wchar_t wch = pwsStr[iUsedLen]; if (wch >= L'0' && wch <= L'9') { fValue += (wch - L'0') * fPrecise; fPrecise *= 0.1f; @@ -486,9 +484,7 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, } return bNegtive ? -fValue : fValue; } -FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, - const FX_WCHAR* srcStr, - size_t count) { +wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count) { ASSERT(dstStr && srcStr && count > 0); for (size_t i = 0; i < count; ++i) if ((dstStr[i] = srcStr[i]) == L'\0') { @@ -496,24 +492,24 @@ FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, } return dstStr; } -int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { +int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count) { ASSERT(s1 && s2 && count > 0); - FX_WCHAR wch1 = 0, wch2 = 0; + wchar_t wch1 = 0, wch2 = 0; while (count-- > 0) { - wch1 = (FX_WCHAR)FXSYS_tolower(*s1++); - wch2 = (FX_WCHAR)FXSYS_tolower(*s2++); + wch1 = (wchar_t)FXSYS_tolower(*s1++); + wch2 = (wchar_t)FXSYS_tolower(*s2++); if (wch1 != wch2) { break; } } return wch1 - wch2; } -int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) { +int32_t FXSYS_strnicmp(const char* s1, const char* s2, size_t count) { ASSERT(s1 && s2 && count > 0); - FX_CHAR ch1 = 0, ch2 = 0; + char ch1 = 0, ch2 = 0; while (count-- > 0) { - ch1 = (FX_CHAR)FXSYS_tolower(*s1++); - ch2 = (FX_CHAR)FXSYS_tolower(*s2++); + ch1 = (char)FXSYS_tolower(*s1++); + ch2 = (char)FXSYS_tolower(*s2++); if (ch1 != ch2) { break; } @@ -652,7 +648,7 @@ void FX_Random_GenerateCrypto(uint32_t* pBuffer, int32_t iCount) { } #ifdef PDF_ENABLE_XFA -static const FX_CHAR gs_FX_pHexChars[] = "0123456789ABCDEF"; +static const char gs_FX_pHexChars[] = "0123456789ABCDEF"; void FX_GUID_CreateV4(FX_GUID* pGUID) { FX_Random_GenerateMT((uint32_t*)pGUID, 4); uint8_t& b = ((uint8_t*)pGUID)[6]; @@ -661,7 +657,7 @@ void FX_GUID_CreateV4(FX_GUID* pGUID) { void FX_GUID_ToString(const FX_GUID* pGUID, CFX_ByteString& bsStr, bool bSeparator) { - FX_CHAR* pBuf = bsStr.GetBuffer(40); + char* pBuf = bsStr.GetBuffer(40); uint8_t b; for (int32_t i = 0; i < 16; i++) { b = ((const uint8_t*)pGUID)[i]; diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h index 2f4b5ad280..4a89a3400e 100644 --- a/core/fxcrt/fx_stream.h +++ b/core/fxcrt/fx_stream.h @@ -38,12 +38,12 @@ typedef DIR FX_FileHandle; #define FX_FILESIZE off_t #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -FX_FileHandle* FX_OpenFolder(const FX_CHAR* path); +FX_FileHandle* FX_OpenFolder(const char* path); bool FX_GetNextFile(FX_FileHandle* handle, CFX_ByteString* filename, bool* bFolder); void FX_CloseFolder(FX_FileHandle* handle); -FX_WCHAR FX_GetFolderSeparator(); +wchar_t FX_GetFolderSeparator(); #define FX_FILEMODE_Write 0 #define FX_FILEMODE_ReadOnly 1 @@ -76,7 +76,7 @@ class IFX_SeekableWriteStream : public IFX_WriteStream { class IFX_SeekableReadStream : public IFX_ReadStream { public: static CFX_RetainPtr<IFX_SeekableReadStream> CreateFromFilename( - const FX_CHAR* filename); + const char* filename); // IFX_ReadStream: bool IsEOF() override; @@ -91,11 +91,11 @@ class IFX_SeekableStream : public IFX_SeekableReadStream, public IFX_SeekableWriteStream { public: static CFX_RetainPtr<IFX_SeekableStream> CreateFromFilename( - const FX_CHAR* filename, + const char* filename, uint32_t dwModes); static CFX_RetainPtr<IFX_SeekableStream> CreateFromFilename( - const FX_WCHAR* filename, + const wchar_t* filename, uint32_t dwModes); // IFX_SeekableReadStream: diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h index cd93f27275..01be6a1901 100644 --- a/core/fxcrt/fx_string.h +++ b/core/fxcrt/fx_string.h @@ -21,8 +21,8 @@ class CFX_ByteString; class CFX_WideString; -using CFX_ByteStringC = CFX_StringCTemplate<FX_CHAR>; -using CFX_WideStringC = CFX_StringCTemplate<FX_WCHAR>; +using CFX_ByteStringC = CFX_StringCTemplate<char>; +using CFX_WideStringC = CFX_StringCTemplate<wchar_t>; #define FXBSTR_ID(c1, c2, c3, c4) \ (((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) | ((uint32_t)c3 << 8) | \ @@ -32,7 +32,7 @@ using CFX_WideStringC = CFX_StringCTemplate<FX_WCHAR>; // avoids the cost of std::string's iterator stability guarantees. class CFX_ByteString { public: - using CharType = FX_CHAR; + using CharType = char; CFX_ByteString(); CFX_ByteString(const CFX_ByteString& other); @@ -42,9 +42,9 @@ class CFX_ByteString { // NOLINTNEXTLINE(runtime/explicit) CFX_ByteString(char ch); // NOLINTNEXTLINE(runtime/explicit) - CFX_ByteString(const FX_CHAR* ptr); + CFX_ByteString(const char* ptr); - CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len); + CFX_ByteString(const char* ptr, FX_STRSIZE len); CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len); explicit CFX_ByteString(const CFX_ByteStringC& bstrc); @@ -54,12 +54,12 @@ class CFX_ByteString { void clear() { m_pData.Reset(); } - static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1); + static CFX_ByteString FromUnicode(const wchar_t* ptr, FX_STRSIZE len = -1); static CFX_ByteString FromUnicode(const CFX_WideString& str); // Explicit conversion to C-style string. // Note: Any subsequent modification of |this| will invalidate the result. - const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; } + const char* c_str() const { return m_pData ? m_pData->m_String : ""; } // Explicit conversion to uint8_t*. // Note: Any subsequent modification of |this| will invalidate the result. @@ -92,12 +92,12 @@ class CFX_ByteString { bool operator<(const CFX_ByteString& str) const; - const CFX_ByteString& operator=(const FX_CHAR* str); + const CFX_ByteString& operator=(const char* str); const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc); const CFX_ByteString& operator=(const CFX_ByteString& stringSrc); - const CFX_ByteString& operator+=(FX_CHAR ch); - const CFX_ByteString& operator+=(const FX_CHAR* str); + const CFX_ByteString& operator+=(char ch); + const CFX_ByteString& operator+=(const char* str); const CFX_ByteString& operator+=(const CFX_ByteString& str); const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc); @@ -109,15 +109,15 @@ class CFX_ByteString { return m_pData ? m_pData->m_String[nIndex] : 0; } - void SetAt(FX_STRSIZE nIndex, FX_CHAR ch); - FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch); + void SetAt(FX_STRSIZE nIndex, char ch); + FX_STRSIZE Insert(FX_STRSIZE index, char ch); FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1); - void Format(const FX_CHAR* lpszFormat, ...); - void FormatV(const FX_CHAR* lpszFormat, va_list argList); + void Format(const char* lpszFormat, ...); + void FormatV(const char* lpszFormat, va_list argList); void Reserve(FX_STRSIZE len); - FX_CHAR* GetBuffer(FX_STRSIZE len); + char* GetBuffer(FX_STRSIZE len); void ReleaseBuffer(FX_STRSIZE len = -1); CFX_ByteString Mid(FX_STRSIZE first) const; @@ -126,24 +126,24 @@ class CFX_ByteString { CFX_ByteString Right(FX_STRSIZE count) const; FX_STRSIZE Find(const CFX_ByteStringC& lpszSub, FX_STRSIZE start = 0) const; - FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const; - FX_STRSIZE ReverseFind(FX_CHAR ch) const; + FX_STRSIZE Find(char ch, FX_STRSIZE start = 0) const; + FX_STRSIZE ReverseFind(char ch) const; void MakeLower(); void MakeUpper(); void TrimRight(); - void TrimRight(FX_CHAR chTarget); + void TrimRight(char chTarget); void TrimRight(const CFX_ByteStringC& lpszTargets); void TrimLeft(); - void TrimLeft(FX_CHAR chTarget); + void TrimLeft(char chTarget); void TrimLeft(const CFX_ByteStringC& lpszTargets); FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld, const CFX_ByteStringC& lpszNew); - FX_STRSIZE Remove(FX_CHAR ch); + FX_STRSIZE Remove(char ch); CFX_WideString UTF8Decode() const; @@ -157,15 +157,15 @@ class CFX_ByteString { static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0); protected: - using StringData = CFX_StringDataTemplate<FX_CHAR>; + using StringData = CFX_StringDataTemplate<char>; void ReallocBeforeWrite(FX_STRSIZE nNewLen); void AllocBeforeWrite(FX_STRSIZE nNewLen); void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const; - void AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen); - void Concat(const FX_CHAR* lpszSrcData, FX_STRSIZE nSrcLen); + void AssignCopy(const char* pSrcData, FX_STRSIZE nSrcLen); + void Concat(const char* lpszSrcData, FX_STRSIZE nSrcLen); CFX_RetainPtr<StringData> m_pData; @@ -190,36 +190,32 @@ inline CFX_ByteString operator+(const CFX_ByteStringC& str1, const CFX_ByteStringC& str2) { return CFX_ByteString(str1, str2); } -inline CFX_ByteString operator+(const CFX_ByteStringC& str1, - const FX_CHAR* str2) { +inline CFX_ByteString operator+(const CFX_ByteStringC& str1, const char* str2) { return CFX_ByteString(str1, str2); } -inline CFX_ByteString operator+(const FX_CHAR* str1, - const CFX_ByteStringC& str2) { +inline CFX_ByteString operator+(const char* str1, const CFX_ByteStringC& str2) { return CFX_ByteString(str1, str2); } -inline CFX_ByteString operator+(const CFX_ByteStringC& str1, FX_CHAR ch) { +inline CFX_ByteString operator+(const CFX_ByteStringC& str1, char ch) { return CFX_ByteString(str1, CFX_ByteStringC(ch)); } -inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteStringC& str2) { +inline CFX_ByteString operator+(char ch, const CFX_ByteStringC& str2) { return CFX_ByteString(ch, str2); } inline CFX_ByteString operator+(const CFX_ByteString& str1, const CFX_ByteString& str2) { return CFX_ByteString(str1.AsStringC(), str2.AsStringC()); } -inline CFX_ByteString operator+(const CFX_ByteString& str1, FX_CHAR ch) { +inline CFX_ByteString operator+(const CFX_ByteString& str1, char ch) { return CFX_ByteString(str1.AsStringC(), CFX_ByteStringC(ch)); } -inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteString& str2) { +inline CFX_ByteString operator+(char ch, const CFX_ByteString& str2) { return CFX_ByteString(ch, str2.AsStringC()); } -inline CFX_ByteString operator+(const CFX_ByteString& str1, - const FX_CHAR* str2) { +inline CFX_ByteString operator+(const CFX_ByteString& str1, const char* str2) { return CFX_ByteString(str1.AsStringC(), str2); } -inline CFX_ByteString operator+(const FX_CHAR* str1, - const CFX_ByteString& str2) { +inline CFX_ByteString operator+(const char* str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2.AsStringC()); } inline CFX_ByteString operator+(const CFX_ByteString& str1, @@ -235,7 +231,7 @@ inline CFX_ByteString operator+(const CFX_ByteStringC& str1, // avoids the cost of std::string's iterator stability guarantees. class CFX_WideString { public: - using CharType = FX_WCHAR; + using CharType = wchar_t; CFX_WideString(); CFX_WideString(const CFX_WideString& other); @@ -243,11 +239,11 @@ class CFX_WideString { // Deliberately implicit to avoid calling on every string literal. // NOLINTNEXTLINE(runtime/explicit) - CFX_WideString(FX_WCHAR ch); + CFX_WideString(wchar_t ch); // NOLINTNEXTLINE(runtime/explicit) - CFX_WideString(const FX_WCHAR* ptr); + CFX_WideString(const wchar_t* ptr); - CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len); + CFX_WideString(const wchar_t* ptr, FX_STRSIZE len); explicit CFX_WideString(const CFX_WideStringC& str); CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2); @@ -265,7 +261,7 @@ class CFX_WideString { // Explicit conversion to C-style wide string. // Note: Any subsequent modification of |this| will invalidate the result. - const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; } + const wchar_t* c_str() const { return m_pData ? m_pData->m_String : L""; } // Explicit conversion to CFX_WideStringC. // Note: Any subsequent modification of |this| will invalidate the result. @@ -278,12 +274,12 @@ class CFX_WideString { FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } bool IsEmpty() const { return !GetLength(); } - const CFX_WideString& operator=(const FX_WCHAR* str); + const CFX_WideString& operator=(const wchar_t* str); const CFX_WideString& operator=(const CFX_WideString& stringSrc); const CFX_WideString& operator=(const CFX_WideStringC& stringSrc); - const CFX_WideString& operator+=(const FX_WCHAR* str); - const CFX_WideString& operator+=(FX_WCHAR ch); + const CFX_WideString& operator+=(const wchar_t* str); + const CFX_WideString& operator+=(wchar_t ch); const CFX_WideString& operator+=(const CFX_WideString& str); const CFX_WideString& operator+=(const CFX_WideStringC& str); @@ -299,67 +295,67 @@ class CFX_WideString { bool operator<(const CFX_WideString& str) const; - FX_WCHAR GetAt(FX_STRSIZE nIndex) const { + wchar_t GetAt(FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; } - FX_WCHAR operator[](FX_STRSIZE nIndex) const { + wchar_t operator[](FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; } - void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch); + void SetAt(FX_STRSIZE nIndex, wchar_t ch); - int Compare(const FX_WCHAR* str) const; + int Compare(const wchar_t* str) const; int Compare(const CFX_WideString& str) const; - int CompareNoCase(const FX_WCHAR* str) const; + int CompareNoCase(const wchar_t* str) const; CFX_WideString Mid(FX_STRSIZE first) const; CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const; CFX_WideString Left(FX_STRSIZE count) const; CFX_WideString Right(FX_STRSIZE count) const; - FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch); + FX_STRSIZE Insert(FX_STRSIZE index, wchar_t ch); FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1); - void Format(const FX_WCHAR* lpszFormat, ...); - void FormatV(const FX_WCHAR* lpszFormat, va_list argList); + void Format(const wchar_t* lpszFormat, ...); + void FormatV(const wchar_t* lpszFormat, va_list argList); void MakeLower(); void MakeUpper(); void TrimRight(); - void TrimRight(FX_WCHAR chTarget); + void TrimRight(wchar_t chTarget); void TrimRight(const CFX_WideStringC& pTargets); void TrimLeft(); - void TrimLeft(FX_WCHAR chTarget); + void TrimLeft(wchar_t chTarget); void TrimLeft(const CFX_WideStringC& pTargets); void Reserve(FX_STRSIZE len); - FX_WCHAR* GetBuffer(FX_STRSIZE len); + wchar_t* GetBuffer(FX_STRSIZE len); void ReleaseBuffer(FX_STRSIZE len = -1); int GetInteger() const; FX_FLOAT GetFloat() const; FX_STRSIZE Find(const CFX_WideStringC& pSub, FX_STRSIZE start = 0) const; - FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const; + FX_STRSIZE Find(wchar_t ch, FX_STRSIZE start = 0) const; FX_STRSIZE Replace(const CFX_WideStringC& pOld, const CFX_WideStringC& pNew); - FX_STRSIZE Remove(FX_WCHAR ch); + FX_STRSIZE Remove(wchar_t ch); CFX_ByteString UTF8Encode() const; CFX_ByteString UTF16LE_Encode() const; protected: - using StringData = CFX_StringDataTemplate<FX_WCHAR>; + using StringData = CFX_StringDataTemplate<wchar_t>; void ReallocBeforeWrite(FX_STRSIZE nLen); void AllocBeforeWrite(FX_STRSIZE nLen); void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const; - void AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen); - void Concat(const FX_WCHAR* lpszSrcData, FX_STRSIZE nSrcLen); + void AssignCopy(const wchar_t* pSrcData, FX_STRSIZE nSrcLen); + void Concat(const wchar_t* lpszSrcData, FX_STRSIZE nSrcLen); CFX_RetainPtr<StringData> m_pData; @@ -372,34 +368,34 @@ inline CFX_WideString operator+(const CFX_WideStringC& str1, return CFX_WideString(str1, str2); } inline CFX_WideString operator+(const CFX_WideStringC& str1, - const FX_WCHAR* str2) { + const wchar_t* str2) { return CFX_WideString(str1, str2); } -inline CFX_WideString operator+(const FX_WCHAR* str1, +inline CFX_WideString operator+(const wchar_t* str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); } -inline CFX_WideString operator+(const CFX_WideStringC& str1, FX_WCHAR ch) { +inline CFX_WideString operator+(const CFX_WideStringC& str1, wchar_t ch) { return CFX_WideString(str1, CFX_WideStringC(ch)); } -inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideStringC& str2) { +inline CFX_WideString operator+(wchar_t ch, const CFX_WideStringC& str2) { return CFX_WideString(ch, str2); } inline CFX_WideString operator+(const CFX_WideString& str1, const CFX_WideString& str2) { return CFX_WideString(str1.AsStringC(), str2.AsStringC()); } -inline CFX_WideString operator+(const CFX_WideString& str1, FX_WCHAR ch) { +inline CFX_WideString operator+(const CFX_WideString& str1, wchar_t ch) { return CFX_WideString(str1.AsStringC(), CFX_WideStringC(ch)); } -inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideString& str2) { +inline CFX_WideString operator+(wchar_t ch, const CFX_WideString& str2) { return CFX_WideString(ch, str2.AsStringC()); } inline CFX_WideString operator+(const CFX_WideString& str1, - const FX_WCHAR* str2) { + const wchar_t* str2) { return CFX_WideString(str1.AsStringC(), str2); } -inline CFX_WideString operator+(const FX_WCHAR* str1, +inline CFX_WideString operator+(const wchar_t* str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2.AsStringC()); } @@ -430,7 +426,7 @@ inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { return FX_atof(FX_UTF8Encode(wsStr).c_str()); } bool FX_atonum(const CFX_ByteStringC& str, void* pData); -FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); +FX_STRSIZE FX_ftoa(FX_FLOAT f, char* buf); uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase); uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase); diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h index c31bef974f..a0878981d8 100644 --- a/core/fxcrt/fx_system.h +++ b/core/fxcrt/fx_system.h @@ -70,8 +70,6 @@ extern "C" { typedef void* FX_POSITION; // Keep until fxcrt containers gone typedef float FX_FLOAT; // Keep, allow upgrade to doubles. typedef double FX_DOUBLE; // Keep, allow downgrade to floats. -typedef char FX_CHAR; // Keep, questionable signedness. -typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) @@ -141,7 +139,7 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); #define FXSYS_wfopen _wfopen #endif #else -FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode); +FXSYS_FILE* FXSYS_wfopen(const wchar_t* filename, const wchar_t* mode); #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #ifdef __cplusplus @@ -153,27 +151,27 @@ FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode); #define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr)) // Overloaded functions for C++ templates -inline FX_STRSIZE FXSYS_len(const FX_CHAR* ptr) { +inline FX_STRSIZE FXSYS_len(const char* ptr) { return FXSYS_strlen(ptr); } -inline FX_STRSIZE FXSYS_len(const FX_WCHAR* ptr) { +inline FX_STRSIZE FXSYS_len(const wchar_t* ptr) { return FXSYS_wcslen(ptr); } -inline int FXSYS_cmp(const FX_CHAR* ptr1, const FX_CHAR* ptr2, size_t len) { +inline int FXSYS_cmp(const char* ptr1, const char* ptr2, size_t len) { return memcmp(ptr1, ptr2, len); } -inline int FXSYS_cmp(const FX_WCHAR* ptr1, const FX_WCHAR* ptr2, size_t len) { +inline int FXSYS_cmp(const wchar_t* ptr1, const wchar_t* ptr2, size_t len) { return wmemcmp(ptr1, ptr2, len); } -inline const FX_CHAR* FXSYS_chr(const FX_CHAR* ptr, FX_CHAR ch, size_t len) { - return reinterpret_cast<const FX_CHAR*>(memchr(ptr, ch, len)); +inline const char* FXSYS_chr(const char* ptr, char ch, size_t len) { + return reinterpret_cast<const char*>(memchr(ptr, ch, len)); } -inline const FX_WCHAR* FXSYS_chr(const FX_WCHAR* ptr, FX_WCHAR ch, size_t len) { +inline const wchar_t* FXSYS_chr(const wchar_t* ptr, wchar_t ch, size_t len) { return wmemchr(ptr, ch, len); } @@ -276,12 +274,12 @@ wchar_t* FXSYS_wcsupr(wchar_t* str); #define FXSYS_LOBYTE(word) ((uint8_t)(word)) #define FXSYS_HIWORD(dword) ((uint16_t)((dword) >> 16)) #define FXSYS_LOWORD(dword) ((uint16_t)(dword)) -int32_t FXSYS_atoi(const FX_CHAR* str); -uint32_t FXSYS_atoui(const FX_CHAR* str); -int32_t FXSYS_wtoi(const FX_WCHAR* str); -int64_t FXSYS_atoi64(const FX_CHAR* str); -int64_t FXSYS_wtoi64(const FX_WCHAR* str); -const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix); +int32_t FXSYS_atoi(const char* str); +uint32_t FXSYS_atoui(const char* str); +int32_t FXSYS_wtoi(const wchar_t* str); +int64_t FXSYS_atoi64(const char* str); +int64_t FXSYS_wtoi64(const wchar_t* str); +const char* FXSYS_i64toa(int64_t value, char* str, int radix); int FXSYS_round(FX_FLOAT f); #define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b)) #ifdef __cplusplus diff --git a/core/fxcrt/fx_system_unittest.cpp b/core/fxcrt/fx_system_unittest.cpp index 4ab37c7bdb..def0043bab 100644 --- a/core/fxcrt/fx_system_unittest.cpp +++ b/core/fxcrt/fx_system_unittest.cpp @@ -16,11 +16,11 @@ namespace { -const FX_CHAR kSentinel = 0x7f; +const char kSentinel = 0x7f; void Check32BitBase16Itoa(int32_t input, const char* expected_output) { const size_t kBufLen = 11; // "-" + 8 digits + NUL + sentinel. - FX_CHAR buf[kBufLen]; + char buf[kBufLen]; buf[kBufLen - 1] = kSentinel; FXSYS_itoa(input, buf, 16); EXPECT_EQ(std::string(expected_output), buf); @@ -29,7 +29,7 @@ void Check32BitBase16Itoa(int32_t input, const char* expected_output) { void Check32BitBase10Itoa(int32_t input, const char* expected_output) { const size_t kBufLen = 13; // "-" + 10 digits + NUL + sentinel. - FX_CHAR buf[kBufLen]; + char buf[kBufLen]; buf[kBufLen - 1] = kSentinel; FXSYS_itoa(input, buf, 10); EXPECT_EQ(std::string(expected_output), buf); @@ -38,7 +38,7 @@ void Check32BitBase10Itoa(int32_t input, const char* expected_output) { void Check32BitBase2Itoa(int32_t input, const char* expected_output) { const size_t kBufLen = 35; // "-" + 32 digits + NUL + sentinel. - FX_CHAR buf[kBufLen]; + char buf[kBufLen]; buf[kBufLen - 1] = kSentinel; FXSYS_itoa(input, buf, 2); EXPECT_EQ(std::string(expected_output), buf); @@ -47,7 +47,7 @@ void Check32BitBase2Itoa(int32_t input, const char* expected_output) { void Check64BitBase16Itoa(int64_t input, const char* expected_output) { const size_t kBufLen = 19; // "-" + 16 digits + NUL + sentinel. - FX_CHAR buf[kBufLen]; + char buf[kBufLen]; buf[kBufLen - 1] = kSentinel; FXSYS_i64toa(input, buf, 16); EXPECT_EQ(std::string(expected_output), buf); @@ -56,7 +56,7 @@ void Check64BitBase16Itoa(int64_t input, const char* expected_output) { void Check64BitBase10Itoa(int64_t input, const char* expected_output) { const size_t kBufLen = 22; // "-" + 19 digits + NUL + sentinel. - FX_CHAR buf[kBufLen]; + char buf[kBufLen]; buf[kBufLen - 1] = kSentinel; FXSYS_i64toa(input, buf, 10); EXPECT_EQ(std::string(expected_output), buf); @@ -65,7 +65,7 @@ void Check64BitBase10Itoa(int64_t input, const char* expected_output) { void Check64BitBase2Itoa(int64_t input, const char* expected_output) { const size_t kBufLen = 67; // "-" + 64 digits + NUL + sentinel. - FX_CHAR buf[kBufLen]; + char buf[kBufLen]; buf[kBufLen - 1] = kSentinel; FXSYS_i64toa(input, buf, 2); EXPECT_EQ(std::string(expected_output), buf); @@ -75,7 +75,7 @@ void Check64BitBase2Itoa(int64_t input, const char* expected_output) { } // namespace TEST(fxcrt, FXSYS_itoa_InvalidRadix) { - FX_CHAR buf[32]; + char buf[32]; FXSYS_itoa(42, buf, 17); // Ours stops at 16. EXPECT_EQ(std::string(""), buf); @@ -115,7 +115,7 @@ TEST(fxcrt, FXSYS_itoa) { } TEST(fxcrt, FXSYS_i64toa_InvalidRadix) { - FX_CHAR buf[32]; + char buf[32]; FXSYS_i64toa(42, buf, 17); // Ours stops at 16. EXPECT_EQ(std::string(""), buf); diff --git a/core/fxcrt/fx_ucd.h b/core/fxcrt/fx_ucd.h index 488c275808..b96d09a406 100644 --- a/core/fxcrt/fx_ucd.h +++ b/core/fxcrt/fx_ucd.h @@ -45,13 +45,13 @@ extern const size_t kFXTextLayoutVerticalMirrorSize; extern const uint16_t kFXTextLayoutBidiMirror[]; extern const size_t kFXTextLayoutBidiMirrorSize; -uint32_t FX_GetUnicodeProperties(FX_WCHAR wch); -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical); +uint32_t FX_GetUnicodeProperties(wchar_t wch); +wchar_t FX_GetMirrorChar(wchar_t wch, bool bRTL, bool bVertical); #ifdef PDF_ENABLE_XFA // As defined in http://www.unicode.org/reports/tr14/ -enum FX_CHARBREAKPROP { +enum FXCHAR_BREAKPROP { FX_CBP_OP = 0, // Opening Punctuation FX_CBP_CL = 1, // Closing Punctuation FX_CBP_QU = 2, // Ambiguous Quotation @@ -114,10 +114,10 @@ inline FX_CHARTYPE GetCharTypeFromProp(uint32_t prop) { return static_cast<FX_CHARTYPE>(prop & FX_CHARTYPEBITSMASK); } -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, - uint32_t dwProps, - bool bRTL, - bool bVertical); +wchar_t FX_GetMirrorChar(wchar_t wch, + uint32_t dwProps, + bool bRTL, + bool bVertical); #endif // PDF_ENABLE_XFA diff --git a/core/fxcrt/fx_unicode.cpp b/core/fxcrt/fx_unicode.cpp index 44fa8e743d..fce826dac8 100644 --- a/core/fxcrt/fx_unicode.cpp +++ b/core/fxcrt/fx_unicode.cpp @@ -6,14 +6,14 @@ #include "core/fxcrt/fx_ucd.h" -uint32_t FX_GetUnicodeProperties(FX_WCHAR wch) { +uint32_t FX_GetUnicodeProperties(wchar_t wch) { size_t idx = static_cast<size_t>(wch); if (idx < kTextLayoutCodePropertiesSize) return kTextLayoutCodeProperties[(uint16_t)wch]; return 0; } -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical) { +wchar_t FX_GetMirrorChar(wchar_t wch, bool bRTL, bool bVertical) { uint32_t dwProps = FX_GetUnicodeProperties(wch); uint32_t dwTemp = (dwProps & 0xFF800000); if (bRTL && dwTemp < 0xFF800000) { @@ -35,10 +35,10 @@ FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical) { } #ifdef PDF_ENABLE_XFA -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, - uint32_t dwProps, - bool bRTL, - bool bVertical) { +wchar_t FX_GetMirrorChar(wchar_t wch, + uint32_t dwProps, + bool bRTL, + bool bVertical) { uint32_t dwTemp = (dwProps & 0xFF800000); if (bRTL && dwTemp < 0xFF800000) { size_t idx = dwTemp >> 23; diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index 761aae7775..b81ae4e0d9 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -367,7 +367,7 @@ uint32_t CXML_Parser::GetCharRef() { break; } if (g_FXCRT_XML_IsDigital(ch)) - code = code * 10 + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(ch)); + code = code * 10 + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch)); break; case 4: m_dwIndex++; @@ -380,7 +380,7 @@ uint32_t CXML_Parser::GetCharRef() { if (nHex) { if (nHex == FXCRTM_XML_CHARTYPE_HexDigital) { code = - (code << 4) + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(ch)); + (code << 4) + FXSYS_toDecimalDigit(static_cast<wchar_t>(ch)); } else if (nHex == FXCRTM_XML_CHARTYPE_HexLowerLetter) { code = (code << 4) + ch - 87; } else { |