bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix, Base/GDL2 GSCompatibility.m (-boolValue)


From: Georg Fleischmann
Subject: Re: Fix, Base/GDL2 GSCompatibility.m (-boolValue)
Date: Sun, 26 Jul 2009 11:10:46 +0800

Hi,

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


Best wishes,
Georg


On 25.07.2009, at 01:28, David Ayers wrote:

Hello Georg,

Am Freitag, den 17.07.2009, 10:50 +0800 schrieb Georg Fleischmann:
here is a patch for Base to make GDL2 on Cocoa work with boolean
values from EOModels.
The boolean values in my EOModel files are stored as "Y" only, not a
complete "Yes" ( allowsNull = Y; ).
This ("Y") works fine on a complete GNUstep system, but fails with
the Compatibility code that is only allowing a complete "YES" (or
"TRUE").

The attached patch makes this work for me with Cocoa.
I tried to make it similar to the latest boolValue method in
GSString, testing for "123456789yYtT".

Best wishes,
Georg

PS: I am still using Base-Version 1.15.0 on Apple, because the
current base-versions doesn't seem to compile any more with Mac OS
10.4.11. Anyway, [GSCompatibility -boolValue] didn't change since then.

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.

I could commit that patch right now, but I had second thoughts that the category would still be useful for older Cocoa/OS X versions. But even
then, it should be synchronized with current implementation of -base.

It would be great if someone who understands the macro magic wrt. OS X
versions could compile the category conditionally and sync the
implementation.

Cheers,
David


*** Source/Additions/GSCompatibility.m.old      Thu Apr 12 22:27:47 2007
--- Source/Additions/GSCompatibility.m  Fri Jul 17 10:29:29 2009
***************
*** 390,404 ****
    */
   - (BOOL) boolValue
   {
!   if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
       {
!         return YES;
!     }
!   if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame)
!     {
!         return YES;
       }
!   return [self intValue] != 0 ? YES : NO;
   }

   - (NSString*) substringFromRange:(NSRange)range
--- 390,405 ----
    */
   - (BOOL) boolValue
   {
!   if ([self length])
       {
!       unichar uc = [self characterAtIndex:0];
!
!       if (uc <= 0x7F && strchr("123456789yYtT", (char)uc) != 0)
!         {
!           return YES;
!         }
       }
!   return NO;
   }

   - (NSString*) substringFromRange:(NSRange)range



_______________________________________________
Bug-gnustep mailing list
Bug-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnustep
--
David Ayers          Fellow of the Free Software Foundation Europe
http://www.fsfe.org                     http://fellowship.fsfe.org








reply via email to

[Prev in Thread] Current Thread [Next in Thread]