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

Side by Side Diff: xfa/fxfa/fm2js/xfa_lexer.cpp

Issue 1919563002: Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: win again again again Created 4 years, 8 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
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 #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
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; 522 XFA_FMKeyword keyword;
524 do { 523 do {
525 iMid = (iStart + iEnd) / 2; 524 int32_t iMid = (iStart + iEnd) / 2;
526 keyword = keyWords[iMid]; 525 keyword = keyWords[iMid];
527 if (uHash == keyword.m_uHash) { 526 if (uHash == keyword.m_uHash) {
528 return keyword.m_type; 527 return keyword.m_type;
529 } else if (uHash < keyword.m_uHash) { 528 } else if (uHash < keyword.m_uHash) {
530 iEnd = iMid - 1; 529 iEnd = iMid - 1;
531 } else { 530 } else {
532 iStart = iMid + 1; 531 iStart = iMid + 1;
533 } 532 }
534 } while (iStart <= iEnd); 533 } while (iStart <= iEnd);
535 return TOKidentifier; 534 return TOKidentifier;
536 } 535 }
537 536
538 void CXFA_FMLexer::Error(XFA_FM_ERRMSG msg, ...) { 537 void CXFA_FMLexer::Error(XFA_FM_ERRMSG msg, ...) {
539 m_pErrorInfo->linenum = m_uCurrentLine; 538 m_pErrorInfo->linenum = m_uCurrentLine;
540 const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg); 539 const FX_WCHAR* lpMessageInfo = XFA_FM_ErrorMsg(msg);
541 va_list ap; 540 va_list ap;
542 va_start(ap, msg); 541 va_start(ap, msg);
543 m_pErrorInfo->message.FormatV(lpMessageInfo, ap); 542 m_pErrorInfo->message.FormatV(lpMessageInfo, ap);
544 va_end(ap); 543 va_end(ap);
545 } 544 }
546 545
547 FX_BOOL CXFA_FMLexer::HasError() const { 546 FX_BOOL CXFA_FMLexer::HasError() const {
548 if (m_pErrorInfo->message.IsEmpty()) { 547 if (m_pErrorInfo->message.IsEmpty()) {
549 return FALSE; 548 return FALSE;
550 } 549 }
551 return TRUE; 550 return TRUE;
552 } 551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698