summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Abd-El-Malek <jam@chromium.org>2014-12-12 17:47:56 -0800
committerJohn Abd-El-Malek <jam@chromium.org>2014-12-12 17:47:56 -0800
commitf6505100fc132ef866adaf3ff1fb7f06d0ca7a9b (patch)
tree73497690daaf5c7f810a4c2a8fa1047c59f738a0
parent217ecf3b39f8d5c01260684848a8886c8ed2bf89 (diff)
downloadpdfium-chromium/2253.tar.xz
TBR=tsepez Review URL: https://codereview.chromium.org/804463003
-rw-r--r--BUILD.gn1
-rw-r--r--core/src/fxge/ge/fx_ge_linux.cpp234
-rw-r--r--pdfium.gyp1
-rw-r--r--third_party/bigint/BigInteger.cc34
-rw-r--r--third_party/bigint/BigInteger.hh16
-rw-r--r--third_party/bigint/BigIntegerUtils.cc5
-rw-r--r--third_party/bigint/BigUnsigned.cc27
-rw-r--r--third_party/bigint/BigUnsigned.hh31
-rw-r--r--third_party/bigint/BigUnsignedInABase.cc28
9 files changed, 237 insertions, 140 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 9b8fdf7cba..ce3bdedee2 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -630,6 +630,7 @@ static_library("fxge") {
"core/src/fxge/ge/fx_ge_device.cpp",
"core/src/fxge/ge/fx_ge_font.cpp",
"core/src/fxge/ge/fx_ge_fontmap.cpp",
+ "core/src/fxge/ge/fx_ge_linux.cpp",
"core/src/fxge/ge/fx_ge_path.cpp",
"core/src/fxge/ge/fx_ge_ps.cpp",
"core/src/fxge/ge/fx_ge_text.cpp",
diff --git a/core/src/fxge/ge/fx_ge_linux.cpp b/core/src/fxge/ge/fx_ge_linux.cpp
new file mode 100644
index 0000000000..ad0a70ab1f
--- /dev/null
+++ b/core/src/fxge/ge/fx_ge_linux.cpp
@@ -0,0 +1,234 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../../include/fxge/fx_ge.h"
+#include "../agg/include/fx_agg_driver.h"
+#include "text_int.h"
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
+static const struct {
+ FX_LPCSTR m_pName;
+ FX_LPCSTR m_pSubstName;
+}
+Base14Substs[] = {
+ {"Courier", "Courier New"},
+ {"Courier-Bold", "Courier New Bold"},
+ {"Courier-BoldOblique", "Courier New Bold Italic"},
+ {"Courier-Oblique", "Courier New Italic"},
+ {"Helvetica", "Arial"},
+ {"Helvetica-Bold", "Arial Bold"},
+ {"Helvetica-BoldOblique", "Arial Bold Italic"},
+ {"Helvetica-Oblique", "Arial Italic"},
+ {"Times-Roman", "Times New Roman"},
+ {"Times-Bold", "Times New Roman Bold"},
+ {"Times-BoldItalic", "Times New Roman Bold Italic"},
+ {"Times-Italic", "Times New Roman Italic"},
+};
+class CFX_LinuxFontInfo : public CFX_FolderFontInfo
+{
+public:
+ virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact);
+ FX_BOOL ParseFontCfg();
+ void* FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL bMatchName);
+};
+#define LINUX_GPNAMESIZE 6
+static const struct {
+ FX_LPCSTR NameArr[LINUX_GPNAMESIZE];
+}
+LinuxGpFontList[] = {
+ {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", "VL Gothic regular"}},
+ {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, "VL Gothic regular"}},
+ {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}},
+ {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}},
+};
+static const FX_LPCSTR g_LinuxGbFontList[] = {
+ "AR PL UMing CN Light",
+ "WenQuanYi Micro Hei",
+ "AR PL UKai CN",
+};
+static const FX_LPCSTR g_LinuxB5FontList[] = {
+ "AR PL UMing TW Light",
+ "WenQuanYi Micro Hei",
+ "AR PL UKai TW",
+};
+static const FX_LPCSTR g_LinuxHGFontList[] = {
+ "UnDotum",
+};
+static FX_INT32 GetJapanesePreference(FX_LPCSTR facearr, int weight, int picth_family)
+{
+ CFX_ByteString face = facearr;
+ if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
+ if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) {
+ return 0;
+ } else {
+ return 1;
+ }
+ } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
+ if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) {
+ return 2;
+ } else {
+ return 3;
+ }
+ }
+ if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
+ return 0;
+ }
+ return 2;
+}
+void* CFX_LinuxFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR cstr_face, FX_BOOL& bExact)
+{
+ CFX_ByteString face = cstr_face;
+ int iBaseFont;
+ for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
+ if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
+ face = Base14Substs[iBaseFont].m_pSubstName;
+ bExact = TRUE;
+ break;
+ }
+ if (iBaseFont < 12) {
+ return GetFont(face);
+ }
+ FX_LPVOID p = NULL;
+ FX_BOOL bCJK = TRUE;
+ switch (charset) {
+ case FXFONT_SHIFTJIS_CHARSET: {
+ FX_INT32 index = GetJapanesePreference(cstr_face, weight, pitch_family);
+ if (index < 0) {
+ break;
+ }
+ for (FX_INT32 i = 0; i < LINUX_GPNAMESIZE; i++)
+ if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) {
+ return p;
+ }
+ }
+ break;
+ case FXFONT_GB2312_CHARSET: {
+ static FX_INT32 s_gbCount = sizeof(g_LinuxGbFontList) / sizeof(FX_LPCSTR);
+ for (FX_INT32 i = 0; i < s_gbCount; i++)
+ if (m_FontList.Lookup(g_LinuxGbFontList[i], p)) {
+ return p;
+ }
+ }
+ break;
+ case FXFONT_CHINESEBIG5_CHARSET: {
+ static FX_INT32 s_b5Count = sizeof(g_LinuxB5FontList) / sizeof(FX_LPCSTR);
+ for (FX_INT32 i = 0; i < s_b5Count; i++)
+ if (m_FontList.Lookup(g_LinuxB5FontList[i], p)) {
+ return p;
+ }
+ }
+ break;
+ case FXFONT_HANGEUL_CHARSET: {
+ static FX_INT32 s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(FX_LPCSTR);
+ for (FX_INT32 i = 0; i < s_hgCount; i++)
+ if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) {
+ return p;
+ }
+ }
+ break;
+ default:
+ bCJK = FALSE;
+ break;
+ }
+ if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
+ return GetFont("Courier New");
+ }
+ return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK);
+}
+static FX_DWORD _LinuxGetCharset(int charset)
+{
+ switch(charset) {
+ case FXFONT_SHIFTJIS_CHARSET:
+ return CHARSET_FLAG_SHIFTJIS;
+ case FXFONT_GB2312_CHARSET:
+ return CHARSET_FLAG_GB;
+ case FXFONT_CHINESEBIG5_CHARSET:
+ return CHARSET_FLAG_BIG5;
+ case FXFONT_HANGEUL_CHARSET:
+ return CHARSET_FLAG_KOREAN;
+ case FXFONT_SYMBOL_CHARSET:
+ return CHARSET_FLAG_SYMBOL;
+ case FXFONT_ANSI_CHARSET:
+ return CHARSET_FLAG_ANSI;
+ default:
+ break;
+ }
+ return 0;
+}
+static FX_INT32 _LinuxGetSimilarValue(int weight, FX_BOOL bItalic, int pitch_family, FX_DWORD style)
+{
+ FX_INT32 iSimilarValue = 0;
+ if ((style & FXFONT_BOLD) == (weight > 400)) {
+ iSimilarValue += 16;
+ }
+ if ((style & FXFONT_ITALIC) == bItalic) {
+ iSimilarValue += 16;
+ }
+ if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) {
+ iSimilarValue += 16;
+ }
+ if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) {
+ iSimilarValue += 8;
+ }
+ if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) {
+ iSimilarValue += 8;
+ }
+ return iSimilarValue;
+}
+void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL bMatchName)
+{
+ CFontFaceInfo* pFind = NULL;
+ FX_DWORD charset_flag = _LinuxGetCharset(charset);
+ FX_INT32 iBestSimilar = 0;
+ FX_POSITION pos = m_FontList.GetStartPosition();
+ while (pos) {
+ CFX_ByteString bsName;
+ CFontFaceInfo* pFont = NULL;
+ m_FontList.GetNextAssoc(pos, bsName, (FX_LPVOID&)pFont);
+ if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHARSET) {
+ continue;
+ }
+ FX_INT32 iSimilarValue = 0;
+ FX_INT32 index = bsName.Find(family);
+ if (bMatchName && index < 0) {
+ continue;
+ }
+ if (!bMatchName && index > 0) {
+ iSimilarValue += 64;
+ }
+ iSimilarValue = _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles);
+ if (iSimilarValue > iBestSimilar) {
+ iBestSimilar = iSimilarValue;
+ pFind = pFont;
+ }
+ }
+ return pFind;
+}
+IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
+{
+ CFX_LinuxFontInfo* pInfo = FX_NEW CFX_LinuxFontInfo;
+ if (!pInfo) {
+ return NULL;
+ }
+ if (!pInfo->ParseFontCfg()) {
+ pInfo->AddPath("/usr/share/fonts");
+ pInfo->AddPath("/usr/share/X11/fonts/Type1");
+ pInfo->AddPath("/usr/share/X11/fonts/TTF");
+ pInfo->AddPath("/usr/local/share/fonts");
+ }
+ return pInfo;
+}
+FX_BOOL CFX_LinuxFontInfo::ParseFontCfg()
+{
+ return FALSE;
+}
+void CFX_GEModule::InitPlatform()
+{
+ m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
+}
+void CFX_GEModule::DestroyPlatform()
+{
+}
+#endif
diff --git a/pdfium.gyp b/pdfium.gyp
index 6b4b8bcea5..cc28ada629 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -644,6 +644,7 @@
'core/src/fxge/ge/fx_ge_device.cpp',
'core/src/fxge/ge/fx_ge_font.cpp',
'core/src/fxge/ge/fx_ge_fontmap.cpp',
+ 'core/src/fxge/ge/fx_ge_linux.cpp',
'core/src/fxge/ge/fx_ge_path.cpp',
'core/src/fxge/ge/fx_ge_ps.cpp',
'core/src/fxge/ge/fx_ge_text.cpp',
diff --git a/third_party/bigint/BigInteger.cc b/third_party/bigint/BigInteger.cc
index bac578f974..93b57e4255 100644
--- a/third_party/bigint/BigInteger.cc
+++ b/third_party/bigint/BigInteger.cc
@@ -20,11 +20,7 @@ BigInteger::BigInteger(const Blk *b, Index blen, Sign s) : mag(b, blen) {
switch (s) {
case zero:
if (!mag.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const Blk *, Index, Sign): Cannot use a sign of zero with a nonzero magnitude";
-#endif
sign = zero;
break;
case positive:
@@ -35,11 +31,7 @@ BigInteger::BigInteger(const Blk *b, Index blen, Sign s) : mag(b, blen) {
default:
/* g++ seems to be optimizing out this case on the assumption
* that the sign is a valid member of the enumeration. Oh well. */
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const Blk *, Index, Sign): Invalid sign";
-#endif
}
}
@@ -47,11 +39,7 @@ BigInteger::BigInteger(const BigUnsigned &x, Sign s) : mag(x) {
switch (s) {
case zero:
if (!mag.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const BigUnsigned &, Sign): Cannot use a sign of zero with a nonzero magnitude";
-#endif
sign = zero;
break;
case positive:
@@ -62,11 +50,7 @@ BigInteger::BigInteger(const BigUnsigned &x, Sign s) : mag(x) {
default:
/* g++ seems to be optimizing out this case on the assumption
* that the sign is a valid member of the enumeration. Oh well. */
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::BigInteger(const BigUnsigned &, Sign): Invalid sign";
-#endif
}
}
@@ -114,12 +98,7 @@ inline X convertBigUnsignedToPrimitiveAccess(const BigUnsigned &a) {
template <class X>
X BigInteger::convertToUnsignedPrimitive() const {
if (sign == negative)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::to<Primitive>: "
- "Cannot convert a negative integer to an unsigned type";
-#endif
else
return convertBigUnsignedToPrimitiveAccess<X>(mag);
}
@@ -146,12 +125,7 @@ X BigInteger::convertToSignedPrimitive() const {
}
// Otherwise fall through.
}
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::to<Primitive>: "
- "Value is too big to fit in the requested type";
-#endif
}
unsigned long BigInteger::toUnsignedLong () const { return convertToUnsignedPrimitive<unsigned long > (); }
@@ -179,11 +153,7 @@ BigInteger::CmpRes BigInteger::compareTo(const BigInteger &x) const {
// Compare the magnitudes, but return the opposite result
return CmpRes(-mag.compareTo(x.mag));
default:
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger internal error";
-#endif
}
}
@@ -315,11 +285,7 @@ void BigInteger::divideWithRemainder(const BigInteger &b, BigInteger &q) {
// Defend against aliased calls;
// same idea as in BigUnsigned::divideWithRemainder .
if (this == &q)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::divideWithRemainder: Cannot write quotient and remainder into the same variable";
-#endif
if (this == &b || &q == &b) {
BigInteger tmpB(b);
divideWithRemainder(tmpB, q);
diff --git a/third_party/bigint/BigInteger.hh b/third_party/bigint/BigInteger.hh
index a239d3c954..320a22f7b7 100644
--- a/third_party/bigint/BigInteger.hh
+++ b/third_party/bigint/BigInteger.hh
@@ -164,11 +164,7 @@ inline BigInteger BigInteger::operator *(const BigInteger &x) const {
}
inline BigInteger BigInteger::operator /(const BigInteger &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator /: division by zero";
-#endif
BigInteger q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -176,11 +172,7 @@ inline BigInteger BigInteger::operator /(const BigInteger &x) const {
}
inline BigInteger BigInteger::operator %(const BigInteger &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator %: division by zero";
-#endif
BigInteger q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -210,11 +202,7 @@ inline void BigInteger::operator *=(const BigInteger &x) {
}
inline void BigInteger::operator /=(const BigInteger &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator /=: division by zero";
-#endif
/* The following technique is slightly faster than copying *this first
* when x is large. */
BigInteger q;
@@ -224,11 +212,7 @@ inline void BigInteger::operator /=(const BigInteger &x) {
}
inline void BigInteger::operator %=(const BigInteger &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigInteger::operator %=: division by zero";
-#endif
BigInteger q;
// Mods *this by x. Don't care about quotient left in q.
divideWithRemainder(x, q);
diff --git a/third_party/bigint/BigIntegerUtils.cc b/third_party/bigint/BigIntegerUtils.cc
index fac8ac34b1..f48334d961 100644
--- a/third_party/bigint/BigIntegerUtils.cc
+++ b/third_party/bigint/BigIntegerUtils.cc
@@ -42,11 +42,8 @@ std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) {
if (osFlags & os.showbase)
os << '0';
} else
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags";
-#endif
+
std::string s = std::string(BigUnsignedInABase(x, base));
os << s;
return os;
diff --git a/third_party/bigint/BigUnsigned.cc b/third_party/bigint/BigUnsigned.cc
index 863fadcb39..e38e4aa26d 100644
--- a/third_party/bigint/BigUnsigned.cc
+++ b/third_party/bigint/BigUnsigned.cc
@@ -195,12 +195,7 @@ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
return;
} else if (a.len < b.len)
// If a is shorter than b, the result is negative.
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::subtract: "
- "Negative result in unsigned calculation";
-#endif
// Some variables...
bool borrowIn, borrowOut;
Blk temp;
@@ -233,11 +228,7 @@ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
* predictable state. */
if (borrowIn) {
len = 0;
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::subtract: Negative result in unsigned calculation";
-#endif
} else
// Copy over the rest of the blocks
for (; i < a.len; i++)
@@ -400,11 +391,7 @@ void BigUnsigned::divideWithRemainder(const BigUnsigned &b, BigUnsigned &q) {
* It would be silly to try to write quotient and remainder to the
* same variable. Rule that out right away. */
if (this == &q)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::divideWithRemainder: Cannot write quotient and remainder into the same variable";
-#endif
/* Now *this and q are separate, so the only concern is that b might be
* aliased to one of them. If so, use a temporary copy of b. */
if (this == &b || &q == &b) {
@@ -614,12 +601,7 @@ void BigUnsigned::bitShiftLeft(const BigUnsigned &a, int b) {
DTRT_ALIASED(this == &a, bitShiftLeft(a, b));
if (b < 0) {
if (b << 1 == 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::bitShiftLeft: "
- "Pathological shift amount not implemented";
-#endif
else {
bitShiftRight(a, -b);
return;
@@ -644,12 +626,7 @@ void BigUnsigned::bitShiftRight(const BigUnsigned &a, int b) {
DTRT_ALIASED(this == &a, bitShiftRight(a, b));
if (b < 0) {
if (b << 1 == 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::bitShiftRight: "
- "Pathological shift amount not implemented";
-#endif
else {
bitShiftLeft(a, -b);
return;
@@ -705,11 +682,7 @@ void BigUnsigned::operator ++(int) {
// Prefix decrement
void BigUnsigned::operator --() {
if (len == 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator --(): Cannot decrement an unsigned zero";
-#endif
Index i;
bool borrow = true;
for (i = 0; borrow; i++) {
diff --git a/third_party/bigint/BigUnsigned.hh b/third_party/bigint/BigUnsigned.hh
index accd4d6782..de4c18e066 100644
--- a/third_party/bigint/BigUnsigned.hh
+++ b/third_party/bigint/BigUnsigned.hh
@@ -267,11 +267,7 @@ inline BigUnsigned BigUnsigned::operator *(const BigUnsigned &x) const {
}
inline BigUnsigned BigUnsigned::operator /(const BigUnsigned &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator /: division by zero";
-#endif
BigUnsigned q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -279,11 +275,7 @@ inline BigUnsigned BigUnsigned::operator /(const BigUnsigned &x) const {
}
inline BigUnsigned BigUnsigned::operator %(const BigUnsigned &x) const {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator %: division by zero";
-#endif
BigUnsigned q, r;
r = *this;
r.divideWithRemainder(x, q);
@@ -326,11 +318,7 @@ inline void BigUnsigned::operator *=(const BigUnsigned &x) {
}
inline void BigUnsigned::operator /=(const BigUnsigned &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator /=: division by zero";
-#endif
/* The following technique is slightly faster than copying *this first
* when x is large. */
BigUnsigned q;
@@ -340,11 +328,7 @@ inline void BigUnsigned::operator /=(const BigUnsigned &x) {
}
inline void BigUnsigned::operator %=(const BigUnsigned &x) {
if (x.isZero())
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::operator %=: division by zero";
-#endif
BigUnsigned q;
// Mods *this by x. Don't care about quotient left in q.
divideWithRemainder(x, q);
@@ -398,12 +382,7 @@ void BigUnsigned::initFromPrimitive(X x) {
template <class X>
void BigUnsigned::initFromSignedPrimitive(X x) {
if (x < 0)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned constructor: "
- "Cannot construct a BigUnsigned from a negative number";
-#endif
else
initFromPrimitive(x);
}
@@ -427,12 +406,7 @@ X BigUnsigned::convertToPrimitive() const {
return x;
// Otherwise fall through.
}
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::to<Primitive>: "
- "Value is too big to fit in the requested type";
-#endif
}
/* Wrap the above in an x >= 0 test to make sure we got a nonnegative result,
@@ -445,12 +419,7 @@ X BigUnsigned::convertToSignedPrimitive() const {
if (x >= 0)
return x;
else
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsigned::to(Primitive): "
- "Value is too big to fit in the requested type";
-#endif
}
#endif
diff --git a/third_party/bigint/BigUnsignedInABase.cc b/third_party/bigint/BigUnsignedInABase.cc
index a24042d538..72fe256a5f 100644
--- a/third_party/bigint/BigUnsignedInABase.cc
+++ b/third_party/bigint/BigUnsignedInABase.cc
@@ -10,20 +10,12 @@ BigUnsignedInABase::BigUnsignedInABase(const Digit *d, Index l, Base base)
: NumberlikeArray<Digit>(d, l), base(base) {
// Check the base
if (base < 2)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase::BigUnsignedInABase(const Digit *, Index, Base): The base must be at least 2";
-#endif
// Validate the digits.
for (Index i = 0; i < l; i++)
if (blk[i] >= base)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase::BigUnsignedInABase(const Digit *, Index, Base): A digit is too large for the specified base";
-#endif
// Eliminate any leading zeros we may have been passed.
zapLeadingZeros();
@@ -46,11 +38,7 @@ namespace {
BigUnsignedInABase::BigUnsignedInABase(const BigUnsigned &x, Base base) {
// Check the base
if (base < 2)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase(BigUnsigned, Base): The base must be at least 2";
-#endif
this->base = base;
// Get an upper bound on how much space we need
@@ -91,11 +79,7 @@ BigUnsignedInABase::operator BigUnsigned() const {
BigUnsignedInABase::BigUnsignedInABase(const std::string &s, Base base) {
// Check the base.
if (base > 36)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase(std::string, Base): The default string conversion routines use the symbol set 0-9, A-Z and therefore support only up to base 36. You tried a conversion with a base over 36; write your own string conversion routine.";
-#endif
// Save the base.
// This pattern is seldom seen in C++, but the analogous ``this.'' is common in Java.
this->base = base;
@@ -116,29 +100,17 @@ BigUnsignedInABase::BigUnsignedInABase(const std::string &s, Base base) {
else if (theSymbol >= 'a' && theSymbol <= 'z')
blk[digitNum] = theSymbol - 'a' + 10;
else
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase(std::string, Base): Bad symbol in input. Only 0-9, A-Z, a-z are accepted.";
-#endif
if (blk[digitNum] >= base)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase::BigUnsignedInABase(const Digit *, Index, Base): A digit is too large for the specified base";
-#endif
}
zapLeadingZeros();
}
BigUnsignedInABase::operator std::string() const {
if (base > 36)
-#ifdef FOXIT_CHROME_BUILD
abort();
-#else
- throw "BigUnsignedInABase ==> std::string: The default string conversion routines use the symbol set 0-9, A-Z and therefore support only up to base 36. You tried a conversion with a base over 36; write your own string conversion routine.";
-#endif
if (len == 0)
return std::string("0");
// Some compilers don't have push_back, so use a char * buffer instead.