[Spice-devel] [PATCH 1/2] generator, fix binary name

Christophe Fergeau cfergeau at redhat.com
Tue Jul 10 06:52:05 PDT 2012


On Tue, Jul 10, 2012 at 02:33:24PM +0200, Peter Hatina wrote:
> Another try.
> 
> Peter Hatina
> EMEA ENG-Desktop Development
> Red Hat Czech, Brno
> 
> ---
>  generator/Makefile.am |    2 +-
>  generator/options.cpp |    6 ++++--
>  generator/options.h   |    1 +
>  3 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/generator/Makefile.am b/generator/Makefile.am
> index b6a01f2..ce7f42c 100644
> --- a/generator/Makefile.am
> +++ b/generator/Makefile.am
> @@ -1,4 +1,4 @@
> -bin_PROGRAMS                = spice_xpi_generator
> +bin_PROGRAMS                = spice-xpi-generator
>  spice_xpi_generator_SOURCES =      \
>  		generator.cpp      \
>  		main.cpp           \
> diff --git a/generator/options.cpp b/generator/options.cpp
> index 723ca7e..806c721 100644
> --- a/generator/options.cpp
> +++ b/generator/options.cpp
> @@ -18,6 +18,7 @@
>  #include <iostream>
>  extern "C" {
>  #  include <getopt.h>
> +#  include <libgen.h>

I'd go with the GNU version of basename, the fact that the one from
libgen.h is modifying its argument is a bit worrisome (see man 3 basename).

Looks good otherwise.

Christophe

>  }
>  #include "options.h"
>  
> @@ -25,7 +26,8 @@ Options::Options(int argc, char **argv):
>      m_help(false),
>      m_good(true),
>      m_input_filename(),
> -    m_output_filename()
> +    m_output_filename(),
> +    m_bin_name(argv && argv[0] ? basename(argv[0]) : "spice-xpi-generator")
>  {
>      static struct option longopts[] = {
>          { "input",  required_argument, NULL, 'i' },
> @@ -60,7 +62,7 @@ Options::~Options()
>  void Options::printHelp() const
>  {
>      std::cout << "Spice-xpi test page generator\n\n"
> -              << "Usage: ./generator [-h] [-i input] [-o output]\n\n"
> +              << "Usage: " << m_bin_name << " [-h] [-i input] [-o output]\n\n"
>                << "Application options:\n"
>                << "  -i, --input     input filename (stdin used, if not specified)\n"
>                << "  -o, --output    output filename (stdout used, if not specified)\n"
> diff --git a/generator/options.h b/generator/options.h
> index 7c990e5..dfac369 100644
> --- a/generator/options.h
> +++ b/generator/options.h
> @@ -37,6 +37,7 @@ private:
>      bool m_good;
>      std::string m_input_filename;
>      std::string m_output_filename;
> +    const std::string m_bin_name;
>  };
>  
>  #endif // OPTIONS_H
> -- 
> 1.7.10.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120710/9bcf94eb/attachment-0001.pgp>


More information about the Spice-devel mailing list