Hey,
Am Sonntag, den 26.07.2009, 11:10 +0800 schrieb Georg Fleischmann:
> > I believe this is not correct. -boolValue is documented in Cocoa
> > to do
> > pretty much what the compatibility implementation does. So I believe
> > the "correct" fix would be to simply remove our compatibility
> > category.
>
> [NSString boolValue] has just been added in Mac OS 10.5, but
> basically the method does the same thing.
> I feel it still makes sense to have this method in GSCompatibility,
> since Mac OS 10.4 is good.
>
>
> > It would be great if someone who understands the macro magic wrt. OS X
> > versions could compile the category conditionally and sync the
> > implementation.
>
> The following does it:
>
>
> #ifndef MAC_OS_X_VERSION_10_5
> - (BOOL) boolValue
> {
> ...
> }
> #endif
Well that version will work for the current version but will compile it
again for future versions. My best bet would be something like the
attached patch. Richard, is this usage of the API macros legitimate?
Cheers,
David
PS: The patch is untested since I do not have an Cocoa version.
--
David Ayers Fellow of the Free Software Foundation Europe
http://www.fsfe.org http://fellowship.fsfe.org
Index: Source/Additions/GSCompatibility.m
===================================================================
--- Source/Additions/GSCompatibility.m (Revision 28408)
+++ Source/Additions/GSCompatibility.m (Arbeitskopie)
@@ -394,6 +394,7 @@
@implementation NSString(GSCompatibility)
+#if OS_API_VERSION (MAC_OS_X_VERSION_10_2,MAC_OS_X_VERSION_10_5)
// From GNUStep
/**
* If the string consists of the words 'true' or 'yes' (case insensitive)
@@ -402,16 +403,20 @@
*/
- (BOOL) boolValue
{
- if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
+ static NSCharacterSet *yes = nil;
+
+ if (yes == nil)
{
- return YES;
+ yes = RETAIN([NSCharacterSet characterSetWithCharactersInString:
+ @"123456789yYtT"]);
}
- if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame)
+ if ([self rangeOfCharacterFromSet: yes].length > 0)
{
- return YES;
+ return YES;
}
- return [self intValue] != 0 ? YES : NO;
+ return NO;
}
+#endif
- (NSString*) substringFromRange:(NSRange)range
{
_______________________________________________
Bug-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnustep