diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-07-28 14:07:04 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-28 18:21:44 +0000 |
commit | e7a99de4f711302d57fe22682a9a8c3cfddb458c (patch) | |
tree | 7bb176d42e2a2181f014b41bd621d6b242ed20e7 /fpdfsdk/fpdfppo.cpp | |
parent | 106eecd27f346a0bc7f11f29a058a8fd16a77682 (diff) | |
download | pdfium-e7a99de4f711302d57fe22682a9a8c3cfddb458c.tar.xz |
Convert calls to Mid() to Left() or Right() if possible
The various string/byte classes support Mid(), Left(), and Right() for
extracting substrings. Mid() can handle all possible cases, but Left()
and Right() are useful for common cases and more explicit about what
is going on.
Calls like Mid(offset, length - offset) can be converted to
Right(length - offset). Calls like Mid(0, length) can be converted to
Left(length).
If the substring being extracted does not extend all the way to one of
the edges of the string, then Mid() still needs to be used.
BUG=pdfium:828
Change-Id: I2ec46ad3d71aac0f7b513e103c69cbe8c854cf62
Reviewed-on: https://pdfium-review.googlesource.com/9510
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfppo.cpp')
-rw-r--r-- | fpdfsdk/fpdfppo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp index d05fab9c0b..bc3d769574 100644 --- a/fpdfsdk/fpdfppo.cpp +++ b/fpdfsdk/fpdfppo.cpp @@ -91,7 +91,7 @@ bool ParserPageRangeString(CFX_ByteString rangstring, nStringTo = rangstring.Find(',', nStringFrom); if (nStringTo == -1) nStringTo = nLength; - cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom); + cbMidRange = rangstring.Right(nStringTo - nStringFrom); int nMid = cbMidRange.Find('-'); if (nMid == -1) { long lPageNum = atol(cbMidRange.c_str()); @@ -99,7 +99,7 @@ bool ParserPageRangeString(CFX_ByteString rangstring, return false; pageArray->push_back((uint16_t)lPageNum); } else { - int nStartPageNum = atol(cbMidRange.Mid(0, nMid).c_str()); + int nStartPageNum = atol(cbMidRange.Left(nMid).c_str()); if (nStartPageNum == 0) return false; |