mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Various improvements and bugfixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7856 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
65241c052d
commit
4386ba0c61
5 changed files with 428 additions and 130 deletions
|
@ -343,15 +343,47 @@ handle_printf_atsign (FILE *stream,
|
|||
{
|
||||
if (length > 0)
|
||||
{
|
||||
unichar *s = NSZoneMalloc(fastZone(self), sizeof(unichar)*length);
|
||||
int i;
|
||||
BOOL isAscii = YES;
|
||||
|
||||
if (chars != 0)
|
||||
if (chars == 0)
|
||||
{
|
||||
memcpy(s, chars, sizeof(unichar)*length);
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"nul pointer but non-zero length"];
|
||||
}
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
if (chars[i] >= 128)
|
||||
{
|
||||
isAscii = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isAscii == YES)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = NSZoneMalloc(fastZone(self), length);
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
s[i] = (unsigned char)chars[i];
|
||||
}
|
||||
self = [self initWithCStringNoCopy: s
|
||||
length: length
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
unichar *s;
|
||||
|
||||
s = NSZoneMalloc(fastZone(self), sizeof(unichar)*length);
|
||||
|
||||
memcpy(s, chars, sizeof(unichar)*length);
|
||||
self = [self initWithCharactersNoCopy: s
|
||||
length: length
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
self = [self initWithCharactersNoCopy: s
|
||||
length: length
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue