[PATCH v2] covoar/ Explanations.cc: Handle newline at end of file
Alex White
alex.white at oarcorp.com
Fri Jun 25 03:37:52 UTC 2021
---
tester/covoar/Explanations.cc | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc
index 1449fb2..4d177eb 100644
--- a/tester/covoar/Explanations.cc
+++ b/tester/covoar/Explanations.cc
@@ -85,26 +85,24 @@ namespace Coverage {
line++;
// Get the explanation
- while (1) {
- explain.getline( inputBuffer, MAX_LINE_LENGTH );
- // fprintf( stderr, "%d - %s\n", line, inputBuffer );
- if (explain.fail()) {
- std::ostringstream what;
- what << "line " << line
- << "out of sync at the explanation";
- throw rld::error( what, "Explanations::load" );
- }
- inputBuffer[ strlen(inputBuffer) - 1] = '\0';
+ for (std::string input_line; std::getline( explain, input_line ); ) {
line++;
- const char delimiter[4] = "+++";
- if (!strncmp( inputBuffer, delimiter, 3 )) {
+ const std::string delimiter = "+++";
+ if (input_line.compare( delimiter ) == 0) {
break;
}
// XXX only taking last line. Needs to be a vector
- e.explanation.push_back( inputBuffer );
+ e.explanation.push_back( input_line );
}
+ if (explain.fail()) {
+ std::ostringstream what;
+ what << "line " << line
+ << "out of sync at the explanation";
+ throw rld::error( what, "Explanations::load" );
+ }
+
// Add this to the set of Explanations
set[ e.startingPoint ] = e;
}
--
2.27.0
More information about the devel
mailing list