mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix miseed from last string changes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13154 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
faf010f1b6
commit
1039d5d38e
3 changed files with 50 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
2002-03-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSString.m: lossyCString_c() fix in line with recent
|
||||
changes ... cope with case where internal coding is not same as
|
||||
external coding.
|
||||
|
||||
2002-03-18 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Tools/gdomap.c (gdomap_log): Write to stdout if prio=LOG_INFO.
|
||||
|
|
|
@ -1212,11 +1212,50 @@ isEqual_u(ivars self, id anObject)
|
|||
static inline const char*
|
||||
lossyCString_c(ivars self)
|
||||
{
|
||||
unsigned char *r = (unsigned char*)_fastMallocBuffer(self->_count+1);
|
||||
char *r;
|
||||
|
||||
memcpy(r, self->_contents.c, self->_count);
|
||||
r[self->_count] = '\0';
|
||||
return (const char*)r;
|
||||
if (self->_count == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (defEnc == intEnc)
|
||||
{
|
||||
r = (char*)_fastMallocBuffer(self->_count+1);
|
||||
|
||||
if (self->_count > 0)
|
||||
{
|
||||
memcpy(r, self->_contents.c, self->_count);
|
||||
}
|
||||
r[self->_count] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
unichar *u = 0;
|
||||
unsigned l = 0;
|
||||
unsigned s = 0;
|
||||
|
||||
/*
|
||||
* The external C string encoding is not compatible with the internal
|
||||
* 8-bit character strings ... we must convert from internal format to
|
||||
* unicode and then to the external C string encoding.
|
||||
*/
|
||||
if (GSToUnicode(&u, &l, self->_contents.c, self->_count, intEnc,
|
||||
NSDefaultMallocZone(), 0) == NO)
|
||||
{
|
||||
[NSException raise: NSCharacterConversionException
|
||||
format: @"Can't convert to/from Unicode string."];
|
||||
}
|
||||
if (GSFromUnicode((unsigned char**)&r, &s, u, l, defEnc,
|
||||
NSDefaultMallocZone(), GSUniTerminate|GSUniTemporary) == NO)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), u);
|
||||
[NSException raise: NSCharacterConversionException
|
||||
format: @"Can't convert to/from Unicode string."];
|
||||
}
|
||||
NSZoneFree(NSDefaultMallocZone(), u);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline const char*
|
||||
|
|
|
@ -196,6 +196,7 @@ main ()
|
|||
|
||||
t = [Target new];
|
||||
p = [[MyProxy alloc] initWithTarget: t];
|
||||
[p loopInt: 1];
|
||||
|
||||
#define SETUP(X) \
|
||||
sig = [t methodSignatureForSelector: @selector(X)]; \
|
||||
|
|
Loading…
Reference in a new issue