Comitting changes from baseline to this branch.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/NibCompatibility@22812 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-04-25 03:28:59 +00:00
parent 82d81e046e
commit aa248d3860
16 changed files with 265 additions and 68 deletions

View file

@ -3,6 +3,54 @@
* Source/NSKeyedUnarchiver.m: Added private method replaceObject:
withObject:.
2006-04-24 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate.m: Avoid a couple of minor rounding errors
by using floating point constants for millisecond multipliers.
2006-04-24 Alex Perez <aperez@alexperez.com>
* Source/NSProcessInfo.m: Elaborated upon the
GNU_MISSING_MAIN_FUNCTION_CALL error message, adding a section about
the most common cause of the error being mismatched gui and base
library versions. Feel free to make more clear or re-word.
2006-04-17 Adam Fedor <fedor@gnu.org>
* Source/NSTimeZone.m: Remove space in @ string define (causes
problems with gcc 2.95).
2006-04-14 Jeremy Bettis <jeremy@deadbeef.com>
* Source/win32/GSFileHandleWin32.m: Fix background reading of pipes.
Several changes for Openstep compatiblity: Don't queue notification,
don't raise exception when asked to read while a background operation
is in progress.
* Source/win32/GSRunLoopCtxt.m: If there are no handles to block on
but there is a timer, sleep until the timer needs to wake up.
2006-04-12 Jeremy Bettis <jeremy@deadbeef.com>
* Source/NSTimeZone.m: Use native time zone files under Solaris.
* Source/GSFFCallInvocation.m: If the returning context is expecting
a void* but we have a different return type just cast it. This
normally is because the method was not declared and has defaulted
to returning id.
* Source/win32/NSUserDefaultsWin32.m: Write defaults to registry as
unicode strings, read in either unicode(REG_SZ) or ascii(REG_BINARY).
* Source/win32-load.h: In mingw, fileSystemRepresentation is unicode
* Source/objc-load.m: In mingw, fileSystemRepresentation is unicode
* Source/NSPropertyList.m (propertyListFromData:mutabilityOption:format:errorDescription:):
Don't call memcmp if the data is smaller than 8 bytes.
* Source/NSFileManager.m (isExecutableFileAtPath:):
Added a comment
* Source/NSBundle.m (objc_executable_location):
A cast was obsuring a misuse of fileSystemRepresentation
2006-04-10 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPropertyList.m (BinaryPLGenerator - storeCount:):
Corrected line forgotten when applying last patch.
>>>>>>> .merge-right.r22807
2006-04-04 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSXML.m: ([GSSAXHandler-dealloc]) fix memory leak.

View file

@ -427,9 +427,9 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
size_t chunkCount;
size_t chunkSize;
memcpy(newArray, map->nodeChunks, (map->chunkCount)*sizeof(GSIMapNode));
if (map->nodeChunks != 0)
{
memcpy(newArray, map->nodeChunks, (map->chunkCount)*sizeof(GSIMapNode));
NSZoneFree(map->zone, map->nodeChunks);
}
map->nodeChunks = newArray;

View file

@ -979,6 +979,9 @@ GSInvocationCallback (void *callback_data, va_alist args)
#undef CASE_TYPE
#define CASE_TYPE(_T, _V, _F) \
case _T: \
if (typeinfo->type == __VAvoidp) \
va_return_ptr(args, void *, *(void **)retval); \
else \
_F(args, *(_V *)retval); \
break;

View file

@ -255,10 +255,14 @@ static NSString *ExecutablePath()
/* This function is provided for objc-load.c, although I'm not sure it
really needs it (So far only needed if using GNU dld library) */
#ifdef __MINGW32__
const unichar *
#else
const char *
#endif
objc_executable_location (void)
{
return (const char*)[[ExecutablePath() stringByDeletingLastPathComponent]
return [[ExecutablePath() stringByDeletingLastPathComponent]
fileSystemRepresentation];
}

View file

@ -268,7 +268,7 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
m = m * 60;
c = a - h - m;
*second = (int)c;
*mil = (a - h - m - c) * 1000;
*mil = (int)((a - h - m - c) * 1000.0);
}
/**
@ -1897,7 +1897,7 @@ static void Grow(DescriptionInfo *info, unsigned size)
s -= (_seconds_since_ref + offset(_time_zone, self));
s = fabs(s);
s -= floor(s);
v = (int)(s * 1000);
v = (int)(s * 1000.0);
}
Grow(info, 3);
info->t[info->offset+2] = (v%10) + '0';

View file

@ -1491,6 +1491,7 @@ static NSStringEncoding defaultEncoding;
{
return NO;
}
// TODO: Actually should check all extensions in env var PATHEXT
if ([[[path pathExtension] lowercaseString] isEqualToString: @"exe"])
{
return YES;
@ -1905,13 +1906,6 @@ static NSStringEncoding defaultEncoding;
#if defined(__MINGW32__)
- (const GSNativeChar*) fileSystemRepresentationWithPath: (NSString*)path
{
NSRange r;
r = [path rangeOfString: @"/"];
if (r.length > 0)
{
path = [path stringByReplacingString: @"/" withString: @"\\"];
}
return
(const GSNativeChar*)[path cStringUsingEncoding: NSUnicodeStringEncoding];
}

View file

@ -126,7 +126,13 @@ establish the argv and environment variables.\n"
#define _GNU_MISSING_MAIN_FUNCTION_CALL @"\nGNUSTEP Internal Error:\n\
The private GNUstep function to establish the argv and environment\n\
variables was not called.\n\
Please report the error to bug-gnustep@gnu.org.\n\n"
\n\
Mismatched library versions between GNUstep Foundation (base) and AppKit\n\
(gui) is most often the cause of this message. Please be sure you\n\
are using known compatible versions and not a mismatched set. Generally,\n\
we recommend you use versions of base and gui which were released together.\n\
\n\
For more detailed assistance, please report the error to bug-gnustep@gnu.org.\n\n"
#endif
#endif
@ -263,6 +269,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
/* Copy the argument list */
if (argv)
{
NSString *str;
NSMutableSet *mySet;
@ -291,6 +298,40 @@ _gnu_process_args(int argc, char *argv[], char *env[])
RELEASE(arg0);
}
#if defined(__MINGW32__)
// It appears that in some versions of mingw32 __argv is no longer supported
// However GetCommandLine always works. Perhaps this should be the default case
// as it is unicode.
else
{
unichar **argvw = CommandLineToArgvW(GetCommandLineW(), &argc);
NSString *str;
NSMutableSet *mySet;
id obj_argv[argc];
int added = 1;
mySet = [NSMutableSet new];
/* Copy the zero'th argument to the argument list */
obj_argv[0] = arg0;
for (i = 1; i < argc; i++)
{
str = [NSString stringWithCharacters: argvw[i] length: wcslen(argvw[i])];
if ([str hasPrefix: @"--GNU-Debug="])
[mySet addObject: [str substringFromIndex: 12]];
else
obj_argv[added++] = str;
}
IF_NO_GC(RELEASE(_gnu_arguments));
_gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added];
IF_NO_GC(RELEASE(_debug_set));
_debug_set = mySet;
RELEASE(arg0);
}
#endif
/* Copy the evironment list */
{
NSMutableArray *keys = [NSMutableArray new];

View file

@ -2255,7 +2255,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
{
bytes = [data bytes];
length = [data length];
if (length > 0 && memcmp(bytes, "bplist00", 8) == 0)
if (length >= 8 && memcmp(bytes, "bplist00", 8) == 0)
{
format = NSPropertyListBinaryFormat_v1_0;
}
@ -3304,7 +3304,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
code = 0x11;
[dest appendBytes: &code length: 1];
c = count;
NSSwapHostShortToBig(c);
c = NSSwapHostShortToBig(c);
[dest appendBytes: &c length: 2];
}
else

View file

@ -147,7 +147,12 @@
/* Many systems have this file */
#define SYSTEM_TIME_FILE @"/etc/localtime"
/* If TZDIR told us where the zoneinfo files are, don't append anything else */
#ifdef TZDIR
#define POSIX_TZONES @""
#else
#define POSIX_TZONES @"posix/"
#endif
/* Possible location of system time zone files */
static NSString *tzdir = nil;
@ -2004,6 +2009,9 @@ static NSMapTable *absolutes = 0;
* Common locations for timezone info on unix systems.
*/
static NSString *zoneDirs[] = {
#ifdef TZDIR
@TZDIR,
#endif
@"/usr/share/zoneinfo",
@"/usr/lib/zoneinfo",
@"/usr/local/share/zoneinfo",

View file

@ -55,7 +55,11 @@
#include "dynamic-load.h"
/* Declaration from NSBundle.m */
#ifdef __MINGW32__
const unichar *objc_executable_location (void);
#else
const char *objc_executable_location (void);
#endif
/* dynamic_loaded is YES if the dynamic loader was sucessfully initialized. */
static BOOL dynamic_loaded;
@ -101,7 +105,11 @@ objc_check_undefineds(FILE *errorStream)
static int
objc_initialize_loading(FILE *errorStream)
{
#ifdef __MINGW32__
const unichar *path;
#else
const char *path;
#endif
dynamic_loaded = NO;
path = objc_executable_location();

View file

@ -34,7 +34,7 @@ typedef void* dl_symbol_t;
if no initialization needed.
*/
static int
__objc_dynamic_init(const char* exec_path)
__objc_dynamic_init(const unichar* exec_path)
{
return 0;
}

View file

@ -35,7 +35,6 @@
#include "Foundation/NSException.h"
#include "Foundation/NSRunLoop.h"
#include "Foundation/NSNotification.h"
#include "Foundation/NSNotificationQueue.h"
#include "Foundation/NSHost.h"
#include "Foundation/NSByteOrder.h"
#include "Foundation/NSProcessInfo.h"
@ -108,7 +107,16 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey";
}
else
{
len = read(descriptor, buf, len);
DWORD readBytes=-1;
if (ReadFile((HANDLE)_get_osfhandle(descriptor), buf, len, &readBytes, NULL)) {
return readBytes;
} else {
DWORD err = GetLastError();
if (err == ERROR_BROKEN_PIPE || err == ERROR_HANDLE_EOF) {
return readBytes;
}
return -1;
}
}
return len;
}
@ -634,13 +642,10 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
*/
if (n != nil)
{
NSNotificationQueue *q;
NSNotificationCenter *q;
q = [NSNotificationQueue defaultQueue];
[q enqueueNotification: n
postingStyle: NSPostASAP
coalesceMask: NSNotificationNoCoalescing
forModes: modes];
q = [NSNotificationCenter defaultCenter];
[q postNotification: n];
}
}
@ -1220,18 +1225,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
}
if (readInfo)
{
id operation = [readInfo objectForKey: NotificationKey];
if (operation == NSFileHandleConnectionAcceptedNotification)
{
[NSException raise: NSFileHandleOperationException
format: @"accept already in progress"];
}
else
{
[NSException raise: NSFileHandleOperationException
format: @"read already in progress"];
}
[self receivedEventRead];
}
}
@ -1677,7 +1671,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{
NSMutableDictionary *info = readInfo;
NSNotification *n;
NSNotificationQueue *q;
NSNotificationCenter *q;
NSArray *modes;
NSString *name;
@ -1695,17 +1689,14 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
RELEASE(info); /* Retained by the notification. */
q = [NSNotificationQueue defaultQueue];
[q enqueueNotification: n
postingStyle: NSPostASAP
coalesceMask: NSNotificationNoCoalescing
forModes: modes];
q = [NSNotificationCenter defaultCenter];
[q postNotification: n];
}
- (void) postWriteNotification
{
NSMutableDictionary *info = [writeInfo objectAtIndex: 0];
NSNotificationQueue *q;
NSNotificationCenter *q;
NSNotification *n;
NSArray *modes;
NSString *name;
@ -1719,11 +1710,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
writePos = 0;
[writeInfo removeObjectAtIndex: 0]; /* Retained by notification. */
q = [NSNotificationQueue defaultQueue];
[q enqueueNotification: n
postingStyle: NSPostASAP
coalesceMask: NSNotificationNoCoalescing
forModes: modes];
q = [NSNotificationCenter defaultCenter];
[q postNotification: n];
if ((writeOK || connectOK) && [writeInfo count] > 0)
{
[self watchWriteDescriptor]; /* In case of queued writes. */
@ -1772,18 +1760,30 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
for (i = 0; i < [modes count]; i++)
{
if (event)
[l removeEvent: (void*)(uintptr_t)event
type: ET_HANDLE
forMode: [modes objectAtIndex: i]
all: YES];
else
[l removeEvent:0
type: ET_TRIGGER
forMode: [modes objectAtIndex: i]
all: YES];
}
}
else
{
if (event)
[l removeEvent: (void*)(uintptr_t)event
type: ET_HANDLE
forMode: NSDefaultRunLoopMode
all: YES];
else
[l removeEvent:0
type: ET_TRIGGER
forMode: NSDefaultRunLoopMode
all: YES];
}
}
@ -1813,7 +1813,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
for (i = 0; i < [modes count]; i++)
{
[l removeEvent: (void*)(uintptr_t)event
type: ET_HANDLE
type: event ? ET_HANDLE : ET_TRIGGER
forMode: [modes objectAtIndex: i]
all: YES];
}
@ -1821,7 +1821,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else
{
[l removeEvent: (void*)(uintptr_t)event
type: ET_HANDLE
type: event ? ET_HANDLE : ET_TRIGGER
forMode: NSDefaultRunLoopMode
all: YES];
}
@ -1844,19 +1844,31 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
for (i = 0; i < [modes count]; i++)
{
if (event)
[l addEvent: (void*)(uintptr_t)event
type: ET_HANDLE
watcher: self
forMode: [modes objectAtIndex: i]];
else
[l addEvent:0
type: ET_TRIGGER
watcher: self
forMode: [modes objectAtIndex: i]];
}
[readInfo setObject: modes forKey: NSFileHandleNotificationMonitorModes];
}
else
{
if (event)
[l addEvent: (void*)(uintptr_t)event
type: ET_HANDLE
watcher: self
forMode: NSDefaultRunLoopMode];
else
[l addEvent:0
type: ET_TRIGGER
watcher: self
forMode: NSDefaultRunLoopMode];
}
}
@ -1882,7 +1894,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
for (i = 0; i < [modes count]; i++)
{
[l addEvent: (void*)(uintptr_t)event
type: ET_HANDLE
type: event ? ET_HANDLE : ET_TRIGGER
watcher: self
forMode: [modes objectAtIndex: i]];
}
@ -1890,7 +1902,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else
{
[l addEvent: (void*)(uintptr_t)event
type: ET_HANDLE
type: event ? ET_HANDLE : ET_TRIGGER
watcher: self
forMode: NSDefaultRunLoopMode];
}
@ -1979,8 +1991,17 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
}
else if (received < 0)
{
if (WSAGetLastError() != WSAEINTR
&& WSAGetLastError() != WSAEWOULDBLOCK)
if (isSocket && (WSAGetLastError() != WSAEINTR
&& WSAGetLastError() != WSAEWOULDBLOCK))
{
NSString *s;
s = [NSString stringWithFormat: @"Read attempt failed - %s",
GSLastErrorStr(errno)];
[readInfo setObject: s forKey: GSFileHandleNotificationError];
[self postReadNotification];
}
else if (!isSocket && (GetLastError() != ERROR_NO_DATA))
{
NSString *s;
@ -2089,6 +2110,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{
[self setNonBlocking: YES];
}
if (isSocket) {
if (WSAEnumNetworkEvents((SOCKET)_get_osfhandle(descriptor),
event, &ocurredEvents) == SOCKET_ERROR)
{
@ -2149,6 +2171,17 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
NSLog(@"Event not get %d", ocurredEvents.lNetworkEvents);
abort();
}
} else {
if ([writeInfo count] > 0)
{
[self receivedEventWrite];
}
else
{
[self receivedEventRead];
}
GSNotifyASAP();
}
}
- (NSDate*) timedOutEvent: (void*)data
@ -2184,8 +2217,21 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{
unsigned long dummy;
if (isSocket != YES)
if (isSocket != YES) {
// Not a file and not a socket, must be a pipe
DWORD mode;
if (flag)
mode = PIPE_NOWAIT;
else
mode = PIPE_WAIT;
if (SetNamedPipeHandleState((HANDLE)_get_osfhandle(descriptor), &mode, NULL, NULL)) {
isNonBlocking = flag;
} else {
NSLog(@"unable to set pipe non-blocking mode - %d",
GetLastError());
}
return;
}
if (flag)
{

View file

@ -413,6 +413,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
}
else
{
SleepEx(wait_timeout, TRUE);
wait_return = WAIT_OBJECT_0;
}
NSDebugMLLog(@"NSRunLoop", @"wait returned %d", wait_return);

View file

@ -205,7 +205,7 @@ struct NSUserDefaultsWin32_DomainInfo
{
DWORD i = 0;
unichar *name = malloc(200);
unsigned char *data = malloc(1000);
unichar *data = malloc(1000);
DWORD namelenbuf = 100, datalenbuf = 1000;
DWORD type;
@ -219,7 +219,7 @@ struct NSUserDefaultsWin32_DomainInfo
&namelen,
NULL,
&type,
data,
(void*)data,
&datalen);
if (rc == ERROR_SUCCESS)
{
@ -228,12 +228,31 @@ struct NSUserDefaultsWin32_DomainInfo
id v;
NSString *k;
v = [NSString stringWithCString: data
switch (type) {
case REG_SZ: {
int datacharlen = datalen / 2;
if (datacharlen > 0 && data[datacharlen-1] == 0)
datacharlen--;
v = [NSString stringWithCharacters:data length:datacharlen];
}
break;
case REG_BINARY: {
v = [NSString stringWithCString: (char*)data
encoding: NSASCIIStringEncoding];
}
break;
default:
NSLog(@"Bad registry type %d for '%S'", type, name);
v = 0;
}
v = [v propertyList];
if (v)
{
k = [NSString stringWithCharacters: name length: namelen];
[domainDict setObject: v forKey: k];
}
}
NS_HANDLER
NSLog(@"Bad registry value for '%S'", name);
NS_ENDHANDLER
@ -271,7 +290,7 @@ struct NSUserDefaultsWin32_DomainInfo
{
DWORD i = 0;
unichar *name = malloc(200);
unsigned char *data = malloc(1000);
unichar *data = malloc(1000);
DWORD namelenbuf = 100, datalenbuf = 1000;
DWORD type;
@ -279,13 +298,19 @@ struct NSUserDefaultsWin32_DomainInfo
{
DWORD namelen = namelenbuf, datalen = datalenbuf;
// RegEnumValueW returns the data as a wide string
// but returns the length in bytes.
// To add insult to injury, datalen includes the terminating
// NULL character, unless there isn't enough room, in which
// case it doesn't.
rc = RegEnumValueW(dinfo->userKey,
i,
name,
&namelen,
NULL,
&type,
data,
(void*)data,
&datalen);
if (rc == ERROR_SUCCESS)
{
@ -294,12 +319,31 @@ struct NSUserDefaultsWin32_DomainInfo
id v;
NSString *k;
v = [NSString stringWithCString: data
switch (type) {
case REG_SZ: {
int datacharlen = datalen / 2;
if (datacharlen > 0 && data[datacharlen-1] == 0)
datacharlen--;
v = [NSString stringWithCharacters:data length:datacharlen];
}
break;
case REG_BINARY: {
v = [NSString stringWithCString: (char*)data
encoding: NSASCIIStringEncoding];
}
break;
default:
NSLog(@"Bad registry type %d for '%S'", type, name);
v = 0;
}
v = [v propertyList];
if (v)
{
k = [NSString stringWithCharacters: name length: namelen];
[domainDict setObject: v forKey: k];
}
}
NS_HANDLER
NSLog(@"Bad registry value for '%S'", name);
NS_ENDHANDLER
@ -523,16 +567,16 @@ struct NSUserDefaultsWin32_DomainInfo
if (oldvalue == nil || [value isEqual: oldvalue] == NO)
{
NSString *result = nil;
const unsigned char *ptr;
const unichar *ptr;
GSPropertyListMake(value, nil, NO, NO, 0, &result);
ptr = [result cStringUsingEncoding: NSASCIIStringEncoding];
ptr = UNISTR(result);
rc = RegSetValueExW(dinfo->userKey,
UNISTR(valName),
0,
REG_BINARY,
ptr,
strlen(ptr) + 1);
REG_SZ,
(void*)ptr,
2*(wcslen(ptr) + 1));
if (rc != ERROR_SUCCESS)
{
NSLog(@"Failed to insert HKEY_CURRENT_USER\\%@\\%@ (%x)",

View file

@ -90,7 +90,7 @@ autogsdoc_AGSDOC_FILES = autogsdoc.m \
autogsdoc_DOC_INSTALL_DIR = Developer/Tools
# Use local version of autogsdoc in case it is not installed
AUTOGSDOC=./obj/autogsdoc
AUTOGSDOC=./$(GNUSTEP_OBJ_PREFIX)/autogsdoc
include Makefile.preamble

View file

@ -5,7 +5,7 @@
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
*/
#if defined(__MINGW__) || defined(__MINGW32__)
#if defined(__MINGW32__)
#include <windows.h>
#include <winsock2.h>
#else
@ -16,7 +16,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#endif /* __MINGW__ */
#endif /* __MINGW32__ */
#include <sys/file.h>
#include <sys/stat.h>