Better tests for CFXJSE_FormCalcContext::Decode().
Fix the obvious overruns along the way.
Scope variables tighter to avoid potential for duplicate insertion of
stale values under dubious logic. Then combine some redundant code.
Introduce new functions for wide character classification.
Change-Id: I937c5c4030e4f614c399b6b3d82a43331008efd7
Reviewed-on: https://pdfium-review.googlesource.com/c/45793
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
index 2e46c26..ef79196 100644
--- a/core/fxcrt/fx_extension.h
+++ b/core/fxcrt/fx_extension.h
@@ -72,6 +72,10 @@
return !((c & 0x80) || !std::isxdigit(c));
}
+inline bool FXSYS_IsWideHexDigit(wchar_t c) {
+ return !((c & 0xFFFFFF80) || !std::isxdigit(c));
+}
+
inline int FXSYS_HexCharToInt(char c) {
if (!FXSYS_IsHexDigit(c))
return 0;
@@ -79,6 +83,13 @@
return upchar > '9' ? upchar - 'A' + 10 : upchar - '0';
}
+inline int FXSYS_WideHexCharToInt(wchar_t c) {
+ if (!FXSYS_IsWideHexDigit(c))
+ return 0;
+ char upchar = std::toupper(static_cast<char>(c));
+ return upchar > '9' ? upchar - 'A' + 10 : upchar - '0';
+}
+
inline bool FXSYS_IsDecimalDigit(char c) {
return !((c & 0x80) || !std::isdigit(c));
}