summaryrefslogtreecommitdiff
path: root/integer.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-01-24 15:35:45 -0500
committerJeffrey Walton <noloader@gmail.com>2018-01-24 15:35:45 -0500
commit30bcc7022d036ccd2d690e17e19f277b4fa71250 (patch)
tree0fff10c9560da803e635a71dddd8a3ee1f33d226 /integer.cpp
parent85993b2529a22ba58cf6ceb0ef178724a1fe5262 (diff)
downloadcryptopp-git-30bcc7022d036ccd2d690e17e19f277b4fa71250.tar.gz
Clear clang-tidy warnings
Diffstat (limited to 'integer.cpp')
-rw-r--r--integer.cpp40
1 files changed, 15 insertions, 25 deletions
diff --git a/integer.cpp b/integer.cpp
index 833bb3cd..e9846bde 100644
--- a/integer.cpp
+++ b/integer.cpp
@@ -3645,32 +3645,24 @@ std::istream& operator>>(std::istream& in, Integer &a)
return in;
}
+// Ensure base 10 is default
+inline int FlagToBase(long f) {
+ return f == std::ios::hex ? 16 : (f == std::ios::oct ? 8 : 10);
+}
+
+inline char FlagToSuffix(long f) {
+ return f == std::ios::hex ? 'h' : (f == std::ios::oct ? 'o' : '.');
+}
+
+// Ensure base 10 is default
std::ostream& operator<<(std::ostream& out, const Integer &a)
{
// Get relevant conversion specifications from ostream.
- const long f = out.flags() & std::ios::basefield; // Get base digits.
- int base, block;
- char suffix;
- switch(f)
- {
- case std::ios::oct :
- base = 8;
- block = 8;
- suffix = 'o';
- break;
- case std::ios::hex :
- base = 16;
- block = 4;
- suffix = 'h';
- break;
- default :
- base = 10;
- block = 3;
- suffix = '.';
- }
+ const long f = out.flags() & std::ios::basefield;
+ const int base = FlagToBase(f);
+ const char suffix = FlagToSuffix(f);
Integer temp1=a, temp2;
-
if (a.IsNegative())
{
out << '-';
@@ -3698,8 +3690,6 @@ std::ostream& operator<<(std::ostream& out, const Integer &a)
while (i--)
{
out << s[i];
-// if (i && !(i%block))
-// out << ",";
}
#ifdef CRYPTOPP_USE_STD_SHOWBASE
@@ -3873,7 +3863,7 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
word borrow = Subtract(diff.reg, a.reg, b.reg, bSize);
CopyWords(diff.reg+bSize, a.reg+bSize, aSize-bSize);
borrow = Decrement(diff.reg+bSize, aSize-bSize, borrow);
- CRYPTOPP_ASSERT(!borrow);
+ CRYPTOPP_ASSERT(!borrow); CRYPTOPP_UNUSED(borrow);
diff.sign = Integer::POSITIVE;
}
else if (aSize == bSize)
@@ -3894,7 +3884,7 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
word borrow = Subtract(diff.reg, b.reg, a.reg, aSize);
CopyWords(diff.reg+aSize, b.reg+aSize, bSize-aSize);
borrow = Decrement(diff.reg+aSize, bSize-aSize, borrow);
- CRYPTOPP_ASSERT(!borrow);
+ CRYPTOPP_ASSERT(!borrow); CRYPTOPP_UNUSED(borrow);
diff.sign = Integer::NEGATIVE;
}
}