Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: xfa/src/fxfa/src/fm2js/xfa_lexer.h

Issue 1701363003: Fix some issues with CXFA_FMParse/CXFA_FMLexer infinite looping. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address nits Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp ('k') | xfa/src/fxfa/src/fm2js/xfa_lexer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _XFA_FM_LEXER_H 7 #ifndef _XFA_FM_LEXER_H
8 #define _XFA_FM_LEXER_H 8 #define _XFA_FM_LEXER_H
9
10 #include <memory>
11
9 enum XFA_FM_TOKEN { 12 enum XFA_FM_TOKEN {
10 TOKand, 13 TOKand,
11 TOKlparen, 14 TOKlparen,
12 TOKrparen, 15 TOKrparen,
13 TOKmul, 16 TOKmul,
14 TOKplus, 17 TOKplus,
15 TOKcomma, 18 TOKcomma,
16 TOKminus, 19 TOKminus,
17 TOKdot, 20 TOKdot,
18 TOKdiv, 21 TOKdiv,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 TOKstar, 72 TOKstar,
70 TOKidentifier, 73 TOKidentifier,
71 TOKunderscore, 74 TOKunderscore,
72 TOKdollar, 75 TOKdollar,
73 TOKexclamation, 76 TOKexclamation,
74 TOKcall, 77 TOKcall,
75 TOKstring, 78 TOKstring,
76 TOKnumber, 79 TOKnumber,
77 TOKreserver 80 TOKreserver
78 }; 81 };
82
79 struct XFA_FMKeyword { 83 struct XFA_FMKeyword {
80 XFA_FM_TOKEN m_type; 84 XFA_FM_TOKEN m_type;
81 uint32_t m_uHash; 85 uint32_t m_uHash;
82 const FX_WCHAR* m_keword; 86 const FX_WCHAR* m_keword;
83 }; 87 };
88
84 const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op); 89 const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op);
90
85 class CXFA_FMToken { 91 class CXFA_FMToken {
86 public: 92 public:
87 CXFA_FMToken(); 93 CXFA_FMToken();
88 CXFA_FMToken(FX_DWORD uLineNum); 94 explicit CXFA_FMToken(FX_DWORD uLineNum);
89 ~CXFA_FMToken(); 95
90 CFX_WideStringC m_wstring; 96 CFX_WideStringC m_wstring;
91 XFA_FM_TOKEN m_type; 97 XFA_FM_TOKEN m_type;
92 FX_DWORD m_uLinenum; 98 FX_DWORD m_uLinenum;
93 CXFA_FMToken* m_pNext;
94 }; 99 };
100
95 class CXFA_FMLexer { 101 class CXFA_FMLexer {
96 public: 102 public:
97 CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo); 103 CXFA_FMLexer(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
98 ~CXFA_FMLexer();
99 CXFA_FMToken* NextToken(); 104 CXFA_FMToken* NextToken();
100 FX_DWORD Number(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); 105 FX_DWORD Number(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd);
101 FX_DWORD String(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd); 106 FX_DWORD String(CXFA_FMToken* t, const FX_WCHAR* p, const FX_WCHAR*& pEnd);
102 FX_DWORD Identifiers(CXFA_FMToken* t, 107 FX_DWORD Identifiers(CXFA_FMToken* t,
103 const FX_WCHAR* p, 108 const FX_WCHAR* p,
104 const FX_WCHAR*& pEnd); 109 const FX_WCHAR*& pEnd);
105 void Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd); 110 void Comment(const FX_WCHAR* p, const FX_WCHAR*& pEnd);
106 XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p); 111 XFA_FM_TOKEN IsKeyword(const CFX_WideStringC& p);
107 void SetCurrentLine(FX_DWORD line) { m_uCurrentLine = line; } 112 void SetCurrentLine(FX_DWORD line) { m_uCurrentLine = line; }
108 void SetToken(CXFA_FMToken* pToken) { 113 void SetToken(CXFA_FMToken* pToken) {
109 if (m_pToken) { 114 if (m_pToken.get() != pToken)
110 delete m_pToken; 115 m_pToken.reset(pToken);
111 }
112 m_pToken = pToken;
113 } 116 }
114 const FX_WCHAR* SavePos() { return m_ptr; } 117 const FX_WCHAR* SavePos() { return m_ptr; }
115 void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; } 118 void RestorePos(const FX_WCHAR* pPos) { m_ptr = pPos; }
116 void Error(XFA_FM_ERRMSG msg, ...); 119 void Error(XFA_FM_ERRMSG msg, ...);
117 FX_BOOL HasError() const; 120 FX_BOOL HasError() const;
118 121
119 protected: 122 protected:
120 CXFA_FMToken* Scan(); 123 CXFA_FMToken* Scan();
121 const FX_WCHAR* m_pScript; 124
122 const FX_WCHAR* m_ptr; 125 const FX_WCHAR* m_ptr;
123 FX_STRSIZE m_uLength;
124 FX_DWORD m_uCurrentLine; 126 FX_DWORD m_uCurrentLine;
125 CXFA_FMToken* m_pToken; 127 std::unique_ptr<CXFA_FMToken> m_pToken;
126 CXFA_FMErrorInfo* m_pErrorInfo; 128 CXFA_FMErrorInfo* m_pErrorInfo;
127 }; 129 };
130
128 #endif 131 #endif
OLDNEW
« no previous file with comments | « xfa/src/fxfa/src/fm2js/xfa_fmparse.cpp ('k') | xfa/src/fxfa/src/fm2js/xfa_lexer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698