diff options
author | Lei Zhang <thestig@chromium.org> | 2017-04-24 16:16:49 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-25 13:11:17 +0000 |
commit | ab1faaa7f81b7dafe03d546341c6a643a58b3678 (patch) | |
tree | 76278cedc2e5787b4a5b814cf1150efe3038c435 /xfa/fgas | |
parent | ef002c85521278e3082517297cf60372d7751cb1 (diff) | |
download | pdfium-ab1faaa7f81b7dafe03d546341c6a643a58b3678.tar.xz |
Use fx_extension.h utilities in more places in xfa/
Change-Id: Id58c313aa446ecfa223e5c8edc095586b62a61fa
Reviewed-on: https://pdfium-review.googlesource.com/4455
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas')
-rw-r--r-- | xfa/fgas/crt/cfgas_formatstring.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index d4ac87c7bc..0c2e307b7c 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -89,6 +89,16 @@ int32_t ParseTimeZone(const wchar_t* pStr, int32_t iLen, FX_TIMEZONE* tz) { return iStart; } +int32_t ConvertHex(int32_t iKeyValue, wchar_t ch) { + if (std::iswdigit(ch)) + return iKeyValue * 16 + ch - '0'; + if (FXSYS_islower(ch)) + return iKeyValue * 16 + ch - 'a' + 10; + if (FXSYS_isupper(ch)) + return iKeyValue * 16 + ch - 'A' + 10; + return iKeyValue; +} + CFX_WideString GetLiteralText(const wchar_t* pStrPattern, int32_t& iPattern, int32_t iLenPattern) { @@ -104,9 +114,8 @@ CFX_WideString GetLiteralText(const wchar_t* pStrPattern, if ((iPattern + 1 >= iLenPattern) || ((pStrPattern[iPattern + 1] != '\'') && (iQuote % 2 == 0))) { break; - } else { - iQuote++; } + iQuote++; iPattern++; } else if (pStrPattern[iPattern] == '\\' && (iPattern + 1 < iLenPattern) && pStrPattern[iPattern + 1] == 'u') { @@ -115,13 +124,7 @@ CFX_WideString GetLiteralText(const wchar_t* pStrPattern, int32_t i = 0; while (iPattern < iLenPattern && i++ < 4) { wchar_t ch = pStrPattern[iPattern++]; - if ((ch >= '0' && ch <= '9')) { - iKeyValue = iKeyValue * 16 + ch - '0'; - } else if ((ch >= 'a' && ch <= 'f')) { - iKeyValue = iKeyValue * 16 + ch - 'a' + 10; - } else if ((ch >= 'A' && ch <= 'F')) { - iKeyValue = iKeyValue * 16 + ch - 'A' + 10; - } + iKeyValue = ConvertHex(iKeyValue, ch); } if (iKeyValue != 0) { wsOutput += (wchar_t)(iKeyValue & 0x0000FFFF); @@ -158,13 +161,7 @@ CFX_WideString GetLiteralTextReverse(const wchar_t* pStrPattern, int32_t i = 1; for (; i < iLen && i < 5; i++) { wchar_t ch = wsOutput[i]; - if ((ch >= '0' && ch <= '9')) { - iKeyValue = iKeyValue * 16 + ch - '0'; - } else if ((ch >= 'a' && ch <= 'f')) { - iKeyValue = iKeyValue * 16 + ch - 'a' + 10; - } else if ((ch >= 'A' && ch <= 'F')) { - iKeyValue = iKeyValue * 16 + ch - 'A' + 10; - } + iKeyValue = ConvertHex(iKeyValue, ch); } if (iKeyValue != 0) { wsOutput.Delete(0, i); |