[rtems-tools commit] covoar/Explanations.cc: Handle newline at end of file
Joel Sherrill
joel at rtems.org
Mon Jun 28 20:31:22 UTC 2021
Module: rtems-tools
Branch: master
Commit: 654e09087a5639f55500372b7bdc88c5c9d3fa18
Changeset: http://git.rtems.org/rtems-tools/commit/?id=654e09087a5639f55500372b7bdc88c5c9d3fa18
Author: Alex White <alex.white at oarcorp.com>
Date: Fri Jun 18 15:52:27 2021 -0500
covoar/Explanations.cc: Handle newline at end of file
---
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..9b4c1f6 100644
--- a/tester/covoar/Explanations.cc
+++ b/tester/covoar/Explanations.cc
@@ -85,24 +85,22 @@ 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
More information about the vc
mailing list