summaryrefslogtreecommitdiff
path: root/third_party/bigint/BigInteger.hh
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-12-02 16:34:20 -0800
committerBo Xu <bo_xu@foxitsoftware.com>2014-12-02 16:34:20 -0800
commit91dd8c77ae849c22a8e4c9275e3f728b474b5be5 (patch)
tree79c1805c6a18ab234053f79fc4e10edabad5eef1 /third_party/bigint/BigInteger.hh
parent44047c3300d07192a67b1714084cc2d43b1e9bd9 (diff)
downloadpdfium-91dd8c77ae849c22a8e4c9275e3f728b474b5be5.tar.xz
Modify big integer library
This patch follows https://pdfium.googlesource.com/pdfium/+/44047c3300d07192a67b1714084cc2d43b1e9bd9 Modify the library to resolve compile error, add copyright notice and change pdfium.gyp and BUILD.gn R=tsepez@chromium.org Review URL: https://codereview.chromium.org/754743003
Diffstat (limited to 'third_party/bigint/BigInteger.hh')
-rw-r--r--third_party/bigint/BigInteger.hh34
1 files changed, 30 insertions, 4 deletions
diff --git a/third_party/bigint/BigInteger.hh b/third_party/bigint/BigInteger.hh
index cf6e91056f..a239d3c954 100644
--- a/third_party/bigint/BigInteger.hh
+++ b/third_party/bigint/BigInteger.hh
@@ -1,3 +1,9 @@
+// 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 by Matt McCutchen, see the LICENSE file.
+
#ifndef BIGINTEGER_H
#define BIGINTEGER_H
@@ -157,14 +163,24 @@ inline BigInteger BigInteger::operator *(const BigInteger &x) const {
return ans;
}
inline BigInteger BigInteger::operator /(const BigInteger &x) const {
- if (x.isZero()) throw "BigInteger::operator /: division by zero";
+ 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);
return q;
}
inline BigInteger BigInteger::operator %(const BigInteger &x) const {
- if (x.isZero()) throw "BigInteger::operator %: division by zero";
+ 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);
@@ -193,7 +209,12 @@ inline void BigInteger::operator *=(const BigInteger &x) {
multiply(*this, x);
}
inline void BigInteger::operator /=(const BigInteger &x) {
- if (x.isZero()) throw "BigInteger::operator /=: division by zero";
+ 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;
@@ -202,7 +223,12 @@ inline void BigInteger::operator /=(const BigInteger &x) {
*this = q;
}
inline void BigInteger::operator %=(const BigInteger &x) {
- if (x.isZero()) throw "BigInteger::operator %=: division by zero";
+ 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);