EXAMINE: Convert another test to Autotest framework.
[pspp] / src / ui / gui / main.c
index eddf3fe3347b750844442d3e8ccbcb8a1065d4f8..0c88204ae1469347daf7b25347cb4873883f8eec 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "libpspp/argv-parser.h"
 #include "libpspp/assertion.h"
+#include "libpspp/cast.h"
 #include "libpspp/getl.h"
 #include "libpspp/version.h"
 #include "libpspp/copyleft.h"
@@ -145,7 +146,7 @@ startup_option_callback (int id, void *show_splash_)
     case OPT_VERSION:
       version_etc (stdout, "psppire", PACKAGE_NAME, PACKAGE_VERSION,
                    "Ben Pfaff", "John Darrington", "Jason Stover",
-                   (char *) NULL);
+                   NULL_SENTINEL);
       exit (EXIT_SUCCESS);
 
     case OPT_NO_SPLASH:
@@ -262,11 +263,12 @@ main (int argc, char *argv[])
       g_warning ("%s", vers);
     }
 
-  /* Let GDK remove any options that it owns. */
-  gdk_init (&argc, &argv);
 
-  /* Parse our own options. */
   ss = create_source_stream ();
+  /* Parse our own options. 
+     This must come BEFORE gdk_init otherwise options such as 
+     --help --version which ought to work without an X server, won't.
+  */
   parser = argv_parser_create ();
   argv_parser_add_options (parser, startup_options, N_STARTUP_OPTIONS,
                            startup_option_callback, &show_splash);
@@ -275,6 +277,11 @@ main (int argc, char *argv[])
     exit (EXIT_FAILURE);
   argv_parser_destroy (parser);
 
+  /* Initialise GDK.  Theoretically this call can remove options from argc,argv if
+     it thinks they are gdk options.
+     However there shouldn't be any here because of the gtk_parse_args call above. */
+  gdk_init (&argc, &argv);
+
   init_p.splash_window = create_splash_window ();
   init_p.ss = ss;
   init_p.data_file = optind < argc ? argv[optind] : NULL;