From: Nick Bowler Date: Tue, 11 Feb 2020 01:37:12 +0000 (-0500) Subject: Improve --version output. X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/commitdiff_plain/268cd12f990b95d82d00e639288563c6c6ce9452 Improve --version output. A program's version text, when requested by the user, is not an error message. Kind of silly to direct it to the standard error stream. Adjust the program so that version text goes to standard output, and format the message to be consistent with the GNU coding standards. --- diff --git a/configure.ac b/configure.ac index 3632fb1..0fd20f7 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ dnl License GPLv2+: GNU General Public License version 2 or any later version. dnl This is free software: you are free to change and redistribute it. dnl There is NO WARRANTY, to the extent permitted by law. -AC_INIT([gob-dx], [2.0.20a], [nbowler@draconx.ca]) +AC_INIT([GObject Builder], [2.0.20a], [nbowler@draconx.ca], [gob-dx]) AC_CONFIG_SRCDIR([src/treefuncs.def]) AC_CONFIG_HEADERS([config.h]) diff --git a/src/main.c b/src/main.c index 60c128a..b0e7505 100644 --- a/src/main.c +++ b/src/main.c @@ -4520,6 +4520,18 @@ generate_outfiles(void) print_header_postfixes(); } +static void print_version(void) +{ + printf("%s (%s) %s\n", PACKAGE_NAME, PACKAGE_TARNAME, PACKAGE_VERSION); + putchar('\n'); + puts("Copyright (C) 2013 George (Jiri) Lebl et al."); + puts("Copyright (C) 2020 Nick Bowler"); + puts("License GPLv2+: GNU GPL version 2 or later ."); + puts("This is free software: you are free to change and redistribute it."); + puts("There is NO WARRANTY, to the extent permitted by law."); + +} + static void print_usage(FILE *f) { fprintf(f, "Usage: %s [options] file.gob\n", g_get_prgname()); @@ -4644,7 +4656,7 @@ parse_options(int argc, char *argv[]) print_help(); exit(0); } else if(strcmp(argv[i], "--version")==0) { - fprintf(stderr, "Gob version %s\n", VERSION); + print_version(); exit(0); } else if(strcmp(argv[i], "--exit-on-warn")==0) { exit_on_warn = TRUE; diff --git a/tests/options.at b/tests/options.at index 22e9609..30be9e2 100644 --- a/tests/options.at +++ b/tests/options.at @@ -17,8 +17,6 @@ dnl standard output, and contains the correct version number. AT_SETUP([--version option]) AT_KEYWORDS([option])dnl -# Currently prints to standard error :( -AT_XFAIL_IF([:]) AT_CHECK([gob2 invalid-file.gob --version --invalid-option], [0], [stdout]) AT_CHECK([awk 'NR == 1 { print $NF }' stdout], [0], [AT_PACKAGE_VERSION ])