diff --git a/ChangeLog b/ChangeLog index ff67cdfd8..1d9058f69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-08-14 Richard Frith-Macdonald + + * Source/GSString.m: Allow 'true' as boolean value + * Source/NSConcreteNumber.m: Output 'YES' as boolean in description. + * Source/NSNotificationCenter.m: Fix dumb memory leak. + * Source/NSNumber.m: Output 'YES' as boolean in description. + * Source/NSUserDefaults.m: Set 'YES' as boolean string. + * Headers/Foundation/NSObject.h: Fix v dumb memory leak. + 2002-08-11 Richard Frith-Macdonald * configure.ac: Check for libxml version 2.3.0 or greater to ensure diff --git a/Headers/gnustep/base/NSObject.h b/Headers/gnustep/base/NSObject.h index 5f93f0e12..3c64dae05 100644 --- a/Headers/gnustep/base/NSObject.h +++ b/Headers/gnustep/base/NSObject.h @@ -392,7 +392,7 @@ id __object = (id)(object); (__object != nil) ? [__object retain] : nil; }) #endif #ifndef TEST_RELEASE #define TEST_RELEASE(object) ({\ -id __object = (id)(object); if (__object != nil) [__object retain]; }) +id __object = (id)(object); if (__object != nil) [__object release]; }) #endif #ifndef TEST_AUTORELEASE #define TEST_AUTORELEASE(object) ({\ diff --git a/Source/GSString.m b/Source/GSString.m index c23248cd5..e3200625a 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -548,6 +548,14 @@ boolValue_c(ivars self) { return YES; } + else if (len == 4 + && (self->_contents.c[0] == 'T' || self->_contents.c[0] == 't') + && (self->_contents.c[1] == 'R' || self->_contents.c[1] == 'r') + && (self->_contents.c[2] == 'U' || self->_contents.c[2] == 'u') + && (self->_contents.c[3] == 'E' || self->_contents.c[3] == 'e')) + { + return YES; + } else { unsigned char buf[len+1]; @@ -580,6 +588,14 @@ boolValue_u(ivars self) { return YES; } + else if (l == 4 + && (buf[0] == 'T' || buf[0] == 't') + && (buf[1] == 'R' || buf[1] == 'r') + && (buf[2] == 'U' || buf[2] == 'u') + && (buf[3] == 'E' || buf[3] == 'e')) + { + return YES; + } else { return atoi(buf); diff --git a/Source/NSConcreteNumber.m b/Source/NSConcreteNumber.m index 096ce5e70..f00289c1d 100644 --- a/Source/NSConcreteNumber.m +++ b/Source/NSConcreteNumber.m @@ -376,7 +376,7 @@ - (NSString*) descriptionWithLocale: (NSDictionary*)locale { #if TYPE_ORDER == 0 - return (data) ? @"true" : @"false"; + return (data) ? @"YES" : @"NO"; #else NSString *result = [NSString alloc]; diff --git a/Source/NSNotificationCenter.m b/Source/NSNotificationCenter.m index 1620fe7cf..b625f048e 100644 --- a/Source/NSNotificationCenter.m +++ b/Source/NSNotificationCenter.m @@ -954,7 +954,7 @@ static NSNotificationCenter *default_center = nil; [NSException raise: NSInvalidArgumentException format: @"Tried to post a notification with no name."]; } - object = TEST_RETAIN([notification object]); + object = [notification object]; if (object != nil) { object = CHEATGC(object); diff --git a/Source/NSNumber.m b/Source/NSNumber.m index d93043695..a5d38635b 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -683,7 +683,7 @@ static Class doubleNumberClass; switch (info->typeLevel) { case 0: - return [self boolValue] ? @"true" : @"false"; + return [self boolValue] ? @"YES" : @"NO"; break; case 1: diff --git a/Source/NSObject.m b/Source/NSObject.m index 777de83c7..11ba0838a 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1258,7 +1258,7 @@ static BOOL double_release_check_enabled = NO; } /** - * Returns a flag to differnetiate between 'true' objects, and objects + * Returns a flag to differentiate between 'true' objects, and objects * which are proxies for other objects (ie they forward messages to the * other objects).
* The default implementation returns NO. diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 1ae368933..9ed7f000e 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -814,7 +814,10 @@ static NSString *pathForUser(NSString *user) * and returns its boolean representation.
* Returns NO if it is not a boolean.
* The text 'yes' or 'true' or any non zero numeric value is considered - * to be a boolean YES. Other string values are NO. + * to be a boolean YES. Other string values are NO.
+ * NB. This differs slightly from the documented behavior for MacOS-X + * (August 2002) in that the GNUstep version accepts the string 'TRUE' + * as equivalent to 'YES'. */ - (BOOL) boolForKey: (NSString*)defaultName { @@ -949,8 +952,9 @@ static NSString *pathForUser(NSString *user) } /** - * Sets a boolean value for defaultName in the application domain. - *
Calls -setObject:forKey: to make the change. + * Sets a boolean value for defaultName in the application domain.
+ * The boolean value is stored as a string - either YES or NO. + * Calls -setObject:forKey: to make the change. */ - (void) setBool: (BOOL)value forKey: (NSString*)defaultName {