Tidied win32 stuff

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4237 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-05-11 09:21:38 +00:00
parent 7adcc6d423
commit 76595f8207
16 changed files with 104 additions and 51 deletions

View file

@ -1,3 +1,24 @@
Tue May 11 10:40:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/include/preface.h: Attempt to standardise win32 conditional
compilation by using __WIN32__ throughout.
* NSDate.m: Standardize win32 stuff using __WIN32__
Open files with "rb" or "wb" only for winw3.
* NSFileManager.m: Standardize win32 stuff using __WIN32__
* NSHost.m: Standardize win32 stuff using __WIN32__
* NSLog.m: Standardize win32 stuff using __WIN32__
* NSProcessInfo.m: Standardize win32 stuff using __WIN32__
* NSString.m: Standardize win32 stuff using __WIN32__
* NSTask.m: Standardize win32 stuff using __WIN32__
* NSThread.m: Standardize win32 stuff using __WIN32__
* NSUser.m: Standardize win32 stuff using __WIN32__
* NSUserDefaults.m: Standardize win32 stuff using __WIN32__
* Time.m: Standardize win32 stuff using __WIN32__
* UnixFileHandle.m: Standardize win32 stuff using __WIN32__
* NSData.m: Standardize win32 stuff using __WIN32__
* NSTimeZone.m: Standardize win32 stuff using __WIN32__
Open files with "rb" or "wb" only for winw3.
Mon May 10 8:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSString.m: ([-rangeOfComposedCharacterSequenceAtIndex:])

View file

@ -29,7 +29,13 @@
#include <base/objc-gnu2next.h>
#include <base/fake-main.h>
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__) || defined(_WIN32) || defined(__MS_WIN32__)
#ifndef __WIN32__
#define __WIN32__
#endif
#endif
#if defined(__WIN32__)
#include <windows.h>
#define GNUSTEP_BASE_SOCKET_MESSAGE (WM_USER + 1)
#endif

View file

@ -124,7 +124,11 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len, NSZone* zone)
NSLog(@"Open (%s) attempt failed - bad path", thePath);
return NO;
}
#if defined(__WIN32__)
theFile = fopen(thePath, "rb");
#else
theFile = fopen(thePath, "r");
#endif
if (theFile == NULL) /* We failed to open the file. */
{
@ -522,7 +526,11 @@ failure:
else
{
strcpy(thePath, theRealPath);
#if defined(__WIN32__)
theFile = fopen(thePath, "wb");
#else
theFile = fopen(thePath, "w");
#endif
}
#else
if (useAuxiliaryFile)
@ -544,7 +552,11 @@ failure:
}
/* Open the file (whether temp or real) for writing. */
#if defined(__WIN32__)
theFile = fopen(thePath, "wb");
#else
theFile = fopen(thePath, "w");
#endif
#endif
if (theFile == NULL) /* Something went wrong; we weren't

View file

@ -33,6 +33,7 @@
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSScanner.h>
#include <base/preface.h>
#include <base/behavior.h>
#include <base/fast.x>
#ifndef __WIN32__
@ -109,7 +110,7 @@ otherTime(NSDate* other)
NSTimeInterval
GSTimeNow()
{
#if !defined(__WIN32__) && !defined(_WIN32)
#if !defined(__WIN32__)
volatile NSTimeInterval interval;
struct timeval tp;

View file

@ -1,7 +1,7 @@
/*
NSFileManager.m
Copyright (C) 1997 Free Software Foundation, Inc.
Copyright (C) 1997-1999 Free Software Foundation, Inc.
Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
Author: Ovidiu Predescu <ovidiu@net-community.com>
@ -60,13 +60,7 @@
#define DIR_enum_state DIR
#ifdef __WIN32__
#ifndef _WIN32
#define _WIN32
#endif
#endif
#if defined(_WIN32)
#if defined(__WIN32__)
#define WIN32ERR ((DWORD)0xFFFFFFFF)
#endif
@ -76,7 +70,7 @@
# include <limits.h> /* for PATH_MAX */
# include <utime.h>
#else
#ifdef _WIN32
#ifdef __WIN32__
# include <limits.h>
# include <sys/utime.h>
#else
@ -195,7 +189,7 @@ static NSFileManager* defaultManager = nil;
{
const char* cpath = [self fileSystemRepresentationWithPath: path];
#if defined(_WIN32)
#if defined(__WIN32__)
return SetCurrentDirectory(cpath);
#else
return (chdir(cpath) == 0);
@ -205,7 +199,7 @@ static NSFileManager* defaultManager = nil;
- (BOOL) createDirectoryAtPath: (NSString*)path
attributes: (NSDictionary*)attributes
{
#if defined(_WIN32)
#if defined(__WIN32__)
return CreateDirectory([self fileSystemRepresentationWithPath: path], NULL);
#else
const char* cpath;
@ -296,7 +290,7 @@ static NSFileManager* defaultManager = nil;
{
char path[PATH_MAX];
#if defined(_WIN32)
#if defined(__WIN32__)
if (GetCurrentDirectory(PATH_MAX, path) > PATH_MAX)
return nil;
#else
@ -637,7 +631,7 @@ static NSFileManager* defaultManager = nil;
return NO;
else
{
#if defined(_WIN32)
#if defined(__WIN32__)
DWORD res;
res = GetFileAttributes(cpath);
@ -676,7 +670,7 @@ static NSFileManager* defaultManager = nil;
return NO;
else
{
#if defined(_WIN32)
#if defined(__WIN32__)
DWORD res= GetFileAttributes(cpath);
if (res == WIN32ERR)
@ -696,7 +690,7 @@ static NSFileManager* defaultManager = nil;
return NO;
else
{
#if defined(_WIN32)
#if defined(__WIN32__)
DWORD res= GetFileAttributes(cpath);
if (res == WIN32ERR)
@ -716,7 +710,7 @@ static NSFileManager* defaultManager = nil;
return NO;
else
{
#if defined(_WIN32)
#if defined(__WIN32__)
DWORD res= GetFileAttributes(cpath);
int len = strlen(cpath);
@ -852,7 +846,7 @@ static NSFileManager* defaultManager = nil;
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path
{
#if defined(_WIN32)
#if defined(__WIN32__)
long long totalsize, freesize;
id values[5];
id keys[5] = {
@ -937,7 +931,7 @@ static NSFileManager* defaultManager = nil;
NSDate *date;
BOOL allOk = YES;
#ifndef _WIN32
#ifndef __WIN32__
num = [attributes objectForKey: NSFileOwnerAccountNumber];
if (num)
{
@ -995,7 +989,7 @@ static NSFileManager* defaultManager = nil;
if (date)
{
struct stat sb;
#if defined(_WIN32) || defined(_POSIX_VERSION)
#if defined(__WIN32__) || defined(_POSIX_VERSION)
struct utimbuf ub;
#else
time_t ub[2];
@ -1005,7 +999,7 @@ static NSFileManager* defaultManager = nil;
allOk = NO;
else
{
#if defined(_WIN32) || defined(_POSIX_VERSION)
#if defined(__WIN32__) || defined(_POSIX_VERSION)
ub.actime = sb.st_atime;
ub.modtime = [date timeIntervalSince1970];
allOk &= (utime(cpath, &ub) == 0);
@ -1096,7 +1090,7 @@ static NSFileManager* defaultManager = nil;
const char* lpath = [self fileSystemRepresentationWithPath: path];
const char* npath = [self fileSystemRepresentationWithPath: otherPath];
#ifdef _WIN32
#ifdef __WIN32__
return NO;
#else
return (symlink(lpath, npath) == 0);
@ -1119,7 +1113,7 @@ static NSFileManager* defaultManager = nil;
- (const char*) fileSystemRepresentationWithPath: (NSString*)path
{
#if 0 && defined(_WIN32)
#if 0 && defined(__WIN32__)
unsigned len = [path length];
NSMutableData *d = [NSMutableData dataWithLength: len + 5];
char *fspath = (char*)[d mutableBytes];

View file

@ -32,14 +32,14 @@
#include <netdb.h>
/* #include <libc.h> */
#ifdef WIN32
#ifdef __WIN32__
#include <Windows32/Sockets.h>
#else
#include <unistd.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#endif /* WIN32 */
#endif /* __WIN32__ */
static NSLock *_hostCacheLock = nil;
static BOOL _hostCacheEnabled = NO;

View file

@ -22,6 +22,7 @@
*/
#include <config.h>
#include <base/preface.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSDate.h>
#include <Foundation/NSException.h>
@ -98,7 +99,7 @@ NSLogv (NSString* format, va_list args)
if (_NSLog_printf_handler == NULL)
_NSLog_printf_handler = *_NSLog_standard_printf_handler;
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
pid = (int)GetCurrentProcessId(),
#else
pid = (int)getpid();

View file

@ -53,6 +53,7 @@
*************************************************************************/
#include <config.h>
#include <base/preface.h>
/* One of these two should have MAXHOSTNAMELEN */
#ifndef __WIN32__
@ -171,7 +172,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
i = 0;
while (env[i])
{
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
char buf[1024];
char *cp;
DWORD len;
@ -429,7 +430,7 @@ int main(int argc, char *argv[], char *env[])
{
int pid;
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
pid = (int)GetCurrentProcessId(),
#else
pid = (int)getpid();

View file

@ -124,7 +124,7 @@ pathSeps()
if (pathSeps == nil)
{
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
pathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/\\"];
#else
pathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
@ -2462,7 +2462,7 @@ else
- (NSString*) stringByResolvingSymlinksInPath
{
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
return self;
#else
NSString *first_half = self, * second_half = @"";
@ -2518,7 +2518,7 @@ else
}
}
return second_half;
#endif /* (__WIN32__) || (_WIN32) */
#endif /* (__WIN32__) */
}
- (NSString*) stringByStandardizingPath
@ -2636,7 +2636,7 @@ else
if ([self length] == 0)
return NO;
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
if ([self indexOfString: @": "] != NSNotFound)
return YES;
#else

View file

@ -514,7 +514,7 @@ extern char *objc_find_executable(const char *name);
#if HAVE_SETPGRP
setpgrp();
#else
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
pid = (int)GetCurrentProcessId(),
#else
pid = (int)getpid();

View file

@ -25,6 +25,7 @@
*/
#include <config.h>
#include <base/preface.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSString.h>
@ -178,7 +179,7 @@ void gnustep_base_thread_callback()
#ifdef HAVE_USLEEP
usleep (30*60*1000000);
#else
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
Sleep (30*60*1000);
#else
sleep (30*60);
@ -193,7 +194,7 @@ void gnustep_base_thread_callback()
#ifdef HAVE_USLEEP
usleep ((int)(delay*1000000));
#else
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
Sleep (delay*1000);
#else
sleep ((int)delay);

View file

@ -544,7 +544,11 @@ decode (const void *ptr)
if (f)
{
fp = fopen([f cString], "rb");
#if defined(__WIN32__)
fp = fopen([f fileSystemRepresentation], "rb");
#else
fp = fopen([f fileSystemRepresentation], "r");
#endif
if (fp != NULL)
{
if (fscanf(fp, "%79s", zone_name) == 1)
@ -658,7 +662,11 @@ decode (const void *ptr)
/* Open file. */
fileName = [NSTimeZone getTimeZoneFile: aTimeZoneName];
file = fopen([fileName cString], "rb");
#if defined(__WIN32__)
file = fopen([fileName fileSystemRepresentation], "rb");
#else
file = fopen([fileName fileSystemRepresentation], "r");
#endif
if (file == NULL)
[NSException raise: fileException format: errMess];
@ -779,7 +787,11 @@ decode (const void *ptr)
/* Read dictionary from file. */
abbreviationDictionary = [[NSMutableDictionary alloc] init];
fileName = [NSTimeZone getAbbreviationFile];
file = fopen([fileName cString], "rb");
#if defined(__WIN32__)
file = fopen([fileName fileSystemRepresentation], "rb");
#else
file = fopen([fileName fileSystemRepresentation], "r");
#endif
if (file == NULL)
[NSException
raise: NSInternalInconsistencyException
@ -826,7 +838,11 @@ decode (const void *ptr)
temp_array[i] = [[NSMutableArray alloc] init];
fileName = [NSTimeZone getRegionsFile];
file = fopen([fileName cString], "rb");
#if defined(__WIN32__)
file = fopen([fileName fileSystemRepresentation], "rb");
#else
file = fopen([fileName fileSystemRepresentation], "r");
#endif
if (file == NULL)
[NSException
raise: NSInternalInconsistencyException

View file

@ -35,7 +35,7 @@
#include <Foundation/NSUserDefaults.h>
#include <stdlib.h> // for getenv()
#if !defined(__WIN32__) && !defined(_WIN32)
#if !defined(__WIN32__)
#include <unistd.h> // for getlogin()
#endif
#if HAVE_PWD_H
@ -68,7 +68,7 @@ NSUserName ()
if (theUserName == nil)
{
const char *login_name = 0;
#if defined(__WIN32__) || defined(_WIN32)
#if defined(__WIN32__)
/* The GetUserName function returns the current user name */
char buf[1024];
DWORD n = 1024;
@ -112,7 +112,7 @@ NSHomeDirectory ()
NSString *
NSHomeDirectoryForUser (NSString *login_name)
{
#if !defined(__WIN32__) && !defined(_WIN32)
#if !defined(__WIN32__)
struct passwd *pw;
pw = getpwnam ([login_name cString]);
return [NSString stringWithCString: pw->pw_dir];
@ -172,7 +172,7 @@ NSString *NSTemporaryDirectory(void)
{
NSFileManager *manager;
NSString *tempDirName, *baseTempDirName;
#ifdef WIN32
#if defined(__WIN32__)
char buffer[1024];
if (GetTempPath(1024, buffer))
baseTempDirName = [NSString stringWithCString: buffer];
@ -202,7 +202,7 @@ NSString *NSOpenStepRootDirectory(void)
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
if (!root)
#ifdef WIN32
#if defined(__WIN32__)
root = @"C:\\";
#else
root = @"/";

View file

@ -30,7 +30,7 @@
#include <libc.h>
/* If POSIX then: #include <unistd.h> */
#endif /* 0 */
#ifndef __WIN32__
#if !defined(__WIN32__)
#include <pwd.h>
#endif
#include <sys/stat.h>

View file

@ -190,7 +190,7 @@ id monthNames;
#endif
return ((long)((end_tms.tms_utime - start_tms.tms_utime +
end_tms.tms_stime - start_tms.tms_stime) * 1000) / CLK_TCK);
#elif defined(__WIN32__) || defined(_WIN32)
#elif defined(__WIN32__)
DWORD start_tick, end_tick;
start_tick = GetTickCount();
@ -215,7 +215,7 @@ id monthNames;
{
#if HAVE_TIMES
struct tms start_tms, end_tms;
#elif defined(__WIN32__) || defined(_WIN32)
#elif defined(__WIN32__)
DWORD start_tick, end_tick;
#else
struct rusage start_ru, end_ru;
@ -226,7 +226,7 @@ id monthNames;
times(&start_tms);
(*aFunc)();
times(&end_tms);
#elif defined(__WIN32__) || defined(_WIN32)
#elif defined(__WIN32__)
#else
getrusage(RUSAGE_SELF, &start_ru);
(*aFunc)();

View file

@ -36,7 +36,7 @@
#include <Foundation/NSHost.h>
#include <Foundation/NSByteOrder.h>
#ifdef WIN32
#if defined(__WIN32__)
#include <Windows32/Sockets.h>
#else
#include <time.h>
@ -46,7 +46,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#endif /* WIN32 */
#endif /* __WIN32__ */
#include <sys/file.h>
#include <sys/stat.h>