[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fix, Base/GDL2 GSCompatibility.m (-boolValue)
From: |
David Ayers |
Subject: |
Re: Fix, Base/GDL2 GSCompatibility.m (-boolValue) |
Date: |
Fri, 24 Jul 2009 19:28:03 +0200 |
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