| OLD | NEW | 
|---|
| 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 #include "xfa/fxfa/fm2js/xfa_lexer.h" | 7 #include "xfa/fxfa/fm2js/xfa_lexer.h" | 
| 8 | 8 | 
| 9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" | 
| 10 | 10 | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 153 }  // namespace | 153 }  // namespace | 
| 154 | 154 | 
| 155 const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op) { | 155 const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op) { | 
| 156   if (op < KEYWORD_START || op > KEYWORD_END) | 156   if (op < KEYWORD_START || op > KEYWORD_END) | 
| 157     return L""; | 157     return L""; | 
| 158   return keyWords[op].m_keyword; | 158   return keyWords[op].m_keyword; | 
| 159 } | 159 } | 
| 160 | 160 | 
| 161 CXFA_FMToken::CXFA_FMToken() : m_type(TOKreserver), m_uLinenum(1) {} | 161 CXFA_FMToken::CXFA_FMToken() : m_type(TOKreserver), m_uLinenum(1) {} | 
| 162 | 162 | 
| 163 CXFA_FMToken::CXFA_FMToken(FX_DWORD uLineNum) | 163 CXFA_FMToken::CXFA_FMToken(uint32_t uLineNum) | 
| 164     : m_type(TOKreserver), m_uLinenum(uLineNum) {} | 164     : m_type(TOKreserver), m_uLinenum(uLineNum) {} | 
| 165 | 165 | 
| 166 CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc, | 166 CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc, | 
| 167                            CXFA_FMErrorInfo* pErrorInfo) | 167                            CXFA_FMErrorInfo* pErrorInfo) | 
| 168     : m_ptr(wsFormCalc.GetPtr()), m_uCurrentLine(1), m_pErrorInfo(pErrorInfo) {} | 168     : m_ptr(wsFormCalc.GetPtr()), m_uCurrentLine(1), m_pErrorInfo(pErrorInfo) {} | 
| 169 | 169 | 
| 170 CXFA_FMToken* CXFA_FMLexer::NextToken() { | 170 CXFA_FMToken* CXFA_FMLexer::NextToken() { | 
| 171   m_pToken.reset(Scan()); | 171   m_pToken.reset(Scan()); | 
| 172   return m_pToken.get(); | 172   return m_pToken.get(); | 
| 173 } | 173 } | 
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 397         if (iRet) { | 397         if (iRet) { | 
| 398           return p; | 398           return p; | 
| 399         } | 399         } | 
| 400         p->m_type = IsKeyword(p->m_wstring); | 400         p->m_type = IsKeyword(p->m_wstring); | 
| 401       } | 401       } | 
| 402         return p; | 402         return p; | 
| 403     } | 403     } | 
| 404   } | 404   } | 
| 405 } | 405 } | 
| 406 | 406 | 
| 407 FX_DWORD CXFA_FMLexer::Number(CXFA_FMToken* t, | 407 uint32_t CXFA_FMLexer::Number(CXFA_FMToken* t, | 
| 408                               const FX_WCHAR* p, | 408                               const FX_WCHAR* p, | 
| 409                               const FX_WCHAR*& pEnd) { | 409                               const FX_WCHAR*& pEnd) { | 
| 410   FX_DOUBLE number = 0; | 410   FX_DOUBLE number = 0; | 
| 411   if (XFA_FMDChar::string2number(p, &number, pEnd)) { | 411   if (XFA_FMDChar::string2number(p, &number, pEnd)) { | 
| 412     return 1; | 412     return 1; | 
| 413   } | 413   } | 
| 414   if (pEnd && XFA_FMDChar::isAlpha(pEnd)) { | 414   if (pEnd && XFA_FMDChar::isAlpha(pEnd)) { | 
| 415     return 1; | 415     return 1; | 
| 416   } | 416   } | 
| 417   t->m_wstring = CFX_WideStringC(p, (pEnd - p)); | 417   t->m_wstring = CFX_WideStringC(p, (pEnd - p)); | 
| 418   return 0; | 418   return 0; | 
| 419 } | 419 } | 
| 420 | 420 | 
| 421 FX_DWORD CXFA_FMLexer::String(CXFA_FMToken* t, | 421 uint32_t CXFA_FMLexer::String(CXFA_FMToken* t, | 
| 422                               const FX_WCHAR* p, | 422                               const FX_WCHAR* p, | 
| 423                               const FX_WCHAR*& pEnd) { | 423                               const FX_WCHAR*& pEnd) { | 
| 424   const FX_WCHAR* pStart = p; | 424   const FX_WCHAR* pStart = p; | 
| 425   uint16_t ch = 0; | 425   uint16_t ch = 0; | 
| 426   XFA_FMDChar::inc(p); | 426   XFA_FMDChar::inc(p); | 
| 427   ch = XFA_FMDChar::get(p); | 427   ch = XFA_FMDChar::get(p); | 
| 428   while (ch) { | 428   while (ch) { | 
| 429     if (!XFA_FMDChar::isAvalid(p)) { | 429     if (!XFA_FMDChar::isAvalid(p)) { | 
| 430       ch = XFA_FMDChar::get(p); | 430       ch = XFA_FMDChar::get(p); | 
| 431       pEnd = p; | 431       pEnd = p; | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 451     } | 451     } | 
| 452   NEXT: | 452   NEXT: | 
| 453     XFA_FMDChar::inc(p); | 453     XFA_FMDChar::inc(p); | 
| 454     ch = XFA_FMDChar::get(p); | 454     ch = XFA_FMDChar::get(p); | 
| 455   } | 455   } | 
| 456   pEnd = p; | 456   pEnd = p; | 
| 457   t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); | 457   t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); | 
| 458   return 0; | 458   return 0; | 
| 459 } | 459 } | 
| 460 | 460 | 
| 461 FX_DWORD CXFA_FMLexer::Identifiers(CXFA_FMToken* t, | 461 uint32_t CXFA_FMLexer::Identifiers(CXFA_FMToken* t, | 
| 462                                    const FX_WCHAR* p, | 462                                    const FX_WCHAR* p, | 
| 463                                    const FX_WCHAR*& pEnd) { | 463                                    const FX_WCHAR*& pEnd) { | 
| 464   const FX_WCHAR* pStart = p; | 464   const FX_WCHAR* pStart = p; | 
| 465   uint16_t ch = 0; | 465   uint16_t ch = 0; | 
| 466   ch = XFA_FMDChar::get(p); | 466   ch = XFA_FMDChar::get(p); | 
| 467   XFA_FMDChar::inc(p); | 467   XFA_FMDChar::inc(p); | 
| 468   if (!XFA_FMDChar::isAvalid(p)) { | 468   if (!XFA_FMDChar::isAvalid(p)) { | 
| 469     pEnd = p; | 469     pEnd = p; | 
| 470     t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); | 470     t->m_wstring = CFX_WideStringC(pStart, (pEnd - pStart)); | 
| 471     Error(FMERR_UNSUPPORTED_CHAR, ch); | 471     Error(FMERR_UNSUPPORTED_CHAR, ch); | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 543   m_pErrorInfo->message.FormatV(lpMessageInfo, ap); | 543   m_pErrorInfo->message.FormatV(lpMessageInfo, ap); | 
| 544   va_end(ap); | 544   va_end(ap); | 
| 545 } | 545 } | 
| 546 | 546 | 
| 547 FX_BOOL CXFA_FMLexer::HasError() const { | 547 FX_BOOL CXFA_FMLexer::HasError() const { | 
| 548   if (m_pErrorInfo->message.IsEmpty()) { | 548   if (m_pErrorInfo->message.IsEmpty()) { | 
| 549     return FALSE; | 549     return FALSE; | 
| 550   } | 550   } | 
| 551   return TRUE; | 551   return TRUE; | 
| 552 } | 552 } | 
| OLD | NEW | 
|---|