mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Attributed string bugfix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13018 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0c745dbe3c
commit
66e38c5a67
2 changed files with 64 additions and 13 deletions
|
@ -1,3 +1,10 @@
|
|||
2002-03-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSAttributedString.m: Applied fix for left-over attributes
|
||||
at end of string. Patch supplied by Alexander Malmberg
|
||||
<alexander@malmberg.org>. Reformatting to conform to GNUstep
|
||||
standards, and optimisation by me.
|
||||
|
||||
2002-03-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Tools/autogsdoc.m: Output gsdoc as UTF8 as we should.
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
|
||||
#define SANITY_CHECKS 0
|
||||
|
||||
static NSDictionary *blank;
|
||||
|
||||
@interface GSAttributedString : NSAttributedString
|
||||
{
|
||||
NSString *_textChars;
|
||||
|
@ -268,6 +270,7 @@ static void _setup()
|
|||
if (infCls == 0)
|
||||
{
|
||||
NSMutableArray *a;
|
||||
NSDictionary *d;
|
||||
|
||||
GSIMapInitWithZoneAndCapacity(&attrMap, NSDefaultMallocZone(), 32);
|
||||
|
||||
|
@ -289,6 +292,9 @@ static void _setup()
|
|||
oatImp = [a methodForSelector: oatSel];
|
||||
remImp = (void (*)())[a methodForSelector: remSel];
|
||||
RELEASE(a);
|
||||
d = [NSDictionary new];
|
||||
blank = cacheAttributes(d);
|
||||
RELEASE(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,7 +317,7 @@ _setAttributesFrom(
|
|||
|
||||
if (aRange.length == 0)
|
||||
{
|
||||
attr = [NSDictionary dictionary];
|
||||
attr = blank;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -469,7 +475,7 @@ _attributesAtIndexEffectiveRange(
|
|||
|
||||
if (attributes == nil)
|
||||
{
|
||||
attributes = [NSDictionary dictionary];
|
||||
attributes = blank;
|
||||
}
|
||||
attributes = cacheAttributes(attributes);
|
||||
info = NEWINFO(z, attributes, 0);
|
||||
|
@ -533,7 +539,7 @@ _attributesAtIndexEffectiveRange(
|
|||
{
|
||||
info = OBJECTAT(i);
|
||||
NSAssert(info->loc > l, NSInternalInconsistencyException);
|
||||
NSAssert(info->loc <= len, NSInternalInconsistencyException);
|
||||
NSAssert(info->loc < len, NSInternalInconsistencyException);
|
||||
l = info->loc;
|
||||
}
|
||||
}
|
||||
|
@ -565,7 +571,7 @@ _attributesAtIndexEffectiveRange(
|
|||
|
||||
if (attributes == nil)
|
||||
{
|
||||
attributes = [NSDictionary dictionary];
|
||||
attributes = blank;
|
||||
}
|
||||
attributes = cacheAttributes(attributes);
|
||||
info = NEWINFO(z, attributes, 0);
|
||||
|
@ -625,7 +631,7 @@ SANITY();
|
|||
}
|
||||
if (attributes == nil)
|
||||
{
|
||||
attributes = [NSDictionary dictionary];
|
||||
attributes = blank;
|
||||
}
|
||||
attributes = cacheAttributes(attributes);
|
||||
SANITY();
|
||||
|
@ -783,6 +789,8 @@ SANITY();
|
|||
attrs = _attributesAtIndexEffectiveRange(start, &effectiveRange,
|
||||
tmpLength, _infoArray, &arrayIndex);
|
||||
|
||||
moveLocations = [aString length] - range.length;
|
||||
|
||||
arrayIndex++;
|
||||
if (NSMaxRange(effectiveRange) < NSMaxRange(range))
|
||||
{
|
||||
|
@ -811,10 +819,32 @@ SANITY();
|
|||
}
|
||||
}
|
||||
}
|
||||
info->loc = NSMaxRange(range);
|
||||
if (NSMaxRange(range) < [_textChars length])
|
||||
{
|
||||
info->loc = NSMaxRange(range);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arrayIndex != 0)
|
||||
{
|
||||
REMOVEAT(arrayIndex);
|
||||
arraySize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDictionary *d = blank;
|
||||
|
||||
unCacheAttributes(info->attrs);
|
||||
DESTROY(info->attrs);
|
||||
d = cacheAttributes(d);
|
||||
info->attrs = d;
|
||||
/* set location so it will be correct after being modified
|
||||
below */
|
||||
info->loc = NSMaxRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
moveLocations = [aString length] - range.length;
|
||||
/*
|
||||
* If we are replacing a range with a zero length string and the
|
||||
* range we are using matches the range replaced, then we must
|
||||
|
@ -827,12 +857,26 @@ SANITY();
|
|||
arrayIndex++;
|
||||
|
||||
if (effectiveRange.location == range.location
|
||||
&& effectiveRange.length == range.length)
|
||||
{
|
||||
arrayIndex--;
|
||||
REMOVEAT(arrayIndex);
|
||||
arraySize--;
|
||||
}
|
||||
&& effectiveRange.length == range.length)
|
||||
{
|
||||
arrayIndex--;
|
||||
if (arrayIndex!=0)
|
||||
{
|
||||
REMOVEAT(arrayIndex);
|
||||
arraySize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDictionary *d = blank;
|
||||
|
||||
info = OBJECTAT(0);
|
||||
unCacheAttributes(info->attrs);
|
||||
DESTROY(info->attrs);
|
||||
d = cacheAttributes(d);
|
||||
info->attrs = d;
|
||||
info->loc = NSMaxRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue