summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_font
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-29 16:42:53 -0700
committerWei Li <weili@chromium.org>2016-03-29 16:42:53 -0700
commit05d53f0355e9889c43bfa436e985d5643f249d99 (patch)
treeeca037b407114efe357e8280a96e44eee182cdfc /core/fpdfapi/fpdf_font
parent602aebc11a615971800d38f8d427a4e4f95c1134 (diff)
downloadpdfium-05d53f0355e9889c43bfa436e985d5643f249d99.tar.xz
Code change to avoid signed/unsigned mismatch warnings.
This makes pdfium code on Linux and Mac sign-compare warning free. The warning flag will be re-enabled after checking on windows clang build. BUG=pdfium:29 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1841643002 .
Diffstat (limited to 'core/fpdfapi/fpdf_font')
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_cidfont.cpp7
-rw-r--r--core/fpdfapi/fpdf_font/font_int.h12
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font.cpp16
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp18
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp12
5 files changed, 33 insertions, 32 deletions
diff --git a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
index de119b75d1..3329f5c577 100644
--- a/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/fpdf_font/cpdf_cidfont.cpp
@@ -155,13 +155,12 @@ uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap,
if (!pCodes)
return 0;
- int nCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count;
- for (int i = 0; i < nCodes; ++i) {
+ for (uint32_t i = 0; i < pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count;
+ ++i) {
if (pCodes[i] == unicode) {
uint32_t CharCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i);
- if (CharCode != 0) {
+ if (CharCode != 0)
return CharCode;
- }
}
}
return 0;
diff --git a/core/fpdfapi/fpdf_font/font_int.h b/core/fpdfapi/fpdf_font/font_int.h
index 3ee4068d7d..fc69b0cbd9 100644
--- a/core/fpdfapi/fpdf_font/font_int.h
+++ b/core/fpdfapi/fpdf_font/font_int.h
@@ -48,8 +48,8 @@ class CFX_StockFontArray {
~CFX_StockFontArray();
// Takes ownership of |pFont|.
- void SetFont(int index, CPDF_Font* pFont);
- CPDF_Font* GetFont(int index) const;
+ void SetFont(uint32_t index, CPDF_Font* pFont);
+ CPDF_Font* GetFont(uint32_t index) const;
private:
std::unique_ptr<CPDF_Font> m_StockFonts[14];
@@ -61,19 +61,19 @@ class CPDF_FontGlobals {
~CPDF_FontGlobals();
void Clear(CPDF_Document* pDoc);
- CPDF_Font* Find(CPDF_Document* pDoc, int index);
+ CPDF_Font* Find(CPDF_Document* pDoc, uint32_t index);
// Takes ownership of |pFont|.
- void Set(CPDF_Document* key, int index, CPDF_Font* pFont);
+ void Set(CPDF_Document* key, uint32_t index, CPDF_Font* pFont);
CPDF_CMapManager m_CMapManager;
struct {
const struct FXCMAP_CMap* m_pMapList;
- int m_Count;
+ uint32_t m_Count;
} m_EmbeddedCharsets[CIDSET_NUM_SETS];
struct {
const uint16_t* m_pMap;
- int m_Count;
+ uint32_t m_Count;
} m_EmbeddedToUnicodes[CIDSET_NUM_SETS];
private:
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp
index b0659b4a52..ce2390ec08 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -45,14 +45,14 @@ CFX_StockFontArray::~CFX_StockFontArray() {
}
}
-CPDF_Font* CFX_StockFontArray::GetFont(int index) const {
- if (index < 0 || index >= FX_ArraySize(m_StockFonts))
+CPDF_Font* CFX_StockFontArray::GetFont(uint32_t index) const {
+ if (index >= FX_ArraySize(m_StockFonts))
return nullptr;
return m_StockFonts[index].get();
}
-void CFX_StockFontArray::SetFont(int index, CPDF_Font* font) {
- if (index < 0 || index >= FX_ArraySize(m_StockFonts))
+void CFX_StockFontArray::SetFont(uint32_t index, CPDF_Font* font) {
+ if (index >= FX_ArraySize(m_StockFonts))
return;
m_StockFonts[index].reset(font);
}
@@ -64,14 +64,16 @@ CPDF_FontGlobals::CPDF_FontGlobals() {
CPDF_FontGlobals::~CPDF_FontGlobals() {}
-CPDF_Font* CPDF_FontGlobals::Find(CPDF_Document* pDoc, int index) {
+CPDF_Font* CPDF_FontGlobals::Find(CPDF_Document* pDoc, uint32_t index) {
auto it = m_StockMap.find(pDoc);
if (it == m_StockMap.end())
return nullptr;
return it->second ? it->second->GetFont(index) : nullptr;
}
-void CPDF_FontGlobals::Set(CPDF_Document* pDoc, int index, CPDF_Font* pFont) {
+void CPDF_FontGlobals::Set(CPDF_Document* pDoc,
+ uint32_t index,
+ CPDF_Font* pFont) {
if (!pdfium::ContainsKey(m_StockMap, pDoc))
m_StockMap[pDoc].reset(new CFX_StockFontArray);
m_StockMap[pDoc]->SetFont(index, pFont);
@@ -121,7 +123,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) {
uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
for (const auto& pair : m_Map) {
- if (pair.second == unicode)
+ if (pair.second == static_cast<uint32_t>(unicode))
return pair.first;
}
return 0;
diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp
index c12b9c5eee..ccf49ee46a 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp
@@ -18,16 +18,16 @@ bool uint_ranges_equal(uint8_t* a, uint8_t* b, size_t count) {
} // namespace
TEST(fpdf_font_cid, CMap_GetCode) {
- EXPECT_EQ(0, CPDF_CMapParser::CMap_GetCode(""));
- EXPECT_EQ(0, CPDF_CMapParser::CMap_GetCode("<"));
- EXPECT_EQ(194, CPDF_CMapParser::CMap_GetCode("<c2"));
- EXPECT_EQ(162, CPDF_CMapParser::CMap_GetCode("<A2"));
- EXPECT_EQ(2802, CPDF_CMapParser::CMap_GetCode("<Af2"));
- EXPECT_EQ(162, CPDF_CMapParser::CMap_GetCode("<A2z"));
+ EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode(""));
+ EXPECT_EQ(0u, CPDF_CMapParser::CMap_GetCode("<"));
+ EXPECT_EQ(194u, CPDF_CMapParser::CMap_GetCode("<c2"));
+ EXPECT_EQ(162u, CPDF_CMapParser::CMap_GetCode("<A2"));
+ EXPECT_EQ(2802u, CPDF_CMapParser::CMap_GetCode("<Af2"));
+ EXPECT_EQ(162u, CPDF_CMapParser::CMap_GetCode("<A2z"));
- EXPECT_EQ(12, CPDF_CMapParser::CMap_GetCode("12"));
- EXPECT_EQ(12, CPDF_CMapParser::CMap_GetCode("12d"));
- EXPECT_EQ(128, CPDF_CMapParser::CMap_GetCode("128"));
+ EXPECT_EQ(12u, CPDF_CMapParser::CMap_GetCode("12"));
+ EXPECT_EQ(12u, CPDF_CMapParser::CMap_GetCode("12d"));
+ EXPECT_EQ(128u, CPDF_CMapParser::CMap_GetCode("128"));
}
TEST(fpdf_font_cid, CMap_GetCodeRange) {
diff --git a/core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp b/core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp
index dd2119e0cf..0c5ad8a66a 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font_unittest.cpp
@@ -6,12 +6,12 @@
#include "testing/gtest/include/gtest/gtest.h"
TEST(fpdf_font, StringToCode) {
- EXPECT_EQ(0, CPDF_ToUnicodeMap::StringToCode(""));
- EXPECT_EQ(194, CPDF_ToUnicodeMap::StringToCode("<c2"));
- EXPECT_EQ(162, CPDF_ToUnicodeMap::StringToCode("<A2"));
- EXPECT_EQ(2802, CPDF_ToUnicodeMap::StringToCode("<Af2"));
- EXPECT_EQ(12, CPDF_ToUnicodeMap::StringToCode("12"));
- EXPECT_EQ(128, CPDF_ToUnicodeMap::StringToCode("128"));
+ EXPECT_EQ(0u, CPDF_ToUnicodeMap::StringToCode(""));
+ EXPECT_EQ(194u, CPDF_ToUnicodeMap::StringToCode("<c2"));
+ EXPECT_EQ(162u, CPDF_ToUnicodeMap::StringToCode("<A2"));
+ EXPECT_EQ(2802u, CPDF_ToUnicodeMap::StringToCode("<Af2"));
+ EXPECT_EQ(12u, CPDF_ToUnicodeMap::StringToCode("12"));
+ EXPECT_EQ(128u, CPDF_ToUnicodeMap::StringToCode("128"));
}
TEST(fpdf_font, StringToWideString) {