mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Fixes from ANOQ.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2657 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8e5f91e5f8
commit
4345bf7ce0
4 changed files with 91 additions and 48 deletions
|
@ -6,9 +6,9 @@
|
|||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
|
||||
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
|
||||
Date: June 1997
|
||||
Date: November 1997
|
||||
|
||||
This file is part of ...
|
||||
This file is part of GNUStep-base
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
|
@ -28,8 +28,24 @@
|
|||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <Foundation/NSAttributedString.h>
|
||||
//FIXME: 1) The NSMutableString object returned from the -mutableString method
|
||||
// in NSMutableAttributedString is NOT tracked for changes to update
|
||||
// NSMutableAttributedString's attributes as it should.
|
||||
|
||||
//FIXME: 2) If out-of-memory exceptions are raised in some methods,
|
||||
// inconsistencies may develop, because the two internal arrays in
|
||||
// NSGAttributedString and NSGMutableAttributedString called
|
||||
// attributeArray and locateArray must always be syncronized.
|
||||
|
||||
//FIXME: 3) The method _setAttributesFrom: must be overridden by
|
||||
// concrete subclasses of NSAttributedString which is WRONG and
|
||||
// VERY bad! I haven't found any other way to make
|
||||
// - initWithString:attributes: the designated initializer
|
||||
// in NSAttributedString and still implement
|
||||
// - initWithAttributedString: without having to override it
|
||||
// in the concrete subclass.
|
||||
|
||||
#include <Foundation/NSGAttributedString.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
|
||||
|
@ -67,14 +83,14 @@ void _setAttributesFrom(
|
|||
void _initWithString(
|
||||
NSString *aString,
|
||||
NSDictionary *attributes,
|
||||
NSString *textChars,
|
||||
NSString **textChars,
|
||||
NSMutableArray **attributeArray,
|
||||
NSMutableArray **locateArray)
|
||||
{
|
||||
if (aString)
|
||||
[textChars initWithString:aString];
|
||||
*textChars = [(*textChars) initWithString:aString];
|
||||
else
|
||||
[textChars init];
|
||||
*textChars = [(*textChars) init];
|
||||
*attributeArray = [[NSMutableArray alloc] init];
|
||||
*locateArray = [[NSMutableArray alloc] init];
|
||||
if(!attributes)
|
||||
|
@ -159,7 +175,7 @@ NSDictionary *_attributesAtIndexEffectiveRange(
|
|||
|
||||
- initWithCoder: aCoder
|
||||
{
|
||||
[super initWithCoder:aCoder];
|
||||
self = [super initWithCoder:aCoder];
|
||||
textChars = [[aCoder decodeObject] retain];
|
||||
attributeArray = [[aCoder decodeObject] retain];
|
||||
locateArray = [[aCoder decodeObject] retain];
|
||||
|
@ -175,8 +191,9 @@ NSDictionary *_attributesAtIndexEffectiveRange(
|
|||
|
||||
- (id)initWithString:(NSString *)aString attributes:(NSDictionary *)attributes
|
||||
{
|
||||
self = [super initWithString:aString attributes:attributes];
|
||||
textChars = [NSString alloc];
|
||||
_initWithString(aString,attributes,textChars,&attributeArray,&locateArray);
|
||||
_initWithString(aString,attributes,&textChars,&attributeArray,&locateArray);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -223,7 +240,7 @@ NSDictionary *_attributesAtIndexEffectiveRange(
|
|||
|
||||
- initWithCoder: aCoder
|
||||
{
|
||||
[super initWithCoder:aCoder];
|
||||
self = [super initWithCoder:aCoder];
|
||||
textChars = [[aCoder decodeObject] retain];
|
||||
attributeArray = [[aCoder decodeObject] retain];
|
||||
locateArray = [[aCoder decodeObject] retain];
|
||||
|
@ -239,8 +256,9 @@ NSDictionary *_attributesAtIndexEffectiveRange(
|
|||
|
||||
- (id)initWithString:(NSString *)aString attributes:(NSDictionary *)attributes
|
||||
{
|
||||
self = [super initWithString:aString attributes:attributes];
|
||||
textChars = [NSMutableString alloc];
|
||||
_initWithString(aString,attributes,textChars,&attributeArray,&locateArray);
|
||||
_initWithString(aString,attributes,&textChars,&attributeArray,&locateArray);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue