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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 return; | 712 return; |
713 | 713 |
714 ReallocBeforeWrite(m_pData->m_nDataLength); | 714 ReallocBeforeWrite(m_pData->m_nDataLength); |
715 FXSYS_strupr(m_pData->m_String); | 715 FXSYS_strupr(m_pData->m_String); |
716 } | 716 } |
717 | 717 |
718 FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) { | 718 FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) { |
719 if (!m_pData || m_pData->m_nDataLength < 1) | 719 if (!m_pData || m_pData->m_nDataLength < 1) |
720 return 0; | 720 return 0; |
721 | 721 |
| 722 FX_CHAR* pstrSource = m_pData->m_String; |
| 723 FX_CHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
| 724 while (pstrSource < pstrEnd) { |
| 725 if (*pstrSource == chRemove) |
| 726 break; |
| 727 pstrSource++; |
| 728 } |
| 729 if (pstrSource == pstrEnd) |
| 730 return 0; |
| 731 |
| 732 ptrdiff_t copied = pstrSource - m_pData->m_String; |
722 ReallocBeforeWrite(m_pData->m_nDataLength); | 733 ReallocBeforeWrite(m_pData->m_nDataLength); |
723 FX_CHAR* pstrSource = m_pData->m_String; | 734 pstrSource = m_pData->m_String + copied; |
724 FX_CHAR* pstrDest = m_pData->m_String; | 735 pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
725 FX_CHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; | 736 |
| 737 FX_CHAR* pstrDest = pstrSource; |
726 while (pstrSource < pstrEnd) { | 738 while (pstrSource < pstrEnd) { |
727 if (*pstrSource != chRemove) { | 739 if (*pstrSource != chRemove) { |
728 *pstrDest = *pstrSource; | 740 *pstrDest = *pstrSource; |
729 pstrDest++; | 741 pstrDest++; |
730 } | 742 } |
731 pstrSource++; | 743 pstrSource++; |
732 } | 744 } |
| 745 |
733 *pstrDest = 0; | 746 *pstrDest = 0; |
734 FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest); | 747 FX_STRSIZE nCount = (FX_STRSIZE)(pstrSource - pstrDest); |
735 m_pData->m_nDataLength -= nCount; | 748 m_pData->m_nDataLength -= nCount; |
736 return nCount; | 749 return nCount; |
737 } | 750 } |
738 | 751 |
739 FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, | 752 FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, |
740 const CFX_ByteStringC& pNew) { | 753 const CFX_ByteStringC& pNew) { |
741 if (!m_pData || pOld.IsEmpty()) | 754 if (!m_pData || pOld.IsEmpty()) |
742 return 0; | 755 return 0; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 fraction %= scale; | 987 fraction %= scale; |
975 scale /= 10; | 988 scale /= 10; |
976 } | 989 } |
977 return buf_size; | 990 return buf_size; |
978 } | 991 } |
979 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { | 992 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { |
980 FX_CHAR buf[32]; | 993 FX_CHAR buf[32]; |
981 FX_STRSIZE len = FX_ftoa(d, buf); | 994 FX_STRSIZE len = FX_ftoa(d, buf); |
982 return CFX_ByteString(buf, len); | 995 return CFX_ByteString(buf, len); |
983 } | 996 } |
OLD | NEW |