From 69da36c5f841e8c6e5ded6c704d9ef58c57d532a Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 9 Mar 2018 17:46:50 +0000 Subject: Explicitly mark helper methods that only operate on ASCII ranges A number of our character helper methods take in wide character types, but only do tests/operations on the ASCII range of characters. As a very quick first pass I am renaming all of the foot-gun methods to explictly call out this behaviour, while I do a bigger cleanup/refactor. BUG=pdfium:1035 Change-Id: Ia035dfa1cb6812fa6d45155c4565475032c4c165 Reviewed-on: https://pdfium-review.googlesource.com/28330 Commit-Queue: Ryan Harrison Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima Reviewed-by: dsinclair --- fxjs/cjs_util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fxjs/cjs_util.cpp') diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index 56bf4133d3..d552fcdf34 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp @@ -264,9 +264,9 @@ CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime, enum CaseMode { kPreserveCase, kUpperCase, kLowerCase }; static wchar_t TranslateCase(wchar_t input, CaseMode eMode) { - if (eMode == kLowerCase && FXSYS_isupper(input)) + if (eMode == kLowerCase && FXSYS_isASCIIupper(input)) return input | 0x20; - if (eMode == kUpperCase && FXSYS_islower(input)) + if (eMode == kUpperCase && FXSYS_isASCIIlower(input)) return input & ~0x20; return input; } @@ -311,7 +311,7 @@ WideString CJS_Util::printx(const WideString& wsFormat, } break; case 'X': { if (iSourceIdx < wsSource.GetLength()) { - if (FXSYS_iswalnum(wsSource[iSourceIdx])) { + if (FXSYS_iswASCIIalnum(wsSource[iSourceIdx])) { wsResult += TranslateCase(wsSource[iSourceIdx], eCaseMode); ++iFormatIdx; } @@ -322,7 +322,7 @@ WideString CJS_Util::printx(const WideString& wsFormat, } break; case 'A': { if (iSourceIdx < wsSource.GetLength()) { - if (FXSYS_iswalpha(wsSource[iSourceIdx])) { + if (FXSYS_iswASCIIalpha(wsSource[iSourceIdx])) { wsResult += TranslateCase(wsSource[iSourceIdx], eCaseMode); ++iFormatIdx; } -- cgit v1.2.3