mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
Fixups for keyed archiving under windows.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22269 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2a3dbbcb03
commit
887b27f9b1
4 changed files with 41 additions and 18 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2006-01-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPropertyList.m: When generating binary plist, fix bug
|
||||
in case where we have to increase table size.
|
||||
* Source/NSKeyedArchiver.m: Update to use binary plist format
|
||||
by default rather than xml format ... MacOS-X compatible and
|
||||
works when libxml2 is not available.
|
||||
* Source/NSKeyedUnarchiver.m: Print NSLog error if attempting to
|
||||
decode an xml archive when no libxml2 is available.
|
||||
|
||||
2006-01-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPathUtilities.m: be more consistent in use of defined values
|
||||
|
|
|
@ -786,7 +786,7 @@ static NSDictionary *makeReference(unsigned ref)
|
|||
_obj = [NSMutableArray new]; // Array of objects.
|
||||
[_obj addObject: @"$null"]; // Placeholder.
|
||||
|
||||
_format = NSPropertyListXMLFormat_v1_0; // FIXME ... should be binary.
|
||||
_format = NSPropertyListBinaryFormat_v1_0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -745,6 +745,13 @@ static NSMapTable globalClassMap = 0;
|
|||
errorDescription: &error];
|
||||
if (_archive == nil)
|
||||
{
|
||||
#ifndef HAVE_LIBXML
|
||||
if (format == NSPropertyListXMLFormat_v1_0)
|
||||
{
|
||||
NSLog(@"Unable to parse XML archive as the base "
|
||||
@"library was not configured with libxml2 support.");
|
||||
}
|
||||
#endif
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2483,7 +2483,8 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
[plData getBytes: postfix range: NSMakeRange(length-32, 32)];
|
||||
offset_size = postfix[6];
|
||||
index_size = postfix[7];
|
||||
table_start = (postfix[28] << 24) + (postfix[29] << 16) + (postfix[30] << 8) + postfix[31];
|
||||
table_start = (postfix[28] << 24) + (postfix[29] << 16)
|
||||
+ (postfix[30] << 8) + postfix[31];
|
||||
if (offset_size < 1 || offset_size > 4)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
|
@ -2492,9 +2493,9 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
}
|
||||
else if (index_size < 1 || index_size > 4)
|
||||
{
|
||||
DESTROY(self); // Bad format
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Unknown table size %d", index_size];
|
||||
DESTROY(self); // Bad format
|
||||
}
|
||||
else if (table_start > length - 32)
|
||||
{
|
||||
|
@ -2541,8 +2542,10 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
unsigned char buffer[offset_size];
|
||||
int i;
|
||||
unsigned long num = 0;
|
||||
NSRange r;
|
||||
|
||||
[data getBytes: &buffer range: NSMakeRange(table_start + offset_size*index, offset_size)];
|
||||
r = NSMakeRange(table_start + offset_size*index, offset_size);
|
||||
[data getBytes: &buffer range: r];
|
||||
for (i = 0; i < offset_size; i++)
|
||||
{
|
||||
num = (num << 8) + buffer[i];
|
||||
|
@ -2998,27 +3001,32 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
|
||||
@implementation BinaryPLGenerator
|
||||
|
||||
+ (void) serializePropertyList: (id)aPropertyList intoData: (NSMutableData *)destination
|
||||
+ (void) serializePropertyList: (id)aPropertyList
|
||||
intoData: (NSMutableData *)destination
|
||||
{
|
||||
BinaryPLGenerator *gen;
|
||||
|
||||
gen = [[BinaryPLGenerator alloc] initWithPropertyList: aPropertyList intoData: destination];
|
||||
gen = [[BinaryPLGenerator alloc]
|
||||
initWithPropertyList: aPropertyList intoData: destination];
|
||||
[gen generate];
|
||||
RELEASE(gen);
|
||||
}
|
||||
|
||||
- (id) initWithPropertyList: (id) aPropertyList intoData: (NSMutableData *)destination
|
||||
- (id) initWithPropertyList: (id) aPropertyList
|
||||
intoData: (NSMutableData *)destination
|
||||
{
|
||||
ASSIGN(root, aPropertyList);
|
||||
ASSIGN(dest, destination);
|
||||
[dest setLength: 0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(root);
|
||||
DESTROY(root);
|
||||
[self cleanup];
|
||||
DESTROY(dest);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -3029,6 +3037,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
|
||||
- (void) setup
|
||||
{
|
||||
[dest setLength: 0];
|
||||
if (index_size == 1)
|
||||
{
|
||||
table_size = 256;
|
||||
|
@ -3048,8 +3057,6 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
|
||||
table = malloc(table_size * sizeof(int));
|
||||
|
||||
// Always restart the destination data
|
||||
[dest setLength: 0];
|
||||
objectsToDoList = [[NSMutableArray alloc] init];
|
||||
objectList = [[NSMutableArray alloc] init];
|
||||
|
||||
|
@ -3059,7 +3066,6 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
|
||||
- (void) cleanup
|
||||
{
|
||||
DESTROY(dest);
|
||||
DESTROY(objectsToDoList);
|
||||
DESTROY(objectList);
|
||||
if (table != NULL)
|
||||
|
@ -3112,7 +3118,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
|||
unsigned int last_offset;
|
||||
|
||||
table_start = [dest length];
|
||||
// This is a bit to much, as the length
|
||||
// This is a bit too much, as the length
|
||||
// of the last object is added.
|
||||
last_offset = table_start;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue