diff --git a/ANNOUNCE b/ANNOUNCE index 5f561492e..9044d55b5 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,7 +1,7 @@ Announcement ************ -The GNUstep Base Library, version 1.5.2, is now available. +The GNUstep Base Library, version 1.6.0, is now available. What is the GNUstep Base Library? ================================= @@ -19,11 +19,11 @@ portion of the OpenStep standard (the Foundation library). There is more information available at the GNUstep homepage at `http://www.gnustep.org'. - Note that versions that have a odd minor release number are unstable -releases (like 1.5.2), which even minor release numbers (1.4.1) are -stable releases. + Note that versions that have a odd minor release number (the second +number, y, in x.y.z) are unstable releases (like 1.5.2), which even +minor release numbers (1.4.1) are stable releases. -Noteworthy changes in version `1.5.2' +Noteworthy changes in version `1.6.0' ===================================== * More MinGW support @@ -41,7 +41,7 @@ Noteworthy changes in version `1.5.2' Where can you get it? How can you compile it? ============================================== - The gnustep-base-1.5.2.tar.gz distribution file has been placed on + The gnustep-base-1.6.0.tar.gz distribution file has been placed on `ftp.gnustep.org' in `pub/gnustep/core'. Please log bug reports on the GNUstep project page diff --git a/ChangeLog b/ChangeLog index c43823a8b..d9d971e16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,139 @@ +2003-03-23 Richard Frith-Macdonald + + * Completed merge of changes from 1.6.0 branch. + +2003-03-17 Adam Fedor + + * Version 1.6.0 + +2003-03-17 Adam Fedor + + * Testing/LoadMe.m (afterLoad): Use description, not name. + * Testing/nsfilemanager.m: Print some output. Clean up. + * Testing/scanner.m, nstimezone.m, release.m: Idem. + + * config/config.vsprintf, config/config.vasprintf: Rewrite to + properly call a variable argument function. + +2003-03-14 Adam Fedor + + * Testing/nsarray.m (compare): Un-nest function. + + * Source/NSProcessInfo.m (-operatingSystem): Add darwin. + +2003-03-13 Richard Frith-Macdonald + + * Source/NSFileManager.m: ([-isDeletableFileAtPath:]) Fix for the + case where the path is a file in the current directory. + +2003-03-11 Adam Fedor + + * configure.ac: Fix some typos (Reported by + Alexander Malmberg ). + +2003-03-07 Richard Frith-Macdonald + + * Headers/gnustep/base/NSSet.h: Added a few non-openstep declarations + * Source/GSCompatibility.m: OAppend() sort dictionary keys even if + locale is nil. + +2003-03-06 Richard Frith-Macdonald + + * Source/NSData.m: Fix reference to zone of deallocated object. + Bug reported by Roland Schwingel + * Source/NSFileManager.m: Fix typo (using logical or rather than + bitwise or) in call to access() + Bug reported by Roland Schwingel + +2003-02-17 + + * GNUmakefile (GNUSTEP_TARGET_INSTALL_PREFIX) + (GNUSTEP_TARGET_LOCAL_ROOT, GNUSTEP_TARGET_NETWORK_ROOT): On + mingw32 replace / with \\057 to avoid the msys shell translating / + with \. + +2003-03-04 Richard Frith-Macdonald + + * config/config.vasprintf.c: + * config/config.vsprintf.c: Correct the number of arguments passed + so that modern compilers don't fail on these files. A compiler + failure is seen by configure as the same as a runtime failure, and + configure would infer incorrect runtime behavior! + +2003-03-01 Richard Frith-Macdonald + + * Source/NSSerializer.m: Fix crash when deserializing a corrupt or + truncated archive ... raise exception rather than segfaulting. + Added code to recognize newer versions of the serialiser format and + give up if they are encountered and cannot be handled. + * Source/GSTcpPort.m: Added code to recognise newer versions of the + port format and give up if they are encountered and cannot be handled. + This allows for the addition of decent versioning in later formats. + +2003-02-28 Richard Frith-Macdonald + + * Tools/AGSParser.m: Fix to understand __attribute__() in declaration. + +2003-02-27 Richard Frith-Macdonald + + * Tools/AGSIndex.m: Convert nil content to empty strings before use. + * Tools/AGSHtml.m: ditto ... prevent some crashes. + +2003-02-24 Richard Frith-Macdonald + + * Source/NSProcessInfo.m (_gnu_process_args): Tidied patch and add + code to print error and abort if argv is null under unixy systems. + +2003-02-24 Tom Koelman + + * Source/NSProcessInfo.m (_gnu_process_args): If argv is 0 (e.g. + on MingW) set executable name using module name info. + +2003-02-23 Richard Frith-Macdonald + + * Source/NSUser.m: Don't prepend HOMEDRIVE to HOMEPATH if HOMEPATH + already contains a drive letter. + +2003-02-22 Richard Frith-Macdonald + + * Source/Additions/GSObjCRuntime.m: GSObjCSetValue() correct to call + ([unableToSetNilForKey:]) when it should. + * Source/NSDecimalNumber.m: Override initialisers from NSNumber to + create NSDecimalNumber objects ... bug report by David Ayers. + +2003-02-21 Richard Frith-Macdonald + + * Source/NSDistributedNotificationCenter.m: ([_connect]) make the + connection to the server usable from any thread. + +2003-02-19 Adam Fedor + + * Source/NSKeyValueCoding.m ([NSObject -handleQueryWithUnboundKey:]): + Raise NSUnknownKeyException. + ([NSObject -handleTakeValue:forUnboundKey:]): Idem. + +2003-02-18 Adam Fedor + + * Source/GSFFIInvocation.m (GSFFIInvocationCallback): Cast + invocation to access ivars correctly. Check validReturn. + +2003-02-18 Tom Koelman + + * Source/NSProcessInfo.m (_gnu_process_args): If argv is 0 (e.g. + on MingW) set executable name to empty string. + +2003-02-17 Richard Frith-Macdonald + + * Source/GSString.m: (fillHole) fix memory overrun (read only) and + argument order errors (in code not normally compiled) spotted by + Manuel Guesdon. + + +2003-03-23 Richard Frith-Macdonald + + * Start merged of changes from 1.6.0 branch. + + 2003-03-20 Richard Frith-Macdonald * Source/GSMime.m: (_unfoldHeader) Check that input pointer doesn't diff --git a/Documentation/announce.texi b/Documentation/announce.texi index 2f474fdbc..518eec02b 100644 --- a/Documentation/announce.texi +++ b/Documentation/announce.texi @@ -22,7 +22,8 @@ portion of the OpenStep standard (the Foundation library). There is more information available at the GNUstep homepage at @samp{http://www.gnustep.org}. -Note that versions that have a odd minor release number are unstable +Note that versions that have a odd minor release number (the second number, +y, in x.y.z) are unstable releases (like 1.5.2), which even minor release numbers (1.4.1) are stable releases. diff --git a/Documentation/news.texi b/Documentation/news.texi index d9be08d28..5c34e99d0 100644 --- a/Documentation/news.texi +++ b/Documentation/news.texi @@ -9,7 +9,7 @@ The currently released version of the library is @samp{@value{GNUSTEP-BASE-VERSION}}. @end ifclear -@section Noteworthy changes in version @samp{1.5.2} +@section Noteworthy changes in version @samp{1.6.0} @itemize @bullet @item More MinGW support diff --git a/Headers/gnustep/base/NSKeyValueCoding.h b/Headers/gnustep/base/NSKeyValueCoding.h index b4bc1cbdb..947b5af42 100644 --- a/Headers/gnustep/base/NSKeyValueCoding.h +++ b/Headers/gnustep/base/NSKeyValueCoding.h @@ -33,6 +33,8 @@ #ifndef STRICT_OPENSTEP +GS_EXPORT NSString* const NSUnknownKeyException; + @interface NSObject (NSKeyValueCoding) + (BOOL) accessInstanceVariablesDirectly; diff --git a/Headers/gnustep/base/NSSet.h b/Headers/gnustep/base/NSSet.h index 69e96ba87..8bb57f91c 100644 --- a/Headers/gnustep/base/NSSet.h +++ b/Headers/gnustep/base/NSSet.h @@ -38,12 +38,17 @@ + (id) setWithArray: (NSArray*)objects; + (id) setWithObject: (id)anObject; + (id) setWithObjects: (id)firstObject, ...; +#ifndef STRICT_OPENSTEP ++ (id) setWithObjects: (id*)objects + count: (unsigned)count; +#endif + (id) setWithSet: (NSSet*)aSet; - (NSArray*) allObjects; - (id) anyObject; - (BOOL) containsObject: (id)anObject; - (unsigned) count; +- (NSString*) description; - (NSString*) descriptionWithLocale: (NSDictionary*)locale; - (id) initWithArray: (NSArray*)other; @@ -61,6 +66,10 @@ - (void) makeObjectsPerform: (SEL)aSelector; - (void) makeObjectsPerform: (SEL)aSelector withObject: (id)argument; +#ifndef STRICT_OPENSTEP +- (void) makeObjectsPerformSelector: (SEL)aSelector; +- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: (id)argument; +#endif - (id) member: (id)anObject; - (NSEnumerator*) objectEnumerator; diff --git a/NEWS b/NEWS index cc7b660cc..d4f151d96 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,9 @@ News **** -The currently released version of the library is `1.5.2'. +The currently released version of the library is `1.6.0'. -Noteworthy changes in version `1.5.2' +Noteworthy changes in version `1.6.0' ===================================== * More MinGW support diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index 83b604270..9c2584233 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -47,6 +47,8 @@ #include #include +@class NSNull; + /** Deprecated ... use GSObjCFindVariable() */ BOOL GSFindInstanceVariable(id obj, const char *name, @@ -1102,6 +1104,12 @@ void GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel, const char *type, unsigned size, int offset) { + static NSNull *null = nil; + + if (null == nil) + { + null = [NSNull new]; + } if (sel != 0) { NSMethodSignature *sig = [self methodSignatureForSelector: sel]; @@ -1117,6 +1125,10 @@ GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel, { [self handleTakeValue: val forUnboundKey: key]; } + else if ((val == nil || val == null) && *type != _C_ID && *type != _C_CLASS) + { + [self unableToSetNilForKey: key]; + } else { switch (*type) @@ -1130,8 +1142,7 @@ GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel, { id *ptr = (id *)((char *)self + offset); - [*ptr autorelease]; - *ptr = [v retain]; + ASSIGN(*ptr, v); } else { diff --git a/Source/DocMakefile b/Source/DocMakefile index 45d9ee534..9e437c723 100644 --- a/Source/DocMakefile +++ b/Source/DocMakefile @@ -130,6 +130,7 @@ Base_AGSDOC_FLAGS = \ -VariablesTemplate TypesAndConstants \ -WordMap '{\ FOUNDATION_EXPORT=extern;FOUNDATION_STATIC_INLINE="";\ + GS_STATIC_INLINE="";\ GS_GEOM_SCOPE=extern;GS_GEOM_ATTR="";\ GS_EXPORT=extern;GS_DECLARE="";\ GS_RANGE_SCOPE=extern;GS_RANGE_ATTR="";\ diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 54f0b624d..e6a72b15f 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -57,11 +57,11 @@ libgnustep-baseadd_SUBPROJECTS=Additions ifeq ($(GNUSTEP_TARGET_OS), mingw32) GNUSTEP_TARGET_INSTALL_PREFIX := \ - $(shell echo $(GNUSTEP_SYSTEM_ROOT) | sed 's|^[a-zA-Z]:/|/|') + $(shell echo $(GNUSTEP_SYSTEM_ROOT) | sed 's|^[a-zA-Z]:/|/|' | sed 's|/|\\\\057|g') GNUSTEP_TARGET_LOCAL_ROOT := \ - $(shell echo $(GNUSTEP_LOCAL_ROOT) | sed 's|^[a-zA-Z]:/|/|') + $(shell echo $(GNUSTEP_LOCAL_ROOT) | sed 's|^[a-zA-Z]:/|/|' | sed 's|/|\\\\057|g') GNUSTEP_TARGET_NETWORK_ROOT := \ - $(shell echo $(GNUSTEP_NETWORK_ROOT) | sed 's|^[a-zA-Z]:/|/|') + $(shell echo $(GNUSTEP_NETWORK_ROOT) | sed 's|^[a-zA-Z]:/|/|' | sed 's|/|\\\\057|g') DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_TARGET_INSTALL_PREFIX) \ -DGNUSTEP_LOCAL_ROOT=$(GNUSTEP_TARGET_LOCAL_ROOT) \ -DGNUSTEP_NETWORK_ROOT=$(GNUSTEP_TARGET_NETWORK_ROOT) \ @@ -70,6 +70,7 @@ DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_TARGET_INSTALL_PREFIX) \ -DGNUSTEP_TARGET_OS=\"$(GNUSTEP_TARGET_OS)\" \ -DLIBRARY_COMBO=\"$(LIBRARY_COMBO)\" + else GNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT) diff --git a/Source/GSCompatibility.m b/Source/GSCompatibility.m index 295d657bc..31b590057 100644 --- a/Source/GSCompatibility.m +++ b/Source/GSCompatibility.m @@ -755,16 +755,112 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, unsigned numKeys = [keyArray count]; NSString *plists[numKeys]; NSString *keys[numKeys]; + BOOL canCompare = YES; + Class lastClass = 0; [keyArray getObjects: keys]; + for (i = 0; i < numKeys; i++) + { + if (GSObjCClass(keys[i]) == lastClass) + continue; + if ([keys[i] respondsToSelector: @selector(compare:)] == NO) + { + canCompare = NO; + break; + } + lastClass = GSObjCClass(keys[i]); + } + + if (canCompare == YES) + { + #define STRIDE_FACTOR 3 + unsigned c,d, stride; + BOOL found; + NSComparisonResult (*comp)(id, SEL, id) = 0; + unsigned int count = numKeys; + #ifdef GSWARN + BOOL badComparison = NO; + #endif + + stride = 1; + while (stride <= count) + { + stride = stride * STRIDE_FACTOR + 1; + } + lastClass = 0; + while (stride > (STRIDE_FACTOR - 1)) + { + // loop to sort for each value of stride + stride = stride / STRIDE_FACTOR; + for (c = stride; c < count; c++) + { + found = NO; + if (stride > c) + { + break; + } + d = c - stride; + while (!found) + { + id a = keys[d + stride]; + id b = keys[d]; + Class x; + NSComparisonResult r; + + x = GSObjCClass(a); + if (x != lastClass) + { + lastClass = x; + comp = (NSComparisonResult (*)(id, SEL, id)) + [a methodForSelector: @selector(compare:)]; + } + r = (*comp)(a, @selector(compare:), b); + if (r < 0) + { + #ifdef GSWARN + if (r != NSOrderedAscending) + { + badComparison = YES; + } + #endif + keys[d + stride] = b; + keys[d] = a; + if (stride > d) + { + break; + } + d -= stride; + } + else + { + #ifdef GSWARN + if (r != NSOrderedDescending + && r != NSOrderedSame) + { + badComparison = YES; + } + #endif + found = YES; + } + } + } + } + #ifdef GSWARN + if (badComparison == YES) + { + NSWarnFLog(@"Detected bad return value from comparison"); + } + #endif + } + + for (i = 0; i < numKeys; i++) + { + plists[i] = (*myObj)(obj, objSel, keys[i]); + } + if (loc == nil) { - for (i = 0; i < numKeys; i++) - { - plists[i] = (*myObj)(obj, objSel, keys[i]); - } - Append(@"{", dest); for (i = 0; i < numKeys; i++) { @@ -777,108 +873,6 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, } else { - BOOL canCompare = YES; - Class lastClass = 0; - - for (i = 0; i < numKeys; i++) - { - if (GSObjCClass(keys[i]) == lastClass) - continue; - if ([keys[i] respondsToSelector: @selector(compare:)] == NO) - { - canCompare = NO; - break; - } - lastClass = GSObjCClass(keys[i]); - } - - if (canCompare == YES) - { - #define STRIDE_FACTOR 3 - unsigned c,d, stride; - BOOL found; - NSComparisonResult (*comp)(id, SEL, id) = 0; - unsigned int count = numKeys; - #ifdef GSWARN - BOOL badComparison = NO; - #endif - - stride = 1; - while (stride <= count) - { - stride = stride * STRIDE_FACTOR + 1; - } - lastClass = 0; - while (stride > (STRIDE_FACTOR - 1)) - { - // loop to sort for each value of stride - stride = stride / STRIDE_FACTOR; - for (c = stride; c < count; c++) - { - found = NO; - if (stride > c) - { - break; - } - d = c - stride; - while (!found) - { - id a = keys[d + stride]; - id b = keys[d]; - Class x; - NSComparisonResult r; - - x = GSObjCClass(a); - if (x != lastClass) - { - lastClass = x; - comp = (NSComparisonResult (*)(id, SEL, id)) - [a methodForSelector: @selector(compare:)]; - } - r = (*comp)(a, @selector(compare:), b); - if (r < 0) - { - #ifdef GSWARN - if (r != NSOrderedAscending) - { - badComparison = YES; - } - #endif - keys[d + stride] = b; - keys[d] = a; - if (stride > d) - { - break; - } - d -= stride; - } - else - { - #ifdef GSWARN - if (r != NSOrderedDescending - && r != NSOrderedSame) - { - badComparison = YES; - } - #endif - found = YES; - } - } - } - } - #ifdef GSWARN - if (badComparison == YES) - { - NSWarnFLog(@"Detected bad return value from comparison"); - } - #endif - } - - for (i = 0; i < numKeys; i++) - { - plists[i] = (*myObj)(obj, objSel, keys[i]); - } - Append(@"{\n", dest); for (i = 0; i < numKeys; i++) { diff --git a/Source/GSFFIInvocation.m b/Source/GSFFIInvocation.m index 416468f68..560b70568 100644 --- a/Source/GSFFIInvocation.m +++ b/Source/GSFFIInvocation.m @@ -41,6 +41,8 @@ typedef struct _NSInvocation_t { /* Function that implements the actual forwarding */ typedef void (*ffi_closure_fun) (ffi_cif*,void*,void**,void*); +typedef void (*f_fun) (); + void GSFFIInvocationCallback(ffi_cif*, void*, void **, void*); /* @@ -267,7 +269,7 @@ GSFFIInvokeWithTargetAndImp(NSInvocation *_inv, id anObject, IMP imp) NSInvocation_t *inv = (NSInvocation_t*)_inv; /* Do it */ - ffi_call(inv->_cframe, imp, (inv->_retval), + ffi_call(inv->_cframe, (f_fun)imp, (inv->_retval), ((cifframe_t *)inv->_cframe)->values); /* Don't decode the return value here (?) */ @@ -412,10 +414,11 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user) this since the return value (retp) really belongs to the closure not the invocation so it will be demallocd at the end of this call */ - if ([sig methodReturnType] && *[sig methodReturnType] == _C_ID) + if ([sig methodReturnType] && *[sig methodReturnType] == _C_ID + && ((NSInvocation_t *)invocation)->_validReturn == YES) { AUTORELEASE(*(id *)retp); - invocation->_validReturn = NO; + ((NSInvocation_t *)invocation)->_validReturn = NO; } /* We need to (re)encode the return type for it's trip back. */ diff --git a/Source/GSString.m b/Source/GSString.m index e09f62703..3eb258bb5 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -1053,14 +1053,14 @@ fillHole(ivars self, unsigned index, unsigned size) if (self->_flags.wide == 1) { - for (i = index; i <= self->_count; i++) + for (i = index; i < self->_count; i++) { self->_contents.u[i] = self->_contents.u[i+size]; } } else { - for (i = index; i <= self->_count; i++) + for (i = index; i < self->_count; i++) { self->_contents.c[i] = self->_contents.c[i+size]; } @@ -1069,14 +1069,14 @@ fillHole(ivars self, unsigned index, unsigned size) #else if (self->_flags.wide == 1) { - memcpy(self->_contents.u + index + size, - self->_contents.u + index, + memcpy(self->_contents.u + index, + self->_contents.u + index + size, sizeof(unichar)*(self->_count - index)); } else { - memcpy(self->_contents.c + index + size, - self->_contents.c + index, (self->_count - index)); + memcpy(self->_contents.c + index, + self->_contents.c + index + size, (self->_count - index)); } #endif // STABLE_MEMCPY self->_flags.hash = 0; diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index 89e87aac2..fa01b69f9 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -288,6 +288,12 @@ decodePort(NSData *data, NSString *defaultAddress) length = GSSwapBigI32ToHost(pih->length); pi = (GSPortInfo*)&pih[1]; pnum = GSSwapBigI16ToHost(pi->num); + if (strncmp(pi->addr, "VER", 3) == 0) + { + NSLog(@"Remote version of GNUstep at %s:%d is more recent than this one", + pi->addr, pnum); + return nil; + } addr = [NSString stringWithCString: pi->addr]; NSDebugFLLog(@"NSPort", @"Decoded port as '%@:%d'", addr, pnum); @@ -1028,6 +1034,13 @@ static Class runLoopClass; rType = GSP_NONE; /* ready for a new item */ p = decodePort(rData, defaultAddress); + if (p == nil) + { + NSLog(@"%@ - unable to decode remote port", self); + DO_UNLOCK(myLock); + [self invalidate]; + return; + } /* * Set up to read another item header. */ diff --git a/Source/Makefile.preamble b/Source/Makefile.preamble index b1a78b3d4..421edcb8c 100644 --- a/Source/Makefile.preamble +++ b/Source/Makefile.preamble @@ -77,9 +77,6 @@ endif ifeq ($(GNUSTEP_TARGET_OS),cygwin) libgnustep-base_LIBRARIES_DEPEND_UPON += -lobjc endif -ifeq ($(findstring darwin, $(GNUSTEP_TARGET_OS)), darwin) -libgnustep-base_LIBRARIES_DEPEND_UPON += -flat_namespace -endif ifeq ($(shared),yes) libgnustep-base_LIBRARIES_DEPEND_UPON += $(CONFIG_SYSTEM_LIBS) endif diff --git a/Source/NSData.m b/Source/NSData.m index 466876cd9..067812652 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -634,8 +634,9 @@ failure: - (id) initWithContentsOfMappedFile: (NSString *)path { #ifdef HAVE_MMAP + NSZone *z = GSObjCZone(self); RELEASE(self); - self = [NSDataMappedFile allocWithZone: GSObjCZone(self)]; + self = [NSDataMappedFile allocWithZone: z]; return [self initWithContentsOfMappedFile: path]; #else return [self initWithContentsOfFile: path]; @@ -2813,7 +2814,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmid == -1) /* Created memory? */ { NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %s", - bufferSize, GSLastErrorStr(errno)); + bufferSize, GSLastErrorStr(errno)); RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; return [self initWithBytes: aBuffer length: bufferSize]; @@ -3476,12 +3477,23 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) struct shmid_ds buf; if (shmctl(shmid, IPC_STAT, &buf) < 0) - NSLog(@"[NSMutableDataShared -dealloc] shared memory control failed - %s", GSLastErrorStr(errno)); + { + NSLog(@"[NSMutableDataShared -dealloc] shared memory " + @"control failed - %s", GSLastErrorStr(errno)); + } else if (buf.shm_nattch == 1) - if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ - NSLog(@"[NSMutableDataShared -dealloc] shared memory delete failed - %s", GSLastErrorStr(errno)); + { + if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ + { + NSLog(@"[NSMutableDataShared -dealloc] shared memory " + @"delete failed - %s", GSLastErrorStr(errno)); + } + } if (shmdt(bytes) < 0) - NSLog(@"[NSMutableDataShared -dealloc] shared memory detach failed - %s", GSLastErrorStr(errno)); + { + NSLog(@"[NSMutableDataShared -dealloc] shared memory " + @"detach failed - %s", GSLastErrorStr(errno)); + } bytes = 0; length = 0; capacity = 0; @@ -3509,7 +3521,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_ACCESS); if (shmid == -1) /* Created memory? */ { - NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory get failed for %u - %s", bufferSize, GSLastErrorStr(errno)); + NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory " + @"get failed for %u - %s", bufferSize, GSLastErrorStr(errno)); RELEASE(self); self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; return [self initWithCapacity: bufferSize]; @@ -3519,7 +3532,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) e = errno; if (bytes == (void*)-1) { - NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory attach failed for %u - %s", bufferSize, GSLastErrorStr(e)); + NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory " + @"attach failed for %u - %s", bufferSize, GSLastErrorStr(e)); bytes = 0; RELEASE(self); self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -3538,20 +3552,23 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) shmid = anId; if (shmctl(shmid, IPC_STAT, &buf) < 0) { - NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory control failed - %s", GSLastErrorStr(errno)); + NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " + @"control failed - %s", GSLastErrorStr(errno)); RELEASE(self); /* Unable to access memory. */ return nil; } if (buf.shm_segsz < bufferSize) { - NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory segment too small"); + NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " + @"segment too small"); RELEASE(self); /* Memory segment too small. */ return nil; } bytes = shmat(shmid, 0, 0); if (bytes == (void*)-1) { - NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory attach failed - %s", GSLastErrorStr(errno)); + NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " + @"attach failed - %s", GSLastErrorStr(errno)); bytes = 0; RELEASE(self); /* Unable to attach to memory. */ return nil; @@ -3571,32 +3588,49 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) newid = shmget(IPC_PRIVATE, size, IPC_CREAT|VM_ACCESS); if (newid == -1) /* Created memory? */ - [NSException raise: NSMallocException - format: @"Unable to create shared memory segment - %s.", - GSLastErrorStr(errno)]; + { + [NSException raise: NSMallocException + format: @"Unable to create shared memory segment (size:%u) - %s.", + size, GSLastErrorStr(errno)]; + } tmp = shmat(newid, 0, 0); if ((int)tmp == -1) /* Attached memory? */ - [NSException raise: NSMallocException - format: @"Unable to attach to shared memory segment."]; + { + [NSException raise: NSMallocException + format: @"Unable to attach to shared memory segment."]; + } memcpy(tmp, bytes, length); if (bytes) { struct shmid_ds buf; if (shmctl(shmid, IPC_STAT, &buf) < 0) - NSLog(@"[NSMutableDataShared -setCapacity:] shared memory control failed - %s", GSLastErrorStr(errno)); + { + NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " + @"control failed - %s", GSLastErrorStr(errno)); + } else if (buf.shm_nattch == 1) - if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ - NSLog(@"[NSMutableDataShared -setCapacity:] shared memory delete failed - %s", GSLastErrorStr(errno)); + { + if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ + { + NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " + @"delete failed - %s", GSLastErrorStr(errno)); + } + } if (shmdt(bytes) < 0) /* Detach memory. */ - NSLog(@"[NSMutableDataShared -setCapacity:] shared memory detach failed - %s", GSLastErrorStr(errno)); + { + NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " + @"detach failed - %s", GSLastErrorStr(errno)); + } } bytes = tmp; shmid = newid; capacity = size; } if (size < length) - length = size; + { + length = size; + } return self; } diff --git a/Source/NSDecimalNumber.m b/Source/NSDecimalNumber.m index aff4c23c1..930a69195 100644 --- a/Source/NSDecimalNumber.m +++ b/Source/NSDecimalNumber.m @@ -271,6 +271,140 @@ static NSDecimalNumber *one; return [self initWithDecimal: decimal]; } +- (id) initWithBool: (BOOL)value +{ + return [self initWithMantissa: (value == YES) ? 1 : 0 + exponent: 0 + isNegative: NO]; +} + +- (id) initWithChar: (signed char)value +{ + if (value < 0) + { + return [self initWithMantissa: -value + exponent: 0 + isNegative: YES]; + } + else + { + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; + } +} + +- (id) initWithDouble: (double)value +{ + return [self initWithBytes: &value objCType: "d"]; +} + +- (id) initWithFloat: (float)value +{ + double d = (double)value; + + return [self initWithBytes: &d objCType: "d"]; +} + +- (id) initWithInt: (signed int)value +{ + if (value < 0) + { + return [self initWithMantissa: -value + exponent: 0 + isNegative: YES]; + } + else + { + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; + } +} + +- (id) initWithLong: (signed long)value +{ + if (value < 0) + { + return [self initWithMantissa: -value + exponent: 0 + isNegative: YES]; + } + else + { + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; + } +} + +- (id) initWithLongLong: (signed long long)value +{ + if (value < 0) + { + return [self initWithMantissa: -value + exponent: 0 + isNegative: YES]; + } + else + { + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; + } +} + +- (id) initWithShort: (signed short)value +{ + if (value < 0) + { + return [self initWithMantissa: -value + exponent: 0 + isNegative: YES]; + } + else + { + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; + } +} + +- (id) initWithUnsignedChar: (unsigned char)value +{ + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; +} + +- (id) initWithUnsignedInt: (unsigned int)value +{ + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; +} + +- (id) initWithUnsignedLong: (unsigned long)value +{ + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; +} + +- (id) initWithUnsignedLongLong: (unsigned long long)value +{ + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; +} + +- (id) initWithUnsignedShort: (unsigned short)value +{ + return [self initWithMantissa: value + exponent: 0 + isNegative: NO]; +} + - (NSString*) descriptionWithLocale: (NSDictionary*)locale { return NSDecimalString(&data, locale); diff --git a/Source/NSDistributedNotificationCenter.m b/Source/NSDistributedNotificationCenter.m index 32bb7f395..f2f0aed7b 100644 --- a/Source/NSDistributedNotificationCenter.m +++ b/Source/NSDistributedNotificationCenter.m @@ -484,6 +484,10 @@ static NSDistributedNotificationCenter *netCenter = nil; @implementation NSDistributedNotificationCenter (Private) +/** + * Establish a connection to the server. This method should only be called + * when protected by the centres lock, so that it is thread-safe. + */ - (void) _connect { if (_remote == nil) @@ -574,6 +578,12 @@ static NSDistributedNotificationCenter *netCenter = nil; Protocol *p = @protocol(GDNCProtocol); [_remote setProtocolForProxy: p]; + + /* + * Ensure that this center can be used safely from different + * threads. + */ + [c enableMultipleThreads]; /* * Ask to be told if the connection goes away. diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 83d97cefe..16bed35ae 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -1243,10 +1243,14 @@ static NSFileManager* defaultManager = nil; } return (res & FILE_ATTRIBUTE_READONLY) ? NO : YES; #else - cpath = [self fileSystemRepresentationWithPath: - [path stringByDeletingLastPathComponent]]; + path = [path stringByDeletingLastPathComponent]; + if ([path length] == 0) + { + path = @"."; + } + cpath = [self fileSystemRepresentationWithPath: path]; - return (access(cpath, X_OK || W_OK) != 0); + return (access(cpath, X_OK | W_OK) == 0); #endif } } diff --git a/Source/NSKeyValueCoding.m b/Source/NSKeyValueCoding.m index b28a22c10..53e8dd6ca 100644 --- a/Source/NSKeyValueCoding.m +++ b/Source/NSKeyValueCoding.m @@ -37,6 +37,8 @@ #include #include +/** An exception for an unknown key */ +NSString* const NSUnknownKeyException = @"NSUnknownKeyException"; /** * This describes an informal protocol for key-value coding. @@ -58,19 +60,31 @@ - (id) handleQueryWithUnboundKey: (NSString*)aKey { - [NSException raise: NSGenericException - format: @"%@ -- %@ 0x%x: Unable to find value for key \"%@\"", - NSStringFromSelector(_cmd), NSStringFromClass([self class]), self, aKey]; - + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + self, + @"NSTargetObjectUserInfoKey", + aKey, + @"NSUnknownUserInfoKey", + nil]; + NSException *exp = [NSException exceptionWithName: NSUnknownKeyException + reason: @"Unable to find value for key" + userInfo: dict]; + [exp raise]; return nil; } - (void) handleTakeValue: (id)anObject forUnboundKey: (NSString*)aKey { - [NSException raise: NSGenericException - format: @"%@ -- %@ 0x%x: Unable set value \"%@\" for key \"%@\"", - NSStringFromSelector(_cmd), NSStringFromClass([self class]), - self, anObject, aKey]; + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + anObject, + @"NSTargetObjectUserInfoKey", + aKey, + @"NSUnknownUserInfoKey", + nil]; + NSException *exp = [NSException exceptionWithName: NSUnknownKeyException + reason: @"Unable to set value for key" + userInfo: dict]; + [exp raise]; } - (id) storedValueForKey: (NSString*)aKey diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 4444a4f54..15cfb45f4 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -178,31 +178,70 @@ _gnu_process_args(int argc, char *argv[], char *env[]) { free(_gnu_arg_zero); } - _gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1); - strcpy(_gnu_arg_zero, argv[0]); + + if (argv != 0) + { + _gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1); + strcpy(_gnu_arg_zero, argv[0]); + } + else + { +#ifdef __MINGW__ + char *buffer; + int buffer_size = 0; + int needed_size = 0; + + while (needed_size == buffer_size) + { + buffer_size = buffer_size + 256; + buffer = (char*)malloc(buffer_size); + needed_size = GetModuleFileNameA(NULL, buffer, buffer_size); + if (needed_size < buffer_size) + { + _gnu_arg_zero = buffer; + } + else + { + free(buffer); + } + } +#else + fprintf(stderr, "Error: for some reason, argv == NULL " + "during GNUstep base initialization\n"); + abort(); +#endif + } /* Getting the process name */ IF_NO_GC(RELEASE(_gnu_processName)); - _gnu_processName = [[NSString stringWithCString: argv[0]] lastPathComponent]; + _gnu_processName + = [[NSString stringWithCString: _gnu_arg_zero] lastPathComponent]; IF_NO_GC(RETAIN(_gnu_processName)); /* Copy the argument list */ { + NSString *str; NSMutableSet *mySet; id obj_argv[argc]; - int added = 0; + int added = 1; mySet = [NSMutableSet new]; - for (i = 0; i < argc; i++) + + /* Copy the zero'th argument to the argument list */ + str = [NSString stringWithCString: _gnu_arg_zero]; + obj_argv[0] = str; + + for (i = 1; i < argc; i++) { - NSString *str = [NSString stringWithCString: argv[i]]; + str = [NSString stringWithCString: argv[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)); @@ -710,6 +749,10 @@ int main(int argc, char *argv[], char *env[]) { os = NSBeOperatingSystem; } + else if ([n hasPrefix: @"darwin"] == YES) + { + os = NSMACHOperatingSystem; + } else if ([n hasPrefix: @"solaris"] == YES) { os = NSSolarisOperatingSystem; diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 5126e77de..76b444612 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -410,10 +410,8 @@ static BOOL shouldBeCompact = NO; * Variables to cache class information. */ static BOOL uniquing = NO; /* Make incoming strings unique */ -static Class IACls = 0; /* Immutable Array */ static Class MACls = 0; /* Mutable Array */ static Class DCls = 0; /* Data */ -static Class IDCls = 0; /* Immutable Dictionary */ static Class MDCls = 0; /* Mutable Dictionary */ static Class USCls = 0; /* Unicode String */ static Class CSCls = 0; /* C String */ @@ -433,29 +431,57 @@ static SEL deiSel; static SEL csInitSel; static SEL usInitSel; static SEL dInitSel; -static SEL iaInitSel; static SEL maInitSel; -static SEL idInitSel; static SEL mdInitSel; +static SEL maAddSel; +static SEL mdSetSel; static IMP csInitImp; static IMP usInitImp; static IMP dInitImp; -static IMP iaInitImp; static IMP maInitImp; -static IMP idInitImp; static IMP mdInitImp; +static IMP maAddImp; +static IMP mdSetImp; -static void +static BOOL initDeserializerInfo(_NSDeserializerInfo* info, NSData *d, unsigned *c, BOOL m) { + unsigned char u; + info->data = d; info->cursor = c; info->mutable = m; info->debImp = (void (*)())[d methodForSelector: debSel]; info->deiImp = (unsigned int (*)())[d methodForSelector: deiSel]; - (*info->debImp)(d, debSel, &info->didUnique, 1, c); + (*info->debImp)(d, debSel, &u, 1, c); + if (u == 0 || u == 1) + { + info->didUnique = u; // Old (current) format + } + else + { + if (u == 'G') + { + const unsigned char *b = [d bytes]; + unsigned int l = [d length]; + + if (*c + 11 < l && memcmp(&b[*c-1], "GNUstepSer", 10) == 0) + { + *c += 9; + (*info->debImp)(d, debSel, &u, 1, c); + NSLog(@"Serialised data version %d not supported ..." + @" try another version of GNUstep"); + return NO; + } + } + NSLog(@"Bad serialised data"); + return NO; + } if (info->didUnique) - GSIArrayInitWithZoneAndCapacity(&info->array, NSDefaultMallocZone(), 16); + { + GSIArrayInitWithZoneAndCapacity(&info->array, NSDefaultMallocZone(), 16); + } + return YES; } static void @@ -565,42 +591,31 @@ deserializeFromInfo(_NSDeserializerInfo* info) case ST_MARRAY: size = (*info->deiImp)(info->data, deiSel, info->cursor); { - id objects[size]; id a; - unsigned i; - for (i = 0; i < size; i++) + a = NSAllocateObject(MACls, 0, NSDefaultMallocZone()); + a = (*maInitImp)(a, maInitSel, size); + if (a != nil) { - objects[i] = deserializeFromInfo(info); - if (objects[i] == nil) + unsigned i; + + for (i = 0; i < size; i++) { -#if !GS_WITH_GC - while (i > 0) + id o = deserializeFromInfo(info); + + if (o == nil) { - [objects[--i] release]; + RELEASE(a); + return nil; } -#endif - objc_free(objects); - return nil; + (*maAddImp)(a, maAddSel, o); + RELEASE(o); + } + if (code != ST_MARRAY && info->mutable == NO) + { + [a makeImmutableCopyOnFail: NO]; } } - if (code == ST_MARRAY || info->mutable) - { - a = NSAllocateObject(MACls, 0, NSDefaultMallocZone()); - a = (*maInitImp)(a, maInitSel, objects, size); - } - else - { - a = NSAllocateObject(IACls, sizeof(id)*size, - NSDefaultMallocZone()); - a = (*iaInitImp)(a, iaInitSel, objects, size); - } -#if !GS_WITH_GC - for (i = 0; i < size; i++) - { - [objects[i] release]; - } -#endif return a; } @@ -608,56 +623,46 @@ deserializeFromInfo(_NSDeserializerInfo* info) case ST_MDICT: size = (*info->deiImp)(info->data, deiSel, info->cursor); { - id keys[size]; - id objects[size]; id d; - unsigned int i; - for (i = 0; i < size; i++) + d = NSAllocateObject(MDCls, 0, NSDefaultMallocZone()); + d = (*mdInitImp)(d, mdInitSel, size); + if (d != nil) { - keys[i] = deserializeFromInfo(info); - if (keys[i] == nil) + unsigned int i; + + for (i = 0; i < size; i++) { -#if !GS_WITH_GC - while (i > 0) + id k = deserializeFromInfo(info); + + if (k == nil) { - [keys[--i] release]; - [objects[i] release]; + RELEASE(d); + return nil; + } + else + { + id o = deserializeFromInfo(info); + + if (o == nil) + { + RELEASE(k); + RELEASE(d); + return nil; + } + else + { + (*mdSetImp)(d, mdSetSel, o, k); + RELEASE(k); + RELEASE(o); + } } -#endif - return nil; } - objects[i] = deserializeFromInfo(info); - if (objects[i] == nil) + if (code != ST_MDICT && info->mutable == NO) { -#if !GS_WITH_GC - [keys[i] release]; - while (i > 0) - { - [keys[--i] release]; - [objects[i] release]; - } -#endif - return nil; + [d makeImmutableCopyOnFail: NO]; } } - if (code == ST_MDICT || info->mutable) - { - d = NSAllocateObject(MDCls, 0, NSDefaultMallocZone()); - d = (*mdInitImp)(d, mdInitSel, objects, keys, size); - } - else - { - d = NSAllocateObject(IDCls, 0, NSDefaultMallocZone()); - d = (*idInitImp)(d, idInitSel, objects, keys, size); - } -#if !GS_WITH_GC - for (i = 0; i < size; i++) - { - [keys[i] release]; - [objects[i] release]; - } -#endif return d; } @@ -728,8 +733,15 @@ deserializeFromInfo(_NSDeserializerInfo* info) _NSDeserializerProxy *proxy; proxy = (_NSDeserializerProxy*)NSAllocateObject(self,0,NSDefaultMallocZone()); - initDeserializerInfo(&proxy->info, RETAIN(d), c, m); - return AUTORELEASE(proxy); + if (initDeserializerInfo(&proxy->info, RETAIN(d), c, m) == YES) + { + return AUTORELEASE(proxy); + } + else + { + DESTROY(proxy); + return nil; + } } - (void) dealloc @@ -784,24 +796,22 @@ deserializeFromInfo(_NSDeserializerInfo* info) csInitSel = @selector(initWithCStringNoCopy:length:freeWhenDone:); usInitSel = @selector(initWithCharactersNoCopy:length:freeWhenDone:); dInitSel = @selector(initWithBytesNoCopy:length:); - iaInitSel = @selector(initWithObjects:count:); - maInitSel = @selector(initWithObjects:count:); - idInitSel = @selector(initWithObjects:forKeys:count:); - mdInitSel = @selector(initWithObjects:forKeys:count:); - IACls = [GSInlineArray class]; + maInitSel = @selector(initWithCapacity:); + mdInitSel = @selector(initWithCapacity:); + maAddSel = @selector(addObject:); + mdSetSel = @selector(setObject:forKey:); MACls = [GSMutableArray class]; DCls = [NSDataMalloc class]; - IDCls = [GSDictionary class]; MDCls = [GSMutableDictionary class]; USCls = [GSUnicodeString class]; CSCls = [GSCString class]; csInitImp = [CSCls instanceMethodForSelector: csInitSel]; usInitImp = [USCls instanceMethodForSelector: usInitSel]; dInitImp = [DCls instanceMethodForSelector: dInitSel]; - iaInitImp = [IACls instanceMethodForSelector: iaInitSel]; maInitImp = [MACls instanceMethodForSelector: maInitSel]; - idInitImp = [IDCls instanceMethodForSelector: idInitSel]; mdInitImp = [MDCls instanceMethodForSelector: mdInitSel]; + maAddImp = [MACls instanceMethodForSelector: maAddSel]; + mdSetImp = [MDCls instanceMethodForSelector: mdSetSel]; } } @@ -817,10 +827,16 @@ deserializeFromInfo(_NSDeserializerInfo* info) return nil; } NSAssert(cursor != 0, NSInvalidArgumentException); - initDeserializerInfo(&info, data, cursor, flag); - o = deserializeFromInfo(&info); - endDeserializerInfo(&info); - return AUTORELEASE(o); + if (initDeserializerInfo(&info, data, cursor, flag) == YES) + { + o = deserializeFromInfo(&info); + endDeserializerInfo(&info); + return AUTORELEASE(o); + } + else + { + return nil; + } } + (id) deserializePropertyListFromData: (NSData*)data @@ -834,10 +850,16 @@ deserializeFromInfo(_NSDeserializerInfo* info) { return nil; } - initDeserializerInfo(&info, data, &cursor, flag); - o = deserializeFromInfo(&info); - endDeserializerInfo(&info); - return AUTORELEASE(o); + if (initDeserializerInfo(&info, data, &cursor, flag) == YES) + { + o = deserializeFromInfo(&info); + endDeserializerInfo(&info); + return AUTORELEASE(o); + } + else + { + return nil; + } } + (id) deserializePropertyListLazilyFromData: (NSData*)data @@ -855,10 +877,16 @@ deserializeFromInfo(_NSDeserializerInfo* info) _NSDeserializerInfo info; id o; - initDeserializerInfo(&info, data, cursor, flag); - o = deserializeFromInfo(&info); - endDeserializerInfo(&info); - return AUTORELEASE(o); + if (initDeserializerInfo(&info, data, cursor, flag) == YES) + { + o = deserializeFromInfo(&info); + endDeserializerInfo(&info); + return AUTORELEASE(o); + } + else + { + return nil; + } } else { diff --git a/Source/NSUser.m b/Source/NSUser.m index 0b9fbf45a..f92684688 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -280,7 +280,7 @@ NSHomeDirectoryForUser(NSString *loginName) /* The environment variable HOMEPATH holds the home directory for the user on Windows NT; Win95 has no concept of home. */ s = GSStringFromWin32EnvironmentVariable("HOMEPATH"); - if (s != nil) + if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':')) { s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE") stringByAppendingString: s]; diff --git a/Testing/LoadMe.m b/Testing/LoadMe.m index 93c794a96..986399f2b 100644 --- a/Testing/LoadMe.m +++ b/Testing/LoadMe.m @@ -21,7 +21,7 @@ - afterLoad { - printf("%s's instance variable is %i\n", [self name], var); + printf("%s's instance variable is %i\n", [self description], var); return self; } diff --git a/Testing/nsarray.m b/Testing/nsarray.m index 2b74b49e1..6e79d353c 100644 --- a/Testing/nsarray.m +++ b/Testing/nsarray.m @@ -4,6 +4,11 @@ #include #include +int compare(id elem1, id elem2, void* context) +{ + return (int)[elem1 performSelector:@selector(compare:) withObject:elem2]; +} + int main() { @@ -129,11 +134,6 @@ main() } { - int compare(id elem1, id elem2, void* context) - { - return (int)[elem1 performSelector:@selector(compare:) withObject:elem2]; - } - // Deriving new arrays NSRange r = NSMakeRange(0, 3); diff --git a/Testing/nsdate.m b/Testing/nsdate.m index 59167b966..ccb66c141 100644 --- a/Testing/nsdate.m +++ b/Testing/nsdate.m @@ -3,7 +3,6 @@ #include #include #include -#include #ifdef __MS_WIN32__ int _MB_init_runtime() diff --git a/Testing/nsfilemanager.m b/Testing/nsfilemanager.m index 1368889f5..f34f03a39 100644 --- a/Testing/nsfilemanager.m +++ b/Testing/nsfilemanager.m @@ -1,5 +1,7 @@ #include +static int errors = 0; + @interface Handler : NSObject - (BOOL) fileManager: (NSFileManager*)manager shouldProceedAfterError: (NSString*)error; @@ -12,12 +14,14 @@ willProcessPath: (NSString*)path; shouldProceedAfterError: (NSString*)error { NSLog(@"Error - %@", error); + errors++; return NO; } - (BOOL) fileManager: (NSFileManager*)manager willProcessPath: (NSString*)path { NSLog(@"Processing %@", path); + errors++; return NO; } @end @@ -39,6 +43,7 @@ main () if ([mgr copyPath: src toPath: dst handler: handler] == NO) { NSLog(@"Copy %@ to %@ failed", src, dst); + errors++; } } @@ -48,10 +53,13 @@ main () if ([mgr removeFileAtPath: src handler: handler] == NO) { NSLog(@"Remove %@ failed", src); + errors++; } } RELEASE(arp); + if (errors == 0) + printf("Tests passed\n"); exit (0); } diff --git a/Testing/nsscanner.m b/Testing/nsscanner.m index abf79a3d4..070320ef9 100644 --- a/Testing/nsscanner.m +++ b/Testing/nsscanner.m @@ -953,5 +953,6 @@ main (int argc, char **argv) runtest (testScanUpToString); runtest (testScanCharactersFromSet); runtest (testScanUpToCharactersFromSet); + printf("Finished Tests\n"); return 0; } diff --git a/Testing/nstimezone.m b/Testing/nstimezone.m index ec019ad43..7310ad5cd 100644 --- a/Testing/nstimezone.m +++ b/Testing/nstimezone.m @@ -1,6 +1,7 @@ /* Test time zone code. */ #include +#include #include #include #include @@ -10,6 +11,7 @@ int main () { id detail; + CREATE_AUTORELEASE_POOL(pool); printf("time zones for PST:\n%s\n", [[[[NSTimeZone abbreviationMap] objectForKey: @"PST"] description] UTF8String]); @@ -17,5 +19,6 @@ main () [[[NSTimeZone timeZoneArray] description] UTF8String]); printf("local time zone:\n%s\n", [[[NSTimeZone localTimeZone] description] UTF8String]); + RELEASE(pool); return 0; } diff --git a/Testing/release.m b/Testing/release.m index 52b3f3ffe..e484d79c9 100644 --- a/Testing/release.m +++ b/Testing/release.m @@ -138,5 +138,6 @@ main () } #endif + printf("Tests finished\n"); exit (0); } diff --git a/Tools/AGSHtml.m b/Tools/AGSHtml.m index 782c04bcd..8b9aa9c32 100644 --- a/Tools/AGSHtml.m +++ b/Tools/AGSHtml.m @@ -775,6 +775,7 @@ static NSMutableSet *textNodes = nil; if (val == nil) { val = text; + if (val == nil) val = @""; } [buf appendString: [self makeAnchor: val ofType: @"label" name: @""]]; } @@ -844,6 +845,7 @@ static NSMutableSet *textNodes = nil; { NSString *content = [t content]; + if (content == nil) content = @""; str = [str stringByAppendingString: content]; } t = [t next]; @@ -1180,6 +1182,7 @@ static NSMutableSet *textNodes = nil; if (val == nil) { val = text; + if (val == nil) val = @""; } [buf appendString: [self makeAnchor: val ofType: @"label" name: text]]; @@ -1219,6 +1222,7 @@ static NSMutableSet *textNodes = nil; { NSString *content = [t content]; + if (content == nil) content = @""; str = [str stringByAppendingString: content]; } t = [t next]; @@ -1333,6 +1337,7 @@ static NSMutableSet *textNodes = nil; { NSString *content = [t content]; + if (content == nil) content = @""; sel = [sel stringByAppendingString: content]; if (hadArg == YES) { @@ -1356,7 +1361,10 @@ static NSMutableSet *textNodes = nil; { if ([t type] == XML_TEXT_NODE) { - str = [str stringByAppendingString: [t content]]; + NSString *content = [t content]; + + if (content == nil) content = @""; + str = [str stringByAppendingString: content]; } t = [t next]; } @@ -1991,6 +1999,7 @@ NSLog(@"Element '%@' not implemented", name); // FIXME { NSString *str = [node content]; + if (str == nil) str = @""; [buf appendString: str]; } else if ([node type] == XML_ENTITY_REF_NODE) @@ -2043,6 +2052,7 @@ NSLog(@"Element '%@' not implemented", name); // FIXME { NSString *text = [[node firstChild] content]; + if (text == nil) text = @""; [buf appendString: indent]; [buf appendString: @"
"]; [buf appendString: [self protocolRef: text]]; diff --git a/Tools/AGSIndex.m b/Tools/AGSIndex.m index eb56b8a4c..e9c28592a 100644 --- a/Tools/AGSIndex.m +++ b/Tools/AGSIndex.m @@ -274,6 +274,7 @@ setDirectory(NSMutableDictionary *dict, NSString *path) { NSMutableDictionary *d; NSString *k; + NSString *c; d = [refs objectForKey: @"contents"]; if (d == nil) @@ -285,7 +286,9 @@ setDirectory(NSMutableDictionary *dict, NSString *path) k = [NSString stringWithFormat: @"%03u%03u%03u%03u", chap, sect, ssect, sssect]; - [d setObject: [[children content] stringByTrimmingSpaces] forKey: k]; + c = [[children content] stringByTrimmingSpaces]; + if (c == nil) c = @""; + [d setObject: c forKey: k]; children = nil; } else if ([name isEqual: @"ivariable"] == YES) @@ -303,6 +306,7 @@ setDirectory(NSMutableDictionary *dict, NSString *path) NSString *val; text = [[children content] stringByTrimmingSpaces]; + if (text == nil) text = @""; children = nil; all = [refs objectForKey: name]; if (all == nil) @@ -352,8 +356,11 @@ setDirectory(NSMutableDictionary *dict, NSString *path) { if ([t type] == XML_TEXT_NODE) { - sel = [sel stringByAppendingString: - [[t content] stringByTrimmingSpaces]]; + NSString *s; + + s = [[t content] stringByTrimmingSpaces]; + if (s == nil) s = @""; + sel = [sel stringByAppendingString: s]; } t = [t next]; } @@ -416,6 +423,7 @@ setDirectory(NSMutableDictionary *dict, NSString *path) else if ([name isEqual: @"title"] == YES) { NSMutableDictionary *d; + NSString *s; d = [refs objectForKey: @"title"]; if (d == nil) @@ -425,8 +433,9 @@ setDirectory(NSMutableDictionary *dict, NSString *path) RELEASE(d); } - [d setObject: [[children content] stringByTrimmingSpaces] - forKey: base]; + s = [[children content] stringByTrimmingSpaces]; + if (s == nil) s = @""; + [d setObject: s forKey: base]; children = nil; } else diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index f106becb3..3673be0f7 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -1344,6 +1344,31 @@ } } + if (buffer[pos] == '_') + { + NSString *ident = [self parseIdentifier]; + + if ([ident isEqualToString: @"__attribute__"] == YES) + { + [self skipSpaces]; + if (pos < length && buffer[pos] == '(') + { + [self skipBlock]; + [self skipSpaces]; + } + } + else + { + [self log: @"Underscore is not from __attribute__"]; + goto fail; + } + if (pos >= length) + { + [self log: @"Unexpected end of declaration"]; + goto fail; + } + } + if (buffer[pos] == ';') { [self skipStatement]; diff --git a/Version b/Version index 84c47763c..f86cffabb 100644 --- a/Version +++ b/Version @@ -6,8 +6,8 @@ GCC_VERSION=2.8.0 # The version number of this release. MAJOR_VERSION=1 -MINOR_VERSION=5 -SUBMINOR_VERSION=2 +MINOR_VERSION=6 +SUBMINOR_VERSION=0 GNUSTEP_BASE_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION} VERSION=${GNUSTEP_BASE_VERSION} diff --git a/config/config.vasprintf.c b/config/config.vasprintf.c index 18231c8ca..f79cefb04 100644 --- a/config/config.vasprintf.c +++ b/config/config.vasprintf.c @@ -1,10 +1,23 @@ /* Exit with status 0 if vasprintf returns the length of the string printed. Some systems return a pointer to the string instead. */ +#include +#include -int main () +static int func(const char *fmt, ...) { + va_list ap; char *buf; - if (vasprintf (&buf, "1234") == 4) + int result; + + va_start(ap, fmt); + result = vasprintf(&buf, fmt, ap); + va_end(ap); + return result; +} + +int main() +{ + if (func("1234", 0) == 4) exit (0); exit (-1); } diff --git a/config/config.vsprintf.c b/config/config.vsprintf.c index 5c1ba9ed3..594f3e947 100644 --- a/config/config.vsprintf.c +++ b/config/config.vsprintf.c @@ -1,10 +1,23 @@ /* Exit with status 0 if vsprintf returns the length of the string printed. Some systems return a pointer to the string instead. */ +#include +#include -int main () +static int func(const char *fmt, ...) { + va_list ap; char buf[128]; - if (vsprintf (buf, "1234") == 4) + int result; + + va_start(ap, fmt); + result = vsprintf(buf, fmt, ap); + va_end(ap); + return result; +} + +int main() +{ + if (func("1234", 0) == 4) exit (0); exit (-1); } diff --git a/configure b/configure index 5138c4ec1..e8489a4ae 100755 --- a/configure +++ b/configure @@ -2656,7 +2656,7 @@ fi # The following one is so that headers of custom libraries into # $GNUSTEP_HDIR are used before the standard ones # -CPPFLAGS="$CPPFLAGS -I $GNUSTEP_HDIR" +CPPFLAGS="$CPPFLAGS -I$GNUSTEP_HDIR" LDFLAGS="$LDFLAGS -L$GNUSTEP_LDIR/$LIBRARY_COMBO -L$GNUSTEP_LDIR" #-------------------------------------------------------------------- @@ -6020,7 +6020,7 @@ else # 64-bit ints not supported - but we need a dummy type for byte-swapping # of 64-bit values arriving from another system. GS_SINT64="struct { gsu8 a8; }" - GS_SINT64="struct { gsu8 a9; }" + GS_SINT64="struct { gsu8 a8; }" GS_HAVE_I64=0 fi fi @@ -6099,7 +6099,7 @@ if test $ac_cv_sizeof_long = 4; then else if test $ac_cv_sizeof_long = 8; then _GSC_S_LNG=_GSC_I64 -v else + else if test $ac_cv_sizeof_long = 16; then _GSC_S_LNG=_GSC_I128 fi diff --git a/configure.ac b/configure.ac index c375f5612..aa431480f 100644 --- a/configure.ac +++ b/configure.ac @@ -369,7 +369,7 @@ if test $ac_cv_sizeof_long = 4; then else if test $ac_cv_sizeof_long = 8; then _GSC_S_LNG=_GSC_I64 -v else + else if test $ac_cv_sizeof_long = 16; then _GSC_S_LNG=_GSC_I128 fi