mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Attempt fix for getCString where internal encoding != external encoding
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23259 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d0852086a5
commit
b77674a4f8
2 changed files with 34 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-08-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSString.m: getCString_c() call getCString_u() to do the
|
||||||
|
work if external encoding != internal encoding.
|
||||||
|
|
||||||
2006-08-11 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-08-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSTask.m: Fixup for path validation error on mingw32
|
* Source/NSTask.m: Fixup for path validation error on mingw32
|
||||||
|
|
|
@ -300,6 +300,12 @@ setup(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Predeclare a few functions
|
||||||
|
*/
|
||||||
|
static void GSStrWiden(GSStr s);
|
||||||
|
static void getCString_u(GSStr self, char *buffer, unsigned int maxLength,
|
||||||
|
NSRange aRange, NSRange *leftoverRange);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The GSPlaceholderString class is used by the abstract cluster root
|
* The GSPlaceholderString class is used by the abstract cluster root
|
||||||
* class to provide temporary objects that will be replaced as soon
|
* class to provide temporary objects that will be replaced as soon
|
||||||
|
@ -1585,12 +1591,33 @@ getCharacters_u(GSStr self, unichar *buffer, NSRange aRange)
|
||||||
aRange.length*sizeof(unichar));
|
aRange.length*sizeof(unichar));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static void
|
||||||
getCString_c(GSStr self, char *buffer, unsigned int maxLength,
|
getCString_c(GSStr self, char *buffer, unsigned int maxLength,
|
||||||
NSRange aRange, NSRange *leftoverRange)
|
NSRange aRange, NSRange *leftoverRange)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the internal and external encodings don't match, the simplest
|
||||||
|
* thing to do is widen the internal data to unicode and use the
|
||||||
|
* unicode function to get the cString.
|
||||||
|
*/
|
||||||
|
if (externalEncoding != internalEncoding)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
@defs(GSMutableString)
|
||||||
|
} o;
|
||||||
|
|
||||||
|
memset(&o, '\0', sizeof(o));
|
||||||
|
o._count = self->_count;
|
||||||
|
o._capacity = self->_count;
|
||||||
|
o._contents.c = self->_contents.c;
|
||||||
|
GSStrWiden((GSStr)&o);
|
||||||
|
getCString_u((GSStr)&o, buffer, maxLength, aRange, leftoverRange);
|
||||||
|
NSZoneFree(o._zone, o._contents.u);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (maxLength > self->_count)
|
if (maxLength > self->_count)
|
||||||
{
|
{
|
||||||
maxLength = self->_count;
|
maxLength = self->_count;
|
||||||
|
@ -1618,7 +1645,7 @@ getCString_c(GSStr self, char *buffer, unsigned int maxLength,
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static void
|
||||||
getCString_u(GSStr self, char *buffer, unsigned int maxLength,
|
getCString_u(GSStr self, char *buffer, unsigned int maxLength,
|
||||||
NSRange aRange, NSRange *leftoverRange)
|
NSRange aRange, NSRange *leftoverRange)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue