bin: factor exception-handling code

* bin/common_setup.cc, bin/common_setup.hh: Define a protected_main()
function that deal with exceptions.
* bin/autcross.cc, bin/autfilt.cc, bin/dstar2tgba.cc, bin/genaut.cc,
bin/genltl.cc, bin/ltl2tgba.cc, bin/ltl2tgta.cc, bin/ltlcross.cc,
bin/ltldo.cc, bin/ltlfilt.cc, bin/ltlgrind.cc, bin/ltlsynt.cc,
bin/randaut.cc, bin/randltl.cc: Use it for all tools.
This commit is contained in:
Alexandre Duret-Lutz 2018-05-16 18:35:59 +02:00
parent fc0ed01a45
commit 645bb55622
16 changed files with 328 additions and 386 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2017 Laboratoire de Recherche et Développement de
// Copyright (C) 2017, 2018 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -822,97 +822,97 @@ print_stats_csv(const char* filename)
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&]() -> unsigned {
const argp ap = { options, parse_opt, "[COMMANDFMT...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[COMMANDFMT...]",
argp_program_doc, children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_automaton();
check_no_automaton();
auto s = tools.size();
if (s == 0)
error(2, 0, "No tool to run? Run '%s --help' for usage.",
program_name);
auto s = tools.size();
if (s == 0)
error(2, 0, "No tool to run? Run '%s --help' for usage.",
program_name);
if (s == 1 && !opt_language_preserved && !no_checks)
error(2, 0, "Since --language-preserved is not used, you need "
"at least two tools to compare.");
if (s == 1 && !opt_language_preserved && !no_checks)
error(2, 0, "Since --language-preserved is not used, you need "
"at least two tools to compare.");
setup_color();
setup_sig_handler();
setup_color();
setup_sig_handler();
autcross_processor p;
if (p.run())
return 2;
autcross_processor p;
if (p.run())
return 2;
if (round_num == 0)
{
error(2, 0, "no automaton to translate");
}
else
{
if (global_error_flag)
if (round_num == 0)
{
std::ostream& err = global_error();
if (bogus_output)
err << ("error: some error was detected during the above runs.\n"
" Check file ")
<< bogus_output_filename
<< " for problematic automata.";
else
err << ("error: some error was detected during the above runs,\n"
" please search for 'error:' messages in the above"
" trace.");
err << std::endl;
end_error();
}
else if (timeout_count == 0 && ignored_exec_fail == 0)
{
std::cerr << "No problem detected." << std::endl;
error(2, 0, "no automaton to translate");
}
else
{
std::cerr << "No major problem detected." << std::endl;
}
unsigned additional_errors = 0U;
additional_errors += timeout_count > 0;
additional_errors += ignored_exec_fail > 0;
if (additional_errors)
{
std::cerr << (global_error_flag ? "Additionally, " : "However, ");
if (timeout_count)
if (global_error_flag)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (timeout_count == 1)
std::cerr << "1 timeout occurred";
std::ostream& err = global_error();
if (bogus_output)
err << ("error: some error was detected during the above "
"runs.\n Check file ")
<< bogus_output_filename
<< " for problematic automata.";
else
std::cerr << timeout_count << " timeouts occurred";
err << ("error: some error was detected during the above "
"runs,\n please search for 'error:' messages"
" in the above trace.");
err << std::endl;
end_error();
}
else if (timeout_count == 0 && ignored_exec_fail == 0)
{
std::cerr << "No problem detected." << std::endl;
}
else
{
std::cerr << "No major problem detected." << std::endl;
}
if (ignored_exec_fail)
unsigned additional_errors = 0U;
additional_errors += timeout_count > 0;
additional_errors += ignored_exec_fail > 0;
if (additional_errors)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (ignored_exec_fail == 1)
std::cerr << "1 non-zero exit status was ignored";
else
std::cerr << ignored_exec_fail
<< " non-zero exit statuses were ignored";
std::cerr << (global_error_flag ? "Additionally, " : "However, ");
if (timeout_count)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (timeout_count == 1)
std::cerr << "1 timeout occurred";
else
std::cerr << timeout_count << " timeouts occurred";
}
if (ignored_exec_fail)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (ignored_exec_fail == 1)
std::cerr << "1 non-zero exit status was ignored";
else
std::cerr << ignored_exec_fail
<< " non-zero exit statuses were ignored";
}
if (additional_errors == 1)
std::cerr << '.';
std::cerr << std::endl;
}
if (additional_errors == 1)
std::cerr << '.';
std::cerr << std::endl;
}
}
if (csv_output)
print_stats_csv(csv_output);
if (csv_output)
print_stats_csv(csv_output);
return global_error_flag;
return global_error_flag;
});
}

View file

@ -1496,13 +1496,10 @@ namespace
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
try
{
// This will ensure that all objects stored in this struct are
// destroyed before global variables.
opt_t o;
@ -1544,19 +1541,11 @@ main(int argc, char** argv)
// Diagnose unused -x options
extra_options.report_unused_options();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
catch (const std::invalid_argument& e)
{
error(2, 0, "%s", e.what());
}
if (automaton_format == Count)
std::cout << match_count << std::endl;
if (automaton_format == Count)
std::cout << match_count << std::endl;
check_cout();
return !match_count;
check_cout();
return match_count ? 0 : 1;
});
}

View file

@ -169,3 +169,23 @@ const struct argp misc_argp = { options, parse_opt_misc,
const struct argp misc_argp_hidden = { options_hidden, parse_opt_misc,
nullptr, nullptr, nullptr,
nullptr, nullptr };
int protected_main(char** progname, std::function<int()> mainfun)
{
try
{
setup(progname);
return mainfun();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
catch (const std::invalid_argument& e)
{
error(2, 0, "%s", e.what());
}
SPOT_UNREACHABLE();
return 2;
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2012, 2013, 2018 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -21,8 +21,13 @@
#include "common_sys.hh"
#include "progname.h"
#include <functional>
void setup(char** progname);
extern const struct argp misc_argp;
extern const struct argp misc_argp_hidden;
// Call setup(progname) then Run mainfun() and handle exceptions.
int protected_main(char** progname, std::function<int()> mainfun);

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2013-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -136,33 +136,26 @@ namespace
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_automaton();
check_no_automaton();
spot::postprocessor post(&extra_options);
post.set_pref(pref | comp | sbacc | colored);
post.set_type(type);
post.set_level(level);
spot::postprocessor post(&extra_options);
post.set_pref(pref | comp | sbacc | colored);
post.set_type(type);
post.set_level(level);
try
{
dstar_processor processor(post);
if (processor.run())
return 2;
// Diagnose unused -x options
extra_options.report_unused_options();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
return 0;
return 0;
});
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2017 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2017, 2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -134,29 +134,22 @@ run_jobs()
int
main(int argc, char** argv)
{
strcpy(F_doc, "the name of the pattern");
strcpy(L_doc, "the argument of the pattern");
setup(argv);
return protected_main(argv, [&] {
strcpy(F_doc, "the name of the pattern");
strcpy(L_doc, "the argument of the pattern");
const argp ap = { options, parse_opt, nullptr, argp_program_doc,
children, nullptr, nullptr };
const argp ap = { options, parse_opt, nullptr, argp_program_doc,
children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (jobs.empty())
error(1, 0, "Nothing to do. Try '%s --help' for more information.",
program_name);
if (jobs.empty())
error(1, 0, "Nothing to do. Try '%s --help' for more information.",
program_name);
try
{
run_jobs();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
flush_cout();
return 0;
flush_cout();
return 0;
});
}

View file

@ -286,27 +286,19 @@ run_jobs()
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, nullptr, argp_program_doc,
children, nullptr, nullptr };
const argp ap = { options, parse_opt, nullptr, argp_program_doc,
children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (jobs.empty())
error(1, 0, "Nothing to do. Try '%s --help' for more information.",
program_name);
if (jobs.empty())
error(1, 0, "Nothing to do. Try '%s --help' for more information.",
program_name);
try
{
run_jobs();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
flush_cout();
return 0;
flush_cout();
return 0;
});
}

View file

@ -158,23 +158,20 @@ namespace
int
main(int argc, char** argv)
{
// By default we name automata using the formula.
opt_name = "%f";
return protected_main(argv, [&] {
// By default we name automata using the formula.
opt_name = "%f";
setup(argv);
const argp ap = { options, parse_opt, "[FORMULA...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[FORMULA...]",
argp_program_doc, children, nullptr, nullptr };
simplification_level = 3;
simplification_level = 3;
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_formula();
check_no_formula();
try
{
spot::translator trans(&extra_options);
trans.set_type(type);
trans.set_pref(pref | comp | sbacc | unambig | colored);
@ -186,11 +183,6 @@ main(int argc, char** argv)
// Diagnose unused -x options
extra_options.report_unused_options();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
return 0;
return 0;
});
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012-2017 Laboratoire de Recherche et Développement
// Copyright (C) 2012-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -224,20 +224,17 @@ namespace
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "[FORMULA...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[FORMULA...]",
argp_program_doc, children, nullptr, nullptr };
simplification_level = 3;
simplification_level = 3;
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_formula();
check_no_formula();
try
{
spot::translator trans(&extra_options);
trans.set_pref(pref | comp | sbacc);
trans.set_type(type);
@ -248,11 +245,6 @@ main(int argc, char** argv)
return 2;
// Diagnose unused -x options
extra_options.report_unused_options();
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
return 0;
return 0;
});
}

View file

@ -1591,108 +1591,109 @@ print_stats_json(const char* filename)
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&]() -> unsigned {
const argp ap = { options, parse_opt, "[COMMANDFMT...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[COMMANDFMT...]",
argp_program_doc, children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_formula();
check_no_formula();
if (tools.empty())
error(2, 0, "No translator to run? Run '%s --help' for usage.",
program_name);
if (tools.empty())
error(2, 0, "No translator to run? Run '%s --help' for usage.",
program_name);
setup_color();
setup_sig_handler();
setup_color();
setup_sig_handler();
processor p;
if (p.run())
return 2;
processor p;
if (p.run())
return 2;
if (formulas.empty())
{
error(2, 0, "no formula to translate");
}
else
{
if (global_error_flag)
if (formulas.empty())
{
std::ostream& err = global_error();
if (bogus_output)
err << ("error: some error was detected during the above runs.\n"
" Check file ")
<< bogus_output_filename
<< " for problematic formulas.";
else
err << ("error: some error was detected during the above runs,\n"
" please search for 'error:' messages in the above"
" trace.");
err << std::endl;
end_error();
}
else if (timeout_count == 0 && ignored_exec_fail == 0 && oom_count == 0)
{
std::cerr << "No problem detected." << std::endl;
error(2, 0, "no formula to translate");
}
else
{
std::cerr << "No major problem detected." << std::endl;
if (global_error_flag)
{
std::ostream& err = global_error();
if (bogus_output)
err << ("error: some error was detected during the above "
"runs.\n Check file ")
<< bogus_output_filename
<< " for problematic formulas.";
else
err << ("error: some error was detected during the above "
"runs,\n please search for 'error:' messages"
" in the above trace.");
err << std::endl;
end_error();
}
else if (timeout_count == 0
&& ignored_exec_fail == 0 && oom_count == 0)
{
std::cerr << "No problem detected." << std::endl;
}
else
{
std::cerr << "No major problem detected." << std::endl;
}
unsigned additional_errors = 0U;
additional_errors += timeout_count > 0;
additional_errors += ignored_exec_fail > 0;
additional_errors += oom_count > 0;
if (additional_errors)
{
std::cerr << (global_error_flag ? "Additionally, " : "However, ");
if (timeout_count)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (timeout_count == 1)
std::cerr << "1 timeout occurred";
else
std::cerr << timeout_count << " timeouts occurred";
}
if (oom_count)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (oom_count == 1)
std::cerr << "1 state-space product was";
else
std::cerr << oom_count << "state-space products were";
std::cerr << " skipped by lack of memory";
}
if (ignored_exec_fail)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (ignored_exec_fail == 1)
std::cerr << "1 non-zero exit status was ignored";
else
std::cerr << ignored_exec_fail
<< " non-zero exit statuses were ignored";
}
if (additional_errors == 1)
std::cerr << '.';
std::cerr << std::endl;
}
}
unsigned additional_errors = 0U;
additional_errors += timeout_count > 0;
additional_errors += ignored_exec_fail > 0;
additional_errors += oom_count > 0;
if (additional_errors)
{
std::cerr << (global_error_flag ? "Additionally, " : "However, ");
if (timeout_count)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (timeout_count == 1)
std::cerr << "1 timeout occurred";
else
std::cerr << timeout_count << " timeouts occurred";
}
delete bogus_output;
delete grind_output;
if (oom_count)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (oom_count == 1)
std::cerr << "1 state-space product was";
else
std::cerr << oom_count << "state-space products were";
std::cerr << " skipped by lack of memory";
}
if (json_output)
print_stats_json(json_output);
if (csv_output)
print_stats_csv(csv_output);
if (ignored_exec_fail)
{
if (additional_errors > 1)
std::cerr << "\n - ";
if (ignored_exec_fail == 1)
std::cerr << "1 non-zero exit status was ignored";
else
std::cerr << ignored_exec_fail
<< " non-zero exit statuses were ignored";
}
if (additional_errors == 1)
std::cerr << '.';
std::cerr << std::endl;
}
}
delete bogus_output;
delete grind_output;
if (json_output)
print_stats_json(json_output);
if (csv_output)
print_stats_csv(csv_output);
return global_error_flag;
return global_error_flag;
});
}

View file

@ -445,40 +445,33 @@ namespace
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "[COMMANDFMT...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[COMMANDFMT...]",
argp_program_doc, children, nullptr, nullptr };
// Disable post-processing as much as possible by default.
level = spot::postprocessor::Low;
pref = spot::postprocessor::Any;
type = spot::postprocessor::Generic;
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
// Disable post-processing as much as possible by default.
level = spot::postprocessor::Low;
pref = spot::postprocessor::Any;
type = spot::postprocessor::Generic;
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_formula();
check_no_formula();
if (tools.empty())
error(2, 0, "No translator to run? Run '%s --help' for usage.",
program_name);
if (tools.empty())
error(2, 0, "No translator to run? Run '%s --help' for usage.",
program_name);
setup_sig_handler();
setup_sig_handler();
spot::postprocessor post;
post.set_pref(pref | comp | sbacc | colored);
post.set_type(type);
post.set_level(level);
spot::postprocessor post;
post.set_pref(pref | comp | sbacc | colored);
post.set_type(type);
post.set_level(level);
try
{
processor p(post);
if (p.run())
return 2;
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
return 0;
return 0;
});
}

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2012-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -795,13 +795,10 @@ namespace
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
try
{
// This will ensure that all objects stored in this struct are
// destroyed before global variables.
opt_t o;
@ -822,19 +819,10 @@ main(int argc, char** argv)
ltl_processor processor(simpl);
if (processor.run())
return 2;
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
catch (const std::invalid_argument& e)
{
error(2, 0, "%s", e.what());
}
if (output_format == count_output)
std::cout << match_count << std::endl;
flush_cout();
return one_match ? 0 : 1;
if (output_format == count_output)
std::cout << match_count << '\n';
flush_cout();
return one_match ? 0 : 1;
});
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014, 2015, 2016, 2017 Laboratoire de Recherche et
// Copyright (C) 2014, 2015, 2016, 2017, 2018 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -183,21 +183,21 @@ parse_opt(int key, char* arg, struct argp_state*)
int
main(int argc, char* argv[])
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]",
argp_program_doc, children, nullptr, nullptr };
const argp ap = { options, parse_opt, "[FILENAME[/COL]...]", argp_program_doc,
children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
mut_opts |= opt_all;
mut_opts |= opt_all;
check_no_formula();
check_no_formula();
mutate_processor processor;
if (processor.run())
return 2;
flush_cout();
return 0;
mutate_processor processor;
if (processor.run())
return 2;
flush_cout();
return 0;
});
}

View file

@ -416,14 +416,15 @@ parse_opt(int key, char* arg, struct argp_state*)
int
main(int argc, char **argv)
{
setup(argv);
const argp ap = { options, parse_opt, nullptr,
argp_program_doc, children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_formula();
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, nullptr,
argp_program_doc, children, nullptr, nullptr };
if (int err = argp_parse(&ap, argc, argv, ARGP_NO_HELP, nullptr, nullptr))
exit(err);
check_no_formula();
spot::translator trans;
ltl_processor processor(trans, input_aps, output_aps);
return processor.run();
spot::translator trans;
ltl_processor processor(trans, input_aps, output_aps);
return processor.run();
});
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2014, 2015, 2016 Laboratoire de Recherche et
// Copyright (C) 2012, 2013, 2014, 2015, 2016, 2018 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -276,15 +276,13 @@ parse_opt(int key, char* arg, struct argp_state* as)
int
main(int argc, char** argv)
{
strcpy(F_doc, "seed number");
strcpy(L_doc, "automaton number");
setup(argv);
return protected_main(argv, [&] {
strcpy(F_doc, "seed number");
strcpy(L_doc, "automaton number");
const argp ap = { options, parse_opt, "N|PROP...", argp_program_doc,
children, nullptr, nullptr };
const argp ap = { options, parse_opt, "N|PROP...", argp_program_doc,
children, nullptr, nullptr };
try
{
// This will ensure that all objects stored in this struct are
// destroyed before global variables.
opt_t o;
@ -404,9 +402,6 @@ main(int argc, char** argv)
if (opt_automata > 0 && automaton_num >= opt_automata)
break;
}
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
return 0;
});
}

View file

@ -236,13 +236,10 @@ parse_opt(int key, char* arg, struct argp_state* as)
int
main(int argc, char** argv)
{
setup(argv);
return protected_main(argv, [&] {
const argp ap = { options, parse_opt, "N|PROP...", argp_program_doc,
children, nullptr, nullptr };
const argp ap = { options, parse_opt, "N|PROP...", argp_program_doc,
children, nullptr, nullptr };
try
{
// This will ensure that all objects stored in this struct are
// destroyed before global variables.
opt_t o;
@ -319,16 +316,7 @@ main(int argc, char** argv)
output_formula_checked(f, nullptr, nullptr, ++count);
}
};
}
catch (const std::runtime_error& e)
{
error(2, 0, "%s", e.what());
}
catch (const std::invalid_argument& e)
{
error(2, 0, "%s", e.what());
}
flush_cout();
return 0;
flush_cout();
return 0;
});
}