mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Minor fix parsing booleans
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14241 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b8e7170255
commit
0422591a90
3 changed files with 23 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2002-08-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSString.m: ([-boolValue]) Accept 'true' as well as 'YES'
|
||||||
|
|
||||||
2002-07-29 Adam Fedor <fedor@gnu.org>
|
2002-07-29 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
* Merge changes from 1.4.0 onto main branch.
|
* Merge changes from 1.4.0 onto main branch.
|
||||||
|
|
|
@ -2182,10 +2182,21 @@ handle_printf_atsign (FILE *stream,
|
||||||
|
|
||||||
// xxx Sould we use NSScanner here ?
|
// xxx Sould we use NSScanner here ?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the string consists of the words 'true' or 'yes' (case insensitive)
|
||||||
|
* or begins with a non-zero numeric value, return YES, otherwise return
|
||||||
|
* NO.
|
||||||
|
*/
|
||||||
- (BOOL) boolValue
|
- (BOOL) boolValue
|
||||||
{
|
{
|
||||||
if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
|
if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
|
||||||
return YES;
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame)
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
return [self intValue] != 0 ? YES : NO;
|
return [self intValue] != 0 ? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -811,14 +811,19 @@ static NSString *pathForUser(NSString *user)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up a value for a specified default using -objectForKey:
|
* Looks up a value for a specified default using -objectForKey:
|
||||||
* and checks that it is a boolean. Returns NO if it is not.
|
* and returns its boolean representation.<br />
|
||||||
|
* Returns NO if it is not a boolean.<br />
|
||||||
|
* The text 'yes' or 'true' or any non zero numeric value is considered
|
||||||
|
* to be a boolean YES. Other string values are NO.
|
||||||
*/
|
*/
|
||||||
- (BOOL) boolForKey: (NSString*)defaultName
|
- (BOOL) boolForKey: (NSString*)defaultName
|
||||||
{
|
{
|
||||||
id obj = [self stringForKey: defaultName];
|
id obj = [self stringForKey: defaultName];
|
||||||
|
|
||||||
if (obj != nil)
|
if (obj != nil)
|
||||||
return [obj boolValue];
|
{
|
||||||
|
return [obj boolValue];
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue