diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-13 16:43:37 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-14 14:14:51 +0000 |
commit | 812e96c2b4c5908a1979da5e27cdcecda0d1dfc9 (patch) | |
tree | f0b0607f6b757eb22237527215094bd87b5d03ba /xfa/fde/xml | |
parent | 893822aa5b6254591f8e80fbffcbb4fa6ad849aa (diff) | |
download | pdfium-812e96c2b4c5908a1979da5e27cdcecda0d1dfc9.tar.xz |
Replace FX_CHAR and FX_WCHAR with underlying types.
Change-Id: I96e0a20d66b9184d22f64d8e4ce0dadd5a78c1e8
Reviewed-on: https://pdfium-review.googlesource.com/2967
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fde/xml')
-rw-r--r-- | xfa/fde/xml/fde_xml.h | 2 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 76 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.h | 56 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp_unittest.cpp | 124 |
4 files changed, 129 insertions, 129 deletions
diff --git a/xfa/fde/xml/fde_xml.h b/xfa/fde/xml/fde_xml.h index e773b30851..399a930615 100644 --- a/xfa/fde/xml/fde_xml.h +++ b/xfa/fde/xml/fde_xml.h @@ -40,6 +40,6 @@ struct FDE_XMLNODE { FDE_XMLNODETYPE eNodeType; }; -bool FDE_IsXMLValidChar(FX_WCHAR ch); +bool FDE_IsXMLValidChar(wchar_t ch); #endif // XFA_FDE_XML_FDE_XML_H_ diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index 3e5edaf459..541fd98a00 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -24,7 +24,7 @@ const uint16_t g_XMLValidCharRange[][2] = {{0x09, 0x09}, {0x20, 0xD7FF}, {0xE000, 0xFFFD}}; -bool FDE_IsXMLWhiteSpace(FX_WCHAR ch) { +bool FDE_IsXMLWhiteSpace(wchar_t ch) { return ch == L' ' || ch == 0x0A || ch == 0x0D || ch == 0x09; } @@ -44,7 +44,7 @@ const FDE_XMLNAMECHAR g_XMLNameChars[] = { {0xF900, 0xFDCF, true}, {0xFDF0, 0xFFFD, true}, }; -bool FDE_IsXMLNameChar(FX_WCHAR ch, bool bFirstChar) { +bool FDE_IsXMLNameChar(wchar_t ch, bool bFirstChar) { int32_t iStart = 0; int32_t iEnd = FX_ArraySize(g_XMLNameChars) - 1; while (iStart <= iEnd) { @@ -62,7 +62,7 @@ bool FDE_IsXMLNameChar(FX_WCHAR ch, bool bFirstChar) { } // namespace -bool FDE_IsXMLValidChar(FX_WCHAR ch) { +bool FDE_IsXMLValidChar(wchar_t ch) { int32_t iStart = 0; int32_t iEnd = FX_ArraySize(g_XMLValidCharRange) - 1; while (iStart <= iEnd) { @@ -137,7 +137,7 @@ int32_t CFDE_XMLNode::GetChildNodeIndex(CFDE_XMLNode* pNode) const { return -1; } -CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath, +CFDE_XMLNode* CFDE_XMLNode::GetPath(const wchar_t* pPath, int32_t iLength, bool bQualifiedName) const { ASSERT(pPath); @@ -148,9 +148,9 @@ CFDE_XMLNode* CFDE_XMLNode::GetPath(const FX_WCHAR* pPath, return nullptr; } CFX_WideString csPath; - const FX_WCHAR* pStart = pPath; - const FX_WCHAR* pEnd = pPath + iLength; - FX_WCHAR ch; + const wchar_t* pStart = pPath; + const wchar_t* pEnd = pPath + iLength; + wchar_t ch; while (pStart < pEnd) { ch = *pStart++; if (ch == L'/') { @@ -562,7 +562,7 @@ bool CFDE_XMLInstruction::GetAttribute(int32_t index, return false; } -bool CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { +bool CFDE_XMLInstruction::HasAttribute(const wchar_t* pwsAttriName) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { if (m_Attributes[i].Compare(pwsAttriName) == 0) { @@ -572,9 +572,9 @@ bool CFDE_XMLInstruction::HasAttribute(const FX_WCHAR* pwsAttriName) const { return false; } -void CFDE_XMLInstruction::GetString(const FX_WCHAR* pwsAttriName, +void CFDE_XMLInstruction::GetString(const wchar_t* pwsAttriName, CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue) const { + const wchar_t* pwsDefValue) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { if (m_Attributes[i].Compare(pwsAttriName) == 0) { @@ -600,7 +600,7 @@ void CFDE_XMLInstruction::SetString(const CFX_WideString& wsAttriName, m_Attributes.push_back(wsAttriValue); } -int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, +int32_t CFDE_XMLInstruction::GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { @@ -611,14 +611,14 @@ int32_t CFDE_XMLInstruction::GetInteger(const FX_WCHAR* pwsAttriName, return iDefValue; } -void CFDE_XMLInstruction::SetInteger(const FX_WCHAR* pwsAttriName, +void CFDE_XMLInstruction::SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%d", iAttriValue); SetString(pwsAttriName, wsValue); } -FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, +FX_FLOAT CFDE_XMLInstruction::GetFloat(const wchar_t* pwsAttriName, FX_FLOAT fDefValue) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { @@ -629,14 +629,14 @@ FX_FLOAT CFDE_XMLInstruction::GetFloat(const FX_WCHAR* pwsAttriName, return fDefValue; } -void CFDE_XMLInstruction::SetFloat(const FX_WCHAR* pwsAttriName, +void CFDE_XMLInstruction::SetFloat(const wchar_t* pwsAttriName, FX_FLOAT fAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%f", fAttriValue); SetString(pwsAttriName, wsValue); } -void CFDE_XMLInstruction::RemoveAttribute(const FX_WCHAR* pwsAttriName) { +void CFDE_XMLInstruction::RemoveAttribute(const wchar_t* pwsAttriName) { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { if (m_Attributes[i].Compare(pwsAttriName) == 0) { @@ -774,7 +774,7 @@ bool CFDE_XMLElement::GetAttribute(int32_t index, return false; } -bool CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { +bool CFDE_XMLElement::HasAttribute(const wchar_t* pwsAttriName) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { if (m_Attributes[i].Compare(pwsAttriName) == 0) @@ -783,9 +783,9 @@ bool CFDE_XMLElement::HasAttribute(const FX_WCHAR* pwsAttriName) const { return false; } -void CFDE_XMLElement::GetString(const FX_WCHAR* pwsAttriName, +void CFDE_XMLElement::GetString(const wchar_t* pwsAttriName, CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue) const { + const wchar_t* pwsDefValue) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { if (m_Attributes[i].Compare(pwsAttriName) == 0) { @@ -811,7 +811,7 @@ void CFDE_XMLElement::SetString(const CFX_WideString& wsAttriName, m_Attributes.push_back(wsAttriValue); } -int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, +int32_t CFDE_XMLElement::GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { @@ -822,14 +822,14 @@ int32_t CFDE_XMLElement::GetInteger(const FX_WCHAR* pwsAttriName, return iDefValue; } -void CFDE_XMLElement::SetInteger(const FX_WCHAR* pwsAttriName, +void CFDE_XMLElement::SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%d", iAttriValue); SetString(pwsAttriName, wsValue); } -FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, +FX_FLOAT CFDE_XMLElement::GetFloat(const wchar_t* pwsAttriName, FX_FLOAT fDefValue) const { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { @@ -840,14 +840,14 @@ FX_FLOAT CFDE_XMLElement::GetFloat(const FX_WCHAR* pwsAttriName, return fDefValue; } -void CFDE_XMLElement::SetFloat(const FX_WCHAR* pwsAttriName, +void CFDE_XMLElement::SetFloat(const wchar_t* pwsAttriName, FX_FLOAT fAttriValue) { CFX_WideString wsValue; wsValue.Format(L"%f", fAttriValue); SetString(pwsAttriName, wsValue); } -void CFDE_XMLElement::RemoveAttribute(const FX_WCHAR* pwsAttriName) { +void CFDE_XMLElement::RemoveAttribute(const wchar_t* pwsAttriName) { int32_t iCount = pdfium::CollectionSize<int32_t>(m_Attributes); for (int32_t i = 0; i < iCount; i += 2) { if (m_Attributes[i].Compare(pwsAttriName) == 0) { @@ -1112,14 +1112,14 @@ CFDE_BlockBuffer::~CFDE_BlockBuffer() { ClearBuffer(); } -FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { +wchar_t* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) { iIndexInBlock = 0; if (!m_BlockArray.GetSize()) { return nullptr; } int32_t iRealIndex = m_iStartPosition + m_iDataLength; if (iRealIndex == m_iBufferSize) { - FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep); + wchar_t* pBlock = FX_Alloc(wchar_t, m_iAllocStep); m_BlockArray.Add(pBlock); m_iBufferSize += m_iAllocStep; return pBlock; @@ -1132,13 +1132,13 @@ bool CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) { ClearBuffer(); int32_t iNumOfBlock = (iBufferSize - 1) / m_iAllocStep + 1; for (int32_t i = 0; i < iNumOfBlock; i++) { - m_BlockArray.Add(FX_Alloc(FX_WCHAR, m_iAllocStep)); + m_BlockArray.Add(FX_Alloc(wchar_t, m_iAllocStep)); } m_iBufferSize = iNumOfBlock * m_iAllocStep; return true; } -void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { +void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, wchar_t ch) { if (iIndex < 0) { return; } @@ -1149,12 +1149,12 @@ void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { if (iBlockIndex >= iBlockSize) { int32_t iNewBlocks = iBlockIndex - iBlockSize + 1; do { - FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep); + wchar_t* pBlock = FX_Alloc(wchar_t, m_iAllocStep); m_BlockArray.Add(pBlock); m_iBufferSize += m_iAllocStep; } while (--iNewBlocks); } - FX_WCHAR* pTextData = m_BlockArray[iBlockIndex]; + wchar_t* pTextData = m_BlockArray[iBlockIndex]; *(pTextData + iInnerIndex) = ch; if (m_iDataLength <= iIndex) { m_iDataLength = iIndex + 1; @@ -1192,7 +1192,7 @@ void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, if (iLength <= 0) { return; } - FX_WCHAR* pBuf = wsTextData.GetBuffer(iLength); + wchar_t* pBuf = wsTextData.GetBuffer(iLength); if (!pBuf) { return; } @@ -1213,9 +1213,9 @@ void CFDE_BlockBuffer::GetTextData(CFX_WideString& wsTextData, if (i == iEndBlockIndex) { iCopyLength -= ((m_iAllocStep - 1) - iEndInnerIndex); } - FX_WCHAR* pBlockBuf = m_BlockArray[i]; + wchar_t* pBlockBuf = m_BlockArray[i]; FXSYS_memcpy(pBuf + iPointer, pBlockBuf + iBufferPointer, - iCopyLength * sizeof(FX_WCHAR)); + iCopyLength * sizeof(wchar_t)); iPointer += iCopyLength; } wsTextData.ReleaseBuffer(iLength); @@ -1286,7 +1286,7 @@ void CFDE_XMLSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream, } m_pBuffer = FX_Alloc( - FX_WCHAR, pdfium::base::ValueOrDieForType<size_t>(alloc_size_safe)); + wchar_t, pdfium::base::ValueOrDieForType<size_t>(alloc_size_safe)); m_pStart = m_pEnd = m_pBuffer; ASSERT(!m_BlockBuffer.IsInitialized()); m_BlockBuffer.InitBuffer(); @@ -1330,7 +1330,7 @@ FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() { } while (m_pStart < m_pEnd) { - FX_WCHAR ch = *m_pStart; + wchar_t ch = *m_pStart; switch (m_syntaxParserState) { case FDE_XmlSyntaxState::Text: if (ch == L'<') { @@ -1778,7 +1778,7 @@ int32_t CFDE_XMLSyntaxParser::GetStatus() const { return m_iParsedBytes * 100 / iStreamLength; } -static int32_t FX_GetUTF8EncodeLength(const FX_WCHAR* pSrc, int32_t iSrcLen) { +static int32_t FX_GetUTF8EncodeLength(const wchar_t* pSrc, int32_t iSrcLen) { uint32_t unicode = 0; int32_t iDstNum = 0; while (iSrcLen-- > 0) { @@ -1811,7 +1811,7 @@ FX_FILESIZE CFDE_XMLSyntaxParser::GetCurrentBinaryPos() const { return m_iParsedBytes + nDstLen; } -void CFDE_XMLSyntaxParser::ParseTextChar(FX_WCHAR character) { +void CFDE_XMLSyntaxParser::ParseTextChar(wchar_t character) { if (m_iIndexInBlock == m_iAllocStep) { m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); if (!m_pCurrentBlock) { @@ -1828,7 +1828,7 @@ void CFDE_XMLSyntaxParser::ParseTextChar(FX_WCHAR character) { if (iLen > 0) { if (csEntity[0] == L'#') { uint32_t ch = 0; - FX_WCHAR w; + wchar_t w; if (iLen > 1 && csEntity[1] == L'x') { for (int32_t i = 2; i < iLen; i++) { w = csEntity[i]; @@ -1853,7 +1853,7 @@ void CFDE_XMLSyntaxParser::ParseTextChar(FX_WCHAR character) { if (ch > kMaxCharRange) ch = ' '; - character = static_cast<FX_WCHAR>(ch); + character = static_cast<wchar_t>(ch); if (character != 0) { m_BlockBuffer.SetTextChar(m_iEntityStart, character); m_iEntityStart++; diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h index d9ccbea506..7ae05a4936 100644 --- a/xfa/fde/xml/fde_xml_imp.h +++ b/xfa/fde/xml/fde_xml_imp.h @@ -56,7 +56,7 @@ class CFDE_XMLNode { void DeleteChildren(); void CloneChildren(CFDE_XMLNode* pClone); - CFDE_XMLNode* GetPath(const FX_WCHAR* pPath, + CFDE_XMLNode* GetPath(const wchar_t* pPath, int32_t iLength = -1, bool bQualifiedName = true) const; @@ -87,17 +87,17 @@ class CFDE_XMLInstruction : public CFDE_XMLNode { bool GetAttribute(int32_t index, CFX_WideString& wsAttriName, CFX_WideString& wsAttriValue) const; - bool HasAttribute(const FX_WCHAR* pwsAttriName) const; - void GetString(const FX_WCHAR* pwsAttriName, + bool HasAttribute(const wchar_t* pwsAttriName) const; + void GetString(const wchar_t* pwsAttriName, CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue = nullptr) const; + const wchar_t* pwsDefValue = nullptr) const; void SetString(const CFX_WideString& wsAttriName, const CFX_WideString& wsAttriValue); - int32_t GetInteger(const FX_WCHAR* pwsAttriName, int32_t iDefValue = 0) const; - void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); - FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fDefValue = 0) const; - void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); - void RemoveAttribute(const FX_WCHAR* pwsAttriName); + int32_t GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue = 0) const; + void SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue); + FX_FLOAT GetFloat(const wchar_t* pwsAttriName, FX_FLOAT fDefValue = 0) const; + void SetFloat(const wchar_t* pwsAttriName, FX_FLOAT fAttriValue); + void RemoveAttribute(const wchar_t* pwsAttriName); int32_t CountData() const; bool GetData(int32_t index, CFX_WideString& wsData) const; void AppendData(const CFX_WideString& wsData); @@ -127,20 +127,20 @@ class CFDE_XMLElement : public CFDE_XMLNode { bool GetAttribute(int32_t index, CFX_WideString& wsAttriName, CFX_WideString& wsAttriValue) const; - bool HasAttribute(const FX_WCHAR* pwsAttriName) const; - void RemoveAttribute(const FX_WCHAR* pwsAttriName); + bool HasAttribute(const wchar_t* pwsAttriName) const; + void RemoveAttribute(const wchar_t* pwsAttriName); - void GetString(const FX_WCHAR* pwsAttriName, + void GetString(const wchar_t* pwsAttriName, CFX_WideString& wsAttriValue, - const FX_WCHAR* pwsDefValue = nullptr) const; + const wchar_t* pwsDefValue = nullptr) const; void SetString(const CFX_WideString& wsAttriName, const CFX_WideString& wsAttriValue); - int32_t GetInteger(const FX_WCHAR* pwsAttriName, int32_t iDefValue = 0) const; - void SetInteger(const FX_WCHAR* pwsAttriName, int32_t iAttriValue); + int32_t GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue = 0) const; + void SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue); - FX_FLOAT GetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fDefValue = 0) const; - void SetFloat(const FX_WCHAR* pwsAttriName, FX_FLOAT fAttriValue); + FX_FLOAT GetFloat(const wchar_t* pwsAttriName, FX_FLOAT fDefValue = 0) const; + void SetFloat(const wchar_t* pwsAttriName, FX_FLOAT fAttriValue); void GetTextData(CFX_WideString& wsText) const; void SetTextData(const CFX_WideString& wsText); @@ -222,7 +222,7 @@ class CFDE_BlockBuffer { bool InitBuffer(int32_t iBufferSize = 1024 * 1024); bool IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } - FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); + wchar_t* GetAvailableBlock(int32_t& iIndexInBlock); inline int32_t GetAllocStep() const { return m_iAllocStep; } inline int32_t& GetDataLengthRef() { return m_iDataLength; } inline void Reset(bool bReserveData = true) { @@ -231,7 +231,7 @@ class CFDE_BlockBuffer { } m_iDataLength = 0; } - void SetTextChar(int32_t iIndex, FX_WCHAR ch); + void SetTextChar(int32_t iIndex, wchar_t ch); int32_t DeleteTextChars(int32_t iCount, bool bDirection = true); void GetTextData(CFX_WideString& wsTextData, int32_t iStart = 0, @@ -243,7 +243,7 @@ class CFDE_BlockBuffer { int32_t& iInnerIndex) const; void ClearBuffer(); - CFX_ArrayTemplate<FX_WCHAR*> m_BlockArray; + CFX_ArrayTemplate<wchar_t*> m_BlockArray; int32_t m_iDataLength; int32_t m_iBufferSize; int32_t m_iAllocStep; @@ -312,7 +312,7 @@ class CFDE_XMLSyntaxParser { TargetData }; - void ParseTextChar(FX_WCHAR ch); + void ParseTextChar(wchar_t ch); CFX_RetainPtr<IFGAS_Stream> m_pStream; int32_t m_iXMLPlaneSize; @@ -321,25 +321,25 @@ class CFDE_XMLSyntaxParser { int32_t m_iLastNodeNum; int32_t m_iParsedChars; int32_t m_iParsedBytes; - FX_WCHAR* m_pBuffer; + wchar_t* m_pBuffer; int32_t m_iBufferChars; bool m_bEOS; - FX_WCHAR* m_pStart; - FX_WCHAR* m_pEnd; + wchar_t* m_pStart; + wchar_t* m_pEnd; FDE_XMLNODE m_CurNode; std::stack<FDE_XMLNODE> m_XMLNodeStack; CFDE_BlockBuffer m_BlockBuffer; int32_t m_iAllocStep; int32_t& m_iDataLength; - FX_WCHAR* m_pCurrentBlock; + wchar_t* m_pCurrentBlock; int32_t m_iIndexInBlock; int32_t m_iTextDataLength; FDE_XmlSyntaxResult m_syntaxParserResult; FDE_XmlSyntaxState m_syntaxParserState; - FX_WCHAR m_wQuotationMark; + wchar_t m_wQuotationMark; int32_t m_iEntityStart; - std::stack<FX_WCHAR> m_SkipStack; - FX_WCHAR m_SkipChar; + std::stack<wchar_t> m_SkipStack; + wchar_t m_SkipChar; }; #endif // XFA_FDE_XML_FDE_XML_IMP_H_ diff --git a/xfa/fde/xml/fde_xml_imp_unittest.cpp b/xfa/fde/xml/fde_xml_imp_unittest.cpp index 6db1b1905a..6191025fd2 100644 --- a/xfa/fde/xml/fde_xml_imp_unittest.cpp +++ b/xfa/fde/xml/fde_xml_imp_unittest.cpp @@ -10,7 +10,7 @@ #include "xfa/fgas/crt/fgas_stream.h" TEST(CFDE_XMLSyntaxParser, CData) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <![CDATA[\n" L" if (a[1] < 3)\n" @@ -18,16 +18,16 @@ TEST(CFDE_XMLSyntaxParser, CData) { L" ]]>\n" L"</script>"; - const FX_WCHAR* cdata = + const wchar_t* cdata = L"\n" L" if (a[1] < 3)\n" L" app.alert(\"Tclams\");\n" L" "; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -65,7 +65,7 @@ TEST(CFDE_XMLSyntaxParser, CData) { } TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <![CDATA[\n" L" if (a[1] < 3)\n" @@ -74,17 +74,17 @@ TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) { L" ]]>\n" L"</script>"; - const FX_WCHAR* cdata = + const wchar_t* cdata = L"\n" L" if (a[1] < 3)\n" L" app.alert(\"Tclams\");\n" L" </script>\n" L" "; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -122,15 +122,15 @@ TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) { } TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <!>\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -164,15 +164,15 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) { } TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <![>\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -200,15 +200,15 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) { } TEST(CFDE_XMLSyntaxParser, IncompleteCData) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <![CDATA>\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -236,15 +236,15 @@ TEST(CFDE_XMLSyntaxParser, IncompleteCData) { } TEST(CFDE_XMLSyntaxParser, UnClosedCData) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <![CDATA[\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -272,15 +272,15 @@ TEST(CFDE_XMLSyntaxParser, UnClosedCData) { } TEST(CFDE_XMLSyntaxParser, EmptyCData) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <![CDATA[]]>\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -318,15 +318,15 @@ TEST(CFDE_XMLSyntaxParser, EmptyCData) { } TEST(CFDE_XMLSyntaxParser, Comment) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <!-- A Comment -->\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -360,15 +360,15 @@ TEST(CFDE_XMLSyntaxParser, Comment) { } TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <!- A Comment -->\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -402,15 +402,15 @@ TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) { } TEST(CFDE_XMLSyntaxParser, CommentEmpty) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <!---->\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -444,15 +444,15 @@ TEST(CFDE_XMLSyntaxParser, CommentEmpty) { } TEST(CFDE_XMLSyntaxParser, CommentThreeDash) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <!--->\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -478,15 +478,15 @@ TEST(CFDE_XMLSyntaxParser, CommentThreeDash) { } TEST(CFDE_XMLSyntaxParser, CommentTwoDash) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">\n" L" <!-->\n" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -512,7 +512,7 @@ TEST(CFDE_XMLSyntaxParser, CommentTwoDash) { } TEST(CFDE_XMLSyntaxParser, Entities) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">" L"B" L"T" @@ -521,10 +521,10 @@ TEST(CFDE_XMLSyntaxParser, Entities) { L"�" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -554,16 +554,16 @@ TEST(CFDE_XMLSyntaxParser, Entities) { } TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">" L"�" L"�" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); @@ -593,16 +593,16 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) { } TEST(CFDE_XMLSyntaxParser, EntityOverflowDecimal) { - const FX_WCHAR* input = + const wchar_t* input = L"<script contentType=\"application/x-javascript\">" L"�" L"�" L"</script>"; - // We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR. - size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR); + // We * sizeof(wchar_t) because we pass in the uint8_t, not the wchar_t. + size_t len = FXSYS_wcslen(input) * sizeof(wchar_t); CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream( - reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0); + reinterpret_cast<uint8_t*>(const_cast<wchar_t*>(input)), len, 0); CFDE_XMLSyntaxParser parser; parser.Init(stream, 256); EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse()); |