| 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 pEnd = p; | 509 pEnd = p; |
| 510 return; | 510 return; |
| 511 } | 511 } |
| 512 XFA_FMDChar::inc(p); | 512 XFA_FMDChar::inc(p); |
| 513 ch = XFA_FMDChar::get(p); | 513 ch = XFA_FMDChar::get(p); |
| 514 } | 514 } |
| 515 pEnd = p; | 515 pEnd = p; |
| 516 } | 516 } |
| 517 | 517 |
| 518 XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) { | 518 XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) { |
| 519 int32_t iLength = str.GetLength(); | 519 uint32_t uHash = FX_HashCode_GetW(str, true); |
| 520 uint32_t uHash = FX_HashCode_String_GetW(str.c_str(), iLength, TRUE); | 520 int32_t iStart = KEYWORD_START; |
| 521 int32_t iStart = KEYWORD_START, iEnd = KEYWORD_END; | 521 int32_t iEnd = KEYWORD_END; |
| 522 int32_t iMid = (iStart + iEnd) / 2; | |
| 523 XFA_FMKeyword keyword; | |
| 524 do { | 522 do { |
| 525 iMid = (iStart + iEnd) / 2; | 523 int32_t iMid = (iStart + iEnd) / 2; |
| 526 keyword = keyWords[iMid]; | 524 XFA_FMKeyword keyword = keyWords[iMid]; |
| 527 if (uHash == keyword.m_uHash) { | 525 if (uHash == keyword.m_uHash) |
| 528 return keyword.m_type; | 526 return keyword.m_type; |
| 529 } else if (uHash < keyword.m_uHash) { | 527 if (uHash < keyword.m_uHash) |
| 530 iEnd = iMid - 1; | 528 iEnd = iMid - 1; |
| 531 } else { | 529 else |
| 532 iStart = iMid + 1; | 530 iStart = iMid + 1; |
| 533 } | |
| 534 } while (iStart <= iEnd); | 531 } while (iStart <= iEnd); |
| 535 return TOKidentifier; | 532 return TOKidentifier; |
| 536 } | 533 } |
| 537 | 534 |
| 538 void CXFA_FMLexer::Error(XFA_FM_ERRMSG msg, ...) { | 535 void CXFA_FMLexer::Error(XFA_FM_ERRMSG msg, ...) { |
| 539 m_pErrorInfo->linenum = m_uCurrentLine; | 536 m_pErrorInfo->linenum = m_uCurrentLine; |
| 540 const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg); | 537 const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg); |
| 541 va_list ap; | 538 va_list ap; |
| 542 va_start(ap, msg); | 539 va_start(ap, msg); |
| 543 m_pErrorInfo->message.FormatV(lpMessageInfo, ap); | 540 m_pErrorInfo->message.FormatV(lpMessageInfo, ap); |
| 544 va_end(ap); | 541 va_end(ap); |
| 545 } | 542 } |
| 546 | 543 |
| 547 FX_BOOL CXFA_FMLexer::HasError() const { | 544 FX_BOOL CXFA_FMLexer::HasError() const { |
| 548 if (m_pErrorInfo->message.IsEmpty()) { | 545 if (m_pErrorInfo->message.IsEmpty()) { |
| 549 return FALSE; | 546 return FALSE; |
| 550 } | 547 } |
| 551 return TRUE; | 548 return TRUE; |
| 552 } | 549 } |
| OLD | NEW |