summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/font/cpdf_cmap.cpp4
-rw-r--r--core/fxcrt/cfx_bytestring.h3
-rw-r--r--core/fxcrt/cfx_string_c_template.h6
-rw-r--r--core/fxcrt/cfx_widestring.h3
4 files changed, 14 insertions, 2 deletions
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 659139f687..0d3745e44a 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -253,12 +253,12 @@ void CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr,
m_PredefinedCMap = bsName;
if (m_PredefinedCMap == "Identity-H" || m_PredefinedCMap == "Identity-V") {
m_Coding = CIDCODING_CID;
- m_bVertical = bsName[9] == 'V';
+ m_bVertical = bsName.Last() == 'V';
m_bLoaded = true;
return;
}
CFX_ByteString cmapid = m_PredefinedCMap;
- m_bVertical = cmapid.Right(1) == "V";
+ m_bVertical = cmapid.Last() == 'V';
if (cmapid.GetLength() > 2) {
cmapid = cmapid.Left(cmapid.GetLength() - 2);
}
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
index a47b5f89ab..261060bda0 100644
--- a/core/fxcrt/cfx_bytestring.h
+++ b/core/fxcrt/cfx_bytestring.h
@@ -120,6 +120,9 @@ class CFX_ByteString {
return m_pData ? m_pData->m_String[index] : 0;
}
+ CharType First() const { return GetLength() ? (*this)[0] : 0; }
+ CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
+
void SetAt(FX_STRSIZE index, char c);
FX_STRSIZE Insert(FX_STRSIZE index, char ch);
diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h
index c46b0c4671..6bc71d853d 100644
--- a/core/fxcrt/cfx_string_c_template.h
+++ b/core/fxcrt/cfx_string_c_template.h
@@ -135,6 +135,12 @@ class CFX_StringCTemplate {
return m_Ptr.Get()[index];
}
+ UnsignedType First() const { return GetLength() ? (*this)[0] : 0; }
+
+ UnsignedType Last() const {
+ return GetLength() ? (*this)[GetLength() - 1] : 0;
+ }
+
const CharType CharAt(const FX_STRSIZE index) const {
ASSERT(IsValidIndex(index));
return static_cast<CharType>(m_Ptr.Get()[index]);
diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h
index 242138853b..100fec6706 100644
--- a/core/fxcrt/cfx_widestring.h
+++ b/core/fxcrt/cfx_widestring.h
@@ -115,6 +115,9 @@ class CFX_WideString {
return m_pData ? m_pData->m_String[index] : 0;
}
+ CharType First() const { return GetLength() ? (*this)[0] : 0; }
+ CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
+
void SetAt(FX_STRSIZE index, wchar_t c);
int Compare(const wchar_t* str) const;