Make -base compile almost without warnings again. Fixes:

- Using the correct format specifier
- Remove substringFromRange: (GNUstep extension) from NSString.h and use the non-deprecated version in -base.
- Delete definitions of methods that are the same in both a class and a category on that class (NSArray and NSObject).

Two files still have warnings:

- The GNUTLS stuff is using a load of deprecated APIs.
- xmlparse.m replaces a method using a category.  This method seems to always return nil.  Not sure what it's meant to do, or why it isn't a delegate of some kind.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Chisnall 2011-08-16 16:04:43 +00:00
parent ca12a84e3f
commit 4cdea64975
19 changed files with 51 additions and 114 deletions

View file

@ -368,7 +368,6 @@ typedef NSUInteger NSStringEncodingConversionOptions;
// Dividing Strings into Substrings
- (NSArray*) componentsSeparatedByString: (NSString*)separator;
- (NSString*) substringFromIndex: (NSUInteger)index;
- (NSString*) substringFromRange: (NSRange)aRange;
- (NSString*) substringToIndex: (NSUInteger)index;
// Finding Ranges of Characters and Substrings

View file

@ -3787,7 +3787,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
}
if (offset > fold)
{
NSLog(@"Name '%@' too long for folding at %u in header", n, fold);
NSLog(@"Name '%@' too long for folding at %" PRIuPTR " in header", n, fold);
}
offset = appendBytes(md, offset, fold, ":", 1);

View file

@ -29,55 +29,6 @@
@implementation NSArray (GNUstepBase)
/**
* Initialize the receiver with the contents of array.
* The order of array is preserved.<br />
* If shouldCopy is YES then the objects are copied
* rather than simply retained.<br />
* Invokes -initWithObjects:count:
*/
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy
{
NSUInteger c = [array count];
GS_BEGINIDBUF(objects, c);
if ([array isProxy])
{
NSUInteger i;
for (i = 0; i < c; i++)
{
objects[i] = [array objectAtIndex: i];
}
}
else
{
[array getObjects: objects];
}
if (shouldCopy == YES)
{
NSUInteger i;
for (i = 0; i < c; i++)
{
objects[i] = [objects[i] copy];
}
self = [self initWithObjects: objects count: c];
#if GS_WITH_GC == 0
while (i > 0)
{
[objects[--i] release];
}
#endif
}
else
{
self = [self initWithObjects: objects count: c];
}
GS_ENDIDBUF();
return self;
}
- (NSUInteger) insertionPosition: (id)item
usingFunction: (NSComparisonResult (*)(id, id, void *))sorter
context: (void *)context

View file

@ -895,7 +895,7 @@ static Class GSInlineArrayClass;
* iteration. If it changes during the iteration then
* objc_enumerationMutation() will be called, throwing an exception.
*/
state->mutationsPtr = (unsigned long *)&_version;
state->mutationsPtr = &_version;
count = MIN(len, _count - state->state);
/* If a mutation has occurred then it's possible that we are being asked to
* get objects from after the end of the array. Don't pass negative values

View file

@ -269,7 +269,7 @@ GSLanguageFromLocale(NSString *locale)
}
if (language == nil)
{
locale = [locale substringFromRange: NSMakeRange(0, 2)];
locale = [locale substringWithRange: NSMakeRange(0, 2)];
language = [dict objectForKey: locale];
}
}

View file

@ -75,7 +75,7 @@ typedef struct objc_category* Category;
unsigned _count;
unsigned _capacity;
int _grow_factor;
int _version;
unsigned long _version;
}
@end

View file

@ -3525,8 +3525,8 @@ static NSLock *cached_proxies_gate = nil;
(GSIMapKey)(NSUInteger)target, (GSIMapVal)((id)anObj));
if (debug_connection > 2)
NSLog(@"add local object (0x%x) target (0x%x) "
@"to connection (%@)", (uintptr_t)object, target, self);
NSLog(@"add local object (%p) target (0x%x) "
@"to connection (%@)", object, target, self);
M_UNLOCK(IrefGate);
}
@ -3603,8 +3603,8 @@ static NSLock *cached_proxies_gate = nil;
M_UNLOCK(cached_proxies_gate);
RELEASE(item);
if (debug_connection > 3)
NSLog(@"placed local object (0x%x) target (0x%x) in cache",
(uintptr_t)anObj, target);
NSLog(@"placed local object (%p) target (0x%x) in cache",
anObj, target);
}
/*
@ -3619,8 +3619,8 @@ static NSLock *cached_proxies_gate = nil;
GSIMapRemoveKey(IlocalTargets, (GSIMapKey)(NSUInteger)target);
if (debug_connection > 2)
NSLog(@"removed local object (0x%x) target (0x%x) "
@"from connection (%@) (ref %d)", (uintptr_t)anObj, target, self, val);
NSLog(@"removed local object (%p) target (0x%x) "
@"from connection (%@) (ref %d)", anObj, target, self, val);
}
M_UNLOCK(IrefGate);
}

View file

@ -3110,7 +3110,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_RDONLY);
if (shmid == -1) /* Created memory? */
{
NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %@",
NSLog(@"[-initWithBytes:length:] shared mem get failed for %" PRIuPTR " - %@",
bufferSize, [NSError _last]);
DESTROY(self);
self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
@ -3120,7 +3120,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
bytes = shmat(shmid, 0, 0);
if (bytes == (void*)-1)
{
NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %@",
NSLog(@"[-initWithBytes:length:] shared mem attach failed for %" PRIuPTR " - %@",
bufferSize, [NSError _last]);
bytes = 0;
DESTROY(self);
@ -3300,7 +3300,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (bytes == 0)
{
NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory "
@"for %u bytes - %@", size, [NSError _last]);
@"for %" PRIuPTR " bytes - %@", size, [NSError _last]);
DESTROY(self);
return nil;
}
@ -3844,7 +3844,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (shmid == -1) /* Created memory? */
{
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory "
@"get failed for %u - %@", bufferSize, [NSError _last]);
@"get failed for %" PRIuPTR " - %@", bufferSize, [NSError _last]);
DESTROY(self);
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithCapacity: bufferSize];
@ -3854,7 +3854,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (bytes == (void*)-1)
{
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory "
@"attach failed for %u - %@", bufferSize, [NSError _last]);
@"attach failed for %" PRIuPTR " - %@", bufferSize, [NSError _last]);
bytes = 0;
DESTROY(self);
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];

View file

@ -205,7 +205,7 @@ enum proxyLocation
if (debug_proxy)
NSLog(@"Receiving a proxy for local object 0x%x "
@"connection 0x%x\n", target, (uintptr_t)decoder_connection);
@"connection %p\n", target, decoder_connection);
o = [decoder_connection locateLocalTarget: target];
if (o == nil)
@ -235,8 +235,8 @@ enum proxyLocation
[aCoder decodeValueOfObjCType: @encode(typeof(target))
at: &target];
if (debug_proxy)
NSLog(@"Receiving a proxy, was local 0x%x connection 0x%x\n",
target, (uintptr_t)decoder_connection);
NSLog(@"Receiving a proxy, was local 0x%x connection %p\n",
target, decoder_connection);
o = [self initWithTarget: target
connection: decoder_connection];
return o;
@ -303,7 +303,7 @@ enum proxyLocation
if (debug_proxy)
NSLog(@"Receiving a triangle-connection proxy 0x%x "
@"connection 0x%x\n", target, (uintptr_t)proxy_connection);
@"connection %p\n", target, proxy_connection);
NSAssert(proxy_connection != decoder_connection,
NSInternalInconsistencyException);
@ -503,8 +503,8 @@ enum proxyLocation
proxy_tag = PROXY_LOCAL_FOR_SENDER;
if (debug_proxy)
NSLog(@"Sending a proxy, will be remote 0x%x connection 0x%x\n",
proxy_target, (uintptr_t)_connection);
NSLog(@"Sending a proxy, will be remote 0x%x connection %p\n",
proxy_target, _connection);
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag))
at: &proxy_tag];
@ -524,8 +524,8 @@ enum proxyLocation
proxy_tag = PROXY_LOCAL_FOR_RECEIVER;
if (debug_proxy)
NSLog(@"Sending a proxy, will be local 0x%x connection 0x%x\n",
proxy_target, (uintptr_t)_connection);
NSLog(@"Sending a proxy, will be local 0x%x connection %p\n",
proxy_target, _connection);
[aRmc encodeValueOfObjCType: @encode(typeof(proxy_tag))
at: &proxy_tag];
@ -562,9 +562,9 @@ enum proxyLocation
if (debug_proxy)
NSLog(@"Sending triangle-connection proxy 0x%x "
@"proxy-conn 0x%x to-proxy 0x%x to-conn 0x%x\n",
localProxy->_handle, (uintptr_t)localProxy->_connection,
proxy_target, (uintptr_t)_connection);
@"proxy-conn %p to-proxy 0x%x to-conn %p\n",
localProxy->_handle, localProxy->_connection,
proxy_target, _connection);
/*
* It's remote here, so we need to tell other side where to form
@ -628,8 +628,8 @@ enum proxyLocation
self = [_connection retainOrAddLocal: self forObject: anObject];
if (debug_proxy)
NSLog(@"Created new local=0x%x object 0x%x target 0x%x connection 0x%x\n",
(uintptr_t)self, (uintptr_t)_object, _handle, (uintptr_t)_connection);
NSLog(@"Created new local=%p object %p target 0x%x connection %p\n",
self, _object, _handle, _connection);
return self;
}
@ -654,8 +654,8 @@ enum proxyLocation
self = [_connection retainOrAddProxy: self forTarget: target];
if (debug_proxy)
NSLog(@"Created new proxy=0x%x target 0x%x connection 0x%x\n",
(uintptr_t)self, _handle, (uintptr_t)_connection);
NSLog(@"Created new proxy=%p target 0x%x connection %p\n",
self, _handle, _connection);
return self;
}
@ -826,8 +826,8 @@ enum proxyLocation
if (_connection)
{
if (debug_proxy > 3)
NSLog(@"retain count for connection (0x%x) is now %u\n",
(uintptr_t)_connection, [_connection retainCount]);
NSLog(@"retain count for connection (%p) is now %" PRIxPTR "\n",
_connection, [_connection retainCount]);
/*
* A proxy for local object retains its target - so we release it.
* For a local object the connection also retains this proxy, so we

View file

@ -170,7 +170,7 @@ static NSRange GSRangeOfCookie(NSString *string);
if (range.location == NSNotFound)
break;
onecookie = [field substringFromRange: range];
onecookie = [field substringWithRange: range];
NS_DURING
dict = GSPropertyListFromCookieFormat(onecookie, version);
NS_HANDLER

View file

@ -118,7 +118,7 @@
if (buffer == (void*)0)
{
NSLog(@"Failed to map %u bytes for execute: %@", _size, [NSError _last]);
NSLog(@"Failed to map %" PRIuPTR " bytes for execute: %@", _size, [NSError _last]);
buffer = 0;
[self dealloc];
self = nil;

View file

@ -1786,7 +1786,7 @@ typedef struct {
rl = [self reservedSpaceLength];
if (length != 0 && length != rl)
{
NSLog(@"bad reserved length - %u", length);
NSLog(@"bad reserved length - %" PRIuPTR, length);
return NO;
}
if ([receivingPort isKindOfClass: messagePortClass] == NO)

View file

@ -209,6 +209,8 @@ ICUToNSRoundingMode (UNumberFormatRoundingMode mode)
case UNUM_ROUND_HALFUP:
result = NSNumberFormatterRoundHalfUp;
break;
default:
result = NSNumberFormatterRoundHalfUp;
}
return result;
@ -1276,7 +1278,7 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
{
while (([placeHolders characterIsMember:
[useFormat characterAtIndex: NSMaxRange(intPartRange)]]
|| [[useFormat substringFromRange:
|| [[useFormat substringWithRange:
NSMakeRange(NSMaxRange(intPartRange), 1)] isEqual:
defaultThousandsSeparator])
&& NSMaxRange(intPartRange) < [useFormat length] - 1)

View file

@ -2308,21 +2308,6 @@ static id gs_weak_load(id obj)
return [self instanceMethodForSelector:aSel];
}
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector
{
struct objc_method* mth;
if (aSelector == 0)
[NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", NSStringFromSelector(_cmd)];
mth = GSGetMethod(self, aSelector, YES, YES);
if (0 == mth)
return nil;
return [NSMethodSignature
signatureWithObjCTypes: method_getTypeEncoding(mth)];
}
- (IMP) methodFor: (SEL)aSel
{
return [self methodForSelector: aSel];

View file

@ -2316,7 +2316,7 @@ static Class tcpPortClass;
rl = [self reservedSpaceLength];
if (length != 0 && length != rl)
{
NSLog(@"bad reserved length - %u", length);
NSLog(@"bad reserved length - %" PRIuPTR, length);
return NO;
}
if ([receivingPort isKindOfClass: tcpPortClass] == NO)

View file

@ -1494,7 +1494,7 @@ static NSURLProtocol *placeholder = nil;
}
else
{
NSLog(@"Unexpected event %d occurred on stream %@ not being used by %@",
NSLog(@"Unexpected event %" PRIdPTR " occurred on stream %@ not being used by %@",
event, stream, self);
}
if (event == NSStreamEventErrorOccurred)
@ -1506,7 +1506,7 @@ static NSURLProtocol *placeholder = nil;
}
else
{
NSLog(@"Unexpected event %d ignored on stream %@ of %@",
NSLog(@"Unexpected event %" PRIdPTR " ignored on stream %@ of %@",
event, stream, self);
}
}
@ -1640,7 +1640,7 @@ static NSURLProtocol *placeholder = nil;
}
else
{
NSLog(@"Unexpected event %d occurred on stream %@ not being used by %@",
NSLog(@"Unexpected event %" PRIdPTR " occurred on stream %@ not being used by %@",
event, stream, self);
}
if (event == NSStreamEventErrorOccurred)
@ -1652,7 +1652,7 @@ static NSURLProtocol *placeholder = nil;
}
else
{
NSLog(@"Unexpected event %d ignored on stream %@ of %@",
NSLog(@"Unexpected event %" PRIdPTR " ignored on stream %@ of %@",
event, stream, self);
}
}

View file

@ -195,7 +195,7 @@
}
else
{
NSLog(@"_dispatch with unexpected status %d", [self streamStatus]);
NSLog(@"_dispatch with unexpected status %" PRIdPTR, [self streamStatus]);
}
}
@end
@ -324,7 +324,7 @@
}
else
{
NSLog(@"_dispatch with unexpected status %d", [self streamStatus]);
NSLog(@"_dispatch with unexpected status %" PRIdPTR, [self streamStatus]);
}
}
@end

View file

@ -2221,7 +2221,7 @@ main(int argc, char **argv, char **env)
options: NSLiteralSearch];
if (r.length == 0)
{
NSLog(@"Missing '#' in href at %u", replace.location);
NSLog(@"Missing '#' in href at %" PRIuPTR, replace.location);
break;
}
href = [href substringFromIndex: NSMaxRange(r)];
@ -2233,7 +2233,7 @@ main(int argc, char **argv, char **env)
options: NSLiteralSearch];
if (r.length == 0)
{
NSLog(@"Missing '$' in href at %u", replace.location);
NSLog(@"Missing '$' in href at %" PRIuPTR, replace.location);
break;
}
type = [href substringToIndex: r.location];
@ -2272,7 +2272,7 @@ main(int argc, char **argv, char **env)
}
if (unit == nil)
{
NSLog(@"Missing unit name terminator at %u",
NSLog(@"Missing unit name terminator at %" PRIuPTR,
replace.location);
break;
}

View file

@ -536,7 +536,7 @@ ihandler(int sig)
if (debugging)
NSLog(@"Adding observer %llu for %@ %@",
anObserver, notificationName, anObject);
(unsigned long long)anObserver, notificationName, anObject);
connection = [(NSDistantObject*)client connectionForProxy];
clients = (NSMapTable*)NSMapGet(connections, connection);
@ -818,7 +818,7 @@ ihandler(int sig)
{
[obs->queue removeObjectAtIndex: 0];
if (debugging)
NSLog(@"Posting to observer %llu with %@", obs->observer, n);
NSLog(@"Posting to observer %llu with %@", (unsigned long long)obs->observer, n);
[obs->client->client postNotificationName: n->name
object: n->object
userInfo: n->info
@ -842,7 +842,7 @@ ihandler(int sig)
{
if (debugging)
NSLog(@"Removing observer %llu for %@ %@",
observer->observer, observer->notificationName,
(unsigned long long)observer->observer, observer->notificationName,
observer->notificationObject);
if (observer->notificationObject)