forbid the use of std::endl on std::cerr

std::cerr will flush after each operator<< by default, so it's simpler
to use \n instead of std::endl, especially if we can merge \n into the
previous string.  Ideally we should prefer \n for std::cout as well,
but there are reasonable cases where we want to call std::endl there,
so it's hard to enforce.

* tests/sanity/style.test: Diagnose occurrences of cerr.*<<.*endl.
* bin/autcross.cc, bin/autfilt.cc, bin/ltlcross.cc, bin/ltlsynt.cc,
spot/tl/formula.cc, spot/twa/bdddict.cc, tests/core/checkpsl.cc,
tests/core/checkta.cc, tests/core/consterm.cc, tests/core/emptchk.cc,
tests/core/equalsf.cc, tests/core/ikwiad.cc, tests/core/kind.cc,
tests/core/length.cc, tests/core/ltlrel.cc, tests/core/parity.cc,
tests/core/randtgba.cc, tests/core/reduc.cc, tests/core/syntimpl.cc,
tests/ltsmin/modelcheck.cc: Fix them.
This commit is contained in:
Alexandre Duret-Lutz 2019-07-15 02:31:13 +02:00
parent b4cced9ba8
commit 09c93a3a3d
21 changed files with 148 additions and 170 deletions

View file

@ -385,8 +385,7 @@ namespace
format(command, tools[tool_num].cmd);
std::string cmd = command.str();
std::cerr << "Running [" << l << tool_num << "]: "
<< cmd << std::endl;
std::cerr << "Running [" << l << tool_num << "]: " << cmd << '\n';
spot::process_timer timer;
timer.start();
int es = exec_with_timeout(cmd.c_str());
@ -623,9 +622,7 @@ namespace
if (!no_checks)
{
std::cerr << "Performing sanity checks and gathering statistics..."
<< std::endl;
std::cerr << "Performing sanity checks and gathering statistics...\n";
{
bool print_first = true;
for (unsigned i = 0; i < mi; ++i)
@ -712,14 +709,14 @@ namespace
}
else
{
std::cerr << "Gathering statistics..." << std::endl;
std::cerr << "Gathering statistics...\n";
}
if (problems && bogus_output)
print_hoa(bogus_output->ostream(), input) << std::endl;
std::cerr << std::endl;
std::cerr << '\n';
// Shall we stop processing now?
abort_run = global_error_flag && stop_on_error;
@ -806,21 +803,20 @@ main(int argc, char** argv)
err << ("error: some error was detected during the above "
"runs.\n Check file ")
<< bogus_output_filename
<< " for problematic automata.";
<< " for problematic automata.\n";
else
err << ("error: some error was detected during the above "
"runs,\n please search for 'error:' messages"
" in the above trace.");
err << std::endl;
" in the above trace.\n");
end_error();
}
else if (timeout_count == 0 && ignored_exec_fail == 0)
{
std::cerr << "No problem detected." << std::endl;
std::cerr << "No problem detected.\n";
}
else
{
std::cerr << "No major problem detected." << std::endl;
std::cerr << "No major problem detected.\n";
}
unsigned additional_errors = 0U;
@ -851,7 +847,7 @@ main(int argc, char** argv)
}
if (additional_errors == 1)
std::cerr << '.';
std::cerr << std::endl;
std::cerr << '\n';
}
}

View file

@ -769,7 +769,7 @@ parse_opt(int key, char* arg, struct argp_state*)
{
std::cerr << ", '" << acc_is_args[i] << '\'';
}
std::cerr << std::endl;
std::cerr << '\n';
exit(2);
}
}

View file

@ -571,8 +571,7 @@ namespace
format(command, tools[translator_num].cmd);
std::string cmd = command.str();
std::cerr << "Running [" << l << translator_num << "]: "
<< cmd << std::endl;
std::cerr << "Running [" << l << translator_num << "]: " << cmd << '\n';
spot::process_timer timer;
timer.start();
int es = exec_with_timeout(cmd.c_str());
@ -1031,8 +1030,7 @@ namespace
std::cerr
<< ("warning: This formula or its negation has already"
" been checked.\n Use --allow-dups if it "
"should not be ignored.\n")
<< std::endl;
"should not be ignored.\n\n");
return 0;
}
}
@ -1136,8 +1134,7 @@ namespace
if (!no_checks)
{
std::cerr << "Performing sanity checks and gathering statistics..."
<< std::endl;
std::cerr << "Performing sanity checks and gathering statistics...\n";
// If we have reference tools, pick the smallest of their
// automata for positive and negative references.
@ -1391,7 +1388,7 @@ namespace
}
else
{
std::cerr << "Gathering statistics..." << std::endl;
std::cerr << "Gathering statistics...\n";
}
spot::atomic_prop_set* ap = spot::atomic_prop_collect(f);
@ -1567,7 +1564,7 @@ namespace
delete pos_map[i];
++seed;
}
std::cerr << std::endl;
std::cerr << '\n';
delete ap;
// Shall we stop processing formulas now?
@ -1702,17 +1699,17 @@ main(int argc, char** argv)
err << ("error: some error was detected during the above "
"runs,\n please search for 'error:' messages"
" in the above trace.");
err << std::endl;
err << '\n';
end_error();
}
else if (timeout_count == 0
&& ignored_exec_fail == 0 && oom_count == 0)
{
std::cerr << "No problem detected." << std::endl;
std::cerr << "No problem detected.\n";
}
else
{
std::cerr << "No major problem detected." << std::endl;
std::cerr << "No major problem detected.\n";
}
unsigned additional_errors = 0U;
@ -1755,7 +1752,7 @@ main(int argc, char** argv)
}
if (additional_errors == 1)
std::cerr << '.';
std::cerr << std::endl;
std::cerr << '\n';
}
}

View file

@ -290,7 +290,7 @@ namespace
auto aut = trans_.run(&f);
if (verbose)
std::cerr << "translating formula done" << std::endl;
std::cerr << "translating formula done\n";
bdd all_inputs = bddtrue;
bdd all_outputs = bddtrue;
for (unsigned i = 0; i < input_aps_.size(); ++i)
@ -369,7 +369,7 @@ namespace
auto owner = complete_env(dpa);
auto pg = spot::parity_game(dpa, owner);
if (verbose)
std::cerr << "parity game built" << std::endl;
std::cerr << "parity game built\n";
timer.stop();
if (opt_print_pg)