From a172a8fc969de7dbc9c6d242eac487f43c75a273 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sat, 6 Apr 2002 09:14:09 +0000 Subject: [PATCH] Switched from #ifdef to #if defined. --- src/xpdev/dirwrap.c | 46 ++++++++++++++++++++++---------------------- src/xpdev/dirwrap.h | 29 +++++++++++++--------------- src/xpdev/filewrap.h | 18 ++++++++--------- src/xpdev/gen_defs.h | 8 ++++---- src/xpdev/genwrap.c | 19 +++++++++--------- src/xpdev/genwrap.h | 20 +++++++++---------- src/xpdev/sockwrap.h | 2 +- 7 files changed, 69 insertions(+), 73 deletions(-) diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index 40daea2c6a..a785204c6d 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -37,28 +37,28 @@ #include <string.h> /* strrchr */ -#ifdef _WIN32 +#if defined(_WIN32) -#include <windows.h> /* WINAPI, etc */ -#include <io.h> /* _findfirst */ + #include <windows.h> /* WINAPI, etc */ + #include <io.h> /* _findfirst */ #elif defined __unix__ -#include <unistd.h> /* usleep */ -#include <fcntl.h> /* O_NOCCTY */ -#include <ctype.h> /* toupper */ + #include <unistd.h> /* usleep */ + #include <fcntl.h> /* O_NOCCTY */ + #include <ctype.h> /* toupper */ -#ifdef __FreeBSD__ -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/kbio.h> -#endif + #if defined(__FreeBSD__) + #include <sys/param.h> + #include <sys/mount.h> + #include <sys/kbio.h> + #endif -#include <sys/ioctl.h> /* ioctl */ + #include <sys/ioctl.h> /* ioctl */ -#ifdef __GLIBC__ /* actually, BSD, but will work for now */ -#include <sys/vfs.h> /* statfs() */ -#endif + #if defined(__GLIBC__) /* actually, BSD, but will work for now */ + #include <sys/vfs.h> /* statfs() */ + #endif #endif /* __unix__ */ @@ -99,7 +99,7 @@ static int glob_compare( const void *arg1, const void *arg2 ) return stricmp( * ( char** ) arg1, * ( char** ) arg2 ); } -#ifdef __BORLANDC__ +#if defined(__BORLANDC__) #pragma argsused #endif @@ -256,7 +256,7 @@ time_t DLLCALL fdate(char *filename) /****************************************************************************/ long DLLCALL flength(char *filename) { -#ifdef __BORLANDC__ /* stat() doesn't work right */ +#if defined(__BORLANDC__) /* stat() doesn't work right */ long handle; struct _finddata_t f; @@ -293,7 +293,7 @@ long DLLCALL flength(char *filename) /****************************************************************************/ BOOL DLLCALL fexist(char *filespec) { -#ifdef _WIN32 +#if defined(_WIN32) long handle; struct _finddata_t f; @@ -369,7 +369,7 @@ BOOL DLLCALL isdir(char *filename) /****************************************************************************/ int DLLCALL getfattr(char* filename) { -#ifdef _WIN32 +#if defined(_WIN32) long handle; struct _finddata_t finddata; @@ -394,14 +394,14 @@ int DLLCALL getfattr(char* filename) /****************************************************************************/ /* Return free disk space in bytes (up to a maximum of 4GB) */ /****************************************************************************/ -#ifdef _WIN32 +#if defined(_WIN32) typedef BOOL(WINAPI * GetDiskFreeSpaceEx_t) (LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER); #endif ulong DLLCALL getfreediskspace(char* path) { -#ifdef _WIN32 +#if defined(_WIN32) char root[16]; DWORD TotalNumberOfClusters; DWORD NumberOfFreeClusters; @@ -424,14 +424,14 @@ ulong DLLCALL getfreediskspace(char* path) &size, // receives the number of bytes on disk NULL)) // receives the free bytes on disk return(0); -#ifdef _ANONYMOUS_STRUCT +#if defined(_ANONYMOUS_STRUCT) if(avail.HighPart) #else if(avail.u.HighPart) #endif return(0xffffffff); /* 4GB max */ -#ifdef _ANONYMOUS_STRUCT +#if defined(_ANONYMOUS_STRUCT) return(avail.LowPart); #else return(avail.u.LowPart); diff --git a/src/xpdev/dirwrap.h b/src/xpdev/dirwrap.h index 65cf1cc2af..d63f998961 100644 --- a/src/xpdev/dirwrap.h +++ b/src/xpdev/dirwrap.h @@ -40,20 +40,20 @@ #include "gen_defs.h" /* ulong */ -#ifdef DLLEXPORT -#undef DLLEXPORT +#if defined(DLLEXPORT) + #undef DLLEXPORT #endif -#ifdef DLLCALL -#undef DLLCALL +#if defined(DLLCALL) + #undef DLLCALL #endif -#ifdef _WIN32 - #ifdef WRAPPER_DLL +#if defined(_WIN32) + #if defined(WRAPPER_DLL) #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT __declspec(dllimport) #endif - #ifdef __BORLANDC__ + #if defined(__BORLANDC__) #define DLLCALL __stdcall #else #define DLLCALL @@ -63,21 +63,15 @@ #define DLLCALL #endif -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif -#ifdef _MSC_VER - #include "msdirent.h" -#else - #include <dirent.h> /* POSIX directory functions */ -#endif - /****************/ /* RTL-specific */ /****************/ -#ifdef __unix__ +#if defined(__unix__) #define ALLFILES "*" /* matches all files in a directory */ #include <glob.h> /* POSIX.2 directory pattern matching function */ @@ -159,8 +153,11 @@ extern "C" { struct dirent * readdir (DIR *__dir); int closedir (DIR *__dir); void rewinddir(DIR *__dir); +#else + #include <dirent.h> /* POSIX directory functions */ #endif + /**********/ /* Macros */ /**********/ @@ -205,7 +202,7 @@ DLLEXPORT char* DLLCALL getfname(char* path); DLLEXPORT int DLLCALL getfattr(char* filename); DLLEXPORT ulong DLLCALL getfreediskspace(char* path); -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/src/xpdev/filewrap.h b/src/xpdev/filewrap.h index 4e8088f561..390d0405ea 100644 --- a/src/xpdev/filewrap.h +++ b/src/xpdev/filewrap.h @@ -82,20 +82,20 @@ /* Prototypes */ /**************/ -#ifdef DLLEXPORT -#undef DLLEXPORT +#if defined(DLLEXPORT) + #undef DLLEXPORT #endif -#ifdef DLLCALL -#undef DLLCALL +#if defined(DLLCALL) + #undef DLLCALL #endif -#ifdef _WIN32 - #ifdef WRAPPER_DLL +#if defined(_WIN32) + #if defined(WRAPPER_DLL) #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT __declspec(dllimport) #endif - #ifdef __BORLANDC__ + #if defined(__BORLANDC__) #define DLLCALL __stdcall #else #define DLLCALL @@ -105,7 +105,7 @@ #define DLLCALL #endif -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif @@ -121,7 +121,7 @@ extern "C" { DLLEXPORT time_t DLLCALL filetime(int fd); -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/src/xpdev/gen_defs.h b/src/xpdev/gen_defs.h index 2d110968e4..5a7b1a1e84 100644 --- a/src/xpdev/gen_defs.h +++ b/src/xpdev/gen_defs.h @@ -38,9 +38,9 @@ #ifndef _GEN_DEFS_H #define _GEN_DEFS_H -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN /* Don't bring in excess baggage */ -#include <windows.h> +#if defined(_WIN32) + #define WIN32_LEAN_AND_MEAN /* Don't bring in excess baggage */ + #include <windows.h> #endif #include <sys/types.h> @@ -88,7 +88,7 @@ enum { }; #ifndef MAX_PATH - #ifdef MAXPATHLEN + #if defined MAXPATHLEN #define MAX_PATH MAXPATHLEN /* clib.h */ #elif defined PATH_MAX #define MAX_PATH PATH_MAX diff --git a/src/xpdev/genwrap.c b/src/xpdev/genwrap.c index 3cb19521c9..0058a327f5 100644 --- a/src/xpdev/genwrap.c +++ b/src/xpdev/genwrap.c @@ -39,13 +39,12 @@ #include <stdlib.h> /* RAND_MAX */ #include <fcntl.h> /* O_NOCTTY */ -#ifdef __unix__ -#ifndef __FreeBSD__ -#include <sys/kd.h> /* KIOCSOUND */ -#endif -#ifdef __FreeBSD__ -#include <sys/kbio.h> -#endif +#if defined(__unix__) + /* KIOCSOUND */ + #if defined(__FreeBSD__) + #include <sys/kbio.h> + #else + #include <sys/kd.h> #endif /* __unix__ */ #include "genwrap.h" /* Verify prototypes */ @@ -53,7 +52,7 @@ /****************************************************************************/ /* Convert ASCIIZ string to upper case */ /****************************************************************************/ -#ifdef __unix__ +#if defined(__unix__) char* DLLCALL strupr(char* str) { char* p=str; @@ -95,7 +94,7 @@ char* strrev(char* str) /* Generate a tone at specified frequency for specified milliseconds */ /* Thanks to Casey Martin for this code */ /****************************************************************************/ -#ifdef __unix__ +#if defined(__unix__) void DLLCALL unix_beep(int freq, int dur) { static int console_fd=-1; @@ -114,7 +113,7 @@ void DLLCALL unix_beep(int freq, int dur) /****************************************************************************/ /* Return random number between 0 and n-1 */ /****************************************************************************/ -#ifndef __BORLANDC__ +#if !defined(__BORLANDC__j) int DLLCALL xp_random(int n) { float f; diff --git a/src/xpdev/genwrap.h b/src/xpdev/genwrap.h index 26c023de84..14d45cf427 100644 --- a/src/xpdev/genwrap.h +++ b/src/xpdev/genwrap.h @@ -41,20 +41,20 @@ #include <stdio.h> /* sprintf */ #include "gen_defs.h" /* ulong */ -#ifdef DLLEXPORT -#undef DLLEXPORT +#if defined(DLLEXPORT) + #undef DLLEXPORT #endif -#ifdef DLLCALL -#undef DLLCALL +#if defined(DLLCALL) + #undef DLLCALL #endif -#ifdef _WIN32 - #ifdef WRAPPER_DLL +#if defined(_WIN32) + #if defined(WRAPPER_DLL) #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT __declspec(dllimport) #endif - #ifdef __BORLANDC__ + #if defined(__BORLANDC__) #define DLLCALL __stdcall #else #define DLLCALL @@ -64,7 +64,7 @@ #define DLLCALL #endif -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif @@ -167,11 +167,11 @@ extern "C" { #endif -#ifdef __BORLANDC__ +#if defined(__BORLANDC__) #define xp_random random #endif -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/src/xpdev/sockwrap.h b/src/xpdev/sockwrap.h index 84e0132a53..94bb07a7a3 100644 --- a/src/xpdev/sockwrap.h +++ b/src/xpdev/sockwrap.h @@ -68,7 +68,7 @@ /**********************************/ /* Socket Implementation-specific */ /**********************************/ -#ifdef _WINSOCKAPI_ +#if defined(_WINSOCKAPI_) #undef EINTR #define EINTR (WSAEINTR-WSABASEERR) -- GitLab