[PATCH] covoar/ Explanations.cc: Handle newline at end of file

Chris Johns chrisj at rtems.org
Fri Jun 18 23:56:29 UTC 2021


On 19/6/21 7:00 am, Alex White wrote:
> ---
>  tester/covoar/Explanations.cc | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc
> index 1449fb2..64cad5c 100644
> --- a/tester/covoar/Explanations.cc
> +++ b/tester/covoar/Explanations.cc
> @@ -87,6 +87,9 @@ namespace Coverage {
>        // Get the explanation
>        while (1) {
>          explain.getline( inputBuffer, MAX_LINE_LENGTH );
> +        if (explain.eof()) {
> +          break;
> +        }
>          // fprintf( stderr, "%d - %s\n", line, inputBuffer );
>          if (explain.fail()) {
>            std::ostringstream what;

Maybe the std::getline example with a C++11 range base loop would be a better
solution?

https://en.cppreference.com/w/cpp/string/basic_string/getline

:)

Chris


More information about the devel mailing list