summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-27 16:28:44 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 21:05:23 +0000
commit33805cc811c722a0c5cd439cff419de252cd39c9 (patch)
treebb6ef4484ff62486e4cc0ea49642278b5da1b746 /xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
parent4191b03e29ef54f37deeadf652ee11cbfb81f9df (diff)
downloadpdfium-33805cc811c722a0c5cd439cff419de252cd39c9.tar.xz
Remove single param Mid() method from string classes
This support is being removed from CFX_ByteString, CFX_ByteStringC, CFX_WideString, and CFX_WideStringC. This standardizes all of these classes to only have one Mid method that takes in 2 params, offset and count. Count now must be positive. The old behaviour of calculating the length for the user if -1 is passed in for the count has been removed. This work is in preperation for converting these classes to not accept negative lengths anywhere and thus make the underlying size type unsigned. BUG=pdfium:828 Change-Id: I5f15e7b7b00b264231817f143e2da88ee6f69e7b Reviewed-on: https://pdfium-review.googlesource.com/9430 Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 445d729668..1910e60e3e 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -1138,7 +1138,8 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
CXFA_Document* pDoc = pContext->GetDocument();
CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
CFX_ByteString szArgString = ValueToUTF8String(argOne.get());
- szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1);
+ FX_STRSIZE pos = szArgString.Find('T', 0);
+ szArgString = szArgString.Mid(pos + 1, szArgString.GetLength() - (pos + 1));
if (szArgString.IsEmpty()) {
args.GetReturnValue()->SetInteger(0);
return;
@@ -3692,7 +3693,9 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
wsDatePattern += wsPattern.Left(iTChar) + L"} ";
CFX_WideString wsTimePattern(L"time{");
- wsTimePattern += wsPattern.Mid(iTChar + 1) + L"}";
+ wsTimePattern +=
+ wsPattern.Mid(iTChar + 1, wsPattern.GetLength() - (iTChar + 1)) +
+ L"}";
wsPattern = wsDatePattern + wsTimePattern;
} break;
case XFA_VT_DATE: {
@@ -3877,7 +3880,10 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
case XFA_VT_DATETIME: {
FX_STRSIZE iTChar = wsPattern.Find(L'T');
CFX_WideString wsDatePattern(L"date{" + wsPattern.Left(iTChar) + L"} ");
- CFX_WideString wsTimePattern(L"time{" + wsPattern.Mid(iTChar + 1) + L"}");
+ CFX_WideString wsTimePattern(
+ L"time{" +
+ wsPattern.Mid(iTChar + 1, wsPattern.GetLength() - (iTChar + 1)) +
+ L"}");
wsPattern = wsDatePattern + wsTimePattern;
CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
pMgr);