mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-21 04:32:03 +00:00
Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16641 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6c7f43d46d
commit
eb5c548496
3 changed files with 45 additions and 17 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2003-05-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSString.m: Fix call to GSFormat() to append to a mutable
|
||||||
|
string whose contents should not be freed.
|
||||||
|
Removed bogus TODO comments saying code broken when defEnc!=intEnc
|
||||||
|
in routines which should never be called when defEnc!=intEnc anyway.
|
||||||
|
|
||||||
2003-05-05 15:28 Alexander Malmberg <alexander@malmberg.org>
|
2003-05-05 15:28 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* Source/Unicode.m (GSFromUnicode, GSToUnicode): Make sure the
|
* Source/Unicode.m (GSFromUnicode, GSToUnicode): Make sure the
|
||||||
|
|
|
@ -985,7 +985,7 @@ else \
|
||||||
* <p>On return, the function result is a flag indicating success (YES)
|
* <p>On return, the function result is a flag indicating success (YES)
|
||||||
* or failure (NO), and on success, the value stored in size is the number
|
* or failure (NO), and on success, the value stored in size is the number
|
||||||
* of characters in the converted string. The converted string itsself is
|
* of characters in the converted string. The converted string itsself is
|
||||||
* stored in the location gioven by dst.<br />
|
* stored in the location given by dst.<br />
|
||||||
* NB. If the value stored in dst has been changed, it is a pointer to
|
* NB. If the value stored in dst has been changed, it is a pointer to
|
||||||
* allocated memory which the caller is responsible for freeing, and the
|
* allocated memory which the caller is responsible for freeing, and the
|
||||||
* caller is <em>still</em> responsible for freeing the original buffer.
|
* caller is <em>still</em> responsible for freeing the original buffer.
|
||||||
|
|
|
@ -1846,6 +1846,7 @@ transmute(ivars self, NSString *aString)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to initialise a 'C' string.
|
* Try to initialise a 'C' string.
|
||||||
|
* Only ever called if defEnc==intEnc
|
||||||
*/
|
*/
|
||||||
- (id) initWithCStringNoCopy: (char*)chars
|
- (id) initWithCStringNoCopy: (char*)chars
|
||||||
length: (unsigned int)length
|
length: (unsigned int)length
|
||||||
|
@ -1861,7 +1862,7 @@ transmute(ivars self, NSString *aString)
|
||||||
format: @"re-initialisation of string"];
|
format: @"re-initialisation of string"];
|
||||||
}
|
}
|
||||||
_count = length;
|
_count = length;
|
||||||
_contents.c = chars; /* TODO: broken if defEnc!=intEnc */
|
_contents.c = chars;
|
||||||
_flags.wide = 0;
|
_flags.wide = 0;
|
||||||
if (flag == YES)
|
if (flag == YES)
|
||||||
{
|
{
|
||||||
|
@ -1876,6 +1877,7 @@ transmute(ivars self, NSString *aString)
|
||||||
/*
|
/*
|
||||||
* The GSCString class is the basic implementation of a concrete
|
* The GSCString class is the basic implementation of a concrete
|
||||||
* 8-bit string class, storing immutable data in a single buffer.
|
* 8-bit string class, storing immutable data in a single buffer.
|
||||||
|
* It is only ever used when defEnc==intEnc
|
||||||
*/
|
*/
|
||||||
@implementation GSCString
|
@implementation GSCString
|
||||||
- (const char *) UTF8String
|
- (const char *) UTF8String
|
||||||
|
@ -1935,7 +1937,7 @@ transmute(ivars self, NSString *aString)
|
||||||
NSString *obj;
|
NSString *obj;
|
||||||
|
|
||||||
obj = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
obj = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||||
obj = [obj initWithCString: _contents.c length: _count]; /* TODO: broken if defEnc!=intEnc */
|
obj = [obj initWithCString: _contents.c length: _count];
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2059,7 +2061,7 @@ transmute(ivars self, NSString *aString)
|
||||||
|
|
||||||
obj = (GSMutableString*)NSAllocateObject(GSMutableStringClass, 0,
|
obj = (GSMutableString*)NSAllocateObject(GSMutableStringClass, 0,
|
||||||
NSDefaultMallocZone());
|
NSDefaultMallocZone());
|
||||||
obj = [obj initWithCString: _contents.c length: _count]; /* TODO: broken if defEnc!=intEnc */
|
obj = [obj initWithCString: _contents.c length: _count];
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2068,7 +2070,7 @@ transmute(ivars self, NSString *aString)
|
||||||
GSMutableString *obj;
|
GSMutableString *obj;
|
||||||
|
|
||||||
obj = (GSMutableString*)NSAllocateObject(GSMutableStringClass, 0, z);
|
obj = (GSMutableString*)NSAllocateObject(GSMutableStringClass, 0, z);
|
||||||
obj = [obj initWithCString: _contents.c length: _count]; /* TODO: broken if defEnc!=intEnc */
|
obj = [obj initWithCString: _contents.c length: _count];
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2143,7 +2145,7 @@ transmute(ivars self, NSString *aString)
|
||||||
_count = length;
|
_count = length;
|
||||||
_contents.c = (unsigned char*)&self[1];
|
_contents.c = (unsigned char*)&self[1];
|
||||||
if (_count > 0)
|
if (_count > 0)
|
||||||
memcpy(_contents.c, chars, length); /* TODO: broken if defEnc!=intEnc */
|
memcpy(_contents.c, chars, length);
|
||||||
_flags.wide = 0;
|
_flags.wide = 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -2168,7 +2170,7 @@ transmute(ivars self, NSString *aString)
|
||||||
NSString *obj;
|
NSString *obj;
|
||||||
|
|
||||||
obj = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
obj = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||||
obj = [obj initWithCString: _contents.c length: _count]; /* TODO: broken if defEnc!=intEnc */
|
obj = [obj initWithCString: _contents.c length: _count];
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
@ -2491,12 +2493,14 @@ transmute(ivars self, NSString *aString)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The GSMutableStrinc class shares a common initial ivar layout with
|
* The GSMutableString class shares a common initial ivar layout with
|
||||||
* the GSString class, but adds a few of its own. It uses _flags.wide
|
* the GSString class, but adds a few of its own. It uses _flags.wide
|
||||||
* to determine whether it should use 8-bit or 16-bit characters and
|
* to determine whether it should use 8-bit or 16-bit characters and
|
||||||
* is capable of changing that flag (and its underlying storage) to
|
* is capable of changing that flag (and its underlying storage) to
|
||||||
* move from an 8-bit to a 16-bit representation is that should be
|
* move from an 8-bit to a 16-bit representation is that should be
|
||||||
* necessary because wide characters have been placed in the string.
|
* necessary because wide characters have been placed in the string.
|
||||||
|
* If defEnc!=intEnc, GSMutableString objects will always have
|
||||||
|
* _flags.wide set, since ite cannot have been initialised as a C String.
|
||||||
*/
|
*/
|
||||||
@implementation GSMutableString
|
@implementation GSMutableString
|
||||||
|
|
||||||
|
@ -2524,11 +2528,28 @@ transmute(ivars self, NSString *aString)
|
||||||
fmt = objc_malloc((len+1)*sizeof(unichar));
|
fmt = objc_malloc((len+1)*sizeof(unichar));
|
||||||
[format getCharacters: fmt];
|
[format getCharacters: fmt];
|
||||||
fmt[len] = '\0';
|
fmt[len] = '\0';
|
||||||
|
/*
|
||||||
|
* If the buffer can't be freed, replace it with one which can before
|
||||||
|
* we attempt to append to the string (and possibly extend buffer)
|
||||||
|
*/
|
||||||
|
if (_flags.free == NO)
|
||||||
|
{
|
||||||
|
unichar *u;
|
||||||
|
|
||||||
|
if (_zone == 0)
|
||||||
|
{
|
||||||
|
_zone = [self zone];
|
||||||
|
}
|
||||||
|
u = NSZoneMalloc(_zone, _capacity * sizeof(unichar));
|
||||||
|
memcpy(u, _contents.u, _count * sizeof(unichar));
|
||||||
|
_contents.u = u;
|
||||||
|
_flags.free = YES;
|
||||||
|
}
|
||||||
f.z = _zone;
|
f.z = _zone;
|
||||||
f.buf = _contents.u;
|
f.buf = _contents.u;
|
||||||
f.len = _count;
|
f.len = _count;
|
||||||
f.size = _capacity;
|
f.size = _capacity;
|
||||||
GSFormat(&f, fmt, ap, nil); /* TODO: _zone might be nil, and _flags.free might be NO */
|
GSFormat(&f, fmt, ap, nil);
|
||||||
_contents.u = f.buf;
|
_contents.u = f.buf;
|
||||||
_count = f.len;
|
_count = f.len;
|
||||||
_capacity = f.size;
|
_capacity = f.size;
|
||||||
|
@ -2610,7 +2631,7 @@ transmute(ivars self, NSString *aString)
|
||||||
{
|
{
|
||||||
copy = NSAllocateObject(GSCInlineStringClass,
|
copy = NSAllocateObject(GSCInlineStringClass,
|
||||||
_count, NSDefaultMallocZone());
|
_count, NSDefaultMallocZone());
|
||||||
copy = [copy initWithCString: _contents.c length: _count]; /* TODO: broken if intEnc!=defEnc */
|
copy = [copy initWithCString: _contents.c length: _count];
|
||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
@ -2628,7 +2649,7 @@ transmute(ivars self, NSString *aString)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
copy = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
copy = (NSString*)NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||||
copy = [copy initWithCString: _contents.c length: _count]; /* TODO: broken if intEnc!=defEnc */
|
copy = [copy initWithCString: _contents.c length: _count];
|
||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
@ -2845,7 +2866,7 @@ transmute(ivars self, NSString *aString)
|
||||||
{
|
{
|
||||||
_count = length;
|
_count = length;
|
||||||
_capacity = length;
|
_capacity = length;
|
||||||
_contents.c = byteString; /* TODO: broken if intEnc!=defEnc */
|
_contents.c = byteString;
|
||||||
_flags.wide = 0;
|
_flags.wide = 0;
|
||||||
if (flag == YES && byteString != 0)
|
if (flag == YES && byteString != 0)
|
||||||
{
|
{
|
||||||
|
@ -2929,7 +2950,7 @@ transmute(ivars self, NSString *aString)
|
||||||
if (_flags.wide == 1)
|
if (_flags.wide == 1)
|
||||||
obj = [obj initWithCharacters: _contents.u length: _count];
|
obj = [obj initWithCharacters: _contents.u length: _count];
|
||||||
else
|
else
|
||||||
obj = [obj initWithCString: _contents.c length: _count]; /* TODO: broken if intEnc!=defEnc */
|
obj = [obj initWithCString: _contents.c length: _count];
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2942,7 +2963,7 @@ transmute(ivars self, NSString *aString)
|
||||||
if (_flags.wide == 1)
|
if (_flags.wide == 1)
|
||||||
obj = [obj initWithCharacters: _contents.u length: _count];
|
obj = [obj initWithCharacters: _contents.u length: _count];
|
||||||
else
|
else
|
||||||
obj = [obj initWithCString: _contents.c length: _count]; /* TODO: broken if intEnc!=defEnc */
|
obj = [obj initWithCString: _contents.c length: _count];
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3173,7 +3194,7 @@ transmute(ivars self, NSString *aString)
|
||||||
{
|
{
|
||||||
sub = (NSString*)NSAllocateObject(GSCInlineStringClass,
|
sub = (NSString*)NSAllocateObject(GSCInlineStringClass,
|
||||||
_count, NSDefaultMallocZone());
|
_count, NSDefaultMallocZone());
|
||||||
sub = [sub initWithCString: self->_contents.c + aRange.location /* TODO: broken if intEnc!=defEnc */
|
sub = [sub initWithCString: self->_contents.c + aRange.location
|
||||||
length: aRange.length];
|
length: aRange.length];
|
||||||
}
|
}
|
||||||
AUTORELEASE(sub);
|
AUTORELEASE(sub);
|
||||||
|
@ -3199,7 +3220,7 @@ transmute(ivars self, NSString *aString)
|
||||||
sub = (NSString*)NSAllocateObject(GSCInlineStringClass,
|
sub = (NSString*)NSAllocateObject(GSCInlineStringClass,
|
||||||
aRange.length,
|
aRange.length,
|
||||||
NSDefaultMallocZone());
|
NSDefaultMallocZone());
|
||||||
sub = [sub initWithCString: self->_contents.c + aRange.location /* TODO: broken if intEnc!=defEnc */
|
sub = [sub initWithCString: self->_contents.c + aRange.location
|
||||||
length: aRange.length];
|
length: aRange.length];
|
||||||
}
|
}
|
||||||
AUTORELEASE(sub);
|
AUTORELEASE(sub);
|
||||||
|
@ -3626,7 +3647,7 @@ transmute(ivars self, NSString *aString)
|
||||||
|
|
||||||
- (const char*) cString
|
- (const char*) cString
|
||||||
{
|
{
|
||||||
return _self->_contents.c; /* TODO: broken if intEnc!=defEnc */
|
return _self->_contents.c;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) retain
|
- (id) retain
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue