Simplify struct TbConvertAdditional.
Replace its const wchar_t* with just wchar_t, since all the strings are
just 1 character in length.
Change-Id: I3dfca707b7f13c4dca59a7c1bf989ef6271df3df
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/74890
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index dd5296a..029ed7a 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -42,8 +42,8 @@
// Map PDF-style directives lacking direct wcsftime directives to
// the value with which they will be replaced.
struct TbConvertAdditional {
- const wchar_t* lpszJSMark;
- int iValue;
+ wchar_t js_mark;
+ int value;
};
const TbConvert TbConvertTable[] = {
@@ -230,23 +230,23 @@
return CJS_Result::Failure(JSMessage::kValueError);
const TbConvertAdditional cTableAd[] = {
- {L"m", month}, {L"d", day},
- {L"H", hour}, {L"h", hour > 12 ? hour - 12 : hour},
- {L"M", min}, {L"s", sec},
+ {L'm', month}, {L'd', day},
+ {L'H', hour}, {L'h', hour > 12 ? hour - 12 : hour},
+ {L'M', min}, {L's', sec},
};
for (size_t i = 0; i < pdfium::size(cTableAd); ++i) {
int iStart = 0;
int iEnd;
- while ((iEnd = cFormat.find(cTableAd[i].lpszJSMark, iStart)) != -1) {
+ while ((iEnd = cFormat.find(cTableAd[i].js_mark, iStart)) != -1) {
if (iEnd > 0) {
if (cFormat[iEnd - 1] == L'%') {
iStart = iEnd + 1;
continue;
}
}
- cFormat.replace(iEnd, wcslen(cTableAd[i].lpszJSMark),
- WideString::Format(L"%d", cTableAd[i].iValue).c_str());
+ cFormat.replace(iEnd, 1,
+ WideString::Format(L"%d", cTableAd[i].value).c_str());
iStart = iEnd;
}
}