mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +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
29ce1ddd8a
commit
5fd6374c07
5 changed files with 193 additions and 42 deletions
|
@ -66,6 +66,7 @@
|
|||
_count = length;
|
||||
_contents_chars = chars;
|
||||
_free_contents = flag;
|
||||
[super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -91,6 +92,14 @@
|
|||
return a;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
unichar *u;
|
||||
OBJC_MALLOC(u, unichar,1);
|
||||
u[0]=(unichar)0;
|
||||
return [self initWithCharactersNoCopy:u length:0 freeWhenDone: YES];
|
||||
}
|
||||
|
||||
// Getting a String's Length
|
||||
|
||||
- (unsigned int) length
|
||||
|
@ -325,6 +334,14 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *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];
|
||||
}
|
||||
|
||||
// xxx Check this
|
||||
- (void) insertString: (NSString*)aString atIndex:(unsigned)index
|
||||
{
|
||||
|
@ -372,17 +389,39 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
|
|||
_count = length;
|
||||
}
|
||||
|
||||
// xxx This should not be in this class
|
||||
/* Override NSString's designated initializer for CStrings. */
|
||||
- (id) initWithCStringNoCopy: (char*)byteString
|
||||
length: (unsigned int)length
|
||||
freeWhenDone: (BOOL)flag
|
||||
{
|
||||
[self initWithCapacity:length];
|
||||
[self setCString:byteString length:length];
|
||||
id a = [[NSGMutableCString alloc] initWithCStringNoCopy: byteString
|
||||
length: length
|
||||
freeWhenDone: flag];
|
||||
[self release];
|
||||
return a;
|
||||
}
|
||||
|
||||
/* Override NSString's designated initializer for Unicode Strings. */
|
||||
- (id) initWithCharactersNoCopy: (unichar*)chars
|
||||
length: (unsigned int)length
|
||||
freeWhenDone: (BOOL)flag
|
||||
{
|
||||
_count = length;
|
||||
_capacity = length+1;
|
||||
_contents_chars = chars;
|
||||
_free_contents = flag;
|
||||
[super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
unichar *u;
|
||||
OBJC_MALLOC(u, unichar,1);
|
||||
u[0]=(unichar)0;
|
||||
return [self initWithCharactersNoCopy:u length:0 freeWhenDone: YES];
|
||||
}
|
||||
|
||||
/* For IndexedCollecting Protocol and other GNU libobjects conformity. */
|
||||
|
||||
/* xxx This should be made to return void, but we need to change
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue