diff options
author | tsepez <tsepez@chromium.org> | 2016-05-12 15:52:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-12 15:52:14 -0700 |
commit | 28c7844c1ef5ea0c8727b890e9ff56b593119a00 (patch) | |
tree | a96e31bbff3c221a0030e3a8a6501a5f81379d0f /core/fpdfapi/fpdf_parser | |
parent | ade9465067098d9f94a13f61741cebf4bb8aac47 (diff) | |
download | pdfium-28c7844c1ef5ea0c8727b890e9ff56b593119a00.tar.xz |
Add CFX_ByteStringC::CharAt() to avoid c_str() and casts.
Most of the time, we want to operate on chars as if they
were unsigned, but there are a few places where we need
the default (questionably signed) values. Consolidate
the casting in a single place rather than forcing callers
to get a char* ptr.
BUG=pdfium:493
Review-Url: https://codereview.chromium.org/1972053003
Diffstat (limited to 'core/fpdfapi/fpdf_parser')
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index 03975149b0..1e9252fa82 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -87,21 +87,20 @@ int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteStringC& key) { } CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) { - int size = bstr.GetLength(); - const FX_CHAR* pSrc = bstr.c_str(); if (bstr.Find('#') == -1) return bstr; + int size = bstr.GetLength(); CFX_ByteString result; FX_CHAR* pDestStart = result.GetBuffer(size); FX_CHAR* pDest = pDestStart; for (int i = 0; i < size; i++) { - if (pSrc[i] == '#' && i < size - 2) { + if (bstr[i] == '#' && i < size - 2) { *pDest++ = - FXSYS_toHexDigit(pSrc[i + 1]) * 16 + FXSYS_toHexDigit(pSrc[i + 2]); + FXSYS_toHexDigit(bstr[i + 1]) * 16 + FXSYS_toHexDigit(bstr[i + 2]); i += 2; } else { - *pDest++ = pSrc[i]; + *pDest++ = bstr[i]; } } result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); |