mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
NSString fixes from Stevo Crvenkovski
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2672 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ec7562e25e
commit
b55bf54177
5 changed files with 193 additions and 42 deletions
|
@ -39,7 +39,8 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self _collectionDealloc];
|
||||
if (_free_contents)
|
||||
OBJC_FREE(_contents_chars);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -52,6 +53,7 @@
|
|||
_count = length;
|
||||
_contents_chars = byteString;
|
||||
_free_contents = flag;
|
||||
[super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -66,6 +68,11 @@
|
|||
return a;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithCString:""];
|
||||
}
|
||||
|
||||
- (void) _collectionReleaseContents
|
||||
{
|
||||
return;
|
||||
|
@ -269,6 +276,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
|||
OBJC_MALLOC(_contents_chars, char, _capacity);
|
||||
_contents_chars[0] = '\0';
|
||||
_free_contents = YES;
|
||||
[super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -278,6 +286,14 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
|||
range.location, range.length);
|
||||
}
|
||||
|
||||
// xxx This should be primitive method
|
||||
- (void) replaceCharactersInRange: (NSRange)range
|
||||
withString: (NSString*)aString
|
||||
{
|
||||
[self deleteCharactersInRange:range];
|
||||
[self insertString:aString atIndex:range.location];
|
||||
}
|
||||
|
||||
- (void) insertString: (NSString*)aString atIndex:(unsigned)index
|
||||
{
|
||||
unsigned c = [aString cStringLength];
|
||||
|
@ -336,11 +352,30 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
|||
length: (unsigned int)length
|
||||
freeWhenDone: (BOOL)flag
|
||||
{
|
||||
[self initWithCapacity:length];
|
||||
[self setCString:byteString length:length];
|
||||
_count = length;
|
||||
_capacity = length+1;
|
||||
_contents_chars = byteString;
|
||||
_free_contents = flag;
|
||||
[super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Override NSString's designated initializer for Unicode Strings. */
|
||||
- (id) initWithCharactersNoCopy: (unichar*)chars
|
||||
length: (unsigned int)length
|
||||
freeWhenDone: (BOOL)flag
|
||||
{
|
||||
id a = [[NSGMutableString alloc] initWithCharactersNoCopy: chars
|
||||
length: length
|
||||
freeWhenDone: flag];
|
||||
[self release];
|
||||
return a;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithCString:""];
|
||||
};
|
||||
|
||||
/* For IndexedCollecting Protocol and other GNU libobjects conformity. */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue