summaryrefslogtreecommitdiff
path: root/xfa/fee/fde_txtedtengine.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-12 15:52:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-12 15:52:14 -0700
commit28c7844c1ef5ea0c8727b890e9ff56b593119a00 (patch)
treea96e31bbff3c221a0030e3a8a6501a5f81379d0f /xfa/fee/fde_txtedtengine.cpp
parentade9465067098d9f94a13f61741cebf4bb8aac47 (diff)
downloadpdfium-28c7844c1ef5ea0c8727b890e9ff56b593119a00.tar.xz
Add CFX_ByteStringC::CharAt() to avoid c_str() and casts.
Most of the time, we want to operate on chars as if they were unsigned, but there are a few places where we need the default (questionably signed) values. Consolidate the casting in a single place rather than forcing callers to get a char* ptr. BUG=pdfium:493 Review-Url: https://codereview.chromium.org/1972053003
Diffstat (limited to 'xfa/fee/fde_txtedtengine.cpp')
-rw-r--r--xfa/fee/fde_txtedtengine.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/xfa/fee/fde_txtedtengine.cpp b/xfa/fee/fde_txtedtengine.cpp
index dfbf02e881..71f510205b 100644
--- a/xfa/fee/fde_txtedtengine.cpp
+++ b/xfa/fee/fde_txtedtengine.cpp
@@ -1603,9 +1603,9 @@ void CFDE_TxtEdtEngine::DeleteSelect() {
IFDE_TxtEdtDoRecord* IFDE_TxtEdtDoRecord::Create(
const CFX_ByteStringC& bsDoRecord) {
- const FX_CHAR* lpBuf = bsDoRecord.c_str();
- int32_t nType = *((int32_t*)lpBuf);
- switch (nType) {
+ const uint32_t* lpBuf =
+ reinterpret_cast<const uint32_t*>(bsDoRecord.raw_str());
+ switch (*lpBuf) {
case FDE_TXTEDT_DORECORD_INS:
return new CFDE_TxtEdtDoRecord_Insert(bsDoRecord);
case FDE_TXTEDT_DORECORD_DEL:
@@ -1669,9 +1669,7 @@ void CFDE_TxtEdtDoRecord_Insert::Serialize(CFX_ByteString& bsDoRecord) const {
}
void CFDE_TxtEdtDoRecord_Insert::Deserialize(
const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader(
- reinterpret_cast<const uint8_t*>(bsDoRecord.c_str()),
- bsDoRecord.GetLength());
+ CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
int32_t nType = 0;
ArchiveLoader >> nType;
ASSERT(nType == FDE_TXTEDT_DORECORD_INS);
@@ -1746,9 +1744,7 @@ void CFDE_TxtEdtDoRecord_DeleteRange::Serialize(
}
void CFDE_TxtEdtDoRecord_DeleteRange::Deserialize(
const CFX_ByteStringC& bsDoRecord) {
- CFX_ArchiveLoader ArchiveLoader(
- reinterpret_cast<const uint8_t*>(bsDoRecord.c_str()),
- bsDoRecord.GetLength());
+ CFX_ArchiveLoader ArchiveLoader(bsDoRecord.raw_str(), bsDoRecord.GetLength());
int32_t nType = 0;
ArchiveLoader >> nType;
ASSERT(nType == FDE_TXTEDT_DORECORD_DEL);