summaryrefslogtreecommitdiff
path: root/fxjs/cjs_util.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-16 21:45:18 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-16 21:45:18 +0000
commit3f1c832dda209cf6682bb75316c07d71332fe6c3 (patch)
tree79e274e65a500bc7964fe4328a6185c805274640 /fxjs/cjs_util.cpp
parent40d522134a11867adb95f77c0b7891932e0739a2 (diff)
downloadpdfium-3f1c832dda209cf6682bb75316c07d71332fe6c3.tar.xz
Make WideString::{Format|FormatV} static
This CL moves the Format and FormatV methods from WideString to be static. Bug: pdfium:934 Change-Id: I9941d6a2a5bbf0a82087cd0ea5d0f8fc42eecd3e Reviewed-on: https://pdfium-review.googlesource.com/18630 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cjs_util.cpp')
-rw-r--r--fxjs/cjs_util.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 9fc1093158..c7bf027695 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -115,19 +115,20 @@ CJS_Return util::printf(CJS_Runtime* pRuntime,
WideString strSegment;
switch (ParseDataType(&c_strFormat)) {
case UTIL_INT:
- strSegment.Format(c_strFormat.c_str(),
- pRuntime->ToInt32(params[iIndex]));
+ strSegment = WideString::Format(c_strFormat.c_str(),
+ pRuntime->ToInt32(params[iIndex]));
break;
case UTIL_DOUBLE:
- strSegment.Format(c_strFormat.c_str(),
- pRuntime->ToDouble(params[iIndex]));
+ strSegment = WideString::Format(c_strFormat.c_str(),
+ pRuntime->ToDouble(params[iIndex]));
break;
case UTIL_STRING:
- strSegment.Format(c_strFormat.c_str(),
- pRuntime->ToWideString(params[iIndex]).c_str());
+ strSegment =
+ WideString::Format(c_strFormat.c_str(),
+ pRuntime->ToWideString(params[iIndex]).c_str());
break;
default:
- strSegment.Format(L"%ls", c_strFormat.c_str());
+ strSegment = WideString::Format(L"%ls", c_strFormat.c_str());
break;
}
c_strResult += strSegment.c_str();
@@ -164,16 +165,16 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
WideString swResult;
switch (pRuntime->ToInt32(params[0])) {
case 0:
- swResult.Format(L"D:%04d%02d%02d%02d%02d%02d", year, month, day, hour,
- min, sec);
+ swResult = WideString::Format(L"D:%04d%02d%02d%02d%02d%02d", year,
+ month, day, hour, min, sec);
break;
case 1:
- swResult.Format(L"%04d.%02d.%02d %02d:%02d:%02d", year, month, day,
- hour, min, sec);
+ swResult = WideString::Format(L"%04d.%02d.%02d %02d:%02d:%02d", year,
+ month, day, hour, min, sec);
break;
case 2:
- swResult.Format(L"%04d/%02d/%02d %02d:%02d:%02d", year, month, day,
- hour, min, sec);
+ swResult = WideString::Format(L"%04d/%02d/%02d %02d:%02d:%02d", year,
+ month, day, hour, min, sec);
break;
default:
return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
@@ -215,9 +216,6 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
};
for (size_t i = 0; i < FX_ArraySize(cTableAd); ++i) {
- WideString sValue;
- sValue.Format(L"%d", cTableAd[i].iValue);
-
int iStart = 0;
int iEnd;
while ((iEnd = cFormat.find(cTableAd[i].lpszJSMark, iStart)) != -1) {
@@ -227,7 +225,8 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
continue;
}
}
- cFormat.replace(iEnd, wcslen(cTableAd[i].lpszJSMark), sValue.c_str());
+ cFormat.replace(iEnd, wcslen(cTableAd[i].lpszJSMark),
+ WideString::Format(L"%d", cTableAd[i].iValue).c_str());
iStart = iEnd;
}
}