Change behavior of -boolValue to match the new MacOS-X method of the same name.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26110 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-02-20 09:56:25 +00:00
parent 726b05507e
commit b4c5948f8d
3 changed files with 34 additions and 69 deletions

View file

@ -2615,21 +2615,26 @@ handle_printf_atsign (FILE *stream,
// xxx Should 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.
* Returns YES when scanning the receiver's text from left to right finds a
* digit in the range 1-9 or a letter in the set ('Y', 'y', 'T', 't').<br />
* Any trailing characters are ignored.<br />
* Any leading whitespace or zeros or signs are also ignored.<br />
* Returns NO if the above conditions are not met.
*/
- (BOOL) boolValue
{
if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
static NSCharacterSet *yes = nil;
if (yes == nil)
{
yes = RETAIN([NSCharacterSet characterSetWithCharactersInString:
@"123456789yYtT"]);
}
if ([self rangeOfCharacterFromSet: yes].length > 0)
{
return YES;
}
if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame)
{
return YES;
}
return [self intValue] != 0 ? YES : NO;
return NO;
}
/**