From 7854f629e50773dc62507a71e8ad7c5b8323d4f4 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sat, 29 Sep 2012 17:34:53 +0200 Subject: [PATCH] bin: factor version display. * src/bin/common_setup.cc (display_version): New function. (setup): Hook the display_version function. (argp_program_bug_address): Define this common variable here. * src/bin/genltl.cc, src/bin/ltl2tgba.cc, src/bin/ltl2tgta.cc, src/bin/ltlfilt.cc, src/bin/randltl.cc (argp_program_bug_address, argp_program_version): Remove these definitions. --- src/bin/common_setup.cc | 17 +++++++++++++++++ src/bin/genltl.cc | 11 ----------- src/bin/ltl2tgba.cc | 11 ----------- src/bin/ltl2tgta.cc | 11 ----------- src/bin/ltlfilt.cc | 11 ----------- src/bin/randltl.cc | 11 ----------- 6 files changed, 17 insertions(+), 55 deletions(-) diff --git a/src/bin/common_setup.cc b/src/bin/common_setup.cc index 7f31a4204..04a3a2d5f 100644 --- a/src/bin/common_setup.cc +++ b/src/bin/common_setup.cc @@ -20,6 +20,21 @@ // 02111-1307, USA. #include "common_setup.hh" +#include "argp.h" + +const char* argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; + +static void +display_version(FILE *stream, struct argp_state*) +{ + fputs(program_name, stream); + fputs(" (" PACKAGE_STRING ")\n\ +\n\ +Copyright (C) 2012 Laboratoire de Recherche et Développement de l'Epita.\n\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ +to the extent permitted by law.\n", stream); +} void setup(char** argv) @@ -28,4 +43,6 @@ setup(char** argv) // errors and display help text. set_program_name(argv[0]); argv[0] = const_cast(program_name); + + argp_program_version_hook = display_version; } diff --git a/src/bin/genltl.cc b/src/bin/genltl.cc index a6b02420c..acbbde7c6 100644 --- a/src/bin/genltl.cc +++ b/src/bin/genltl.cc @@ -81,7 +81,6 @@ #include "common_output.hh" #include "common_range.hh" -#include "misc/_config.h" #include #include #include @@ -96,16 +95,6 @@ using namespace spot; using namespace spot::ltl; -const char* argp_program_version = "\ -genltl (" SPOT_PACKAGE_STRING ")\n\ -\n\ -Copyright (C) 2012 Laboratoire de Recherche et Développement de l'Epita.\n\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ -to the extent permitted by law."; - -const char* argp_program_bug_address = "<" SPOT_PACKAGE_BUGREPORT ">"; - const char argp_program_doc[] ="\ Generate temporal logic formulas from predefined scalable patterns."; diff --git a/src/bin/ltl2tgba.cc b/src/bin/ltl2tgba.cc index 29583885b..72d6b45f1 100644 --- a/src/bin/ltl2tgba.cc +++ b/src/bin/ltl2tgba.cc @@ -33,7 +33,6 @@ #include "common_finput.hh" #include "common_post.hh" -#include "misc/_config.h" #include "ltlvisit/simplify.hh" #include "tgbaalgos/dotty.hh" #include "tgbaalgos/lbtt.hh" @@ -43,16 +42,6 @@ #include "tgbaalgos/stats.hh" #include "tgba/bddprint.hh" -const char* argp_program_version = "\ -ltl2tgba (" SPOT_PACKAGE_STRING ")\n\ -\n\ -Copyright (C) 2012 Laboratoire de Recherche et Développement de l'Epita.\n\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ -to the extent permitted by law."; - -const char* argp_program_bug_address = "<" SPOT_PACKAGE_BUGREPORT ">"; - const char argp_program_doc[] ="\ Translate linear-time formulas (LTL/PSL) into Büchi automata.\n\n\ By default it will apply all available optimizations to output \ diff --git a/src/bin/ltl2tgta.cc b/src/bin/ltl2tgta.cc index 482417483..21bc18590 100644 --- a/src/bin/ltl2tgta.cc +++ b/src/bin/ltl2tgta.cc @@ -34,7 +34,6 @@ #include "common_finput.hh" #include "common_post.hh" -#include "misc/_config.h" #include "ltlparse/public.hh" #include "ltlvisit/simplify.hh" #include "tgbaalgos/dotty.hh" @@ -46,16 +45,6 @@ #include "taalgos/dotty.hh" #include "taalgos/minimize.hh" -const char* argp_program_version = "\ -ltl2tgta (" SPOT_PACKAGE_STRING ")\n\ -\n\ -Copyright (C) 2012 Laboratoire de Recherche et Développement de l'Epita.\n\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ -to the extent permitted by law."; - -const char* argp_program_bug_address = "<" SPOT_PACKAGE_BUGREPORT ">"; - const char argp_program_doc[] ="\ Translate linear-time formulas (LTL/PSL) into Testing Automata.\n\n\ By default it outputs a transition-based generalized Testing Automaton \ diff --git a/src/bin/ltlfilt.cc b/src/bin/ltlfilt.cc index e2c051d7d..b8244304a 100644 --- a/src/bin/ltlfilt.cc +++ b/src/bin/ltlfilt.cc @@ -35,7 +35,6 @@ #include "common_cout.hh" #include "common_r.hh" -#include "misc/_config.h" #include "misc/hash.hh" #include "ltlvisit/simplify.hh" #include "ltlvisit/length.hh" @@ -47,16 +46,6 @@ #include "tgbaalgos/minimize.hh" #include "tgbaalgos/safety.hh" -const char* argp_program_version = "\ -ltlfilter (" SPOT_PACKAGE_STRING ")\n\ -\n\ -Copyright (C) 2012 Laboratoire de Recherche et Développement de l'Epita.\n\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ -to the extent permitted by law."; - -const char* argp_program_bug_address = "<" SPOT_PACKAGE_BUGREPORT ">"; - const char argp_program_doc[] ="\ Read a list of formulas and output them back after some optional processing.\v\ Exit status:\n\ diff --git a/src/bin/randltl.cc b/src/bin/randltl.cc index 85711662e..c906a44dd 100644 --- a/src/bin/randltl.cc +++ b/src/bin/randltl.cc @@ -33,7 +33,6 @@ #include "common_range.hh" #include "common_r.hh" -#include "misc/_config.h" #include #include "ltlast/atomic_prop.hh" #include "ltlast/multop.hh" @@ -46,16 +45,6 @@ #include "misc/random.hh" #include "misc/hash.hh" -const char* argp_program_version = "\ -randltl (" SPOT_PACKAGE_STRING ")\n\ -\n\ -Copyright (C) 2012 Laboratoire de Recherche et Développement de l'Epita.\n\ -This is free software; see the source for copying conditions. There is NO\n\ -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ -to the extent permitted by law."; - -const char* argp_program_bug_address = "<" SPOT_PACKAGE_BUGREPORT ">"; - const char argp_program_doc[] ="\ Generate random temporal logic formulas.\v\ Examples:\n\