summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_filespec.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-04-25 09:43:52 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-25 16:58:04 +0000
commitd524e4bf80314ade4a6aedf77b8b4adaa96bfcee (patch)
tree8ced866d27eca1c14c060b1c4b538fbcba2b6179 /core/fpdfdoc/cpdf_filespec.cpp
parent49f8dc5b1afc4f92110bf40b7639ee1138aa7240 (diff)
downloadpdfium-d524e4bf80314ade4a6aedf77b8b4adaa96bfcee.tar.xz
Delete some CFX string ctors.
Prevent implicit construction of CFX_WideString from non-wchar_t variables. Similarly prevent implicit construction of CFX_ByteString from non-char variables. Fix up CBC_OnedCodaBarWriter which tries to do the above, and simplify code there using pdfium::ContainsValue(). Same for CPDF_FileSpec. Change-Id: I3db7125a68ef3f64c2f235d38e974767cd083dc3 Reviewed-on: https://pdfium-review.googlesource.com/4478 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_filespec.cpp')
-rw-r--r--core/fpdfdoc/cpdf_filespec.cpp43
1 files changed, 17 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);