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

Side by Side Diff: xfa/fgas/crt/fgas_stream.cpp

Issue 1842633004: Fix CData parsing in CFDE_XMLSyntaxParser. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix windows xfa Created 4 years, 8 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/xml/fde_xml_imp_unittest.cpp ('k') | xfa/fgas/crt/fgas_system.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 "xfa/fgas/crt/fgas_stream.h" 7 #include "xfa/fgas/crt/fgas_stream.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 int32_t iMaxLength, 863 int32_t iMaxLength,
864 FX_BOOL& bEOS) { 864 FX_BOOL& bEOS) {
865 FXSYS_assert(m_pData != NULL); 865 FXSYS_assert(m_pData != NULL);
866 FXSYS_assert(pStr != NULL && iMaxLength > 0); 866 FXSYS_assert(pStr != NULL && iMaxLength > 0);
867 int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength); 867 int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength);
868 if (iLen <= 0) { 868 if (iLen <= 0) {
869 return 0; 869 return 0;
870 } 870 }
871 const FX_WCHAR* pSrc = (const FX_WCHAR*)(FX_CHAR*)(m_pData + m_iPosition); 871 const FX_WCHAR* pSrc = (const FX_WCHAR*)(FX_CHAR*)(m_pData + m_iPosition);
872 int32_t iCount = 0; 872 int32_t iCount = 0;
873 while (*pSrc != L'\0' && iCount < iLen) { 873 while (*pSrc && iCount < iLen) {
874 *pStr++ = *pSrc++, iCount++; 874 *pStr++ = *pSrc++;
875 iCount++;
875 } 876 }
876 m_iPosition += iCount * 2; 877 m_iPosition += iCount * 2;
877 bEOS = (*pSrc == L'\0') || (m_iPosition >= m_iLength); 878 bEOS = (*pSrc == L'\0') || (m_iPosition >= m_iLength);
878 return iCount; 879 return iCount;
879 } 880 }
880 int32_t CFX_BufferStreamImp::WriteData(const uint8_t* pBuffer, 881 int32_t CFX_BufferStreamImp::WriteData(const uint8_t* pBuffer,
881 int32_t iBufferSize) { 882 int32_t iBufferSize) {
882 FXSYS_assert(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0); 883 FXSYS_assert(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0);
883 FXSYS_assert(pBuffer != NULL && iBufferSize > 0); 884 FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
884 int32_t iLen = std::min(m_iTotalSize - m_iPosition, iBufferSize); 885 int32_t iLen = std::min(m_iTotalSize - m_iPosition, iBufferSize);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (m_pStreamImp->GetPosition() != m_iPosition) { 1339 if (m_pStreamImp->GetPosition() != m_iPosition) {
1339 m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition); 1340 m_pStreamImp->Seek(FX_STREAMSEEK_Begin, m_iPosition);
1340 } 1341 }
1341 iLen = m_pStreamImp->ReadString(pStr, iLen, bEOS); 1342 iLen = m_pStreamImp->ReadString(pStr, iLen, bEOS);
1342 m_iPosition = m_pStreamImp->GetPosition(); 1343 m_iPosition = m_pStreamImp->GetPosition();
1343 if (iLen > 0 && m_iPosition >= iEnd) { 1344 if (iLen > 0 && m_iPosition >= iEnd) {
1344 bEOS = TRUE; 1345 bEOS = TRUE;
1345 } 1346 }
1346 return iLen; 1347 return iLen;
1347 } 1348 }
1349
1348 int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { 1350 int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) {
1349 FXSYS_assert(pBuffer != NULL && iBufferSize > 0); 1351 FXSYS_assert(pBuffer != NULL && iBufferSize > 0);
1350 if (m_pStreamImp == NULL) { 1352 if (m_pStreamImp == NULL) {
1351 return -1; 1353 return -1;
1352 } 1354 }
1353 if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) { 1355 if ((m_dwAccess & FX_STREAMACCESS_Write) == 0) {
1354 return -1; 1356 return -1;
1355 } 1357 }
1356 int32_t iLen = iBufferSize; 1358 int32_t iLen = iBufferSize;
1357 if (m_eStreamType == FX_STREAMTYPE_Stream) { 1359 if (m_eStreamType == FX_STREAMTYPE_Stream) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 return m_pStream->WriteData((const uint8_t*)pData, (int32_t)size) == 1619 return m_pStream->WriteData((const uint8_t*)pData, (int32_t)size) ==
1618 (int32_t)size; 1620 (int32_t)size;
1619 } 1621 }
1620 FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData, 1622 FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData,
1621 FX_FILESIZE offset, 1623 FX_FILESIZE offset,
1622 size_t size) { 1624 size_t size) {
1623 m_pStream->Seek(FX_STREAMSEEK_Begin, offset); 1625 m_pStream->Seek(FX_STREAMSEEK_Begin, offset);
1624 int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size); 1626 int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size);
1625 return iLen == (int32_t)size; 1627 return iLen == (int32_t)size;
1626 } 1628 }
OLDNEW
« no previous file with comments | « xfa/fde/xml/fde_xml_imp_unittest.cpp ('k') | xfa/fgas/crt/fgas_system.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698