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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 return; | 665 return; |
666 | 666 |
667 ReallocBeforeWrite(m_pData->m_nDataLength); | 667 ReallocBeforeWrite(m_pData->m_nDataLength); |
668 FXSYS_wcsupr(m_pData->m_String); | 668 FXSYS_wcsupr(m_pData->m_String); |
669 } | 669 } |
670 | 670 |
671 FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { | 671 FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { |
672 if (!m_pData || m_pData->m_nDataLength < 1) | 672 if (!m_pData || m_pData->m_nDataLength < 1) |
673 return 0; | 673 return 0; |
674 | 674 |
| 675 FX_WCHAR* pstrSource = m_pData->m_String; |
| 676 FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
| 677 while (pstrSource < pstrEnd) { |
| 678 if (*pstrSource == chRemove) |
| 679 break; |
| 680 pstrSource++; |
| 681 } |
| 682 if (pstrSource == pstrEnd) |
| 683 return 0; |
| 684 |
| 685 ptrdiff_t copied = pstrSource - m_pData->m_String; |
675 ReallocBeforeWrite(m_pData->m_nDataLength); | 686 ReallocBeforeWrite(m_pData->m_nDataLength); |
676 FX_WCHAR* pstrSource = m_pData->m_String; | 687 pstrSource = m_pData->m_String + copied; |
677 FX_WCHAR* pstrDest = m_pData->m_String; | 688 pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
678 FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; | 689 |
| 690 FX_WCHAR* pstrDest = pstrSource; |
679 while (pstrSource < pstrEnd) { | 691 while (pstrSource < pstrEnd) { |
680 if (*pstrSource != chRemove) { | 692 if (*pstrSource != chRemove) { |
681 *pstrDest = *pstrSource; | 693 *pstrDest = *pstrSource; |
682 pstrDest++; | 694 pstrDest++; |
683 } | 695 } |
684 pstrSource++; | 696 pstrSource++; |
685 } | 697 } |
| 698 |
686 *pstrDest = 0; | 699 *pstrDest = 0; |
687 FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest); | 700 FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest); |
688 m_pData->m_nDataLength -= nCount; | 701 m_pData->m_nDataLength -= nCount; |
689 return nCount; | 702 return nCount; |
690 } | 703 } |
691 | 704 |
692 FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld, | 705 FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld, |
693 const CFX_WideStringC& pNew) { | 706 const CFX_WideStringC& pNew) { |
694 if (!m_pData || pOld.IsEmpty()) | 707 if (!m_pData || pOld.IsEmpty()) |
695 return 0; | 708 return 0; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); | 983 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); |
971 CFX_WideString wstr; | 984 CFX_WideString wstr; |
972 if (dest_len) { | 985 if (dest_len) { |
973 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); | 986 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); |
974 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, | 987 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, |
975 dest_len); | 988 dest_len); |
976 wstr.ReleaseBuffer(dest_len); | 989 wstr.ReleaseBuffer(dest_len); |
977 } | 990 } |
978 return wstr; | 991 return wstr; |
979 } | 992 } |
OLD | NEW |