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

Side by Side Diff: xfa/fgas/crt/fgas_codepage.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: fix issue from c4 Created 4 years, 7 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/fde/css/fde_cssstylesheet.cpp ('k') | xfa/fgas/font/fgas_fontutils.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 #include "core/fxcrt/include/fx_ext.h" 7 #include "core/fxcrt/include/fx_ext.h"
8 #include "xfa/fgas/crt/fgas_codepage.h" 8 #include "xfa/fgas/crt/fgas_codepage.h"
9 #include "xfa/fgas/crt/fgas_language.h" 9 #include "xfa/fgas/crt/fgas_language.h"
10 10
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 {0xf637e157, 0x478}, {0xfc213f3a, 0x2717}, {0xff654d14, 0x3b5}, 302 {0xf637e157, 0x478}, {0xfc213f3a, 0x2717}, {0xff654d14, 0x3b5},
303 }; 303 };
304 uint16_t FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) { 304 uint16_t FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) {
305 FXSYS_assert(pStr != NULL); 305 FXSYS_assert(pStr != NULL);
306 if (iLength < 0) { 306 if (iLength < 0) {
307 iLength = FXSYS_strlen(pStr); 307 iLength = FXSYS_strlen(pStr);
308 } 308 }
309 if (iLength == 0) { 309 if (iLength == 0) {
310 return 0xFFFF; 310 return 0xFFFF;
311 } 311 }
312 uint32_t uHash = FX_HashCode_String_GetA(pStr, iLength, TRUE); 312 uint32_t uHash = FX_HashCode_GetA(CFX_ByteStringC(pStr, iLength), true);
313 int32_t iStart = 0, iMid; 313 int32_t iStart = 0;
314 int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1; 314 int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1;
315 FXSYS_assert(iEnd >= 0); 315 FXSYS_assert(iEnd >= 0);
316 do { 316 do {
317 iMid = (iStart + iEnd) / 2; 317 int32_t iMid = (iStart + iEnd) / 2;
318 const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid]; 318 const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid];
319 if (uHash == cp.uHash) { 319 if (uHash == cp.uHash) {
320 return (uint16_t)cp.uCodePage; 320 return (uint16_t)cp.uCodePage;
321 } else if (uHash < cp.uHash) { 321 } else if (uHash < cp.uHash) {
322 iEnd = iMid - 1; 322 iEnd = iMid - 1;
323 } else { 323 } else {
324 iStart = iMid + 1; 324 iStart = iMid + 1;
325 } 325 }
326 } while (iStart <= iEnd); 326 } while (iStart <= iEnd);
327 return 0xFFFF; 327 return 0xFFFF;
328 } 328 }
329 uint16_t FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength) { 329 uint16_t FX_GetCodePageFormStringW(const FX_WCHAR* pStr, int32_t iLength) {
330 if (iLength < 0) { 330 if (iLength < 0) {
331 iLength = FXSYS_wcslen(pStr); 331 iLength = FXSYS_wcslen(pStr);
332 } 332 }
333 if (iLength == 0) { 333 if (iLength == 0) {
334 return 0xFFFF; 334 return 0xFFFF;
335 } 335 }
336 CFX_ByteString csStr; 336 CFX_ByteString csStr;
337 FX_CHAR* pBuf = csStr.GetBuffer(iLength + 1); 337 FX_CHAR* pBuf = csStr.GetBuffer(iLength + 1);
338 for (int32_t i = 0; i < iLength; ++i) { 338 for (int32_t i = 0; i < iLength; ++i) {
339 *pBuf++ = (FX_CHAR)*pStr++; 339 *pBuf++ = (FX_CHAR)*pStr++;
340 } 340 }
341 csStr.ReleaseBuffer(iLength); 341 csStr.ReleaseBuffer(iLength);
342 return FX_GetCodePageFromStringA(csStr.c_str(), iLength); 342 return FX_GetCodePageFromStringA(csStr.c_str(), iLength);
343 } 343 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.cpp ('k') | xfa/fgas/font/fgas_fontutils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698