Bgfix reported by Fred Kiefer

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6497 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-04-23 05:51:38 +00:00
parent 1a4a624d54
commit a65430941b
2 changed files with 18 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2000-04-23 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAttributedString.m: Corrected code of
([-attribute:atIndex:longestEffectiveRange:inRange:]) so that it
compares attributes correctly.
2000-04-20 Jonathan Gapen <jagapen@whitewater.chem.wisc.edu> 2000-04-20 Jonathan Gapen <jagapen@whitewater.chem.wisc.edu>
* Tools/plmerge.m: New tool to merge property lists. * Tools/plmerge.m: New tool to merge property lists.

View file

@ -300,21 +300,26 @@ static Class NSMutableAttributedString_concrete_class;
id attrValue; id attrValue;
id tmpAttrValue; id tmpAttrValue;
NSRange tmpRange; NSRange tmpRange;
BOOL (*eImp)(id,SEL,id);
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length]) if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
{ {
[NSException raise: NSRangeException [NSException raise: NSRangeException
format: @"RangeError in method -attribute:atIndex:longestEffectiveRange:inRange: in class NSAttributedString"]; format: @"RangeError in method -attribute:atIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
} }
if (attributeName == nil)
return nil;
attrValue = [self attribute: attributeName attrValue = [self attribute: attributeName
atIndex: index atIndex: index
effectiveRange: aRange]; effectiveRange: aRange];
if (attributeName == nil)
return nil;
if (aRange == 0) if (aRange == 0)
return attrValue; return attrValue;
/*
* If attrValue == nil then eImp will be zero
*/
eImp = (BOOL(*)(id,SEL,id))[attrValue methodForSelector: @selector(isEqual:)];
while (aRange->location > rangeLimit.location) while (aRange->location > rangeLimit.location)
{ {
@ -322,7 +327,8 @@ static Class NSMutableAttributedString_concrete_class;
tmpDictionary = [self attributesAtIndex: aRange->location-1 tmpDictionary = [self attributesAtIndex: aRange->location-1
effectiveRange: &tmpRange]; effectiveRange: &tmpRange];
tmpAttrValue = [tmpDictionary objectForKey: attributeName]; tmpAttrValue = [tmpDictionary objectForKey: attributeName];
if (tmpAttrValue == attrValue) if (tmpAttrValue == attrValue
|| (eImp != 0 && (*eImp)(attrValue, @selector(isEqual), tmpAttrValue)))
{ {
aRange->length = NSMaxRange(*aRange) - tmpRange.location; aRange->length = NSMaxRange(*aRange) - tmpRange.location;
aRange->location = tmpRange.location; aRange->location = tmpRange.location;
@ -338,7 +344,8 @@ static Class NSMutableAttributedString_concrete_class;
tmpDictionary = [self attributesAtIndex: NSMaxRange(*aRange) tmpDictionary = [self attributesAtIndex: NSMaxRange(*aRange)
effectiveRange: &tmpRange]; effectiveRange: &tmpRange];
tmpAttrValue = [tmpDictionary objectForKey: attributeName]; tmpAttrValue = [tmpDictionary objectForKey: attributeName];
if (tmpAttrValue == attrValue) if (tmpAttrValue == attrValue
|| (eImp != 0 && (*eImp)(attrValue, @selector(isEqual), tmpAttrValue)))
{ {
aRange->length = NSMaxRange(tmpRange) - aRange->location; aRange->length = NSMaxRange(tmpRange) - aRange->location;
} }