summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/cpdf_filespec.cpp43
-rw-r--r--core/fxcrt/cfx_bytestring.h4
-rw-r--r--core/fxcrt/cfx_widestring.h4
3 files changed, 25 insertions, 26 deletions
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index e5f026e573..086515b9a8 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -22,9 +22,9 @@ CFX_WideString ChangeSlashToPlatform(const wchar_t* str) {
while (*str) {
if (*str == '/') {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- result += ':';
+ result += L':';
#else
- result += '\\';
+ result += L'\\';
#endif
} else {
result += *str;
@@ -38,7 +38,7 @@ CFX_WideString ChangeSlashToPDF(const wchar_t* str) {
CFX_WideString result;
while (*str) {
if (*str == '\\' || *str == ':')
- result += '/';
+ result += L'/';
else
result += *str;
@@ -60,19 +60,19 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) {
return ChangeSlashToPlatform(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- if (filepath.GetAt(0) != '/')
+ if (filepath.GetAt(0) != L'/')
return ChangeSlashToPlatform(filepath.c_str());
- if (filepath.GetAt(1) == '/')
+ if (filepath.GetAt(1) == L'/')
return ChangeSlashToPlatform(filepath.c_str() + 1);
- if (filepath.GetAt(2) == '/') {
+ if (filepath.GetAt(2) == L'/') {
CFX_WideString result;
result += filepath.GetAt(1);
- result += ':';
+ result += L':';
result += ChangeSlashToPlatform(filepath.c_str() + 2);
return result;
}
CFX_WideString result;
- result += '\\';
+ result += L'\\';
result += ChangeSlashToPlatform(filepath.c_str());
return result;
#else
@@ -122,33 +122,24 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) {
return CFX_WideString();
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- if (filepath.GetAt(1) == ':') {
- CFX_WideString result;
- result = '/';
+ if (filepath.GetAt(1) == L':') {
+ CFX_WideString result(L'/');
result += filepath.GetAt(0);
- if (filepath.GetAt(2) != '\\')
- result += '/';
+ if (filepath.GetAt(2) != L'\\')
+ result += L'/';
result += ChangeSlashToPDF(filepath.c_str() + 2);
return result;
}
- if (filepath.GetAt(0) == '\\' && filepath.GetAt(1) == '\\')
+ if (filepath.GetAt(0) == L'\\' && filepath.GetAt(1) == L'\\')
return ChangeSlashToPDF(filepath.c_str() + 1);
- if (filepath.GetAt(0) == '\\') {
- CFX_WideString result;
- result = '/';
- result += ChangeSlashToPDF(filepath.c_str());
- return result;
- }
+ if (filepath.GetAt(0) == L'\\')
+ return L'/' + ChangeSlashToPDF(filepath.c_str());
return ChangeSlashToPDF(filepath.c_str());
#elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- if (filepath.Left(sizeof("Mac") - 1) == L"Mac") {
- CFX_WideString result;
- result = '/';
- result += ChangeSlashToPDF(filepath.c_str());
- return result;
- }
+ if (filepath.Left(sizeof("Mac") - 1) == L"Mac")
+ return L'/' + ChangeSlashToPDF(filepath.c_str());
return ChangeSlashToPDF(filepath.c_str());
#else
return CFX_WideString(filepath);
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
index 0ffe92936a..c4d48954ba 100644
--- a/core/fxcrt/cfx_bytestring.h
+++ b/core/fxcrt/cfx_bytestring.h
@@ -35,6 +35,10 @@ class CFX_ByteString {
// NOLINTNEXTLINE(runtime/explicit)
CFX_ByteString(const char* ptr);
+ // No implicit conversions from wide strings.
+ // NOLINTNEXTLINE(runtime/explicit)
+ CFX_ByteString(wchar_t) = delete;
+
CFX_ByteString(const char* ptr, FX_STRSIZE len);
CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h
index fd3c92a15e..977114816d 100644
--- a/core/fxcrt/cfx_widestring.h
+++ b/core/fxcrt/cfx_widestring.h
@@ -35,6 +35,10 @@ class CFX_WideString {
// NOLINTNEXTLINE(runtime/explicit)
CFX_WideString(const wchar_t* ptr);
+ // No implicit conversions from byte strings.
+ // NOLINTNEXTLINE(runtime/explicit)
+ CFX_WideString(char) = delete;
+
CFX_WideString(const wchar_t* ptr, FX_STRSIZE len);
explicit CFX_WideString(const CFX_WideStringC& str);