From: helge Date: Sat, 6 Aug 2005 17:53:52 +0000 (+0000) Subject: improved decoding of bools X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a8b09e4888895d8409ed9888e41fc7d30e4f307;p=sope improved decoding of bools git-svn-id: http://svn.opengroupware.org/SOPE/trunk@979 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/EOControl/ChangeLog b/sope-core/EOControl/ChangeLog index f6e8f381..7b65e8d8 100644 --- a/sope-core/EOControl/ChangeLog +++ b/sope-core/EOControl/ChangeLog @@ -1,3 +1,7 @@ +2005-08-06 Helge Hess + + * EOKeyValueArchiver.m: improved decoding of bools (v4.5.59) + 2005-08-05 Helge Hess * v4.5.58 diff --git a/sope-core/EOControl/EOKeyValueArchiver.m b/sope-core/EOControl/EOKeyValueArchiver.m index 9b8b2fe5..8649be35 100644 --- a/sope-core/EOControl/EOKeyValueArchiver.m +++ b/sope-core/EOControl/EOKeyValueArchiver.m @@ -296,7 +296,23 @@ static BOOL isPListObject(id _obj) { } - (BOOL)decodeBoolForKey:(NSString *)_key { - return [[self->plist objectForKey:_key] boolValue]; + id v; + + if ((v = [self->plist objectForKey:_key]) == nil) + return NO; + + if ([v isKindOfClass:[NSString class]]) { + unsigned l = [v length]; + + if (l == 4 && [v isEqualToString:@"true"]) return YES; + if (l == 5 && [v isEqualToString:@"false"]) return NO; + if (l == 3 && [v isEqualToString:@"YES"]) return YES; + if (l == 2 && [v isEqualToString:@"NO"]) return NO; + if (l == 1 && [v characterAtIndex:0] == '1') return YES; + if (l == 1 && [v characterAtIndex:0] == '0') return NO; + } + + return [v boolValue]; } - (int)decodeIntForKey:(NSString *)_key { return [[self->plist objectForKey:_key] intValue]; diff --git a/sope-core/EOControl/Version b/sope-core/EOControl/Version index 31494853..de3d3ecd 100644 --- a/sope-core/EOControl/Version +++ b/sope-core/EOControl/Version @@ -1,3 +1,3 @@ # version file -SUBMINOR_VERSION:=58 +SUBMINOR_VERSION:=59