summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-26 15:33:58 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-26 15:33:58 -0700
commitf39074c0ae47a84c496782f8b75bcce1e1cfdf59 (patch)
tree077b7f12bff3c4aa4d53c6b74fa32e613cc73a27
parente5cb0b191aed020da99757c117dae014ea65c6ba (diff)
downloadpdfium-chromium/2902.tar.xz
Fix some FX_BOOL / int noise in fxcrt.chromium/2902
Review-Url: https://codereview.chromium.org/2450183003
-rw-r--r--core/fpdfapi/parser/cpdf_parser_unittest.cpp10
-rw-r--r--core/fxcrt/extension.h33
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp2
-rw-r--r--core/fxcrt/fx_extension.cpp76
-rw-r--r--core/fxcrt/fx_stream.h44
-rw-r--r--core/fxcrt/fx_xml_parser.cpp179
-rw-r--r--core/fxcrt/fxcrt_posix.cpp38
-rw-r--r--core/fxcrt/fxcrt_posix.h10
-rw-r--r--core/fxcrt/fxcrt_stream.cpp6
-rw-r--r--core/fxcrt/fxcrt_windows.cpp101
-rw-r--r--core/fxcrt/fxcrt_windows.h8
-rw-r--r--core/fxcrt/xml_int.h24
-rw-r--r--fpdfsdk/fpdf_dataavail.cpp6
-rw-r--r--fpdfsdk/fpdfsave.cpp16
-rw-r--r--fpdfsdk/fpdfview.cpp56
-rw-r--r--fpdfsdk/fsdk_define.h12
-rw-r--r--xfa/fgas/crt/fgas_stream.cpp17
-rw-r--r--xfa/fgas/crt/fgas_stream.h8
-rw-r--r--xfa/fxfa/app/xfa_ffapp.cpp8
-rw-r--r--xfa/fxfa/xfa_ffapp.h2
20 files changed, 339 insertions, 317 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
index 6c6fb213f4..239332784e 100644
--- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
@@ -22,14 +22,14 @@ class CFX_TestBufferRead : public IFX_SeekableReadStream {
void Release() override { delete this; }
// IFX_SeekableReadStream
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
- if (offset < 0 || offset + size > total_size_) {
- return FALSE;
- }
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ if (offset < 0 || offset + size > total_size_)
+ return false;
memcpy(buffer, buffer_ + offset, size);
- return TRUE;
+ return true;
}
+
FX_FILESIZE GetSize() override { return (FX_FILESIZE)total_size_; };
protected:
diff --git a/core/fxcrt/extension.h b/core/fxcrt/extension.h
index 45f6d4f2f0..5b1801bb1b 100644
--- a/core/fxcrt/extension.h
+++ b/core/fxcrt/extension.h
@@ -18,8 +18,8 @@ class IFXCRT_FileAccess {
static IFXCRT_FileAccess* Create();
virtual ~IFXCRT_FileAccess() {}
- virtual FX_BOOL Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0;
- virtual FX_BOOL Open(const CFX_WideStringC& fileName, uint32_t dwMode) = 0;
+ virtual bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) = 0;
+ virtual bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) = 0;
virtual void Close() = 0;
virtual FX_FILESIZE GetSize() const = 0;
virtual FX_FILESIZE GetPosition() const = 0;
@@ -30,8 +30,8 @@ class IFXCRT_FileAccess {
virtual size_t WritePos(const void* pBuffer,
size_t szBuffer,
FX_FILESIZE pos) = 0;
- virtual FX_BOOL Flush() = 0;
- virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0;
+ virtual bool Flush() = 0;
+ virtual bool Truncate(FX_FILESIZE szFile) = 0;
};
#ifdef PDF_ENABLE_XFA
@@ -63,14 +63,12 @@ class CFX_CRTFileStream final : public IFX_SeekableStream {
IFX_SeekableStream* Retain() override;
void Release() override;
FX_FILESIZE GetSize() override;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
size_t ReadBlock(void* buffer, size_t size) override;
- FX_BOOL WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) override;
- FX_BOOL Flush() override;
+ bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool Flush() override;
protected:
std::unique_ptr<IFXCRT_FileAccess> m_pFile;
@@ -80,6 +78,7 @@ class CFX_CRTFileStream final : public IFX_SeekableStream {
#define FX_MEMSTREAM_BlockSize (64 * 1024)
#define FX_MEMSTREAM_Consecutive 0x01
#define FX_MEMSTREAM_TakeOver 0x02
+
class CFX_MemoryStream final : public IFX_MemoryStream {
public:
explicit CFX_MemoryStream(FX_BOOL bConsecutive);
@@ -90,20 +89,18 @@ class CFX_MemoryStream final : public IFX_MemoryStream {
IFX_SeekableStream* Retain() override;
void Release() override;
FX_FILESIZE GetSize() override;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
size_t ReadBlock(void* buffer, size_t size) override;
- FX_BOOL WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) override;
- FX_BOOL Flush() override;
- FX_BOOL IsConsecutive() const override;
+ bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool Flush() override;
+ bool IsConsecutive() const override;
void EstimateSize(size_t nInitSize, size_t nGrowSize) override;
uint8_t* GetBuffer() const override;
void AttachBuffer(uint8_t* pBuffer,
size_t nSize,
- FX_BOOL bTakeOver = FALSE) override;
+ bool bTakeOver = FALSE) override;
void DetachBuffer() override;
protected:
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index e954224d8a..8466e88c56 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -244,7 +244,7 @@ bool CFX_FileBufferArchive::Flush() {
return false;
if (!m_pBuffer || !nRemaining)
return true;
- return m_pFile->WriteBlock(m_pBuffer.get(), nRemaining) > 0;
+ return m_pFile->WriteBlock(m_pBuffer.get(), nRemaining);
}
int32_t CFX_FileBufferArchive::AppendBlock(const void* pBuf, size_t size) {
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 5ac22bd44e..186d98b858 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -4,9 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "core/fxcrt/extension.h"
+
#include <utility>
-#include "core/fxcrt/extension.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_ext.h"
@@ -102,7 +103,7 @@ FX_FILESIZE CFX_MemoryStream::GetSize() {
return (FX_FILESIZE)m_nCurSize;
}
-FX_BOOL CFX_MemoryStream::IsEOF() {
+bool CFX_MemoryStream::IsEOF() {
return m_nCurPos >= (size_t)GetSize();
}
@@ -110,24 +111,23 @@ FX_FILESIZE CFX_MemoryStream::GetPosition() {
return (FX_FILESIZE)m_nCurPos;
}
-FX_BOOL CFX_MemoryStream::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- if (!buffer || !size) {
- return FALSE;
- }
+bool CFX_MemoryStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (!buffer || !size)
+ return false;
FX_SAFE_SIZE_T newPos = size;
newPos += offset;
if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 ||
newPos.ValueOrDie() > m_nCurSize) {
- return FALSE;
+ return false;
}
m_nCurPos = newPos.ValueOrDie();
if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
FXSYS_memcpy(buffer, m_Blocks[0] + (size_t)offset, size);
- return TRUE;
+ return true;
}
size_t nStartBlock = (size_t)offset / m_nGrowSize;
offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
@@ -142,7 +142,7 @@ FX_BOOL CFX_MemoryStream::ReadBlock(void* buffer,
nStartBlock++;
offset = 0;
}
- return TRUE;
+ return true;
}
size_t CFX_MemoryStream::ReadBlock(void* buffer, size_t size) {
@@ -156,17 +156,17 @@ size_t CFX_MemoryStream::ReadBlock(void* buffer, size_t size) {
return nRead;
}
-FX_BOOL CFX_MemoryStream::WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- if (!buffer || !size) {
- return FALSE;
- }
+bool CFX_MemoryStream::WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (!buffer || !size)
+ return false;
+
if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
FX_SAFE_SIZE_T newPos = size;
newPos += offset;
if (!newPos.IsValid())
- return FALSE;
+ return false;
m_nCurPos = newPos.ValueOrDie();
if (m_nCurPos > m_nTotalSize) {
@@ -179,14 +179,14 @@ FX_BOOL CFX_MemoryStream::WriteBlock(const void* buffer,
}
if (!m_Blocks[0]) {
m_Blocks.RemoveAll();
- return FALSE;
+ return false;
}
}
FXSYS_memcpy(m_Blocks[0] + (size_t)offset, buffer, size);
if (m_nCurSize < m_nCurPos) {
m_nCurSize = m_nCurPos;
}
- return TRUE;
+ return true;
}
FX_SAFE_SIZE_T newPos = size;
@@ -215,11 +215,11 @@ FX_BOOL CFX_MemoryStream::WriteBlock(const void* buffer,
return TRUE;
}
-FX_BOOL CFX_MemoryStream::Flush() {
- return TRUE;
+bool CFX_MemoryStream::Flush() {
+ return true;
}
-FX_BOOL CFX_MemoryStream::IsConsecutive() const {
+bool CFX_MemoryStream::IsConsecutive() const {
return !!(m_dwFlags & FX_MEMSTREAM_Consecutive);
}
@@ -242,10 +242,10 @@ uint8_t* CFX_MemoryStream::GetBuffer() const {
void CFX_MemoryStream::AttachBuffer(uint8_t* pBuffer,
size_t nSize,
- FX_BOOL bTakeOver) {
- if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) {
+ bool bTakeOver) {
+ if (!(m_dwFlags & FX_MEMSTREAM_Consecutive))
return;
- }
+
m_Blocks.RemoveAll();
m_Blocks.Add(pBuffer);
m_nTotalSize = m_nCurSize = nSize;
@@ -297,7 +297,7 @@ FX_FILESIZE CFX_CRTFileStream::GetSize() {
return m_pFile->GetSize();
}
-FX_BOOL CFX_CRTFileStream::IsEOF() {
+bool CFX_CRTFileStream::IsEOF() {
return GetPosition() >= GetSize();
}
@@ -305,23 +305,23 @@ FX_FILESIZE CFX_CRTFileStream::GetPosition() {
return m_pFile->GetPosition();
}
-FX_BOOL CFX_CRTFileStream::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- return (FX_BOOL)m_pFile->ReadPos(buffer, size, offset);
+bool CFX_CRTFileStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ return m_pFile->ReadPos(buffer, size, offset) > 0;
}
size_t CFX_CRTFileStream::ReadBlock(void* buffer, size_t size) {
return m_pFile->Read(buffer, size);
}
-FX_BOOL CFX_CRTFileStream::WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- return (FX_BOOL)m_pFile->WritePos(buffer, size, offset);
+bool CFX_CRTFileStream::WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ return !!m_pFile->WritePos(buffer, size, offset);
}
-FX_BOOL CFX_CRTFileStream::Flush() {
+bool CFX_CRTFileStream::Flush() {
return m_pFile->Flush();
}
@@ -359,10 +359,10 @@ IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename) {
}
IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
size_t dwSize,
- FX_BOOL bTakeOver) {
+ bool bTakeOver) {
return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
}
-IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) {
+IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive) {
return new CFX_MemoryStream(bConsecutive);
}
diff --git a/core/fxcrt/fx_stream.h b/core/fxcrt/fx_stream.h
index 2509ec2cd7..8b1d91f4bc 100644
--- a/core/fxcrt/fx_stream.h
+++ b/core/fxcrt/fx_stream.h
@@ -59,7 +59,7 @@ class IFX_WriteStream {
public:
virtual ~IFX_WriteStream() {}
virtual void Release() = 0;
- virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
+ virtual bool WriteBlock(const void* pData, size_t size) = 0;
};
class IFX_ReadStream {
@@ -67,7 +67,7 @@ class IFX_ReadStream {
virtual ~IFX_ReadStream() {}
virtual void Release() = 0;
- virtual FX_BOOL IsEOF() = 0;
+ virtual bool IsEOF() = 0;
virtual FX_FILESIZE GetPosition() = 0;
virtual size_t ReadBlock(void* buffer, size_t size) = 0;
};
@@ -75,23 +75,23 @@ class IFX_ReadStream {
class IFX_SeekableWriteStream : public IFX_WriteStream {
public:
// IFX_WriteStream:
- FX_BOOL WriteBlock(const void* pData, size_t size) override;
+ bool WriteBlock(const void* pData, size_t size) override;
virtual FX_FILESIZE GetSize() = 0;
- virtual FX_BOOL Flush() = 0;
- virtual FX_BOOL WriteBlock(const void* pData,
- FX_FILESIZE offset,
- size_t size) = 0;
+ virtual bool Flush() = 0;
+ virtual bool WriteBlock(const void* pData,
+ FX_FILESIZE offset,
+ size_t size) = 0;
};
class IFX_SeekableReadStream : public IFX_ReadStream {
public:
// IFX_ReadStream:
void Release() override = 0;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
size_t ReadBlock(void* buffer, size_t size) override;
- virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
+ virtual bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
virtual FX_FILESIZE GetSize() = 0;
};
@@ -105,18 +105,18 @@ class IFX_SeekableStream : public IFX_SeekableReadStream,
// IFX_SeekableReadStream:
void Release() override = 0;
- FX_BOOL IsEOF() override = 0;
+ bool IsEOF() override = 0;
FX_FILESIZE GetPosition() override = 0;
size_t ReadBlock(void* buffer, size_t size) override = 0;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0;
FX_FILESIZE GetSize() override = 0;
// IFX_SeekableWriteStream:
- FX_BOOL WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) override = 0;
- FX_BOOL WriteBlock(const void* buffer, size_t size) override;
- FX_BOOL Flush() override = 0;
+ bool WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) override = 0;
+ bool WriteBlock(const void* buffer, size_t size) override;
+ bool Flush() override = 0;
};
IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename,
@@ -138,29 +138,29 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath);
class IFX_MemoryStream : public IFX_SeekableStream {
public:
- virtual FX_BOOL IsConsecutive() const = 0;
+ virtual bool IsConsecutive() const = 0;
virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
virtual uint8_t* GetBuffer() const = 0;
virtual void AttachBuffer(uint8_t* pBuffer,
size_t nSize,
- FX_BOOL bTakeOver = FALSE) = 0;
+ bool bTakeOver = FALSE) = 0;
virtual void DetachBuffer() = 0;
};
IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
size_t nSize,
- FX_BOOL bTakeOver = FALSE);
-IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
+ bool bTakeOver = FALSE);
+IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive = FALSE);
class IFX_BufferRead : public IFX_ReadStream {
public:
// IFX_ReadStream:
void Release() override = 0;
- FX_BOOL IsEOF() override = 0;
+ bool IsEOF() override = 0;
FX_FILESIZE GetPosition() override = 0;
size_t ReadBlock(void* buffer, size_t size) override = 0;
- virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
+ virtual bool ReadNextBlock(bool bRestart = FALSE) = 0;
virtual const uint8_t* GetBlockBuffer() = 0;
virtual size_t GetBlockSize() = 0;
virtual FX_FILESIZE GetBlockOffset() = 0;
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index e6c3543378..f6b81dad93 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -13,6 +13,62 @@
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
+namespace {
+
+#define FXCRTM_XML_CHARTYPE_Normal 0x00
+#define FXCRTM_XML_CHARTYPE_SpaceChar 0x01
+#define FXCRTM_XML_CHARTYPE_Letter 0x02
+#define FXCRTM_XML_CHARTYPE_Digital 0x04
+#define FXCRTM_XML_CHARTYPE_NameIntro 0x08
+#define FXCRTM_XML_CHARTYPE_NameChar 0x10
+#define FXCRTM_XML_CHARTYPE_HexDigital 0x20
+#define FXCRTM_XML_CHARTYPE_HexLowerLetter 0x40
+#define FXCRTM_XML_CHARTYPE_HexUpperLetter 0x60
+#define FXCRTM_XML_CHARTYPE_HexChar 0x60
+
+const uint8_t g_FXCRT_XML_ByteTypes[256] = {
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x18,
+ 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1A, 0x1A, 0x01, 0x01,
+};
+
+bool g_FXCRT_XML_IsWhiteSpace(uint8_t ch) {
+ return !!(g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_SpaceChar);
+}
+
+bool g_FXCRT_XML_IsDigital(uint8_t ch) {
+ return !!(g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Digital);
+}
+
+bool g_FXCRT_XML_IsNameIntro(uint8_t ch) {
+ return !!(g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameIntro);
+}
+
+bool g_FXCRT_XML_IsNameChar(uint8_t ch) {
+ return !!(g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameChar);
+}
+
+} // namespace
+
CXML_DataBufAcc::CXML_DataBufAcc(const uint8_t* pBuffer, size_t size)
: m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {}
@@ -22,7 +78,7 @@ void CXML_DataBufAcc::Release() {
delete this;
}
-FX_BOOL CXML_DataBufAcc::IsEOF() {
+bool CXML_DataBufAcc::IsEOF() {
return m_dwCurPos >= m_dwSize;
}
@@ -34,15 +90,15 @@ size_t CXML_DataBufAcc::ReadBlock(void* buffer, size_t size) {
return 0;
}
-FX_BOOL CXML_DataBufAcc::ReadNextBlock(FX_BOOL bRestart) {
- if (bRestart) {
+bool CXML_DataBufAcc::ReadNextBlock(bool bRestart) {
+ if (bRestart)
m_dwCurPos = 0;
- }
+
if (m_dwCurPos < m_dwSize) {
m_dwCurPos = m_dwSize;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
const uint8_t* CXML_DataBufAcc::GetBlockBuffer() {
@@ -70,7 +126,7 @@ void CXML_DataStmAcc::Release() {
delete this;
}
-FX_BOOL CXML_DataStmAcc::IsEOF() {
+bool CXML_DataStmAcc::IsEOF() {
return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize();
}
@@ -82,21 +138,21 @@ size_t CXML_DataStmAcc::ReadBlock(void* buffer, size_t size) {
return 0;
}
-FX_BOOL CXML_DataStmAcc::ReadNextBlock(FX_BOOL bRestart) {
- if (bRestart) {
+bool CXML_DataStmAcc::ReadNextBlock(bool bRestart) {
+ if (bRestart)
m_nStart = 0;
- }
+
FX_FILESIZE nLength = m_pFileRead->GetSize();
m_nStart += (FX_FILESIZE)m_dwSize;
- if (m_nStart >= nLength) {
- return FALSE;
- }
+ if (m_nStart >= nLength)
+ return false;
+
static const FX_FILESIZE FX_XMLDATASTREAM_BufferSize = 32 * 1024;
m_dwSize = static_cast<size_t>(
std::min(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart));
- if (!m_pBuffer) {
+ if (!m_pBuffer)
m_pBuffer = FX_Alloc(uint8_t, m_dwSize);
- }
+
return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
}
@@ -128,94 +184,45 @@ CXML_Parser::~CXML_Parser() {
}
}
-FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) {
+bool CXML_Parser::Init(uint8_t* pBuffer, size_t size) {
m_pDataAcc = new CXML_DataBufAcc(pBuffer, size);
- return Init(TRUE);
+ return Init(true);
}
-FX_BOOL CXML_Parser::Init(IFX_SeekableReadStream* pFileRead) {
+
+bool CXML_Parser::Init(IFX_SeekableReadStream* pFileRead) {
m_pDataAcc = new CXML_DataStmAcc(pFileRead);
- return Init(TRUE);
+ return Init(true);
}
-FX_BOOL CXML_Parser::Init(IFX_BufferRead* pBuffer) {
- if (!pBuffer) {
- return FALSE;
- }
+
+bool CXML_Parser::Init(IFX_BufferRead* pBuffer) {
+ if (!pBuffer)
+ return false;
+
m_pDataAcc = pBuffer;
- return Init(FALSE);
+ return Init(false);
}
-FX_BOOL CXML_Parser::Init(FX_BOOL bOwndedStream) {
+
+bool CXML_Parser::Init(bool bOwndedStream) {
m_bOwnedStream = bOwndedStream;
m_nOffset = 0;
return ReadNextBlock();
}
-FX_BOOL CXML_Parser::ReadNextBlock() {
- if (!m_pDataAcc->ReadNextBlock()) {
- return FALSE;
- }
+
+bool CXML_Parser::ReadNextBlock() {
+ if (!m_pDataAcc->ReadNextBlock())
+ return false;
+
m_pBuffer = m_pDataAcc->GetBlockBuffer();
m_dwBufferSize = m_pDataAcc->GetBlockSize();
m_nBufferOffset = m_pDataAcc->GetBlockOffset();
m_dwIndex = 0;
return m_dwBufferSize > 0;
}
-FX_BOOL CXML_Parser::IsEOF() {
- if (!m_pDataAcc->IsEOF()) {
- return FALSE;
- }
- return m_dwIndex >= m_dwBufferSize;
-}
-#define FXCRTM_XML_CHARTYPE_Normal 0x00
-#define FXCRTM_XML_CHARTYPE_SpaceChar 0x01
-#define FXCRTM_XML_CHARTYPE_Letter 0x02
-#define FXCRTM_XML_CHARTYPE_Digital 0x04
-#define FXCRTM_XML_CHARTYPE_NameIntro 0x08
-#define FXCRTM_XML_CHARTYPE_NameChar 0x10
-#define FXCRTM_XML_CHARTYPE_HexDigital 0x20
-#define FXCRTM_XML_CHARTYPE_HexLowerLetter 0x40
-#define FXCRTM_XML_CHARTYPE_HexUpperLetter 0x60
-#define FXCRTM_XML_CHARTYPE_HexChar 0x60
-uint8_t g_FXCRT_XML_ByteTypes[256] = {
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,
- 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x18,
- 0x00, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1A, 0x1A, 0x01, 0x01,
-};
-FX_BOOL g_FXCRT_XML_IsWhiteSpace(uint8_t ch) {
- return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_SpaceChar) != 0;
-}
-FX_BOOL g_FXCRT_XML_IsLetter(uint8_t ch) {
- return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Letter) != 0;
-}
-FX_BOOL g_FXCRT_XML_IsDigital(uint8_t ch) {
- return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Digital) != 0;
-}
-FX_BOOL g_FXCRT_XML_IsNameIntro(uint8_t ch) {
- return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameIntro) != 0;
-}
-FX_BOOL g_FXCRT_XML_IsNameChar(uint8_t ch) {
- return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameChar) != 0;
-}
-FX_BOOL g_FXCRT_XML_IsHexChar(uint8_t ch) {
- return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar) != 0;
+
+bool CXML_Parser::IsEOF() {
+ return m_pDataAcc->IsEOF() && m_dwIndex >= m_dwBufferSize;
}
+
void CXML_Parser::SkipWhiteSpaces() {
m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
if (IsEOF()) {
diff --git a/core/fxcrt/fxcrt_posix.cpp b/core/fxcrt/fxcrt_posix.cpp
index b5efdc28f4..a96f164c7f 100644
--- a/core/fxcrt/fxcrt_posix.cpp
+++ b/core/fxcrt/fxcrt_posix.cpp
@@ -36,20 +36,24 @@ CFXCRT_FileAccess_Posix::CFXCRT_FileAccess_Posix() : m_nFD(-1) {}
CFXCRT_FileAccess_Posix::~CFXCRT_FileAccess_Posix() {
Close();
}
-FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
- uint32_t dwMode) {
- if (m_nFD > -1) {
- return FALSE;
- }
- int32_t nFlags, nMasks;
+
+bool CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName,
+ uint32_t dwMode) {
+ if (m_nFD > -1)
+ return false;
+
+ int32_t nFlags;
+ int32_t nMasks;
FXCRT_Posix_GetFileMode(dwMode, nFlags, nMasks);
m_nFD = open(fileName.c_str(), nFlags, nMasks);
return m_nFD > -1;
}
-FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
- uint32_t dwMode) {
+
+bool CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName,
+ uint32_t dwMode) {
return Open(FX_UTF8Encode(fileName).AsStringC(), dwMode);
}
+
void CFXCRT_FileAccess_Posix::Close() {
if (m_nFD < 0) {
return;
@@ -115,16 +119,18 @@ size_t CFXCRT_FileAccess_Posix::WritePos(const void* pBuffer,
}
return Write(pBuffer, szBuffer);
}
-FX_BOOL CFXCRT_FileAccess_Posix::Flush() {
- if (m_nFD < 0) {
- return FALSE;
- }
+
+bool CFXCRT_FileAccess_Posix::Flush() {
+ if (m_nFD < 0)
+ return false;
+
return fsync(m_nFD) > -1;
}
-FX_BOOL CFXCRT_FileAccess_Posix::Truncate(FX_FILESIZE szFile) {
- if (m_nFD < 0) {
- return FALSE;
- }
+
+bool CFXCRT_FileAccess_Posix::Truncate(FX_FILESIZE szFile) {
+ if (m_nFD < 0)
+ return false;
+
return !ftruncate(m_nFD, szFile);
}
diff --git a/core/fxcrt/fxcrt_posix.h b/core/fxcrt/fxcrt_posix.h
index 37f6548d40..20faa5c02f 100644
--- a/core/fxcrt/fxcrt_posix.h
+++ b/core/fxcrt/fxcrt_posix.h
@@ -17,9 +17,9 @@ class CFXCRT_FileAccess_Posix : public IFXCRT_FileAccess {
CFXCRT_FileAccess_Posix();
~CFXCRT_FileAccess_Posix() override;
- // IFXCRT_FileAccess
- FX_BOOL Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
- FX_BOOL Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
+ // IFXCRT_FileAccess:
+ bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
+ bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
void Close() override;
FX_FILESIZE GetSize() const override;
FX_FILESIZE GetPosition() const override;
@@ -30,8 +30,8 @@ class CFXCRT_FileAccess_Posix : public IFXCRT_FileAccess {
size_t WritePos(const void* pBuffer,
size_t szBuffer,
FX_FILESIZE pos) override;
- FX_BOOL Flush() override;
- FX_BOOL Truncate(FX_FILESIZE szFile) override;
+ bool Flush() override;
+ bool Truncate(FX_FILESIZE szFile) override;
protected:
int32_t m_nFD;
diff --git a/core/fxcrt/fxcrt_stream.cpp b/core/fxcrt/fxcrt_stream.cpp
index 638a183177..48b8a79379 100644
--- a/core/fxcrt/fxcrt_stream.cpp
+++ b/core/fxcrt/fxcrt_stream.cpp
@@ -6,11 +6,11 @@
#include "core/fxcrt/fx_stream.h"
-FX_BOOL IFX_SeekableWriteStream::WriteBlock(const void* pData, size_t size) {
+bool IFX_SeekableWriteStream::WriteBlock(const void* pData, size_t size) {
return WriteBlock(pData, GetSize(), size);
}
-FX_BOOL IFX_SeekableReadStream::IsEOF() {
+bool IFX_SeekableReadStream::IsEOF() {
return FALSE;
}
@@ -22,6 +22,6 @@ size_t IFX_SeekableReadStream::ReadBlock(void* buffer, size_t size) {
return 0;
}
-FX_BOOL IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) {
+bool IFX_SeekableStream::WriteBlock(const void* buffer, size_t size) {
return WriteBlock(buffer, GetSize(), size);
}
diff --git a/core/fxcrt/fxcrt_windows.cpp b/core/fxcrt/fxcrt_windows.cpp
index ec16373f02..87bbe96a5c 100644
--- a/core/fxcrt/fxcrt_windows.cpp
+++ b/core/fxcrt/fxcrt_windows.cpp
@@ -28,6 +28,7 @@ void FXCRT_Windows_GetFileMode(uint32_t dwMode,
dwCreation = OPEN_EXISTING;
}
}
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -39,80 +40,91 @@ WINBASEAPI BOOL WINAPI SetFilePointerEx(HANDLE hFile,
#ifdef __cplusplus
}
#endif
+
CFXCRT_FileAccess_Win64::CFXCRT_FileAccess_Win64() : m_hFile(nullptr) {}
+
CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() {
Close();
}
-FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName,
- uint32_t dwMode) {
- if (m_hFile) {
+
+bool CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName,
+ uint32_t dwMode) {
+ if (m_hFile)
return FALSE;
- }
+
uint32_t dwAccess, dwShare, dwCreation;
FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation);
m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, nullptr,
dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr);
if (m_hFile == INVALID_HANDLE_VALUE)
m_hFile = nullptr;
+
return !!m_hFile;
}
-FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName,
- uint32_t dwMode) {
- if (m_hFile) {
+
+bool CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName,
+ uint32_t dwMode) {
+ if (m_hFile)
return FALSE;
- }
+
uint32_t dwAccess, dwShare, dwCreation;
FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation);
m_hFile = ::CreateFileW((LPCWSTR)fileName.c_str(), dwAccess, dwShare, nullptr,
dwCreation, FILE_ATTRIBUTE_NORMAL, nullptr);
if (m_hFile == INVALID_HANDLE_VALUE)
m_hFile = nullptr;
+
return !!m_hFile;
}
+
void CFXCRT_FileAccess_Win64::Close() {
- if (!m_hFile) {
+ if (!m_hFile)
return;
- }
+
::CloseHandle(m_hFile);
m_hFile = nullptr;
}
+
FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const {
- if (!m_hFile) {
+ if (!m_hFile)
return 0;
- }
+
LARGE_INTEGER size = {};
- if (!::GetFileSizeEx(m_hFile, &size)) {
+ if (!::GetFileSizeEx(m_hFile, &size))
return 0;
- }
+
return (FX_FILESIZE)size.QuadPart;
}
+
FX_FILESIZE CFXCRT_FileAccess_Win64::GetPosition() const {
- if (!m_hFile) {
+ if (!m_hFile)
return (FX_FILESIZE)-1;
- }
+
LARGE_INTEGER dist = {};
LARGE_INTEGER newPos = {};
- if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_CURRENT)) {
+ if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_CURRENT))
return (FX_FILESIZE)-1;
- }
+
return (FX_FILESIZE)newPos.QuadPart;
}
+
FX_FILESIZE CFXCRT_FileAccess_Win64::SetPosition(FX_FILESIZE pos) {
- if (!m_hFile) {
+ if (!m_hFile)
return (FX_FILESIZE)-1;
- }
+
LARGE_INTEGER dist;
dist.QuadPart = pos;
LARGE_INTEGER newPos = {};
- if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_BEGIN)) {
+ if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_BEGIN))
return (FX_FILESIZE)-1;
- }
+
return (FX_FILESIZE)newPos.QuadPart;
}
+
size_t CFXCRT_FileAccess_Win64::Read(void* pBuffer, size_t szBuffer) {
- if (!m_hFile) {
+ if (!m_hFile)
return 0;
- }
+
size_t szRead = 0;
if (!::ReadFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szRead,
nullptr)) {
@@ -120,10 +132,11 @@ size_t CFXCRT_FileAccess_Win64::Read(void* pBuffer, size_t szBuffer) {
}
return szRead;
}
+
size_t CFXCRT_FileAccess_Win64::Write(const void* pBuffer, size_t szBuffer) {
- if (!m_hFile) {
+ if (!m_hFile)
return 0;
- }
+
size_t szWrite = 0;
if (!::WriteFile(m_hFile, pBuffer, (DWORD)szBuffer, (LPDWORD)&szWrite,
nullptr)) {
@@ -131,20 +144,22 @@ size_t CFXCRT_FileAccess_Win64::Write(const void* pBuffer, size_t szBuffer) {
}
return szWrite;
}
+
size_t CFXCRT_FileAccess_Win64::ReadPos(void* pBuffer,
size_t szBuffer,
FX_FILESIZE pos) {
- if (!m_hFile) {
+ if (!m_hFile)
return 0;
- }
- if (pos >= GetSize()) {
+
+ if (pos >= GetSize())
return 0;
- }
- if (SetPosition(pos) == (FX_FILESIZE)-1) {
+
+ if (SetPosition(pos) == (FX_FILESIZE)-1)
return 0;
- }
+
return Read(pBuffer, szBuffer);
}
+
size_t CFXCRT_FileAccess_Win64::WritePos(const void* pBuffer,
size_t szBuffer,
FX_FILESIZE pos) {
@@ -156,16 +171,18 @@ size_t CFXCRT_FileAccess_Win64::WritePos(const void* pBuffer,
}
return Write(pBuffer, szBuffer);
}
-FX_BOOL CFXCRT_FileAccess_Win64::Flush() {
- if (!m_hFile) {
- return FALSE;
- }
- return ::FlushFileBuffers(m_hFile);
+
+bool CFXCRT_FileAccess_Win64::Flush() {
+ if (!m_hFile)
+ return false;
+
+ return !!::FlushFileBuffers(m_hFile);
}
-FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) {
- if (SetPosition(szFile) == (FX_FILESIZE)-1) {
- return FALSE;
- }
- return ::SetEndOfFile(m_hFile);
+
+bool CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) {
+ if (SetPosition(szFile) == (FX_FILESIZE)-1)
+ return false;
+
+ return !!::SetEndOfFile(m_hFile);
}
#endif
diff --git a/core/fxcrt/fxcrt_windows.h b/core/fxcrt/fxcrt_windows.h
index 19cef0adc2..f8f948360d 100644
--- a/core/fxcrt/fxcrt_windows.h
+++ b/core/fxcrt/fxcrt_windows.h
@@ -16,8 +16,8 @@ class CFXCRT_FileAccess_Win64 : public IFXCRT_FileAccess {
~CFXCRT_FileAccess_Win64() override;
// IFXCRT_FileAccess
- FX_BOOL Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
- FX_BOOL Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
+ bool Open(const CFX_ByteStringC& fileName, uint32_t dwMode) override;
+ bool Open(const CFX_WideStringC& fileName, uint32_t dwMode) override;
void Close() override;
FX_FILESIZE GetSize() const override;
FX_FILESIZE GetPosition() const override;
@@ -28,8 +28,8 @@ class CFXCRT_FileAccess_Win64 : public IFXCRT_FileAccess {
size_t WritePos(const void* pBuffer,
size_t szBuffer,
FX_FILESIZE pos) override;
- FX_BOOL Flush() override;
- FX_BOOL Truncate(FX_FILESIZE szFile) override;
+ bool Flush() override;
+ bool Truncate(FX_FILESIZE szFile) override;
protected:
void* m_hFile;
diff --git a/core/fxcrt/xml_int.h b/core/fxcrt/xml_int.h
index aa157c2333..bc9ea3dd48 100644
--- a/core/fxcrt/xml_int.h
+++ b/core/fxcrt/xml_int.h
@@ -21,10 +21,10 @@ class CXML_DataBufAcc : public IFX_BufferRead {
// IFX_BufferRead
void Release() override;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
size_t ReadBlock(void* buffer, size_t size) override;
- FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override;
+ bool ReadNextBlock(bool bRestart = FALSE) override;
const uint8_t* GetBlockBuffer() override;
size_t GetBlockSize() override;
FX_FILESIZE GetBlockOffset() override;
@@ -42,10 +42,10 @@ class CXML_DataStmAcc : public IFX_BufferRead {
// IFX_BufferRead
void Release() override;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
size_t ReadBlock(void* buffer, size_t size) override;
- FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override;
+ bool ReadNextBlock(bool bRestart = FALSE) override;
const uint8_t* GetBlockBuffer() override;
size_t GetBlockSize() override;
FX_FILESIZE GetBlockOffset() override;
@@ -62,13 +62,13 @@ class CXML_Parser {
CXML_Parser();
~CXML_Parser();
- FX_BOOL Init(uint8_t* pBuffer, size_t size);
- FX_BOOL Init(IFX_SeekableReadStream* pFileRead);
- FX_BOOL Init(IFX_BufferRead* pBuffer);
- FX_BOOL Init(FX_BOOL bOwndedStream);
- FX_BOOL ReadNextBlock();
- FX_BOOL IsEOF();
- FX_BOOL HaveAvailData();
+ bool Init(uint8_t* pBuffer, size_t size);
+ bool Init(IFX_SeekableReadStream* pFileRead);
+ bool Init(IFX_BufferRead* pBuffer);
+ bool Init(bool bOwndedStream);
+ bool ReadNextBlock();
+ bool IsEOF();
+ bool HaveAvailData();
void SkipWhiteSpaces();
void GetName(CFX_ByteString& space, CFX_ByteString& name);
void GetAttrValue(CFX_WideString& value);
@@ -85,7 +85,7 @@ class CXML_Parser {
void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement);
IFX_BufferRead* m_pDataAcc;
- FX_BOOL m_bOwnedStream;
+ bool m_bOwnedStream;
FX_FILESIZE m_nOffset;
FX_BOOL m_bSaveSpaceChars;
const uint8_t* m_pBuffer;
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index 0bf67e9826..45d3b2aa5d 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -67,9 +67,9 @@ class CFPDF_FileAccessWrap : public IFX_SeekableReadStream {
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override { return m_pFileAccess->m_FileLen; }
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
- return m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset,
- (uint8_t*)buffer, size);
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ return !!m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset,
+ (uint8_t*)buffer, size);
}
void Release() override {}
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 9cdc714f3f..03a9db1168 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -39,8 +39,8 @@
class CFX_IFileWrite final : public IFX_WriteStream {
public:
CFX_IFileWrite();
- FX_BOOL Init(FPDF_FILEWRITE* pFileWriteStruct);
- FX_BOOL WriteBlock(const void* pData, size_t size) override;
+ bool Init(FPDF_FILEWRITE* pFileWriteStruct);
+ bool WriteBlock(const void* pData, size_t size) override;
void Release() override;
protected:
@@ -53,20 +53,20 @@ CFX_IFileWrite::CFX_IFileWrite() {
m_pFileWriteStruct = nullptr;
}
-FX_BOOL CFX_IFileWrite::Init(FPDF_FILEWRITE* pFileWriteStruct) {
+bool CFX_IFileWrite::Init(FPDF_FILEWRITE* pFileWriteStruct) {
if (!pFileWriteStruct)
- return FALSE;
+ return false;
m_pFileWriteStruct = pFileWriteStruct;
- return TRUE;
+ return true;
}
-FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size) {
+bool CFX_IFileWrite::WriteBlock(const void* pData, size_t size) {
if (!m_pFileWriteStruct)
- return FALSE;
+ return false;
m_pFileWriteStruct->WriteBlock(m_pFileWriteStruct, pData, size);
- return TRUE;
+ return true;
}
void CFX_IFileWrite::Release() {
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index be56c531d2..03aedf6874 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -112,7 +112,7 @@ FX_FILESIZE CFPDF_FileStream::GetSize() {
return 0;
}
-FX_BOOL CFPDF_FileStream::IsEOF() {
+bool CFPDF_FileStream::IsEOF() {
return m_nCurPos >= GetSize();
}
@@ -120,18 +120,18 @@ FX_FILESIZE CFPDF_FileStream::GetPosition() {
return m_nCurPos;
}
-FX_BOOL CFPDF_FileStream::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+bool CFPDF_FileStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
if (!buffer || !size || !m_pFS->ReadBlock)
- return FALSE;
+ return false;
if (m_pFS->ReadBlock(m_pFS->clientData, (FPDF_DWORD)offset, buffer,
(FPDF_DWORD)size) == 0) {
m_nCurPos = offset + size;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
size_t CFPDF_FileStream::ReadBlock(void* buffer, size_t size) {
@@ -153,23 +153,23 @@ size_t CFPDF_FileStream::ReadBlock(void* buffer, size_t size) {
return 0;
}
-FX_BOOL CFPDF_FileStream::WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+bool CFPDF_FileStream::WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
if (!m_pFS || !m_pFS->WriteBlock)
- return FALSE;
+ return false;
if (m_pFS->WriteBlock(m_pFS->clientData, (FPDF_DWORD)offset, buffer,
(FPDF_DWORD)size) == 0) {
m_nCurPos = offset + size;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-FX_BOOL CFPDF_FileStream::Flush() {
+bool CFPDF_FileStream::Flush() {
if (!m_pFS || !m_pFS->Flush)
- return TRUE;
+ return true;
return m_pFS->Flush(m_pFS->clientData) == 0;
}
@@ -186,21 +186,21 @@ void CPDF_CustomAccess::Release() {
delete this;
}
-FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- if (offset < 0) {
- return FALSE;
- }
+bool CPDF_CustomAccess::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (offset < 0)
+ return false;
+
FX_SAFE_FILESIZE newPos =
pdfium::base::checked_cast<FX_FILESIZE, size_t>(size);
newPos += offset;
if (!newPos.IsValid() ||
newPos.ValueOrDie() > static_cast<FX_FILESIZE>(m_FileAccess.m_FileLen)) {
- return FALSE;
+ return false;
}
- return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset, (uint8_t*)buffer,
- size);
+ return !!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,
+ reinterpret_cast<uint8_t*>(buffer), size);
}
// 0 bit: FPDF_POLICY_MACHINETIME_ACCESS
@@ -388,18 +388,18 @@ class CMemFile final : public IFX_SeekableReadStream {
void Release() override { delete this; }
FX_FILESIZE GetSize() override { return m_size; }
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
if (offset < 0) {
- return FALSE;
+ return false;
}
FX_SAFE_FILESIZE newPos =
pdfium::base::checked_cast<FX_FILESIZE, size_t>(size);
newPos += offset;
if (!newPos.IsValid() || newPos.ValueOrDie() > m_size) {
- return FALSE;
+ return false;
}
FXSYS_memcpy(buffer, m_pBuf + offset, size);
- return TRUE;
+ return true;
}
private:
diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h
index 4fea138779..aeb42d2d11 100644
--- a/fpdfsdk/fsdk_define.h
+++ b/fpdfsdk/fsdk_define.h
@@ -33,7 +33,7 @@ class CPDF_CustomAccess final : public IFX_SeekableReadStream {
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override;
void Release() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
private:
FPDF_FILEACCESS m_FileAccess;
@@ -49,14 +49,12 @@ class CFPDF_FileStream : public IFX_SeekableStream {
IFX_SeekableStream* Retain() override;
void Release() override;
FX_FILESIZE GetSize() override;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
size_t ReadBlock(void* buffer, size_t size) override;
- FX_BOOL WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) override;
- FX_BOOL Flush() override;
+ bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool Flush() override;
void SetPosition(FX_FILESIZE pos) { m_nCurPos = pos; }
diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp
index f0a2a88100..6da4e9ed8c 100644
--- a/xfa/fgas/crt/fgas_stream.cpp
+++ b/xfa/fgas/crt/fgas_stream.cpp
@@ -291,16 +291,16 @@ class CFX_TextStream : public IFX_Stream {
class CFGAS_FileRead : public IFX_SeekableReadStream {
public:
- CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream);
+ CFGAS_FileRead(IFX_Stream* pStream, bool bReleaseStream);
~CFGAS_FileRead() override;
// IFX_SeekableReadStream
void Release() override;
FX_FILESIZE GetSize() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
protected:
- FX_BOOL m_bReleaseStream;
+ bool m_bReleaseStream;
IFX_Stream* m_pStream;
};
@@ -1469,12 +1469,14 @@ IFX_Stream* CFX_Stream::CreateSharedStream(uint32_t dwAccess,
}
return pShared;
}
+
IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream,
- FX_BOOL bReleaseStream) {
+ bool bReleaseStream) {
ASSERT(pBaseStream);
return new CFGAS_FileRead(pBaseStream, bReleaseStream);
}
-CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, FX_BOOL bReleaseStream)
+
+CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, bool bReleaseStream)
: m_bReleaseStream(bReleaseStream), m_pStream(pStream) {
ASSERT(m_pStream);
}
@@ -1486,9 +1488,8 @@ CFGAS_FileRead::~CFGAS_FileRead() {
FX_FILESIZE CFGAS_FileRead::GetSize() {
return (FX_FILESIZE)m_pStream->GetLength();
}
-FX_BOOL CFGAS_FileRead::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+
+bool CFGAS_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
m_pStream->Seek(FX_STREAMSEEK_Begin, (int32_t)offset);
int32_t iLen = m_pStream->ReadData((uint8_t*)buffer, (int32_t)size);
return iLen == (int32_t)size;
diff --git a/xfa/fgas/crt/fgas_stream.h b/xfa/fgas/crt/fgas_stream.h
index c61688d7a7..34d684f9ca 100644
--- a/xfa/fgas/crt/fgas_stream.h
+++ b/xfa/fgas/crt/fgas_stream.h
@@ -10,11 +10,6 @@
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/fx_system.h"
-class IFX_Stream;
-
-IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream,
- FX_BOOL bReleaseStream);
-
enum FX_STREAMACCESS {
FX_STREAMACCESS_Binary = 0x00,
FX_STREAMACCESS_Text = 0x01,
@@ -68,4 +63,7 @@ class IFX_Stream {
virtual uint16_t SetCodePage(uint16_t wCodePage) = 0;
};
+IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream,
+ bool bReleaseStream);
+
#endif // XFA_FGAS_CRT_FGAS_STREAM_H_
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
index d60d48fa75..06cad02253 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/app/xfa_ffapp.cpp
@@ -37,9 +37,7 @@ FX_FILESIZE CXFA_FileRead::GetSize() {
return dwSize;
}
-FX_BOOL CXFA_FileRead::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
int32_t iCount = m_Data.GetSize();
int32_t index = 0;
while (index < iCount) {
@@ -58,13 +56,13 @@ FX_BOOL CXFA_FileRead::ReadBlock(void* buffer,
FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead);
size -= dwRead;
if (size == 0) {
- return TRUE;
+ return true;
}
buffer = (uint8_t*)buffer + dwRead;
offset = 0;
index++;
}
- return FALSE;
+ return false;
}
void CXFA_FileRead::Release() {
diff --git a/xfa/fxfa/xfa_ffapp.h b/xfa/fxfa/xfa_ffapp.h
index 5e8289538b..543d78c2ee 100644
--- a/xfa/fxfa/xfa_ffapp.h
+++ b/xfa/fxfa/xfa_ffapp.h
@@ -31,7 +31,7 @@ class CXFA_FileRead : public IFX_SeekableReadStream {
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
void Release() override;
protected: