mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Property list updates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14966 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a88b0eb08c
commit
b8b64cb3e5
8 changed files with 641 additions and 682 deletions
|
@ -678,47 +678,11 @@ failure:
|
|||
|
||||
- (NSString*) description
|
||||
{
|
||||
NSString *str;
|
||||
const char *src;
|
||||
char *dest;
|
||||
int length;
|
||||
int i;
|
||||
int j;
|
||||
NSZone *z;
|
||||
extern void GSPropertyListMake(id, NSDictionary*, BOOL, unsigned, id*);
|
||||
NSMutableString *result = nil;
|
||||
|
||||
src = [self bytes];
|
||||
length = [self length];
|
||||
z = [self zone];
|
||||
#define num2char(num) ((num) < 0xa ? ((num)+'0') : ((num)+0x57))
|
||||
|
||||
/* we can just build a cString and convert it to an NSString */
|
||||
#if GS_WITH_GC
|
||||
dest = (char*) NSZoneMalloc(GSAtomicMallocZone(), 2*length+length/4+3);
|
||||
#else
|
||||
dest = (char*) NSZoneMalloc(z, 2*length+length/4+3);
|
||||
#endif
|
||||
if (dest == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"No memory for description of NSData object"];
|
||||
}
|
||||
dest[0] = '<';
|
||||
for (i = 0, j = 1; i < length; i++, j++)
|
||||
{
|
||||
dest[j++] = num2char((src[i]>>4) & 0x0f);
|
||||
dest[j] = num2char(src[i] & 0x0f);
|
||||
if ((i&0x3) == 3 && i != length-1)
|
||||
{
|
||||
/* if we've just finished a 32-bit int, print a space */
|
||||
dest[++j] = ' ';
|
||||
}
|
||||
}
|
||||
dest[j++] = '>';
|
||||
dest[j] = '\0';
|
||||
str = [[NSString allocWithZone: z] initWithCStringNoCopy: dest
|
||||
length: j
|
||||
freeWhenDone: YES];
|
||||
return AUTORELEASE(str);
|
||||
GSPropertyListMake(self, nil, NO, 0, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue