* Source/NSData.m: Various 64-bit compatibility fixes, mostly changing

unsgined to NSUInteger.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34822 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2012-02-27 02:12:19 +00:00
parent 14330e67e1
commit 20b792c173
2 changed files with 34 additions and 25 deletions

View file

@ -1,3 +1,8 @@
2012-02-26 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSData.m: Various 64-bit compatibility fixes, mostly changing
unsgined to NSUInteger.
2012-02-26 Fred Kiefer <FredKiefer@gmx.de> 2012-02-26 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSXMLNode.m (execute_xpath): Use correct node for * Source/NSXMLNode.m (execute_xpath): Use correct node for

View file

@ -141,7 +141,7 @@ static SEL appendSel;
static IMP appendImp; static IMP appendImp;
static BOOL static BOOL
readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) readContentsOfFile(NSString* path, void** buf, long* len, NSZone* zone)
{ {
#if defined(__MINGW__) #if defined(__MINGW__)
const unichar *thePath = 0; const unichar *thePath = 0;
@ -176,6 +176,10 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
goto failure; goto failure;
} }
// FIXME: since fseek returns a long, this code will fail on files
// larger than ~2GB on 32-bit systems. Probably this entire function should
// be removed and NSFileHandle used instead. -Eric
/* /*
* Seek to the end of the file. * Seek to the end of the file.
*/ */
@ -629,7 +633,7 @@ failure:
- (id) initWithContentsOfFile: (NSString*)path - (id) initWithContentsOfFile: (NSString*)path
{ {
void *fileBytes; void *fileBytes;
unsigned fileLength; long fileLength;
#if GS_WITH_GC #if GS_WITH_GC
if (readContentsOfFile(path, &fileBytes, &fileLength, 0) == NO) if (readContentsOfFile(path, &fileBytes, &fileLength, 0) == NO)
@ -754,7 +758,7 @@ failure:
*/ */
- (void) getBytes: (void*)buffer range: (NSRange)aRange - (void) getBytes: (void*)buffer range: (NSRange)aRange
{ {
unsigned size = [self length]; NSUInteger size = [self length];
GS_RANGE_CHECK(aRange, size); GS_RANGE_CHECK(aRange, size);
memcpy(buffer, [self bytes] + aRange.location, aRange.length); memcpy(buffer, [self bytes] + aRange.location, aRange.length);
@ -774,7 +778,7 @@ failure:
- (NSData*) subdataWithRange: (NSRange)aRange - (NSData*) subdataWithRange: (NSRange)aRange
{ {
void *buffer; void *buffer;
unsigned l = [self length]; NSUInteger l = [self length];
GS_RANGE_CHECK(aRange, l); GS_RANGE_CHECK(aRange, l);
@ -796,8 +800,8 @@ failure:
- (NSUInteger) hash - (NSUInteger) hash
{ {
unsigned char buf[64]; unsigned char buf[64];
unsigned l = [self length]; NSUInteger l = [self length];
unsigned ret =0; NSUInteger ret =0;
l = MIN(l,64); l = MIN(l,64);
@ -1866,7 +1870,7 @@ failure:
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
unsigned length = [self length]; NSUInteger length = [self length];
void *bytes = [self mutableBytes]; void *bytes = [self mutableBytes];
if ([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding])
@ -1877,7 +1881,7 @@ failure:
} }
else else
{ {
[aCoder encodeValueOfObjCType: @encode(unsigned int) [aCoder encodeValueOfObjCType: @encode(NSUInteger)
at: &length]; at: &length];
if (length) if (length)
{ {
@ -1913,9 +1917,9 @@ failure:
} }
else else
{ {
unsigned l; NSUInteger l;
[aCoder decodeValueOfObjCType: @encode(unsigned int) at: &l]; [aCoder decodeValueOfObjCType: @encode(NSUInteger) at: &l];
if (l) if (l)
{ {
void *b; void *b;
@ -2012,7 +2016,7 @@ failure:
- (void) appendBytes: (const void*)aBuffer - (void) appendBytes: (const void*)aBuffer
length: (NSUInteger)bufferSize length: (NSUInteger)bufferSize
{ {
unsigned oldLength = [self length]; NSUInteger oldLength = [self length];
void* buffer; void* buffer;
[self setLength: oldLength + bufferSize]; [self setLength: oldLength + bufferSize];
@ -2042,8 +2046,8 @@ failure:
- (void) replaceBytesInRange: (NSRange)aRange - (void) replaceBytesInRange: (NSRange)aRange
withBytes: (const void*)bytes withBytes: (const void*)bytes
{ {
unsigned size = [self length]; NSUInteger size = [self length];
unsigned need = NSMaxRange(aRange); NSUInteger need = NSMaxRange(aRange);
if (aRange.location > size) if (aRange.location > size)
{ {
@ -2069,10 +2073,10 @@ failure:
withBytes: (const void*)bytes withBytes: (const void*)bytes
length: (NSUInteger)length length: (NSUInteger)length
{ {
unsigned size = [self length]; NSUInteger size = [self length];
unsigned end = NSMaxRange(aRange); NSUInteger end = NSMaxRange(aRange);
int shift = length - aRange.length; NSInteger shift = length - aRange.length;
unsigned need = size + shift; NSUInteger need = size + shift;
void *buf; void *buf;
if (aRange.location > size) if (aRange.location > size)
@ -2119,7 +2123,7 @@ failure:
*/ */
- (void) resetBytesInRange: (NSRange)aRange - (void) resetBytesInRange: (NSRange)aRange
{ {
unsigned size = [self length]; NSUInteger size = [self length];
GS_RANGE_CHECK(aRange, size); GS_RANGE_CHECK(aRange, size);
memset((char*)[self bytes] + aRange.location, 0, aRange.length); memset((char*)[self bytes] + aRange.location, 0, aRange.length);
@ -3342,8 +3346,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{ {
if (bufferSize > 0) if (bufferSize > 0)
{ {
unsigned oldLength = length; NSUInteger oldLength = length;
unsigned minimum = length + bufferSize; NSUInteger minimum = length + bufferSize;
if (aBuffer == 0) if (aBuffer == 0)
{ {
@ -3369,12 +3373,12 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{ {
if (minimum > capacity) if (minimum > capacity)
{ {
unsigned nextCapacity = capacity + growth; NSUInteger nextCapacity = capacity + growth;
unsigned nextGrowth = capacity ? capacity : 1; NSUInteger nextGrowth = capacity ? capacity : 1;
while (nextCapacity < minimum) while (nextCapacity < minimum)
{ {
unsigned tmp = nextCapacity + nextGrowth; NSUInteger tmp = nextCapacity + nextGrowth;
nextGrowth = nextCapacity; nextGrowth = nextCapacity;
nextCapacity = tmp; nextCapacity = tmp;
@ -3392,7 +3396,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (void) replaceBytesInRange: (NSRange)aRange - (void) replaceBytesInRange: (NSRange)aRange
withBytes: (const void*)moreBytes withBytes: (const void*)moreBytes
{ {
unsigned need = NSMaxRange(aRange); NSUInteger need = NSMaxRange(aRange);
if (aRange.location > length) if (aRange.location > length)
{ {
@ -3760,7 +3764,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (void) setData: (NSData*)data - (void) setData: (NSData*)data
{ {
unsigned l = [data length]; NSUInteger l = [data length];
[self setCapacity: l]; [self setCapacity: l];
length = l; length = l;