From 09c93a3a3d52e75fdf2b2a4472f275c3c495e20a Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 15 Jul 2019 02:31:13 +0200 Subject: [PATCH] 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. --- bin/autcross.cc | 22 +++---- bin/autfilt.cc | 2 +- bin/ltlcross.cc | 21 +++---- bin/ltlsynt.cc | 4 +- spot/tl/formula.cc | 2 +- spot/twa/bdddict.cc | 10 ++-- tests/core/checkpsl.cc | 4 +- tests/core/checkta.cc | 4 +- tests/core/consterm.cc | 4 +- tests/core/emptchk.cc | 6 +- tests/core/equalsf.cc | 4 +- tests/core/ikwiad.cc | 12 ++-- tests/core/kind.cc | 6 +- tests/core/length.cc | 6 +- tests/core/ltlrel.cc | 4 +- tests/core/parity.cc | 60 +++++++++---------- tests/core/randtgba.cc | 114 +++++++++++++++++-------------------- tests/core/reduc.cc | 10 ++-- tests/core/syntimpl.cc | 4 +- tests/ltsmin/modelcheck.cc | 13 ++--- tests/sanity/style.test | 6 +- 21 files changed, 148 insertions(+), 170 deletions(-) diff --git a/bin/autcross.cc b/bin/autcross.cc index 8067ea774..97183db92 100644 --- a/bin/autcross.cc +++ b/bin/autcross.cc @@ -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'; } } diff --git a/bin/autfilt.cc b/bin/autfilt.cc index 042e66746..f8cbf7dc4 100644 --- a/bin/autfilt.cc +++ b/bin/autfilt.cc @@ -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); } } diff --git a/bin/ltlcross.cc b/bin/ltlcross.cc index 514c7db2d..c575011a5 100644 --- a/bin/ltlcross.cc +++ b/bin/ltlcross.cc @@ -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'; } } diff --git a/bin/ltlsynt.cc b/bin/ltlsynt.cc index 3603648ee..99e7410eb 100644 --- a/bin/ltlsynt.cc +++ b/bin/ltlsynt.cc @@ -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) diff --git a/spot/tl/formula.cc b/spot/tl/formula.cc index 783ef6621..c844a0d1f 100644 --- a/spot/tl/formula.cc +++ b/spot/tl/formula.cc @@ -1736,7 +1736,7 @@ namespace spot { if (!cnt++) std::cerr << "*** m.uniq is not empty ***\n"; - i->dump(std::cerr) << std::endl; + i->dump(std::cerr) << '\n'; } return cnt == 0; } diff --git a/spot/twa/bdddict.cc b/spot/twa/bdddict.cc index b74a808c3..f1dc88450 100644 --- a/spot/twa/bdddict.cc +++ b/spot/twa/bdddict.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2009, 2012-2018 Laboratoire de Recherche et +// Copyright (C) 2009, 2012-2019 Laboratoire de Recherche et // Développement de l'Epita (LRDE). // Copyright (C) 2003-2006 Laboratoire d'Informatique de Paris 6 // (LIP6), département Systèmes Répartis Coopératifs (SRC), Université @@ -346,17 +346,17 @@ namespace spot { if (var_seen) { - std::cerr << "var_map is empty but Var in map" << std::endl; + std::cerr << "var_map is empty but Var in map\n"; fail = true; } if (acc_seen) { - std::cerr << "acc_map is empty but Acc in map" << std::endl; + std::cerr << "acc_map is empty but Acc in map\n"; fail = true; } if (refs_seen) { - std::cerr << "maps are empty but var_refs is not" << std::endl; + std::cerr << "maps are empty but var_refs is not\n"; fail = true; } if (!fail) @@ -364,7 +364,7 @@ namespace spot } else { - std::cerr << "some maps are not empty" << std::endl; + std::cerr << "some maps are not empty\n"; } dump(std::cerr); abort(); diff --git a/tests/core/checkpsl.cc b/tests/core/checkpsl.cc index b9cb6e746..620001255 100644 --- a/tests/core/checkpsl.cc +++ b/tests/core/checkpsl.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2014-2016, 2018 Laboratoire de Recherche et +// Copyright (C) 2014-2016, 2018-2019 Laboratoire de Recherche et // Développement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. @@ -33,7 +33,7 @@ static void syntax(char* prog) { - std::cerr << prog << " file" << std::endl; + std::cerr << prog << " file\n"; exit(2); } diff --git a/tests/core/checkta.cc b/tests/core/checkta.cc index 5750d5516..111aa4d06 100644 --- a/tests/core/checkta.cc +++ b/tests/core/checkta.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2014-2016, 2018 Laboratoire de Recherche et +// Copyright (C) 2014-2016, 2018, 2019 Laboratoire de Recherche et // Développement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. @@ -37,7 +37,7 @@ static void syntax(char* prog) { - std::cerr << prog << " file" << std::endl; + std::cerr << prog << " file\n"; exit(2); } diff --git a/tests/core/consterm.cc b/tests/core/consterm.cc index dedb2479a..67d563b8e 100644 --- a/tests/core/consterm.cc +++ b/tests/core/consterm.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2010-2012, 2015-2016, 2018 Laboratoire de Recherche +// Copyright (C) 2010-2012, 2015-2016, 2018-2019 Laboratoire de Recherche // et Dévelopement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. @@ -28,7 +28,7 @@ static void syntax(char *prog) { - std::cerr << prog << " formula" << std::endl; + std::cerr << prog << " formula\n"; exit(2); } diff --git a/tests/core/emptchk.cc b/tests/core/emptchk.cc index 171036d55..1a7e2519c 100644 --- a/tests/core/emptchk.cc +++ b/tests/core/emptchk.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2014-2016, 2018 Laboratoire de Recherche et +// Copyright (C) 2014-2016, 2018-2019 Laboratoire de Recherche et // Développement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. @@ -36,7 +36,7 @@ static void syntax(char* prog) { - std::cerr << prog << " file" << std::endl; + std::cerr << prog << " file\n"; exit(2); } @@ -124,7 +124,7 @@ main(int argc, char** argv) auto i = spot::make_emptiness_check_instantiator(algo, &err); if (!i) { - std::cerr << "Failed to parse `" << err << '\'' << std::endl; + std::cerr << "Failed to parse `" << err << "'\n"; exit(2); } diff --git a/tests/core/equalsf.cc b/tests/core/equalsf.cc index 692ddc167..54bfe5f68 100644 --- a/tests/core/equalsf.cc +++ b/tests/core/equalsf.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2008-2012, 2014-2016, 2018 Laboratoire de +// Copyright (C) 2008-2012, 2014-2016, 2018-2019 Laboratoire de // Recherche et Développement de l'Epita (LRDE). // Copyright (C) 2003, 2004, 2006 Laboratoire d'Informatique de // Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC), @@ -36,7 +36,7 @@ static void syntax(char* prog) { - std::cerr << prog << " [-E] file" << std::endl; + std::cerr << prog << " [-E] file\n"; exit(2); } diff --git a/tests/core/ikwiad.cc b/tests/core/ikwiad.cc index c85d44f80..d65bfd273 100644 --- a/tests/core/ikwiad.cc +++ b/tests/core/ikwiad.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2007-2018 Laboratoire de Recherche et Développement +// Copyright (C) 2007-2019 Laboratoire de Recherche et Développement // de l'Epita (LRDE). // Copyright (C) 2003-2007 Laboratoire d'Informatique de Paris 6 // (LIP6), département Systèmes Répartis Coopératifs (SRC), Université @@ -396,7 +396,7 @@ checked_main(int argc, char** argv) if (!echeck_inst) { std::cerr << "Failed to parse argument of -e near `" - << err << '\'' << std::endl; + << err << "'\n"; exit(2); } expect_counter_example = true; @@ -414,7 +414,7 @@ checked_main(int argc, char** argv) if (!echeck_inst) { std::cerr << "Failed to parse argument of -e near `" - << err << '\'' << std::endl; + << err << "'\n"; exit(2); } expect_counter_example = false; @@ -820,13 +820,13 @@ checked_main(int argc, char** argv) std::ifstream fin(argv[formula_index]); if (!fin) { - std::cerr << "Cannot open " << argv[formula_index] << std::endl; + std::cerr << "Cannot open " << argv[formula_index] << '\n'; exit(2); } if (!std::getline(fin, input, '\0')) { - std::cerr << "Cannot read " << argv[formula_index] << std::endl; + std::cerr << "Cannot read " << argv[formula_index] << '\n'; exit(2); } } @@ -952,7 +952,7 @@ checked_main(int argc, char** argv) << "\n varnum: " << s.varnum << "\n cachesize: " << s.cachesize << "\n gbcnum: " << s.gbcnum - << std::endl; + << '\n'; bdd_fprintstat(stderr); dict->dump(std::cerr); } diff --git a/tests/core/kind.cc b/tests/core/kind.cc index 35c69c48e..1dfa7830b 100644 --- a/tests/core/kind.cc +++ b/tests/core/kind.cc @@ -1,6 +1,6 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2010, 2012, 2015, 2016, 2018 Laboratoire de Recherche -// et Developement de l'Epita (LRDE). +// Copyright (C) 2010, 2012, 2015, 2016, 2018, 2019 Laboratoire de +// Recherche et Developement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. // @@ -28,7 +28,7 @@ static void syntax(char *prog) { - std::cerr << prog << " formula" << std::endl; + std::cerr << prog << " formula\n"; exit(2); } diff --git a/tests/core/length.cc b/tests/core/length.cc index 7d99186e4..f49de9358 100644 --- a/tests/core/length.cc +++ b/tests/core/length.cc @@ -1,6 +1,6 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2012, 2015, 2016, 2018 Laboratoire de Recherche et -// Developement de l'Epita (LRDE). +// Copyright (C) 2012, 2015-2016, 2018-2019 Laboratoire de Recherche +// et Developement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. // @@ -28,7 +28,7 @@ static void syntax(char *prog) { - std::cerr << prog << " formula" << std::endl; + std::cerr << prog << " formula\n"; exit(2); } diff --git a/tests/core/ltlrel.cc b/tests/core/ltlrel.cc index 82e001464..88735a1e9 100644 --- a/tests/core/ltlrel.cc +++ b/tests/core/ltlrel.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2013-2016, 2018 Laboratoire de Recherche et +// Copyright (C) 2013-2016, 2018-2019 Laboratoire de Recherche et // Developement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. @@ -28,7 +28,7 @@ static void syntax(char *prog) { - std::cerr << prog << " formula" << std::endl; + std::cerr << prog << " formula\n"; exit(2); } diff --git a/tests/core/parity.cc b/tests/core/parity.cc index 7fd9ba889..28689c41f 100644 --- a/tests/core/parity.cc +++ b/tests/core/parity.cc @@ -1,6 +1,6 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2016, 2018 Laboratoire de Recherche et Développement -// de l'Epita (LRDE). +// Copyright (C) 2016, 2018-2019 Laboratoire de Recherche et +// Développement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. // @@ -174,31 +174,27 @@ static bool is_included(spot::const_twa_graph_ptr left, auto product = spot::product(left, tmp); if (!product->is_empty()) { - std::cerr << "======Not included======" << std::endl; + std::cerr << "======Not included======\n"; if (first_left) - std::cerr << "======First automaton======" << std::endl; + std::cerr << "======First automaton======\n"; else - std::cerr << "======Second automaton======" << std::endl; - spot::print_hoa(std::cerr, left); - std::cerr << std::endl; + std::cerr << "======Second automaton======\n"; + spot::print_hoa(std::cerr, left) << '\n'; if (first_left) - std::cerr << "======Second automaton======" << std::endl; + std::cerr << "======Second automaton======\n"; else - std::cerr << "======First automaton======" << std::endl; - spot::print_hoa(std::cerr, right); - std::cerr << std::endl; + std::cerr << "======First automaton======\n"; + spot::print_hoa(std::cerr, right) << '\n'; if (first_left) - std::cerr << "======!Second automaton======" << std::endl; + std::cerr << "======!Second automaton======\n"; else - std::cerr << "======!First automaton======" << std::endl; - spot::print_hoa(std::cerr, tmp); - std::cerr << std::endl; + std::cerr << "======!First automaton======\n"; + spot::print_hoa(std::cerr, tmp) << '\n'; if (first_left) - std::cerr << "======First X !Second======" <num_sets() << std::endl; - std::cerr << std::endl; + << style[target_style] + << "\norigin: " << kind[origin_max ? 0 : 1] << ' ' + << style[origin_odd ? 0 : 1] << ' ' << num_sets + << "\nactually: " << kind[is_max ? 0 : 1] << ' ' + << style[is_odd ? 0 : 1] << ' ' << aut->num_sets() + << "\n\n"; return false; } return true; @@ -263,9 +257,8 @@ static bool is_almost_colored(spot::const_twa_graph_ptr aut) for (auto t: aut->edges()) if (t.acc.count() > 1) { - std::cerr << "======Not colored======" << std::endl; - spot::print_hoa(std::cerr, aut); - std::cerr << std::endl; + std::cerr << "======Not colored======\n"; + spot::print_hoa(std::cerr, aut) << '\n'; return false; } return true; @@ -276,9 +269,8 @@ static bool is_colored_printerr(spot::const_twa_graph_ptr aut) bool result = is_colored(aut); if (!result) { - std::cerr << "======Not colored======" << std::endl; - spot::print_hoa(std::cerr, aut); - std::cerr << std::endl; + std::cerr << "======Not colored======\n"; + spot::print_hoa(std::cerr, aut) << '\n'; } return result; } diff --git a/tests/core/randtgba.cc b/tests/core/randtgba.cc index 0f4b6f644..7462f2c80 100644 --- a/tests/core/randtgba.cc +++ b/tests/core/randtgba.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2008-2012, 2014-2018 Laboratoire de Recherche et +// Copyright (C) 2008-2012, 2014-2019 Laboratoire de Recherche et // Développement de l'Epita (LRDE). // Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC), @@ -98,58 +98,50 @@ cons_emptiness_check(int num, spot::const_twa_graph_ptr a, static void syntax(char* prog) { - std::cerr << "Usage: "<< prog << " [OPTIONS...] PROPS..." << std::endl - << std::endl - << "General Options:" << std::endl - << " -0 suppress default output, just generate the graph" - << " in memory" << std::endl - << " -1 produce minimal output (for our paper)" << std::endl - << " -g output graph in dot format" << std::endl - << " -s N seed for the random number generator" << std::endl - << " -z display statistics about emptiness-check algorithms" - << std::endl - << " -Z like -z, but print extra statistics after the run" - << " of each algorithm" << std::endl - << std::endl - << "Graph Generation Options:" << std::endl - << " -a N F number of acceptance conditions and probability that" - << " one is true" << std::endl - << " [0 0.0]" << std::endl - << " -d F density of the graph [0.2]" << std::endl - << " -n N number of nodes of the graph [20]" << std::endl - << " -t F probability of the atomic propositions to be true" - << " [0.5]" << std::endl - << " -det generate a deterministic and complete graph [false]" - << std::endl - << std::endl - << "Emptiness-Check Options:" << std::endl - << " -A FILE use all algorithms listed in FILE" << std::endl - << " -D degeneralize TGBA for emptiness-check algorithms that" - << " would" << std::endl - << " otherwise be skipped (implies -e)" << std::endl - << " -e N compare result of all " - << "emptiness checks on N randomly generated graphs" << std::endl - << " -m try to reduce runs, in a second pass (implies -r)" - << std::endl - << " -R N repeat each emptiness-check and accepting run " - << "computation N times" << std::endl - << " -r compute and replay accepting runs (implies -e)" - << std::endl - << " ar:MODE select the mode MODE for accepting runs computation " - << "(implies -r)" << std::endl - << std::endl - << "Where:" << std::endl - << " F are floats between 0.0 and 1.0 inclusive" << std::endl - << " E are floating values" << std::endl - << " S are `KEY=E, KEY=E, ...' strings" << std::endl - << " N are positive integers" << std::endl - << " PROPS are the atomic properties to use on transitions" - << std::endl - << "Use -dp to see the list of KEYs." << std::endl - << std::endl - << "When -i is used, a random graph a synchronized with" - << " each formula." << std::endl << "If -e N is additionally used" - << " N random graphs are generated for each formula." << std::endl; + std::cerr + << "Usage: " << prog + << (" [OPTIONS...] PROPS...\n\n" + "General Options:\n" + " -0 suppress default output, just generate the graph" + " in memory\n" + " -1 produce minimal output (for our paper)\n" + " -g output graph in dot format\n" + " -s N seed for the random number generator\n" + " -z display statistics about emptiness-check algorithms\n" + " -Z like -z, but print extra statistics after the run" + " of each algorithm\n\n" + "Graph Generation Options:\n" + " -a N F number of acceptance conditions and probability that" + " one is true\n" + " [0 0.0]\n" + " -d F density of the graph [0.2]\n" + " -n N number of nodes of the graph [20]\n" + " -t F probability of the atomic propositions to be true" + " [0.5]\n" + " -det generate a deterministic and complete graph [false]\n\n" + "Emptiness-Check Options:\n" + " -A FILE use all algorithms listed in FILE\n" + " -D degeneralize TGBA for emptiness-check algorithms that" + " would\n" + " otherwise be skipped (implies -e)\n" + " -e N compare result of all " + "emptiness checks on N randomly generated graphs\n" + " -m try to reduce runs, in a second pass (implies -r)\n" + " -R N repeat each emptiness-check and accepting run " + "computation N times\n" + " -r compute and replay accepting runs (implies -e)\n" + " ar:MODE select the mode MODE for accepting runs computation " + "(implies -r)\n\n" + "Where:\n" + " F are floats between 0.0 and 1.0 inclusive\n" + " E are floating values\n" + " S are `KEY=E, KEY=E, ...' strings\n" + " N are positive integers\n" + " PROPS are the atomic properties to use on transitions\n" + "Use -dp to see the list of KEYs.\n\n" + "When -i is used, a random graph a synchronized with" + " each formula.\nIf -e N is additionally used" + " N random graphs are generated for each formula.\n"); exit(2); } @@ -161,7 +153,7 @@ to_int(const char* s) int res = strtol(s, &endptr, 10); if (*endptr) { - std::cerr << "Failed to parse `" << s << "' as an integer." << std::endl; + std::cerr << "Failed to parse `" << s << "' as an integer.\n"; exit(1); } return res; @@ -174,7 +166,7 @@ to_int_pos(const char* s, const char* arg) if (res <= 0) { std::cerr << "argument of " << arg - << " (" << res << ") must be positive" << std::endl; + << " (" << res << ") must be positive\n"; exit(1); } return res; @@ -187,7 +179,7 @@ to_int_nonneg(const char* s, const char* arg) if (res < 0) { std::cerr << "argument of " << arg - << " (" << res << ") must be nonnegative" << std::endl; + << " (" << res << ") must be nonnegative\n"; exit(1); } return res; @@ -201,7 +193,7 @@ to_float(const char* s) float res = strtod(s, &endptr); if (*endptr) { - std::cerr << "Failed to parse `" << s << "' as a float." << std::endl; + std::cerr << "Failed to parse `" << s << "' as a float.\n"; exit(1); } return res; @@ -214,7 +206,7 @@ to_float_nonneg(const char* s, const char* arg) if (res < 0) { std::cerr << "argument of " << arg - << " (" << res << ") must be nonnegative" << std::endl; + << " (" << res << ") must be nonnegative\n"; exit(1); } return res; @@ -544,7 +536,7 @@ main(int argc, char** argv) if (!*in) { delete in; - std::cerr << "Failed to open " << argv[argn] << std::endl; + std::cerr << "Failed to open " << argv[argn] << '\n'; exit(2); } } @@ -571,7 +563,7 @@ main(int argc, char** argv) { if (options.parse_options(argv[argn])) { - std::cerr << "Failed to parse " << argv[argn] << std::endl; + std::cerr << "Failed to parse " << argv[argn] << '\n'; exit(2); } } @@ -680,7 +672,7 @@ main(int argc, char** argv) &err); if (!ec_algos[i].inst) { - std::cerr << "Parse error after `" << err << '\'' << std::endl; + std::cerr << "Parse error after `" << err << "'\n"; exit(1); } ec_algos[i].inst->options().set(options); diff --git a/tests/core/reduc.cc b/tests/core/reduc.cc index d6b5a9067..5e820fe61 100644 --- a/tests/core/reduc.cc +++ b/tests/core/reduc.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*_ -// Copyright (C) 2008-2012, 2014-2016, 2018 Laboratoire +// Copyright (C) 2008-2012, 2014-2016, 2018-2019 Laboratoire // de Recherche et Développement de l'Epita (LRDE). // Copyright (C) 2004, 2006, 2007 Laboratoire d'Informatique de Paris // 6 (LIP6), département Systèmes Répartis Coopératifs (SRC), @@ -35,7 +35,7 @@ static void syntax(char* prog) { - std::cerr << prog << " option formula1 (formula2)?" << std::endl; + std::cerr << prog << " option formula1 (formula2)?\n"; exit(2); } @@ -162,7 +162,7 @@ main(int argc, char** argv) fin = new std::ifstream(argv[2]); if (!*fin) { - std::cerr << "Cannot open " << argv[2] << std::endl; + std::cerr << "Cannot open " << argv[2] << '\n'; exit(2); } } @@ -196,7 +196,7 @@ main(int argc, char** argv) { if (readfile) { - std::cerr << "Cannot read from file and check result." << std::endl; + std::cerr << "Cannot read from file and check result.\n"; exit(2); } @@ -232,7 +232,7 @@ main(int argc, char** argv) if (!simp->are_equivalent(input_f, maybe_larger)) { std::cerr << "Incorrect reduction (reduce_size_strictly=0) from `" - << f1s_before << "' to `" << f1l << "'." << std::endl; + << f1s_before << "' to `" << f1l << "'.\n"; exit_code = 3; } } diff --git a/tests/core/syntimpl.cc b/tests/core/syntimpl.cc index d5037c183..2a2a8dc22 100644 --- a/tests/core/syntimpl.cc +++ b/tests/core/syntimpl.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2008-2012, 2014-2016, 2018 Laboratoire de Recherche +// Copyright (C) 2008-2012, 2014-2016, 2018-2019 Laboratoire de Recherche // et Développement de l'Epita (LRDE). // Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 // (LIP6), département Systèmes Répartis Coopératifs (SRC), Université @@ -32,7 +32,7 @@ static void syntax(char* prog) { - std::cerr << prog << " formula1 formula2?" << std::endl; + std::cerr << prog << " formula1 formula2?\n"; exit(2); } diff --git a/tests/ltsmin/modelcheck.cc b/tests/ltsmin/modelcheck.cc index 960828a4f..c6f9bbdf6 100644 --- a/tests/ltsmin/modelcheck.cc +++ b/tests/ltsmin/modelcheck.cc @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2011-2018 Laboratoire de Recherche et Developpement +// Copyright (C) 2011-2019 Laboratoire de Recherche et Developpement // de l'Epita (LRDE) // // This file is part of Spot, a model checking library. @@ -136,7 +136,7 @@ checked_main(int argc, char **argv) break; default: error: - std::cerr << "Unknown option `" << argv[i] << "'." << std::endl; + std::cerr << "Unknown option `" << argv[i] << "'.\n"; exit(1); } --argc; @@ -285,10 +285,9 @@ checked_main(int argc, char **argv) } catch (const std::bad_alloc&) { - std::cerr << "Out of memory during emptiness check." - << std::endl; + std::cerr << "Out of memory during emptiness check.\n"; if (!compress_states) - std::cerr << "Try option -z for state compression." << std::endl; + std::cerr << "Try option -z for state compression.\n"; exit_code = 2; exit(exit_code); } @@ -329,8 +328,8 @@ checked_main(int argc, char **argv) } catch (const std::bad_alloc&) { - std::cerr << "Out of memory while looking for counterexample." - << std::endl; + std::cerr + << "Out of memory while looking for counterexample.\n"; exit_code = 2; exit(exit_code); } diff --git a/tests/sanity/style.test b/tests/sanity/style.test index 1b5762ccd..ffbf02b6f 100755 --- a/tests/sanity/style.test +++ b/tests/sanity/style.test @@ -1,6 +1,6 @@ #! /bin/sh # -*- coding: utf-8 -*- -# Copyright (C) 2009-2018 Laboratoire de Recherche et Développement de +# Copyright (C) 2009-2019 Laboratoire de Recherche et Développement de # l'Epita (LRDE). # Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 # (LIP6), département Systèmes Répartis Coopératifs (SRC), Université @@ -67,7 +67,6 @@ for dir in "$TOP/spot" "$TOP/bin" "$TOP/tests"; do -a -not -path '*.dir/*' \ -a -type f -a -print | while read file; do - if $GREP 'GNU Bison' "$file" >/dev/null || $GREP 'generated by flex' "$file" >/dev/null ; then continue @@ -266,6 +265,9 @@ for dir in "$TOP/spot" "$TOP/bin" "$TOP/tests"; do e$GREP '(->|[.])size\(\) [=!]= 0|![a-zA-Z0-9_]*(->|[.])size\(\)|(if |while |assert)\([a-zA-Z0-9_]*(->|[.])size\(\)\)' $tmp && diag 'Prefer empty() to check emptiness.' + $GREP -E 'std::cerr.*<<.*endl' $tmp && + diag 'std::cerr has unitbuf set; use \\n instead of endl' + e$GREP 'assert\((0|!".*")\)' $tmp && diag 'Prefer SPOT_UNREACHABLE or SPOT_UNIMPLEMENTED.'