Commit 489f719d authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

bin: factor the calls to set_program_name().

* src/bin/common_setup.cc, src/bin/common_setup.hh: New files.
* src/bin/Makefile.am: Add them.
* src/bin/genltl.cc, src/bin/ltl2tgba.cc, src/bin/ltl2tgta.cc,
src/bin/ltlfilt.cc, src/bin/randltl.cc: Adjust.
parent ecca4ba5
......@@ -40,6 +40,8 @@ libcommon_a_SOURCES = \
common_range.hh \
common_r.cc \
common_r.hh \
common_setup.cc \
common_setup.hh \
common_sys.hh
bin_PROGRAMS = ltlfilt genltl randltl ltl2tgba ltl2tgta
......
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "common_setup.hh"
void
setup(char** argv)
{
// Simplify the program name, because argp() uses it to report
// errors and display help text.
set_program_name(argv[0]);
argv[0] = const_cast<char*>(program_name);
}
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef SPOT_BIN_COMMON_SETUP_HH
#define SPOT_BIN_COMMON_SETUP_HH
#include "common_sys.hh"
#include "progname.h"
void setup(char** progname);
#endif // SPOT_BIN_COMMON_SETUP_HH
......@@ -74,10 +74,10 @@
#include <fstream>
#include <argp.h>
#include <cstdlib>
#include "progname.h"
#include "error.h"
#include <vector>
#include "common_setup.hh"
#include "common_output.hh"
#include "common_range.hh"
......@@ -201,16 +201,6 @@ const struct argp_child children[] =
{ 0, 0, 0, 0 }
};
// static int
// to_int(const char* s)
// {
// char* endptr;
// int res = strtol(s, &endptr, 10);
// if (*endptr)
// error(2, 0, "failed to parse '%s' as an integer.", s);
// return res;
// }
static void
enqueue_job(int pattern, const char* range_str)
{
......@@ -858,10 +848,7 @@ run_jobs()
int
main(int argc, char** argv)
{
set_program_name(argv[0]);
// Simplify the program name, because argp() uses it to report errors
// and display help text.
argv[0] = const_cast<char*>(program_name);
setup(argv);
const argp ap = { options, parse_opt, 0, argp_program_doc,
children, 0, 0 };
......
......@@ -25,9 +25,9 @@
#include <iostream>
#include <argp.h>
#include "progname.h"
#include "error.h"
#include "common_setup.hh"
#include "common_r.hh"
#include "common_cout.hh"
#include "common_finput.hh"
......@@ -246,10 +246,7 @@ namespace
int
main(int argc, char** argv)
{
set_program_name(argv[0]);
// Simplify the program name, because argp() uses it to report errors
// and display help text.
argv[0] = const_cast<char*>(program_name);
setup(argv);
const argp ap = { options, parse_opt, "[FORMULA...]",
argp_program_doc, children, 0, 0 };
......
......@@ -26,9 +26,9 @@
#include <fstream>
#include <argp.h>
#include "progname.h"
#include "error.h"
#include "common_setup.hh"
#include "common_r.hh"
#include "common_cout.hh"
#include "common_finput.hh"
......@@ -251,10 +251,7 @@ namespace
int
main(int argc, char** argv)
{
set_program_name(argv[0]);
// Simplify the program name, because argp() uses it to report errors
// and display help text.
argv[0] = const_cast<char*>(program_name);
setup(argv);
const argp ap = { options, parse_opt, "[FORMULA...]",
argp_program_doc, children, 0, 0 };
......
......@@ -27,9 +27,9 @@
#include <fstream>
#include <argp.h>
#include <cstring>
#include "progname.h"
#include "error.h"
#include "common_setup.hh"
#include "common_finput.hh"
#include "common_output.hh"
#include "common_cout.hh"
......@@ -501,10 +501,7 @@ namespace
int
main(int argc, char** argv)
{
set_program_name(argv[0]);
// Simplify the program name, because argp() uses it to report errors
// and display help text.
argv[0] = const_cast<char*>(program_name);
setup(argv);
const argp ap = { options, parse_opt, "[FILENAME...]",
argp_program_doc, children, 0, 0 };
......
......@@ -26,9 +26,9 @@
#include <argp.h>
#include <cstdlib>
#include <iterator>
#include "progname.h"
#include "error.h"
#include "common_setup.hh"
#include "common_output.hh"
#include "common_range.hh"
#include "common_r.hh"
......@@ -252,10 +252,7 @@ parse_opt(int key, char* arg, struct argp_state*)
int
main(int argc, char** argv)
{
set_program_name(argv[0]);
// Simplify the program name, because argp() uses it to report errors
// and display help text.
argv[0] = const_cast<char*>(program_name);
setup(argv);
const argp ap = { options, parse_opt, "PROP...", argp_program_doc,
children, 0, 0 };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment