summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-04-21 09:16:48 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-28 22:35:04 -0400
commit945c45ad50ed31e3acb96fdaafb21640c4669f12 (patch)
treeae2e59ba8d3a49bbd3c3dcece39d53aef691ed44 /utils
parente5b3492f23c2296d0d8221e1787ee585331f726e (diff)
downloadhaskell-945c45ad50ed31e3acb96fdaafb21640c4669f12.tar.gz
Prefer #if defined to #ifdef
Our new CPP linter enforces this.
Diffstat (limited to 'utils')
-rw-r--r--utils/genapply/Main.hs4
-rw-r--r--utils/ghc-pkg/Main.hs10
-rw-r--r--utils/hp2ps/HpFile.c2
-rw-r--r--utils/hp2ps/Main.c2
-rw-r--r--utils/hp2ps/Main.h6
-rw-r--r--utils/lndir/lndir-Xos.h30
-rw-r--r--utils/lndir/lndir-Xosdefs.h32
-rw-r--r--utils/lndir/lndir.c40
-rw-r--r--utils/unlit/unlit.c6
9 files changed, 66 insertions, 66 deletions
diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs
index f9d6ea1e3f..90ae5d7ac0 100644
--- a/utils/genapply/Main.hs
+++ b/utils/genapply/Main.hs
@@ -257,7 +257,7 @@ stackCheck regstatus args args_in_regs fun_info_label (prof_sp, norm_sp) =
char '}'
| otherwise = empty
in
- vcat [ text "#ifdef PROFILING",
+ vcat [ text "#if defined(PROFILING)",
cmp_sp prof_sp,
text "#else",
cmp_sp norm_sp,
@@ -392,7 +392,7 @@ genMkPAP regstatus macro jump live ticker disamb
shuffle_extra_args = (doc, (shuffle_prof_stack, shuffle_norm_stack))
where
- doc = vcat [ text "#ifdef PROFILING",
+ doc = vcat [ text "#if defined(PROFILING)",
shuffle_prof_doc,
text "#else",
shuffle_norm_doc,
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index 9e18c97bc1..80ff77c24b 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -11,8 +11,8 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- We never want to link against terminfo while bootstrapping.
-#ifdef BOOTSTRAPPING
-#ifdef WITH_TERMINFO
+#if defined(BOOTSTRAPPING)
+#if defined(WITH_TERMINFO)
#undef WITH_TERMINFO
#endif
#endif
@@ -89,11 +89,11 @@ import System.Posix hiding (fdToHandle)
import qualified System.Info(os)
#endif
-#ifdef WITH_TERMINFO
+#if defined(WITH_TERMINFO)
import System.Console.Terminfo as Terminfo
#endif
-#ifdef mingw32_HOST_OS
+#if defined(mingw32_HOST_OS)
# if defined(i386_HOST_ARCH)
# define WINDOWS_CCONV stdcall
# elif defined(x86_64_HOST_ARCH)
@@ -1440,7 +1440,7 @@ listPackages verbosity my_flags mPackageName mModuleName = do
if simple_output then show_simple stack else do
-#ifndef WITH_TERMINFO
+#if !defined(WITH_TERMINFO)
mapM_ show_normal stack
#else
let
diff --git a/utils/hp2ps/HpFile.c b/utils/hp2ps/HpFile.c
index deef58201d..e21acf3f91 100644
--- a/utils/hp2ps/HpFile.c
+++ b/utils/hp2ps/HpFile.c
@@ -8,7 +8,7 @@
#include "HpFile.h"
#include "Utilities.h"
-#ifndef atof
+#if !defined(atof)
double atof PROTO((const char *));
#endif
diff --git a/utils/hp2ps/Main.c b/utils/hp2ps/Main.c
index 7731d4c8f0..a44e41c862 100644
--- a/utils/hp2ps/Main.c
+++ b/utils/hp2ps/Main.c
@@ -244,7 +244,7 @@ Fp(char *rootname, char **filename, char *suffix, char *mode)
return(OpenFile(*filename, mode));
}
-#ifdef DEBUG
+#if defined(DEBUG)
void
_stgAssert (filename, linenum)
char *filename;
diff --git a/utils/hp2ps/Main.h b/utils/hp2ps/Main.h
index b023d42656..1eea93f0a2 100644
--- a/utils/hp2ps/Main.h
+++ b/utils/hp2ps/Main.h
@@ -3,14 +3,14 @@
#include "ghcconfig.h"
#include <stdio.h>
-#ifdef __STDC__
+#if defined(__STDC__)
#define PROTO(x) x
#else
#define PROTO(x) ()
#endif
/* our own ASSERT macro (for C) */
-#ifndef DEBUG
+#if !defined(DEBUG)
#define ASSERT(predicate) /*nothing*/
#else
@@ -34,7 +34,7 @@ typedef int boolish;
/* Use "long long" if we have it: the numbers in profiles can easily
* overflow 32 bits after a few seconds execution.
*/
-#ifdef HAVE_LONG_LONG
+#if defined(HAVE_LONG_LONG)
typedef long long int intish;
#else
typedef long int intish;
diff --git a/utils/lndir/lndir-Xos.h b/utils/lndir/lndir-Xos.h
index c6d1e3652c..b423f6b641 100644
--- a/utils/lndir/lndir-Xos.h
+++ b/utils/lndir/lndir-Xos.h
@@ -29,9 +29,9 @@
* Get major data types (esp. caddr_t)
*/
-#ifdef USG
-#ifndef __TYPES__
-#ifdef CRAY
+#if defined(USG)
+#if !defined(__TYPES__)
+#if defined(CRAY)
#define word word_t
#endif /* CRAY */
#include <sys/types.h> /* forgot to protect it... */
@@ -54,12 +54,12 @@
* need to have #defines here.
*/
-#ifndef X_NOT_STDC_ENV
+#if !defined(X_NOT_STDC_ENV)
#include <string.h>
#define index strchr
#define rindex strrchr
#else
-#ifdef SYSV
+#if defined(SYSV)
#include <string.h>
#define index strchr
#define rindex strrchr
@@ -74,18 +74,18 @@
/*
* Get open(2) constants
*/
-#ifdef X_NOT_POSIX
+#if defined(X_NOT_POSIX)
#include <fcntl.h>
-#ifdef USL
+#if defined(USL)
#include <unistd.h>
#endif /* USL */
-#ifdef CRAY
+#if defined(CRAY)
#include <unistd.h>
#endif /* CRAY */
-#ifdef MOTOROLA
+#if defined(MOTOROLA)
#include <unistd.h>
#endif /* MOTOROLA */
-#ifdef SYSV386
+#if defined(SYSV386)
#include <unistd.h>
#endif /* SYSV386 */
#include <sys/file.h>
@@ -104,13 +104,13 @@
* Get struct timeval
*/
-#ifdef SYSV
+#if defined(SYSV)
-#ifndef USL
+#if !defined(USL)
#include <sys/time.h>
#endif
#include <time.h>
-#ifdef CRAY
+#if defined(CRAY)
#undef word
#endif /* CRAY */
#if defined(USG) && !defined(CRAY) && !defined(MOTOROLA)
@@ -118,7 +118,7 @@ struct timeval {
long tv_sec;
long tv_usec;
};
-#ifndef USL_SHARELIB
+#if !defined(USL_SHARELIB)
struct timezone {
int tz_minuteswest;
int tz_dsttime;
@@ -144,6 +144,6 @@ struct timezone {
#define SIGCHLD SIGCLD
#endif
-#ifdef ISC
+#if defined(ISC)
#include <sys/bsdtypes.h>
#endif
diff --git a/utils/lndir/lndir-Xosdefs.h b/utils/lndir/lndir-Xosdefs.h
index 7e232c97c5..09658937ad 100644
--- a/utils/lndir/lndir-Xosdefs.h
+++ b/utils/lndir/lndir-Xosdefs.h
@@ -34,63 +34,63 @@
* You may still have to define _POSIX_SOURCE to get it.
*/
-#ifdef NOSTDHDRS
+#if defined(NOSTDHDRS)
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
-#ifdef NeXT
+#if defined(NeXT)
#define X_NOT_POSIX
#endif
-#ifdef sony
-#ifndef SYSTYPE_SYSV
+#if defined(sony)
+#if !defined(SYSTYPE_SYSV)
#define X_NOT_POSIX
#endif
#endif
-#ifdef UTEK
+#if defined(UTEK)
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
-#ifdef CRAY
+#if defined(CRAY)
#define X_NOT_POSIX
#endif
-#ifdef vax
-#ifndef ultrix /* assume vanilla BSD */
+#if defined(vax)
+#if !defined(ultrix) /* assume vanilla BSD */
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif
-#ifdef luna
+#if defined(luna)
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
-#ifdef Mips
+#if defined(Mips)
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
-#ifdef USL
-#ifdef SYSV /* (release 3.2) */
+#if defined(USL)
+#if defined(SYSV) /* (release 3.2) */
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif
-#ifdef SYSV386
-#ifdef SYSV
+#if defined(SYSV386)
+#if defined(SYSV)
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif
-#ifdef MOTOROLA
-#ifdef SYSV
+#if defined(MOTOROLA)
+#if defined(SYSV)
#define X_NOT_STDC_ENV
#endif
#endif
diff --git a/utils/lndir/lndir.c b/utils/lndir/lndir.c
index 8269f6ec9e..87f2824166 100644
--- a/utils/lndir/lndir.c
+++ b/utils/lndir/lndir.c
@@ -52,27 +52,27 @@ in this Software without prior written authorization from the X Consortium.
#include <sys/param.h>
#include <errno.h>
-#ifndef X_NOT_POSIX
+#if !defined(X_NOT_POSIX)
#include <dirent.h>
#else
-#ifdef SYSV
+#if defined(SYSV)
#include <dirent.h>
#else
-#ifdef USG
+#if defined(USG)
#include <dirent.h>
#else
#include <sys/dir.h>
-#ifndef dirent
+#if !defined(dirent)
#define dirent direct
#endif
#endif
#endif
#endif
-#ifndef MAXPATHLEN
+#if !defined(MAXPATHLEN)
#define MAXPATHLEN 2048
#endif
-#ifdef __CYGWIN32__
+#if defined(__CYGWIN32__)
#include <sys/cygwin.h>
#endif
@@ -80,7 +80,7 @@ in this Software without prior written authorization from the X Consortium.
#include <stdarg.h>
#endif
-#ifdef X_NOT_STDC_ENV
+#if defined(X_NOT_STDC_ENV)
extern int errno;
#endif
int silent = 0; /* -silent */
@@ -92,13 +92,13 @@ char *curdir;
int force=0;
-#ifdef WIN32
+#if defined(WIN32)
#define mymkdir(X, Y) mkdir(X)
#else
#define mymkdir(X, Y) mkdir(X, Y)
#endif
-#ifndef WIN32
+#if !defined(WIN32)
#define SYMLINKS
#define BELIEVE_ST_NLINK
#endif
@@ -177,7 +177,7 @@ int copyfile(const char *oldpath, const char *newpath) {
ssize_t s;
char buf[BUFSIZE];
-#ifdef SYMLINKS
+#if defined(SYMLINKS)
if (copy == 0) {
return symlink(oldpath, newpath);
} else {
@@ -217,7 +217,7 @@ int copyfile(const char *oldpath, const char *newpath) {
}
fclose(f_old);
return 0;
-#ifdef SYMLINKS
+#if defined(SYMLINKS)
}
#endif
}
@@ -289,7 +289,7 @@ int rel; /* if true, prepend "../" to fn before using */
strcpy (p, dp->d_name);
if (
-#ifdef BELIEVE_ST_NLINK
+#if defined(BELIEVE_ST_NLINK)
n_dirs > 0
#else
/* st_nlink is 1 on Windows, so we have to keep looking for
@@ -302,14 +302,14 @@ int rel; /* if true, prepend "../" to fn before using */
continue;
}
-#ifdef S_ISDIR
+#if defined(S_ISDIR)
if(S_ISDIR(sb.st_mode))
#else
if (sb.st_mode & S_IFDIR)
#endif
{
/* directory */
-#ifndef __CYGWIN32__ /* don't trust cygwin's n_dirs count */
+#if !defined(__CYGWIN32__) /* don't trust cygwin's n_dirs count */
n_dirs--;
#endif
if (dp->d_name[0] == '.' &&
@@ -343,7 +343,7 @@ int rel; /* if true, prepend "../" to fn before using */
continue;
}
}
-#ifdef SYMLINKS
+#if defined(SYMLINKS)
if (readlink (dp->d_name, symbuf, sizeof(symbuf) - 1) >= 0) {
msg ("%s: is a link instead of a directory", dp->d_name);
curdir = rcurdir = ocurdir;
@@ -365,7 +365,7 @@ int rel; /* if true, prepend "../" to fn before using */
}
/* non-directory */
-#ifdef SYMLINKS
+#if defined(SYMLINKS)
symlen = readlink (dp->d_name, symbuf, sizeof(symbuf) - 1);
if (symlen >= 0)
symbuf[symlen] = '\0';
@@ -409,7 +409,7 @@ char **av;
char *prog_name = av[0];
char* tn;
struct stat fs, ts;
-#ifdef __CYGWIN32__
+#if defined(__CYGWIN32__)
/*
The lndir code assumes unix-style paths to work. cygwin
lets you get away with using dos'ish paths (e.g., "f:/oo")
@@ -442,7 +442,7 @@ char **av;
quit (1, "usage: %s [-f] [-silent] [-ignorelinks] fromdir [todir]",
prog_name);
-#ifdef __CYGWIN32__
+#if defined(__CYGWIN32__)
cygwin_conv_to_full_posix_path(av[0], fn);
#else
fn = av[0];
@@ -460,7 +460,7 @@ char **av;
}
else {
quiterr (1, tn);
-#ifdef S_ISDIR
+#if defined(S_ISDIR)
if (!(S_ISDIR(ts.st_mode)))
#else
if (!(ts.st_mode & S_IFDIR))
@@ -474,7 +474,7 @@ char **av;
/* from directory */
if (stat (fn, &fs) < 0)
quiterr (1, fn);
-#ifdef S_ISDIR
+#if defined(S_ISDIR)
if (!(S_ISDIR(fs.st_mode)))
#else
if (!(fs.st_mode & S_IFDIR))
diff --git a/utils/unlit/unlit.c b/utils/unlit/unlit.c
index 9a697eba95..4eb91d71be 100644
--- a/utils/unlit/unlit.c
+++ b/utils/unlit/unlit.c
@@ -61,7 +61,7 @@
#define LENBEGINCODE 12
#define ENDCODE "\\end{code}"
#define LENENDCODE 10
-#ifdef PSEUDOCODE
+#if defined(PSEUDOCODE)
/* According to Will Partain, the inventor of pseudocode, this gone now. */
#define MISSINGENDPSEUDOCODE "unlit: missing \\end{pseudocode}\n"
#define BEGINPSEUDOCODE "\\begin{pseudocode}"
@@ -227,7 +227,7 @@ static line readline(FILE *istream, FILE *ostream) {
return BEGIN;
if (strcmp(buf, ENDCODE) == 0)
return END;
-#ifdef PSEUDOCODE
+#if defined(PSEUDOCODE)
else if (strcmp(buf, BEGINPSEUDOCODE) == 0)
return PSEUDO;
#endif
@@ -280,7 +280,7 @@ static void unlit(char *file, FILE *istream, FILE *ostream)
}
defnsread++;
}
-#ifdef PSEUDOCODE
+#if defined(PSEUDOCODE)
if (this == PSEUDO) {
char lineb[1000];
for(;;) {