cast: New macro NULL_SENTINEL. 20100924040502/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 24 Sep 2010 03:18:01 +0000 (20:18 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 24 Sep 2010 03:18:01 +0000 (20:18 -0700)
src/libpspp/cast.h
src/output/ascii.c
src/output/options.c
src/ui/gui/main.c
src/ui/terminal/terminal-opts.c

index 5c64fac864a8e1eb78588dcc7558177d759ce0e1..00e42d6603cc68963f498c6d5ce0ab780c1b19f6 100644 (file)
         (CHECK_POINTER_COMPATIBILITY (&((STRUCT *) 0)->MEMBER, POINTER), \
          (STRUCT *) ((char *) (POINTER) - offsetof (STRUCT, MEMBER)))
 
+/* A null pointer constant suitable for use in a varargs parameter list.
+
+   This is useful because a literal 0 may not have the same width as a null
+   pointer.  NULL by itself is also insufficient because in C it may expand to
+   simply 0. */
+#define NULL_SENTINEL ((void *) NULL)
+
 #endif /* libpspp/cast.h */
index 12cde8e5f2f8b18722d1fd0bc0988896900cac69..c9f96b21b58cbd287d2d41152e572ee6a658bd7d 100644 (file)
 #include <stdint.h>
 #include <stdlib.h>
 
-#include <data/file-name.h>
-#include <data/settings.h>
-#include <libpspp/assertion.h>
-#include <libpspp/compiler.h>
-#include <libpspp/message.h>
-#include <libpspp/start-date.h>
-#include <libpspp/string-map.h>
-#include <libpspp/version.h>
-#include <output/cairo.h>
-#include <output/chart-item-provider.h>
-#include <output/message-item.h>
-#include <output/options.h>
-#include <output/tab.h>
-#include <output/text-item.h>
-#include <output/driver-provider.h>
-#include <output/render.h>
-#include <output/table-item.h>
-
-#include "error.h"
-#include "minmax.h"
-#include "xalloc.h"
+#include "data/file-name.h"
+#include "data/settings.h"
+#include "libpspp/assertion.h"
+#include "libpspp/cast.h"
+#include "libpspp/compiler.h"
+#include "libpspp/message.h"
+#include "libpspp/start-date.h"
+#include "libpspp/string-map.h"
+#include "libpspp/version.h"
+#include "output/cairo.h"
+#include "output/chart-item-provider.h"
+#include "output/driver-provider.h"
+#include "output/message-item.h"
+#include "output/options.h"
+#include "output/render.h"
+#include "output/tab.h"
+#include "output/table-item.h"
+#include "output/text-item.h"
+
+#include "gl/error.h"
+#include "gl/minmax.h"
+#include "gl/xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -184,7 +185,7 @@ ascii_create (const char *file_name, enum settings_output_devices device_type,
                             "bold", EMPH_BOLD,
                             "underline", EMPH_UNDERLINE,
                             "none", EMPH_NONE,
-                            NULL);
+                            NULL_SENTINEL);
 
   a->chart_file_name = parse_chart_file_name (opt (d, o, "charts", file_name));
 
index e0259f0936246e9f5f49a184de9239176eaf57e6..694ffc233ebe86aea4b5ba4bcf2b12e4a54f4929 100644 (file)
@@ -145,7 +145,7 @@ parse_boolean (struct driver_option *o)
    O has no user-specified value, then O's default value is treated the same
    way.  If the default value still does not match, parse_enum() returns 0.
 
-   Example: parse_enum (o, "a", 1, "b", 2, NULL) returns 1 if O's
+   Example: parse_enum (o, "a", 1, "b", 2, NULL_SENTINEL) returns 1 if O's
    value if "a", 2 if O's value is "b".
 
    Destroys O. */
index a78d248aeb38e0301e8706455e4767f0856a9255..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",
-                   NULL);
+                   NULL_SENTINEL);
       exit (EXIT_SUCCESS);
 
     case OPT_NO_SPLASH:
index 929fd3878defb8c4f0a02b3f70982d1cc4ec7c8c..d885cd0ef627a0b400c0c911d671a8d8f440dcad 100644 (file)
@@ -28,6 +28,7 @@
 #include "language/syntax-file.h"
 #include "libpspp/argv-parser.h"
 #include "libpspp/assertion.h"
+#include "libpspp/cast.h"
 #include "libpspp/compiler.h"
 #include "libpspp/getl.h"
 #include "libpspp/llx.h"
@@ -273,7 +274,7 @@ terminal_option_callback (int id, void *to_)
     case OPT_VERSION:
       version_etc (stdout, "pspp", PACKAGE_NAME, PACKAGE_VERSION,
                    "Ben Pfaff", "John Darrington", "Jason Stover",
-                   NULL);
+                   NULL_SENTINEL);
       exit (EXIT_SUCCESS);
 
     default: