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

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

Issue 1801383002: Re-enable several MSVC warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 634 }
635 FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld); 635 FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld);
636 if (nSourceLen == 0) { 636 if (nSourceLen == 0) {
637 return 0; 637 return 0;
638 } 638 }
639 FX_STRSIZE nReplacementLen = lpszNew ? FXSYS_wcslen(lpszNew) : 0; 639 FX_STRSIZE nReplacementLen = lpszNew ? FXSYS_wcslen(lpszNew) : 0;
640 FX_STRSIZE nCount = 0; 640 FX_STRSIZE nCount = 0;
641 FX_WCHAR* lpszStart = m_pData->m_String; 641 FX_WCHAR* lpszStart = m_pData->m_String;
642 FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength; 642 FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength;
643 FX_WCHAR* lpszTarget; 643 FX_WCHAR* lpszTarget;
644 { 644 {
Tom Sepez 2016/03/16 18:34:59 nit: brace needed here?
Wei Li 2016/03/17 02:24:05 Done.
645 while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) && 645 while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) !=
646 nullptr &&
646 lpszStart < lpszEnd) { 647 lpszStart < lpszEnd) {
Tom Sepez 2016/03/16 18:34:59 This should be fine. Not sure we want to write it
Wei Li 2016/03/17 02:24:05 For pdfium code, this warning is not that useful.
647 nCount++; 648 nCount++;
648 lpszStart = lpszTarget + nSourceLen; 649 lpszStart = lpszTarget + nSourceLen;
649 } 650 }
650 } 651 }
651 if (nCount > 0) { 652 if (nCount > 0) {
652 CopyBeforeWrite(); 653 CopyBeforeWrite();
653 FX_STRSIZE nOldLength = m_pData->m_nDataLength; 654 FX_STRSIZE nOldLength = m_pData->m_nDataLength;
654 FX_STRSIZE nNewLength = 655 FX_STRSIZE nNewLength =
655 nOldLength + (nReplacementLen - nSourceLen) * nCount; 656 nOldLength + (nReplacementLen - nSourceLen) * nCount;
656 if (m_pData->m_nAllocLength < nNewLength || m_pData->m_nRefs > 1) { 657 if (m_pData->m_nAllocLength < nNewLength || m_pData->m_nRefs > 1) {
657 StringData* pOldData = m_pData; 658 StringData* pOldData = m_pData;
658 const FX_WCHAR* pstr = m_pData->m_String; 659 const FX_WCHAR* pstr = m_pData->m_String;
659 m_pData = StringData::Create(nNewLength); 660 m_pData = StringData::Create(nNewLength);
660 if (!m_pData) { 661 if (!m_pData) {
661 return 0; 662 return 0;
662 } 663 }
663 FXSYS_memcpy(m_pData->m_String, pstr, 664 FXSYS_memcpy(m_pData->m_String, pstr,
664 pOldData->m_nDataLength * sizeof(FX_WCHAR)); 665 pOldData->m_nDataLength * sizeof(FX_WCHAR));
665 pOldData->Release(); 666 pOldData->Release();
666 } 667 }
667 lpszStart = m_pData->m_String; 668 lpszStart = m_pData->m_String;
668 lpszEnd = m_pData->m_String + std::max(m_pData->m_nDataLength, nNewLength); 669 lpszEnd = m_pData->m_String + std::max(m_pData->m_nDataLength, nNewLength);
669 { 670 {
670 while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != 671 while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) !=
671 NULL && 672 nullptr &&
672 lpszStart < lpszEnd) { 673 lpszStart < lpszEnd) {
673 FX_STRSIZE nBalance = 674 FX_STRSIZE nBalance =
674 nOldLength - 675 nOldLength -
675 (FX_STRSIZE)(lpszTarget - m_pData->m_String + nSourceLen); 676 (FX_STRSIZE)(lpszTarget - m_pData->m_String + nSourceLen);
676 FXSYS_memmove(lpszTarget + nReplacementLen, lpszTarget + nSourceLen, 677 FXSYS_memmove(lpszTarget + nReplacementLen, lpszTarget + nSourceLen,
677 nBalance * sizeof(FX_WCHAR)); 678 nBalance * sizeof(FX_WCHAR));
678 FXSYS_memcpy(lpszTarget, lpszNew, nReplacementLen * sizeof(FX_WCHAR)); 679 FXSYS_memcpy(lpszTarget, lpszNew, nReplacementLen * sizeof(FX_WCHAR));
679 lpszStart = lpszTarget + nReplacementLen; 680 lpszStart = lpszTarget + nReplacementLen;
680 lpszStart[nBalance] = 0; 681 lpszStart[nBalance] = 0;
681 nOldLength += (nReplacementLen - nSourceLen); 682 nOldLength += (nReplacementLen - nSourceLen);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 int dest_len = 1042 int dest_len =
1042 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0); 1043 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0);
1043 CFX_WideString wstr; 1044 CFX_WideString wstr;
1044 if (dest_len) { 1045 if (dest_len) {
1045 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); 1046 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len);
1046 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len); 1047 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len);
1047 wstr.ReleaseBuffer(dest_len); 1048 wstr.ReleaseBuffer(dest_len);
1048 } 1049 }
1049 return wstr; 1050 return wstr;
1050 } 1051 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698