mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
attempt fix for bug #30040
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30625 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
81620f8d4e
commit
d90b469ede
2 changed files with 56 additions and 17 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2010-06-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSPropertyList.m: When encoding OSX binary property list,
|
||||||
|
try to differentiate between integer and float items which have the
|
||||||
|
same numeric value (bug #30040).
|
||||||
|
|
||||||
2010-06-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-06-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSURL.m:
|
* Source/NSURL.m:
|
||||||
|
|
|
@ -443,7 +443,7 @@ foundIgnorableWhitespace: (NSString *)string
|
||||||
@interface BinaryPLGenerator : NSObject
|
@interface BinaryPLGenerator : NSObject
|
||||||
{
|
{
|
||||||
NSMutableData *dest;
|
NSMutableData *dest;
|
||||||
NSMutableArray *objectList;
|
NSMapTable *objectList;
|
||||||
NSMutableArray *objectsToDoList;
|
NSMutableArray *objectsToDoList;
|
||||||
id root;
|
id root;
|
||||||
|
|
||||||
|
@ -3231,6 +3231,28 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
/* Test two items for equality ... boith are objects.
|
||||||
|
* If either is an NSNumber, we insist that they are the same class
|
||||||
|
* so that numbers with the same numeric value but different classes
|
||||||
|
* are not treated as the same number (that confuses OSXs decoding).
|
||||||
|
*/
|
||||||
|
static BOOL
|
||||||
|
isEqualFunc(const void *item1, const void *item2,
|
||||||
|
NSUInteger (*size)(const void *item))
|
||||||
|
{
|
||||||
|
id o1 = (id)item1;
|
||||||
|
id o2 = (id)item2;
|
||||||
|
|
||||||
|
if ([o1 isKindOfClass: [NSNumber class]]
|
||||||
|
|| [o2 isKindOfClass: [NSNumber class]])
|
||||||
|
{
|
||||||
|
if ([o1 class] != [o2 class])
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [o1 isEqual: o2];
|
||||||
|
}
|
||||||
|
|
||||||
@implementation BinaryPLGenerator
|
@implementation BinaryPLGenerator
|
||||||
|
|
||||||
|
@ -3270,6 +3292,9 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
- (void) setup
|
- (void) setup
|
||||||
{
|
{
|
||||||
|
NSPointerFunctions *k;
|
||||||
|
NSPointerFunctions *v;
|
||||||
|
|
||||||
[dest setLength: 0];
|
[dest setLength: 0];
|
||||||
if (index_size == 1)
|
if (index_size == 1)
|
||||||
{
|
{
|
||||||
|
@ -3288,13 +3313,20 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
table_size = UINT_MAX;
|
table_size = UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
table = objc_malloc(table_size * sizeof(int));
|
table = NSZoneMalloc(0, table_size * sizeof(int));
|
||||||
|
|
||||||
objectsToDoList = [[NSMutableArray alloc] init];
|
objectsToDoList = [[NSMutableArray alloc] init];
|
||||||
objectList = [[NSMutableArray alloc] init];
|
k = [NSPointerFunctions pointerFunctionsWithOptions:
|
||||||
|
NSPointerFunctionsObjectPersonality];
|
||||||
|
[k setIsEqualFunction: isEqualFunc];
|
||||||
|
v = [NSPointerFunctions pointerFunctionsWithOptions:
|
||||||
|
NSPointerFunctionsIntegerPersonality|NSPointerFunctionsOpaqueMemory];
|
||||||
|
objectList = [[NSMapTable alloc] initWithKeyPointerFunctions: k
|
||||||
|
valuePointerFunctions: v
|
||||||
|
capacity: 1000];
|
||||||
|
|
||||||
[objectsToDoList addObject: root];
|
[objectsToDoList addObject: root];
|
||||||
[objectList addObject: root];
|
[objectList setObject: (id)1 forKey: root];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) cleanup
|
- (void) cleanup
|
||||||
|
@ -3303,7 +3335,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
DESTROY(objectList);
|
DESTROY(objectList);
|
||||||
if (table != NULL)
|
if (table != NULL)
|
||||||
{
|
{
|
||||||
objc_free(table);
|
NSZoneFree(0, table);
|
||||||
table = NULL;
|
table = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3325,14 +3357,15 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
- (void) markOffset: (unsigned int) offset for: (id)object
|
- (void) markOffset: (unsigned int) offset for: (id)object
|
||||||
{
|
{
|
||||||
unsigned int oid;
|
int oid;
|
||||||
|
|
||||||
oid = [objectList indexOfObject: object];
|
oid = (int)(NSInteger)[objectList objectForKey: object];
|
||||||
if (oid == NSNotFound)
|
if (oid <= 0)
|
||||||
{
|
{
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"Unknown object %@.", object];
|
format: @"Unknown object %@.", object];
|
||||||
}
|
}
|
||||||
|
oid--;
|
||||||
if (oid >= table_size)
|
if (oid >= table_size)
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
|
@ -3380,7 +3413,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
len = [objectList count];
|
len = [objectList count];
|
||||||
size = offset_size * len;
|
size = offset_size * len;
|
||||||
|
|
||||||
buffer = objc_malloc(size);
|
buffer = NSZoneMalloc(0, size);
|
||||||
|
|
||||||
if (offset_size == 1)
|
if (offset_size == 1)
|
||||||
{
|
{
|
||||||
|
@ -3430,7 +3463,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
}
|
}
|
||||||
|
|
||||||
[dest appendBytes: buffer length: size];
|
[dest appendBytes: buffer length: size];
|
||||||
objc_free(buffer);
|
NSZoneFree(0, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) writeMetaData
|
- (void) writeMetaData
|
||||||
|
@ -3463,17 +3496,17 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
- (unsigned int) indexForObject: (id)object
|
- (unsigned int) indexForObject: (id)object
|
||||||
{
|
{
|
||||||
unsigned int index;
|
int index;
|
||||||
|
|
||||||
index = [objectList indexOfObject: object];
|
index = (int)[objectList objectForKey: object];
|
||||||
if (index == NSNotFound)
|
if (index <= 0)
|
||||||
{
|
{
|
||||||
index = [objectList count];
|
index = [objectList count];
|
||||||
[objectList addObject: object];
|
[objectList setObject: (id)(++index) forKey: object];
|
||||||
[objectsToDoList addObject: object];
|
[objectsToDoList addObject: object];
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) storeIndex: (unsigned int)index
|
- (void) storeIndex: (unsigned int)index
|
||||||
|
@ -3618,7 +3651,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
code = 0x6F;
|
code = 0x6F;
|
||||||
[dest appendBytes: &code length: 1];
|
[dest appendBytes: &code length: 1];
|
||||||
buffer = objc_malloc(sizeof(unichar)*(len + 1));
|
buffer = NSZoneMalloc(0, sizeof(unichar)*(len + 1));
|
||||||
[self storeCount: len];
|
[self storeCount: len];
|
||||||
[string getCharacters: buffer];
|
[string getCharacters: buffer];
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
|
@ -3626,7 +3659,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
buffer[i] = NSSwapHostShortToBig(buffer[i]);
|
buffer[i] = NSSwapHostShortToBig(buffer[i]);
|
||||||
}
|
}
|
||||||
[dest appendBytes: buffer length: sizeof(unichar)*len];
|
[dest appendBytes: buffer length: sizeof(unichar)*len];
|
||||||
objc_free(buffer);
|
NSZoneFree(0, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue