mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Handle bigger numbers in binary property lists.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20241 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3846b6a732
commit
b2733f403a
2 changed files with 18 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-10-21 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSPropertyList.m (GSBinaryPLParser objectAtIndex:):
|
||||||
|
Changed integer handling to unsigned long long to support bigger numbers.
|
||||||
|
|
||||||
2004-10-20 Richard Frith-Macdonald <rfm@gnu.org>
|
2004-10-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Foundation/Foundation.h: include NSXMLParser
|
* Headers/Foundation/Foundation.h: include NSXMLParser
|
||||||
|
|
|
@ -2441,13 +2441,13 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
offset_size = postfix[6];
|
offset_size = postfix[6];
|
||||||
index_size = postfix[7];
|
index_size = postfix[7];
|
||||||
table_start = 256*256*postfix[29] + 256*postfix[30] + postfix[31];
|
table_start = 256*256*postfix[29] + 256*postfix[30] + postfix[31];
|
||||||
if (offset_size < 1 || offset_size > 3)
|
if (offset_size < 1 || offset_size > 4)
|
||||||
{
|
{
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"Unknown table size %d", offset_size];
|
format: @"Unknown table size %d", offset_size];
|
||||||
DESTROY(self); // Bad format
|
DESTROY(self); // Bad format
|
||||||
}
|
}
|
||||||
else if (index_size < 1 || index_size > 3)
|
else if (index_size < 1 || index_size > 4)
|
||||||
{
|
{
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"Unknown table size %d", index_size];
|
format: @"Unknown table size %d", index_size];
|
||||||
|
@ -2469,7 +2469,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned) offsetForIndex: (unsigned)index
|
- (unsigned long) offsetForIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
if (index > table_len)
|
if (index > table_len)
|
||||||
{
|
{
|
||||||
|
@ -2497,12 +2497,12 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
{
|
{
|
||||||
unsigned char buffer[offset_size];
|
unsigned char buffer[offset_size];
|
||||||
int i;
|
int i;
|
||||||
unsigned num = 0;
|
unsigned long num = 0;
|
||||||
|
|
||||||
[data getBytes: &buffer range: NSMakeRange(table_start + offset_size*index, offset_size)];
|
[data getBytes: &buffer range: NSMakeRange(table_start + offset_size*index, offset_size)];
|
||||||
for (i = 0; i < offset_size; i++)
|
for (i = 0; i < offset_size; i++)
|
||||||
{
|
{
|
||||||
num = num*256 + buffer[i];
|
num = (num << 8) + buffer[i];
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
@ -2538,7 +2538,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
*counter += index_size;
|
*counter += index_size;
|
||||||
for (i = 0; i < index_size; i++)
|
for (i = 0; i < index_size; i++)
|
||||||
{
|
{
|
||||||
num = num*256 + buffer[i];
|
num = (num << 8) + buffer[i];
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
@ -2573,13 +2573,13 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
unsigned len = 1 << (c - 0x10);
|
unsigned len = 1 << (c - 0x10);
|
||||||
unsigned char buffer[len];
|
unsigned char buffer[len];
|
||||||
int i;
|
int i;
|
||||||
unsigned num = 0;
|
unsigned long num = 0;
|
||||||
|
|
||||||
[data getBytes: &buffer range: NSMakeRange(*counter, len)];
|
[data getBytes: &buffer range: NSMakeRange(*counter, len)];
|
||||||
*counter += len;
|
*counter += len;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
num = num*256 + buffer[i];
|
num = (num << 8) + buffer[i];
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
@ -2601,7 +2601,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
- (id) objectAtIndex: (unsigned)index
|
- (id) objectAtIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
unsigned char next;
|
unsigned char next;
|
||||||
unsigned counter = [self offsetForIndex: index];
|
unsigned counter = [self offsetForIndex: index];
|
||||||
id result = nil;
|
id result = nil;
|
||||||
|
|
||||||
[data getBytes: &next range: NSMakeRange(counter,1)];
|
[data getBytes: &next range: NSMakeRange(counter,1)];
|
||||||
|
@ -2618,20 +2618,20 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
// YES
|
// YES
|
||||||
result = [NSNumber numberWithBool: YES];
|
result = [NSNumber numberWithBool: YES];
|
||||||
}
|
}
|
||||||
else if ((next >= 0x10) && (next < 0x1F))
|
else if ((next >= 0x10) && (next < 0x17))
|
||||||
{
|
{
|
||||||
// integer number
|
// integer number
|
||||||
unsigned len = 1 << (next - 0x10);
|
unsigned len = 1 << (next - 0x10);
|
||||||
int num = 0;
|
unsigned long long num = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned char buffer[16];
|
unsigned char buffer[16];
|
||||||
|
|
||||||
[data getBytes: buffer range: NSMakeRange(counter, len)];
|
[data getBytes: buffer range: NSMakeRange(counter, len)];
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
num = num*256 + buffer[i];
|
num = (num << 8) + buffer[i];
|
||||||
}
|
}
|
||||||
result = [NSNumber numberWithInt: num];
|
result = [NSNumber numberWithUnsignedLongLong: num];
|
||||||
}
|
}
|
||||||
else if (next == 0x22)
|
else if (next == 0x22)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue