From 0efccfc12fb16b8eb5a6c05bd087f38567e9a50b Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Sat, 10 Feb 2007 18:58:10 +0000 Subject: [PATCH] Initialize variables; detect/report errors during gnucash command-line options parsing. Formatting. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15554 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/bin/gnucash-bin.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/bin/gnucash-bin.c b/src/bin/gnucash-bin.c index 69e12e23ac..52fa6c0666 100644 --- a/src/bin/gnucash-bin.c +++ b/src/bin/gnucash-bin.c @@ -66,13 +66,12 @@ static int is_development_version = FALSE; #endif /* Command-line option variables */ -static int gnucash_show_version; -static const char *add_quotes_file; -static int nofile; -static const char *file_to_load; -// static int loglevel; -static gchar **log_flags; -static gchar *log_to_filename; +static int gnucash_show_version = 0; +static const char *add_quotes_file = NULL; +static int nofile = 0; +static const char *file_to_load = NULL; +static gchar **log_flags = NULL; +static gchar *log_to_filename = NULL; static void gnc_print_unstable_message(void) @@ -263,24 +262,33 @@ gnucash_command_line(int *argc, char **argv) context = g_option_context_new (" [datafile]"); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (FALSE)); - g_option_context_parse (context, argc, &argv, &error); + if (!g_option_context_parse (context, argc, &argv, &error)) + { + g_error("error parsing command line args: %s", error->message); + } g_option_context_free (context); + if (error) + g_error_free(error); if (*argc > 0) file_to_load = argv[1]; if (gnucash_show_version) { if (is_development_version) - /* Translators: %s is the version number */ - g_print(_("GnuCash %s development version"), VERSION); - else - /* Translators: %s is the version number */ - g_print(_("GnuCash %s"), VERSION); - g_print("\n"); - /* Translators: 1st %s is the build date; 2nd %s is the SVN - revision number */ + { + /* Translators: %s is the version number */ + g_print(_("GnuCash %s development version"), VERSION); + } + else + { + /* Translators: %s is the version number */ + g_print(_("GnuCash %s"), VERSION); + } + g_print("\n"); + /* Translators: 1st %s is the build date; 2nd %s is the SVN + revision number */ g_print(_("Built %s from r%s"), GNUCASH_BUILD_DATE, GNUCASH_SVN_REV); - g_print("\n"); + g_print("\n"); exit(0); }