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

Side by Side Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 733693003: Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebasing to latest origin/master. Created 6 years, 1 month 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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 #include "../../../third_party/numerics/safe_math.h" 8 #include "../../../third_party/numerics/safe_math.h"
9 9
10 static CFX_StringDataW* FX_AllocStringW(int nLen) 10 static CFX_StringDataW* FX_AllocStringW(int nLen)
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 return; 579 return;
580 } 580 }
581 FXSYS_wcsupr(m_pData->m_String); 581 FXSYS_wcsupr(m_pData->m_String);
582 } 582 }
583 FX_STRSIZE CFX_WideString::Find(FX_LPCWSTR lpszSub, FX_STRSIZE nStart) const 583 FX_STRSIZE CFX_WideString::Find(FX_LPCWSTR lpszSub, FX_STRSIZE nStart) const
584 { 584 {
585 FX_STRSIZE nLength = GetLength(); 585 FX_STRSIZE nLength = GetLength();
586 if (nLength < 1 || nStart > nLength) { 586 if (nLength < 1 || nStart > nLength) {
587 return -1; 587 return -1;
588 } 588 }
589 FX_LPCWSTR lpsz = (FX_LPCWSTR)FXSYS_wcsstr(m_pData->m_String + nStart, lpszS ub); 589 FX_LPCWSTR lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub);
590 return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String); 590 return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
591 } 591 }
592 FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const 592 FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const
593 { 593 {
594 if (m_pData == NULL) { 594 if (m_pData == NULL) {
595 return -1; 595 return -1;
596 } 596 }
597 FX_STRSIZE nLength = m_pData->m_nDataLength; 597 FX_STRSIZE nLength = m_pData->m_nDataLength;
598 if (nStart >= nLength) { 598 if (nStart >= nLength) {
599 return -1; 599 return -1;
600 } 600 }
601 FX_LPCWSTR lpsz = (FX_LPCWSTR)FXSYS_wcschr(m_pData->m_String + nStart, ch); 601 FX_LPCWSTR lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch);
602 return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String); 602 return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
603 } 603 }
604 void CFX_WideString::TrimRight(FX_LPCWSTR lpszTargetList) 604 void CFX_WideString::TrimRight(FX_LPCWSTR lpszTargetList)
605 { 605 {
606 FXSYS_assert(lpszTargetList != NULL); 606 FXSYS_assert(lpszTargetList != NULL);
607 if (m_pData == NULL || *lpszTargetList == 0) { 607 if (m_pData == NULL || *lpszTargetList == 0) {
608 return; 608 return;
609 } 609 }
610 CopyBeforeWrite(); 610 CopyBeforeWrite();
611 FX_STRSIZE len = GetLength(); 611 FX_STRSIZE len = GetLength();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 return (CFX_CharMap*)&g_DefaultJISMapper; 1120 return (CFX_CharMap*)&g_DefaultJISMapper;
1121 case 936: 1121 case 936:
1122 return (CFX_CharMap*)&g_DefaultGBKMapper; 1122 return (CFX_CharMap*)&g_DefaultGBKMapper;
1123 case 949: 1123 case 949:
1124 return (CFX_CharMap*)&g_DefaultUHCMapper; 1124 return (CFX_CharMap*)&g_DefaultUHCMapper;
1125 case 950: 1125 case 950:
1126 return (CFX_CharMap*)&g_DefaultBig5Mapper; 1126 return (CFX_CharMap*)&g_DefaultBig5Mapper;
1127 } 1127 }
1128 return NULL; 1128 return NULL;
1129 } 1129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698