diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-09-01 11:14:18 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-01 15:26:31 +0000 |
commit | 57cb5447d68c01eddba0618c3a8fe450b180f917 (patch) | |
tree | 5f17dc4c02c331d81a005db179c4a2a9b51b7e46 /fpdfsdk/javascript | |
parent | ffb6ccf6a2699cbb2bfc925c96609fae5124f51f (diff) | |
download | pdfium-57cb5447d68c01eddba0618c3a8fe450b180f917.tar.xz |
Adjust loops in preperation for FX_STRSIZE int->size_t
Adjust loop conditions and behaviours in preperation for convering the
underlying type of FX_STRSIZE to size_t. These changes are not
dependent on the type switch occuring, so can be landed before hand.
BUG=pdfium:828
Change-Id: I5f950c99c10e5ef0836959e3b1dd2e09f8f5afc0
Reviewed-on: https://pdfium-review.googlesource.com/12750
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r-- | fpdfsdk/javascript/Document.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index d5875aca69..77f67b5c8f 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -1016,16 +1016,17 @@ bool Document::documentFileName(CJS_Runtime* pRuntime, return false; } CFX_WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath(); - FX_STRSIZE i = wsFilePath.GetLength() - 1; - for (; i >= 0; i--) { - if (wsFilePath[i] == L'\\' || wsFilePath[i] == L'/') + FX_STRSIZE i = wsFilePath.GetLength(); + for (; i > 0; i--) { + if (wsFilePath[i - 1] == L'\\' || wsFilePath[i - 1] == L'/') break; } - if (i >= 0 && i < wsFilePath.GetLength() - 1) { - vp << (wsFilePath.GetBuffer(wsFilePath.GetLength()) + i + 1); - } else { + + if (i > 0 && i < wsFilePath.GetLength()) + vp << (wsFilePath.GetBuffer(wsFilePath.GetLength()) + i); + else vp << L""; - } + return true; } |