git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25256 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-06-14 05:20:17 +00:00
parent da789a0c2b
commit 7ced4e5508
2 changed files with 30 additions and 14 deletions

View file

@ -1,6 +1,7 @@
2007-06-14 Richard Frith-Macdonald <rfm@gnu.org> 2007-06-14 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Source/NSNumber.m: Implement ([isEqualToValue:]) * Source/NSNumber.m: Implement ([isEqualToValue:])
* Source/NSPredicate.m: Fix bug #20169
2007-06-13 Richard Frith-Macdonald <rfm@gnu.org> 2007-06-13 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -757,7 +757,7 @@
return NO; return NO;
} }
return ([leftResult rangeOfString: rightResult options: compareOptions].location != NSNotFound); return ([rightResult rangeOfString: leftResult options: compareOptions].location != NSNotFound);
case NSCustomSelectorPredicateOperatorType: case NSCustomSelectorPredicateOperatorType:
{ {
BOOL (*function)(id,SEL,id) = (BOOL (*)(id,SEL,id))[leftResult methodForSelector: _selector]; BOOL (*function)(id,SEL,id) = (BOOL (*)(id,SEL,id))[leftResult methodForSelector: _selector];
@ -1652,8 +1652,10 @@
NSPredicateOperatorType type = 0; NSPredicateOperatorType type = 0;
unsigned opts = 0; unsigned opts = 0;
NSExpression *left; NSExpression *left;
NSExpression *right;
NSPredicate *p; NSPredicate *p;
BOOL negate = NO; BOOL negate = NO;
BOOL swap = NO;
if ([self scanPredicateKeyword: @"ANY"]) if ([self scanPredicateKeyword: @"ANY"])
{ {
@ -1679,8 +1681,8 @@
{ {
type = NSLessThanPredicateOperatorType; type = NSLessThanPredicateOperatorType;
} }
else if ([self scanString: @"<=" intoString: NULL] || else if ([self scanString: @"<=" intoString: NULL]
[self scanString: @"=<" intoString: NULL]) || [self scanString: @"=<" intoString: NULL])
{ {
type = NSLessThanOrEqualToPredicateOperatorType; type = NSLessThanOrEqualToPredicateOperatorType;
} }
@ -1688,18 +1690,18 @@
{ {
type = NSGreaterThanPredicateOperatorType; type = NSGreaterThanPredicateOperatorType;
} }
else if ([self scanString: @">=" intoString: NULL] || else if ([self scanString: @">=" intoString: NULL]
[self scanString: @"=>" intoString: NULL]) || [self scanString: @"=>" intoString: NULL])
{ {
type = NSGreaterThanOrEqualToPredicateOperatorType; type = NSGreaterThanOrEqualToPredicateOperatorType;
} }
else if ([self scanString: @"==" intoString: NULL] || else if ([self scanString: @"==" intoString: NULL]
[self scanString: @"=" intoString: NULL]) || [self scanString: @"=" intoString: NULL])
{ {
type = NSEqualToPredicateOperatorType; type = NSEqualToPredicateOperatorType;
} }
else if ([self scanString: @"!=" intoString: NULL] || else if ([self scanString: @"!=" intoString: NULL]
[self scanString: @"<>" intoString: NULL]) || [self scanString: @"<>" intoString: NULL])
{ {
type = NSNotEqualToPredicateOperatorType; type = NSNotEqualToPredicateOperatorType;
} }
@ -1719,11 +1721,15 @@
{ {
type = NSEndsWithPredicateOperatorType; type = NSEndsWithPredicateOperatorType;
} }
else if ([self scanPredicateKeyword: @"IN"] || else if ([self scanPredicateKeyword: @"IN"])
[self scanPredicateKeyword: @"CONTAINS"])
{ {
type = NSInPredicateOperatorType; type = NSInPredicateOperatorType;
} }
else if ([self scanPredicateKeyword: @"CONTAINS"])
{
type = NSInPredicateOperatorType;
swap = YES;
}
else if ([self scanPredicateKeyword: @"BETWEEN"]) else if ([self scanPredicateKeyword: @"BETWEEN"])
{ {
// Requires special handling to transfer into AND of // Requires special handling to transfer into AND of
@ -1778,8 +1784,17 @@
opts = NSDiacriticInsensitivePredicateOption; opts = NSDiacriticInsensitivePredicateOption;
} }
right = [self parseExpression];
if (swap == YES)
{
NSExpression *tmp = left;
left = right;
right = tmp;
}
p = [NSComparisonPredicate predicateWithLeftExpression: left p = [NSComparisonPredicate predicateWithLeftExpression: left
rightExpression: [self parseExpression] rightExpression: right
modifier: modifier modifier: modifier
type: type type: type
options: opts]; options: opts];