From 0bc02c152bd0c178a5946196e2054a5cdc7650f4 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 26 Feb 2018 21:02:52 +0000 Subject: Add some more missing consts. Get things out of the .data section. Change-Id: I375cf00186a3d5d8d10f5d147bd4b692f5db3683 Reviewed-on: https://pdfium-review.googlesource.com/27130 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- xfa/fxfa/fm2js/cxfa_fmlexer.cpp | 2 +- xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp | 10 ---------- xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h | 8 ++++++-- xfa/fxfa/parser/cxfa_node_statics.cpp | 8 ++++++-- 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp index 41989f0a2d..3559fb7aeb 100644 --- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp @@ -78,7 +78,7 @@ const XFA_FMKeyword keyWords[] = { }; #ifndef NDEBUG -const wchar_t* tokenStrings[] = { +const wchar_t* const tokenStrings[] = { L"TOKand", L"TOKlparen", L"TOKrparen", L"TOKmul", L"TOKplus", L"TOKcomma", L"TOKminus", L"TOKdot", L"TOKdiv", L"TOKlt", L"TOKassign", L"TOKgt", diff --git a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp index 6312ba6b3d..023516bb6e 100644 --- a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.cpp @@ -4,17 +4,7 @@ #include "xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h" -namespace { - -// Arbitarily picked by looking at how deep a translation got before hitting -// the getting fuzzer memory limits. Should be larger then |kMaxParseDepth| in -// cxfa_fmparser.cpp. -const unsigned int kMaxDepth = 5000; - -} // namespace - unsigned long CXFA_FMToJavaScriptDepth::depth_ = 0; -unsigned long CXFA_FMToJavaScriptDepth::max_depth_ = kMaxDepth; void CXFA_FMToJavaScriptDepth::Reset() { depth_ = 0; diff --git a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h index 14f87a68f5..f4cd1be472 100644 --- a/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h +++ b/xfa/fxfa/fm2js/cxfa_fmtojavascriptdepth.h @@ -10,13 +10,17 @@ class CXFA_FMToJavaScriptDepth { CXFA_FMToJavaScriptDepth() { depth_++; } ~CXFA_FMToJavaScriptDepth() { depth_--; } - bool IsWithinMaxDepth() const { return depth_ <= max_depth_; } + bool IsWithinMaxDepth() const { return depth_ <= kMaxDepth; } static void Reset(); private: + // Arbitarily picked by looking at how deep a translation got before hitting + // the getting fuzzer memory limits. Should be larger then |kMaxParseDepth| in + // cxfa_fmparser.cpp. + const unsigned long kMaxDepth = 5000; + static unsigned long depth_; - static unsigned long max_depth_; }; #endif // XFA_FXFA_FM2JS_CXFA_FMTOJAVASCRIPTDEPTH_H_ diff --git a/xfa/fxfa/parser/cxfa_node_statics.cpp b/xfa/fxfa/parser/cxfa_node_statics.cpp index 93860c6a0a..3d64c1a66f 100644 --- a/xfa/fxfa/parser/cxfa_node_statics.cpp +++ b/xfa/fxfa/parser/cxfa_node_statics.cpp @@ -318,7 +318,9 @@ namespace { struct ElementNameInfo { uint32_t hash; XFA_Element element; -} ElementNameToEnum[] = { +}; + +const ElementNameInfo ElementNameToEnum[] = { {0x23ee3 /* ps */, XFA_Element::Ps}, {0x25363 /* to */, XFA_Element::To}, {0x2587e /* ui */, XFA_Element::Ui}, @@ -631,7 +633,9 @@ struct ElementNameInfo { struct AttributeNameInfo { uint32_t hash; XFA_Attribute attribute; -} AttributeNameInfoToEnum[] = { +}; + +const AttributeNameInfo AttributeNameInfoToEnum[] = { {0x68 /* h */, XFA_Attribute::H}, {0x77 /* w */, XFA_Attribute::W}, {0x78 /* x */, XFA_Attribute::X}, -- cgit v1.2.3