From 3f1c832dda209cf6682bb75316c07d71332fe6c3 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 16 Nov 2017 21:45:18 +0000 Subject: 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 Commit-Queue: dsinclair --- fxjs/cjs_util.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'fxjs/cjs_util.cpp') 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; } } -- cgit v1.2.3