summaryrefslogtreecommitdiff
path: root/datatest.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2021-03-19 18:53:18 -0400
committerJeffrey Walton <noloader@gmail.com>2021-03-19 18:53:18 -0400
commit3b76ccc5a5ff2444c0f4c73246f978cbba870fee (patch)
tree83360dad9484ea9c4bd09387a344a62913677410 /datatest.cpp
parentd32ff560ebe03422190f51b4a11425e6226eac82 (diff)
downloadcryptopp-git-3b76ccc5a5ff2444c0f4c73246f978cbba870fee.tar.gz
Use istream.fail() in Readline()
Diffstat (limited to 'datatest.cpp')
-rw-r--r--datatest.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/datatest.cpp b/datatest.cpp
index bdcad918..6634964e 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -49,12 +49,13 @@ const TestData *s_currentTestData = NULLPTR;
const std::string testDataFilename = "cryptest.dat";
// Handles CR, LF, and CRLF properly
+// For istream.fail() see https://stackoverflow.com/q/34395801/608639.
bool Readline(std::istream& stream, std::string& line)
{
line.clear();
line.reserve(64);
- while (stream.good())
+ while (!stream.fail())
{
int ch = stream.get();
if (ch == '\r')
@@ -81,7 +82,7 @@ bool Readline(std::istream& stream, std::string& line)
// Non-binding shrink to fit
line.reserve(0);
- return stream.good();
+ return !stream.fail();
}
std::string TrimSpace(const std::string& str)
@@ -1104,7 +1105,6 @@ inline char LastChar(const std::string& str) {
// because Unix&Linux uses LF, OS X uses CR, and Windows uses CRLF. If this function
// is modified, then run 'cryptest.exe tv rsa_pkcs1_1_5' as a test. Its the parser
// file from hell. If it can be parsed without error, then things are likely OK.
-// For istream.fail() see https://stackoverflow.com/q/34395801/608639.
bool GetField(std::istream &is, std::string &name, std::string &value)
{
std::string line;