Conditional Compilation per GCS 3.5
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 4 Jul 2020 06:38:33 +0000 (08:38 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 4 Jul 2020 06:38:29 +0000 (08:38 +0200)
Deal with conditional compilation using the way recommended by
the GNU Coding Standards Section 3.5

https://www.gnu.org/prep/standards/html_node/Conditional-Compilation.html#Conditional-Compilation

src/ui/gui/main.c

index 51d225765c12796d21cdaf1aff7f8f02dc5a8eea..ecb07f83ff378fb6c2c725220396642a68b551f5 100644 (file)
@@ -1,5 +1,6 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2004, 2005, 2006, 2010, 2011, 2012, 2013, 2014, 2015, 2016  Free Software Foundation
+   Copyright (C) 2004, 2005, 2006, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+   2020 Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include <gtk/gtk.h>
 #include <stdlib.h>
-#if ENABLE_RELOCATABLE && defined(__APPLE__)
 #include <sys/stat.h>
+#include <sys/resource.h>
+#if ENABLE_RELOCATABLE && defined(__APPLE__)
+static const bool apple_relocatable = true;
+#else
+static const bool apple_relocatable = false;
 #endif
 
 #include "language/lexer/include-path.h"
@@ -317,7 +322,6 @@ process_pre_start_arguments (int *argc, char ***argv)
   g_option_context_free (oc);
 }
 
-#if ENABLE_RELOCATABLE && defined(__APPLE__)
 static void
 pspp_macos_setenv (const char * progname)
 {
@@ -374,30 +378,29 @@ pspp_macos_setenv (const char * progname)
         }
     }
 }
-#endif
 
 int
 main (int argc, char *argv[])
 {
-
-#if ENABLE_RELOCATABLE && defined(__APPLE__)
-  /* remove MacOS session identifier from the command line args */
-  gint newargc = 0;
-  for (gint i = 0; i < argc; i++)
+  if (apple_relocatable)
     {
-      if (!g_str_has_prefix (argv[i], "-psn_"))
+      /* remove MacOS session identifier from the command line args */
+      gint newargc = 0;
+      for (gint i = 0; i < argc; i++)
         {
-          argv[newargc] = argv[i];
-          newargc++;
+          if (!g_str_has_prefix (argv[i], "-psn_"))
+            {
+              argv[newargc] = argv[i];
+              newargc++;
+            }
         }
+      if (argc > newargc)
+        {
+          argv[newargc] = NULL; /* glib expects NULL terminated array */
+          argc = newargc;
+        }
+      pspp_macos_setenv (argv[0]);
     }
-  if (argc > newargc)
-    {
-      argv[newargc] = NULL; /* glib expects NULL terminated array */
-      argc = newargc;
-    }
-  pspp_macos_setenv (argv[0]);
-#endif
 
   set_program_name (argv[0]);