mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
bugfix initialising mutable string.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16667 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f07090eb44
commit
dc23cb8a10
2 changed files with 35 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2003-05-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSString.m: ([-initWithCStringNocopy:length:freeWhenDone:])
|
||||||
|
check encodings and convert to unicode if necessary. Thanks to
|
||||||
|
Alaxander for pointing out bug.
|
||||||
|
|
||||||
2003-05-06 Richard Frith-Macdonald <rfm@gnu.org>
|
2003-05-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSString.m: Fix call to GSFormat() to append to a mutable
|
* Source/GSString.m: Fix call to GSFormat() to append to a mutable
|
||||||
|
|
|
@ -424,7 +424,7 @@ setup(void)
|
||||||
{
|
{
|
||||||
self = [self initWithCharactersNoCopy: u length: l freeWhenDone: YES];
|
self = [self initWithCharactersNoCopy: u length: l freeWhenDone: YES];
|
||||||
}
|
}
|
||||||
if (flag == YES)
|
if (flag == YES && chars != 0)
|
||||||
{
|
{
|
||||||
NSZoneFree(NSZoneFromPointer(chars), chars);
|
NSZoneFree(NSZoneFromPointer(chars), chars);
|
||||||
}
|
}
|
||||||
|
@ -2860,20 +2860,36 @@ transmute(ivars self, NSString *aString)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCStringNoCopy: (char*)byteString
|
- (id) initWithCStringNoCopy: (char*)chars
|
||||||
length: (unsigned int)length
|
length: (unsigned int)length
|
||||||
freeWhenDone: (BOOL)flag
|
freeWhenDone: (BOOL)flag
|
||||||
{
|
{
|
||||||
_count = length;
|
if (defEnc == intEnc)
|
||||||
_capacity = length;
|
{
|
||||||
_contents.c = byteString;
|
unichar *u = 0;
|
||||||
_flags.wide = 0;
|
unsigned l = 0;
|
||||||
if (flag == YES && byteString != 0)
|
|
||||||
|
if (GSToUnicode(&u, &l, chars, length, defEnc, GSObjCZone(self), 0) == NO)
|
||||||
|
{
|
||||||
|
DESTROY(self);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self = [self initWithCharactersNoCopy: u length: l freeWhenDone: YES];
|
||||||
|
}
|
||||||
|
if (flag == YES && chars != 0)
|
||||||
|
{
|
||||||
|
NSZoneFree(NSZoneFromPointer(chars), chars);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag == YES && chars != 0)
|
||||||
{
|
{
|
||||||
#if GS_WITH_GC
|
#if GS_WITH_GC
|
||||||
_zone = GSAtomicMallocZone();
|
_zone = GSAtomicMallocZone();
|
||||||
#else
|
#else
|
||||||
_zone = NSZoneFromPointer(byteString);
|
_zone = NSZoneFromPointer(chars);
|
||||||
#endif
|
#endif
|
||||||
_flags.free = 1;
|
_flags.free = 1;
|
||||||
}
|
}
|
||||||
|
@ -2881,6 +2897,11 @@ transmute(ivars self, NSString *aString)
|
||||||
{
|
{
|
||||||
_zone = 0;
|
_zone = 0;
|
||||||
}
|
}
|
||||||
|
_count = length;
|
||||||
|
_capacity = length;
|
||||||
|
_contents.c = chars;
|
||||||
|
_flags.wide = 0;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue