@@ -15,11 +15,11 @@ * file. */ #include "config.h" -#import "OFString+PropertyListValue.h" +#import "OFString+PropertyListParsing.h" #import "OFArray.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFNumber.h" @@ -27,11 +27,11 @@ #import "OFXMLElement.h" #import "OFInvalidFormatException.h" #import "OFUnsupportedVersionException.h" -int _OFString_PropertyListValue_reference; +int _OFString_PropertyListParsing_reference; static id parseElement(OFXMLElement *element); static OFArray * parseArrayElement(OFXMLElement *element) @@ -123,11 +123,27 @@ } static OFNumber * parseIntegerElement(OFXMLElement *element) { - return [OFNumber numberWithIntMax: element.decimalValue]; + void *pool = objc_autoreleasePoolPush(); + OFString *stringValue; + OFNumber *ret; + + stringValue = element.stringValue.stringByDeletingEnclosingWhitespaces; + + if ([stringValue hasPrefix: @"-"]) + ret = [OFNumber numberWithLongLong: stringValue.longLongValue]; + else + ret = [OFNumber numberWithUnsignedLongLong: + stringValue.unsignedLongLongValue]; + + [ret retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; } static id parseElement(OFXMLElement *element) { @@ -158,12 +174,12 @@ return parseIntegerElement(element); else @throw [OFInvalidFormatException exception]; } -@implementation OFString (PropertyListValue) -- (id)propertyListValue +@implementation OFString (PropertyListParsing) +- (id)objectByParsingPropertyList { void *pool = objc_autoreleasePoolPush(); OFXMLElement *rootElement = [OFXMLElement elementWithXMLString: self]; OFXMLAttribute *versionAttribute; OFArray OF_GENERIC(OFXMLElement *) *elements;