mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Fix for substrings of mutable strings
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8043 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c19fd6da52
commit
324f4f6778
3 changed files with 38 additions and 10 deletions
|
@ -2618,34 +2618,54 @@ transmute(ivars self, NSString *aString)
|
|||
|
||||
- (NSString*) substringFromRange: (NSRange)aRange
|
||||
{
|
||||
NSString *sub;
|
||||
|
||||
GS_RANGE_CHECK(aRange, _count);
|
||||
|
||||
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
return [GSUnicodeStringClass stringWithCharacters:
|
||||
self->_contents.u + aRange.location length: aRange.length];
|
||||
sub = (NSString*)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count*sizeof(unichar), NSDefaultMallocZone());
|
||||
sub = [sub initWithCharactersNoCopy: self->_contents.u + aRange.location
|
||||
length: aRange.length
|
||||
freeWhenDone: NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [GSCStringClass stringWithCString:
|
||||
self->_contents.c + aRange.location length: aRange.length];
|
||||
sub = (NSString*)NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
sub = [sub initWithCStringNoCopy: self->_contents.c + aRange.location
|
||||
length: aRange.length
|
||||
freeWhenDone: NO];
|
||||
}
|
||||
AUTORELEASE(sub);
|
||||
return sub;
|
||||
}
|
||||
|
||||
- (NSString*) substringWithRange: (NSRange)aRange
|
||||
{
|
||||
NSString *sub;
|
||||
|
||||
GS_RANGE_CHECK(aRange, _count);
|
||||
|
||||
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
return [GSUnicodeStringClass stringWithCharacters:
|
||||
self->_contents.u + aRange.location length: aRange.length];
|
||||
sub = (NSString*)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count*sizeof(unichar), NSDefaultMallocZone());
|
||||
sub = [sub initWithCharactersNoCopy: self->_contents.u + aRange.location
|
||||
length: aRange.length
|
||||
freeWhenDone: NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [GSCStringClass stringWithCString:
|
||||
self->_contents.c + aRange.location length: aRange.length];
|
||||
sub = (NSString*)NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
sub = [sub initWithCStringNoCopy: self->_contents.c + aRange.location
|
||||
length: aRange.length
|
||||
freeWhenDone: NO];
|
||||
}
|
||||
AUTORELEASE(sub);
|
||||
return sub;
|
||||
}
|
||||
|
||||
// private method for Unicode level 3 implementation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue