summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_font
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2015-10-29 15:08:50 -0400
committerdan sinclair <dsinclair@chromium.org>2015-10-29 15:08:50 -0400
commit23d576f0b498bd4f37ef2175916223a2e5ea0324 (patch)
treeb6561f688e88f00b437eba6128c1b5129d813a7e /core/src/fpdfapi/fpdf_font
parent589f7e0a57675efce9810c15a3e9b7c49bf0bc90 (diff)
downloadpdfium-23d576f0b498bd4f37ef2175916223a2e5ea0324.tar.xz
Revert "Cleanup some numeric code."
This reverts commit 589f7e0a57675efce9810c15a3e9b7c49bf0bc90. Broke the build on Mac, unable to find std::isdigit. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1428853002 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp41
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp32
2 files changed, 53 insertions, 20 deletions
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index e5389f8c77..543816b03a 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -8,7 +8,6 @@
#include "../../../include/fpdfapi/fpdf_page.h"
#include "../../../include/fpdfapi/fpdf_pageobj.h"
#include "../../../include/fpdfapi/fpdf_resource.h"
-#include "../../../include/fxcrt/fx_ext.h"
#include "../../../include/fxge/fx_freetype.h"
#include "../fpdf_page/pageint.h"
#include "font_int.h"
@@ -512,25 +511,32 @@ FX_DWORD CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
static FX_DWORD _StringToCode(const CFX_ByteStringC& str) {
const FX_CHAR* buf = str.GetCStr();
int len = str.GetLength();
- if (len == 0)
+ if (len == 0) {
return 0;
-
+ }
int result = 0;
if (buf[0] == '<') {
for (int i = 1; i < len; i++) {
- if (!std::isxdigit(buf[i]))
+ int digit;
+ if (buf[i] >= '0' && buf[i] <= '9') {
+ digit = buf[i] - '0';
+ } else if (buf[i] >= 'a' && buf[i] <= 'f') {
+ digit = buf[i] - 'a' + 10;
+ } else if (buf[i] >= 'A' && buf[i] <= 'F') {
+ digit = buf[i] - 'A' + 10;
+ } else {
break;
- result = result * 16 + HexCharToDigit(buf[i]);
+ }
+ result = result * 16 + digit;
}
return result;
}
-
for (int i = 0; i < len; i++) {
- if (!std::isdigit(buf[i]))
+ if (buf[i] < '0' || buf[i] > '9') {
break;
+ }
result = result * 10 + buf[i] - '0';
}
-
return result;
}
static CFX_WideString _StringDataAdd(CFX_WideString str) {
@@ -554,18 +560,25 @@ static CFX_WideString _StringDataAdd(CFX_WideString str) {
static CFX_WideString _StringToWideString(const CFX_ByteStringC& str) {
const FX_CHAR* buf = str.GetCStr();
int len = str.GetLength();
- if (len == 0)
+ if (len == 0) {
return CFX_WideString();
-
+ }
CFX_WideString result;
if (buf[0] == '<') {
int byte_pos = 0;
FX_WCHAR ch = 0;
for (int i = 1; i < len; i++) {
- if (!std::isxdigit(buf[i]))
+ int digit;
+ if (buf[i] >= '0' && buf[i] <= '9') {
+ digit = buf[i] - '0';
+ } else if (buf[i] >= 'a' && buf[i] <= 'f') {
+ digit = buf[i] - 'a' + 10;
+ } else if (buf[i] >= 'A' && buf[i] <= 'F') {
+ digit = buf[i] - 'A' + 10;
+ } else {
break;
-
- ch = ch * 16 + HexCharToDigit(buf[i]);
+ }
+ ch = ch * 16 + digit;
byte_pos++;
if (byte_pos == 4) {
result += ch;
@@ -575,6 +588,8 @@ static CFX_WideString _StringToWideString(const CFX_ByteStringC& str) {
}
return result;
}
+ if (buf[0] == '(') {
+ }
return result;
}
void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 165ef5bad5..02f0933f36 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -7,7 +7,6 @@
#include "../../../include/fpdfapi/fpdf_module.h"
#include "../../../include/fpdfapi/fpdf_page.h"
#include "../../../include/fpdfapi/fpdf_resource.h"
-#include "../../../include/fxcrt/fx_ext.h"
#include "../../../include/fxge/fx_freetype.h"
#include "../../../include/fxge/fx_ge.h"
#include "../fpdf_cmaps/cmap_int.h"
@@ -191,15 +190,22 @@ FX_DWORD CMap_GetCode(const CFX_ByteStringC& word) {
if (word.GetAt(0) == '<') {
for (int i = 1; i < word.GetLength(); i++) {
uint8_t digit = word.GetAt(i);
- if (!std::isxdigit(digit))
+ if (digit >= '0' && digit <= '9') {
+ digit = digit - '0';
+ } else if (digit >= 'a' && digit <= 'f') {
+ digit = digit - 'a' + 10;
+ } else if (digit >= 'A' && digit <= 'F') {
+ digit = digit - 'A' + 10;
+ } else {
return num;
- num = num * 16 + HexCharToDigit(digit);
+ }
+ num = num * 16 + digit;
}
} else {
for (int i = 0; i < word.GetLength(); i++) {
- if (!std::isdigit(word.GetAt(i)))
+ if (word.GetAt(i) < '0' || word.GetAt(i) > '9') {
return num;
-
+ }
num = num * 10 + word.GetAt(i) - '0';
}
}
@@ -225,7 +231,13 @@ bool CMap_GetCodeRange(CMap_CodeRange& range,
for (i = 0; i < range.m_CharSize; ++i) {
uint8_t digit1 = first.GetAt(i * 2 + 1);
uint8_t digit2 = first.GetAt(i * 2 + 2);
- range.m_Lower[i] = HexCharToDigit(digit1) * 16 + HexCharToDigit(digit2);
+ uint8_t byte = (digit1 >= '0' && digit1 <= '9')
+ ? (digit1 - '0')
+ : ((digit1 & 0xdf) - 'A' + 10);
+ byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9')
+ ? (digit2 - '0')
+ : ((digit2 & 0xdf) - 'A' + 10));
+ range.m_Lower[i] = byte;
}
FX_DWORD size = second.GetLength();
@@ -234,7 +246,13 @@ bool CMap_GetCodeRange(CMap_CodeRange& range,
((FX_DWORD)i * 2 + 1 < size) ? second.GetAt((FX_STRSIZE)i * 2 + 1) : 0;
uint8_t digit2 =
((FX_DWORD)i * 2 + 2 < size) ? second.GetAt((FX_STRSIZE)i * 2 + 2) : 0;
- range.m_Upper[i] = HexCharToDigit(digit1) * 16 + HexCharToDigit(digit2);
+ uint8_t byte = (digit1 >= '0' && digit1 <= '9')
+ ? (digit1 - '0')
+ : ((digit1 & 0xdf) - 'A' + 10);
+ byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9')
+ ? (digit2 - '0')
+ : ((digit2 & 0xdf) - 'A' + 10));
+ range.m_Upper[i] = byte;
}
return true;
}