diff --git a/ChangeLog b/ChangeLog index c3c571056..a32ad101b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,98 @@ +2006-10-20 Richard Frith-Macdonald + + * Source/Additions/GSPrivate.m: + * Source/GSFormat.h: + Deleted unused files. + * Headers/Foundation/NSError.h: + * Source/NSError.m: + Updated to current MacOS-X spec. + * Source/NSIndexPath.m: + * Source/NSSocketPortNameServer.m: + * Source/NSTimeZone.m: + * Source/NSHashTable.m: + * Source/NSBundle.m: + * Source/NSPropertyList.m: + * Source/libgnustep-base-entry.m: + * Source/GSConcreteValueTemplate.m: + * Source/NSScanner.m: + * Source/NSProcessInfo.m: + * Source/NSGeometry.m: + * Source/NSSocketPort.m: + * Source/NSUndoManager.m: + * Source/NSMethodSignature.m: + * Source/NSFormatter.m: + * Source/NSUserDefaults.m: + * Source/NSArray.m: + * Source/NSMessagePortNameServer.m: + * Source/objc-gnu2next.m: + * Source/GSStream.m: + * Source/NSDebug.m: + * Source/unix/GSRunLoopCtxt.m: + * Source/GSConcreteValue.m: + * Source/NSDistributedLock.m: + * Source/NSFileHandle.m: + * Source/preface.m: + * Source/NSAssertionHandler.m: + * Source/NSConcreteNumberTemplate.m: + * Source/GSHTTPURLHandle.m: + * Source/NSZone.m: + * Source/NSCallBacks.m: + * Source/NSMessagePort.m: + * Source/GSDictionary.m: + * Source/GSPrivate.h: + * Source/GSCountedSet.m: + * Source/win32/GSFileHandleWin32.m: + * Source/win32/GSRunLoopCtxt.m: + * Source/win32/NSMessagePortWin32.m: + * Source/win32/NSStreamWin32.m: + * Source/NSFileManager.m: + * Source/NSConcreteNumber.m: + * Source/NSNotificationCenter.m: + * Source/externs.m: + * Source/NSRange.m: + * Source/NSException.m: + * Source/NSCopyObject.m: + * Source/mframe.m: + * Source/NSObject.m: + * Source/NSString.m: + * Source/Additions/Unicode.m: + * Source/Additions/GNUmakefile: + * Source/Additions/GSCompatibility.m: + * Source/Additions/GSCategories.m: + * Source/GSSet.m: + * Source/GSString.m: + * Source/NSThread.m: + * Source/NSData.m: + * Source/NSHost.m: + * Source/NSProxy.m: + * Source/NSProtocolChecker.m: + * Source/NSPipe.m: + * Source/GSValue.m: + * Source/NSDictionary.m: + * Source/NSClassDescription.m: + * Source/NSSerializer.m: + * Source/NSNull.m: + * Source/NSValue.m: + * Source/NSCountedSet.m: + * Source/NSLog.m: + * Source/GSFormat.m: + * Source/NSIndexSet.m: + * Source/GSFileHandle.m: + * Source/NSLock.m: + * Source/NSDistantObject.m: + * Source/NSTask.m: + * Source/NSPortNameServer.m: + * Source/NSNumberFormatter.m: + * Source/NSXMLParser.m: + * Source/GSFTPURLHandle.m: + * Source/NSEnumerator.m: + * Source/GSURLPrivate.h: + * SSL/GSSSLHandle.m: + Move from GSPrivate class to GSPrivate functions as majority prefer + that. Make some more private functions use GSPrivate prefix and be + unlinkable outside base. Rationalise error string generation. + Tidy up FSF address in comments. + 2006-10-19 Richard Frith-Macdonald * Documentation/manual/DistributedObjects.texi: Update for current API diff --git a/Headers/Foundation/NSError.h b/Headers/Foundation/NSError.h index d8b558138..42b142a30 100644 --- a/Headers/Foundation/NSError.h +++ b/Headers/Foundation/NSError.h @@ -1,5 +1,5 @@ /** Interface for NSError for GNUStep - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004,2006 Free Software Foundation, Inc. Written by: Richard Frith-Macdonald Date: May 2004 @@ -27,15 +27,16 @@ #ifndef __NSError_h_GNUSTEP_BASE_INCLUDE #define __NSError_h_GNUSTEP_BASE_INCLUDE -#ifndef STRICT_OPENSTEP #include +#if OS_API_VERSION(100300,GS_API_LATEST) + #if defined(__cplusplus) extern "C" { #endif -@class NSDictionary, NSString; +@class NSArray, NSDictionary, NSString; /** * Key for user info dictionary component which describes the error in @@ -49,6 +50,42 @@ GS_EXPORT NSString* const NSLocalizedDescriptionKey; */ GS_EXPORT NSString* const NSUnderlyingErrorKey; +#if OS_API_VERSION(100400,GS_API_LATEST) +/** + * This key can be used to store the file path of a resource involved + * in the error (eg unreadable file). + */ +GS_EXPORT NSString* const NSFilePathErrorKey; +/** + * Key for an [NSNumber] containing an NSStringEncoding value. + */ +GS_EXPORT NSString* const NSStringEncodingErrorKey; +/** + * This can be used to store the URLK involved in the error. + */ +GS_EXPORT NSString* const NSURLErrorKey; +/** + * Key to store a string describing what caused the error to occur. + */ +GS_EXPORT NSString* const NSLocalizedFailureReasonErrorKey; +/** + * Key to store an [NSArray] of strings suitable for use as the + * titles of buttons in an alert panel used to attempt error + * recovery in a GUI application. + */ +GS_EXPORT NSString* const NSLocalizedRecoveryOptionsErrorKey; +/** + * Key to store a string providing a hint on how to use the buttons + * in an alert panel. + */ +GS_EXPORT NSString* const NSLocalizedRecoverySuggestionErrorKey; +/** + * Key to store an object which can be used to attempt to recover from + * the error. + */ +GS_EXPORT NSString* const NSRecoveryAttempterErrorKey; +#endif + /** * Domain for system errors (on MACH). */ @@ -61,11 +98,21 @@ GS_EXPORT NSString* const NSOSStatusErrorDomain; * Domain for system and system library errors. */ GS_EXPORT NSString* const NSPOSIXErrorDomain; +#if OS_API_VERSION(100400,GS_API_LATEST) +/** + * Domain for Foundation and AppKit (base and gui) errors. + */ +GS_EXPORT NSString* const NSCocoaErrorDomain; +#endif /** - * Error information class. + * Error information class.
+ * NSError instances are used to pass information about runtime errors + * from lower levels to higher levels of the program.
+ * These should be used instead of exceptions where an error is caused + * by external factors (such as a resource file not being present) + * rather than a programming error (where NSException should be used). */ -// TODO: document what this is for, especially since it's not in OS X @interface NSError : NSObject { @private @@ -101,13 +148,49 @@ GS_EXPORT NSString* const NSPOSIXErrorDomain; code: (int)aCode userInfo: (NSDictionary*)aDictionary; -/** +/** * Return a human readable description for the error.
* The default implementation uses the value from the user info dictionary * if it is available, otherwise it generates a generic one from domain * and code. */ -- (NSString *)localizedDescription; +- (NSString *) localizedDescription; + +#if OS_API_VERSION(100400,GS_API_LATEST) +/** + * Return a human readable explanation of the reason for the error + * (if known). This should normally be a more discursive explanation + * then the short one provided by the -localizedDescription method.
+ * The default implementation uses the value from the user info dictionary + * if it is available, otherwise it returns nil. + */ +- (NSString *) localizedFailureReason; + +/** + * Returns an array of strings to be used as titles of buttons in an + * alert panel when offering the user optionbs to try to recover from + * the error.
+ * The default implementation uses the value from the user info dictionary + * if it is available, otherwise it returns nil. + */ +- (NSArray *) localizedRecoveryOptions; + +/** + * Returns a string used as the secondary text in an alert panel, + * suggesting how the user might select an option to attempt to + * recover from the error.
+ * The default implementation uses the value from the user info dictionary + * if it is available, otherwise it returns nil. + */ +- (NSString *) localizedRecoverySuggestion; + +/** + * Not yet useful in GNUstep.
+ * The default implementation uses the value from the user info dictionary + * if it is available, otherwise it returns nil. + */ +- (id) recoveryAttempter; +#endif /** * Return the user info for this instance (or nil if none is set)
@@ -124,5 +207,6 @@ GS_EXPORT NSString* const NSPOSIXErrorDomain; } #endif -#endif /* STRICT_OPENSTEP */ +#endif + #endif /* __NSError_h_GNUSTEP_BASE_INCLUDE*/ diff --git a/SSL/GSSSLHandle.m b/SSL/GSSSLHandle.m index ccd9bf989..af131b004 100644 --- a/SSL/GSSSLHandle.m +++ b/SSL/GSSSLHandle.m @@ -80,10 +80,9 @@ #ifdef HAVE_UNISTD_H #include #endif -#include static NSString* -sslError(int err, int e) +sslError(int err) { NSString *str; @@ -107,8 +106,12 @@ sslError(int err, int e) str = @"Want X509 Lookup Error"; break; case SSL_ERROR_SYSCALL: - str = [NSString stringWithFormat: @"Syscall error %d - %@", - e, [_GSPrivate error: e]]; + { + NSError *e = [NSError _last]; + + str = [NSString stringWithFormat: @"Syscall error %d - %@", + [e code], [e description]]; + } break; case SSL_ERROR_SSL: str = @"SSL Error: really helpful"; @@ -224,7 +227,6 @@ sslError(int err, int e) } if (ret != 1) { - int e = errno; NSDate *final; NSDate *when; NSTimeInterval last = 0.0; @@ -253,7 +255,6 @@ sslError(int err, int e) ret = SSL_accept(ssl); if (ret != 1) { - e = errno; err = SSL_get_error(ssl, ret); } else @@ -271,7 +272,7 @@ sslError(int err, int e) * Some other error ... not just a timeout or disconnect */ NSLog(@"unable to accept SSL connection from %@:%@ - %@", - address, service, sslError(err, e)); + address, service, sslError(err)); ERR_print_errors_fp(stderr); } @@ -330,7 +331,6 @@ sslError(int err, int e) } if (ret != 1) { - int e = errno; NSDate *final; NSDate *when; NSTimeInterval last = 0.0; @@ -359,7 +359,6 @@ sslError(int err, int e) ret = SSL_connect(ssl); if (ret != 1) { - e = errno; err = SSL_get_error(ssl, ret); } else @@ -371,13 +370,14 @@ sslError(int err, int e) RELEASE(final); if (err != SSL_ERROR_NONE) { + if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) { /* * Some other error ... not just a timeout or disconnect */ NSLog(@"unable to make SSL connection to %@:%@ - %@", - address, service, sslError(err, e)); + address, service, sslError(err)); ERR_print_errors_fp(stderr); } RELEASE(self); @@ -439,7 +439,7 @@ sslError(int err, int e) if (ret != 1) { NSLog(@"Failed to set certificate file to %@ - %@", - certFile, sslError(ERR_get_error(), errno)); + certFile, sslError(ERR_get_error())); } } if ([privateKey length] > 0) @@ -449,7 +449,7 @@ sslError(int err, int e) if (ret != 1) { NSLog(@"Failed to set private key file to %@ - %@", - privateKey, sslError(ERR_get_error(), errno)); + privateKey, sslError(ERR_get_error())); } } } diff --git a/Source/Additions/GNUmakefile b/Source/Additions/GNUmakefile index 7de125729..d494a77d6 100644 --- a/Source/Additions/GNUmakefile +++ b/Source/Additions/GNUmakefile @@ -40,7 +40,6 @@ Additions_OBJC_FILES =\ GSMime.m \ GSXML.m \ GSFunctions.m \ - GSPrivate.m \ behavior.m ifneq ($(OBJC_RUNTIME_LIB), gnu) diff --git a/Source/Additions/GSCategories.m b/Source/Additions/GSCategories.m index f27de550e..334616ef0 100644 --- a/Source/Additions/GSCategories.m +++ b/Source/Additions/GSCategories.m @@ -900,6 +900,80 @@ static void MD5Transform (uint32_t buf[4], uint32_t const in[16]) } @end + + +/** + * GNUstep specific (non-standard) additions to the NSError class. + * Possibly to be made public + */ +@implementation NSError(GSCategories) + +#ifndef HAVE_STRERROR +static const char * +strerror(int eno) +{ + extern char *sys_errlist[]; + extern int sys_nerr; + + if (eno < 0 || eno >= sys_nerr) + { + return("unknown error number"); + } + return(sys_errlist[eno]); +} +#endif + +/* + * Returns an NSError instance encapsulating the last system error. + * The user info dictionary of this object will be mutable, so that + * additional information can be placed in it by higher level code. + */ ++ (NSError*) _last +{ + NSError *error; + NSString *domain; + NSDictionary *info; + long code; +#if defined(__MINGW32__) + LPVOID lpMsgBuf; + NSString *message; + + code = GetLastError(); + domain = NSOSStatusErrorDomain; + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR) &lpMsgBuf, 0, NULL ); + message = [NSString stringWithCharacters: lpMsgBuf length: wcslen(lpMsgBuf)]; + LocalFree(lpMsgBuf); + info = [NSMutableDictionary dictionaryWithObjectsAndKeys: + message, NSLocalizedDescriptionKey, + nil]; +#else + extern int errno; + NSString *message; + + code = errno; + /* FIXME ... not all are POSIX, should we use NSMachErrorDomain for some? */ + domain = NSPOSIXErrorDomain; + message = [NSString stringWithCString: strerror(code) + encoding: [NSString defaultCStringEncoding]]; + /* FIXME ... can we do better localisation? */ + info = [NSMutableDictionary dictionaryWithObjectsAndKeys: + message, NSLocalizedDescriptionKey, + nil]; +#endif + + /* NB we use a mutable dictionary so that calling code can add extra + * information to the dictionary before passing it up to higher level + * code. + */ + error = [self errorWithDomain: domain code: code userInfo: info]; + return error; +} +@end + + + /** * GNUstep specific (non-standard) additions to the NSNumber class. */ diff --git a/Source/Additions/GSCompatibility.m b/Source/Additions/GSCompatibility.m index c66dc84a9..1e1c005d0 100644 --- a/Source/Additions/GSCompatibility.m +++ b/Source/Additions/GSCompatibility.m @@ -250,7 +250,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); RELEASE(self); return nil; } @@ -268,7 +268,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0) { NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr), - NSSwapBigShortToHost(sin.sin_port), [_GSPrivate error]); + NSSwapBigShortToHost(sin.sin_port), [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -276,7 +276,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (listen(net, 5) < 0) { - NSLog(@"unable to listen on port - %@", [_GSPrivate error]); + NSLog(@"unable to listen on port - %@", [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -284,7 +284,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (getsockname(net, (struct sockaddr*)&sin, &size) < 0) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -313,7 +313,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); return nil; } diff --git a/Source/Additions/GSPrivate.m b/Source/Additions/GSPrivate.m deleted file mode 100644 index 29a623330..000000000 --- a/Source/Additions/GSPrivate.m +++ /dev/null @@ -1,81 +0,0 @@ -/* Private internal methods for use within the base library - - Copyright (C) 2006 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - -*/ -#include "config.h" -#include -#include -#include "GNUstepBase/GSCategories.h" -#include "GNUstepBase/GSLock.h" -#include "GSPrivate.h" - -/* Test for ASCII whitespace which is safe for unicode characters */ -#define space(C) ((C) > 127 ? NO : isspace(C)) - -#ifndef HAVE_STRERROR -const char * -strerror(int eno) -{ - extern char *sys_errlist[]; - extern int sys_nerr; - - if (eno < 0 || eno >= sys_nerr) - { - return("unknown error number"); - } - return(sys_errlist[eno]); -} -#endif - -@implementation GSPrivate - -- (NSString*) error -{ -#if defined(__MINGW32__) - return [self error: GetLastError()]; -#else - extern int errno; - return [self error: errno]; -#endif -} - -- (NSString*) error: (long)number -{ - NSString *text; -#if defined(__MINGW32__) - LPVOID lpMsgBuf; - - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, number, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR) &lpMsgBuf, 0, NULL ); - text = [NSString stringWithCharacters: lpMsgBuf length: wcslen(lpMsgBuf)]; - LocalFree(lpMsgBuf); -#else - text = [NSString stringWithCString: strerror(number) - encoding: [NSString defaultCStringEncoding]]; -#endif - return text; -} -@end - - diff --git a/Source/Additions/Unicode.m b/Source/Additions/Unicode.m index 13a9ea4ee..3ef2ceb0a 100644 --- a/Source/Additions/Unicode.m +++ b/Source/Additions/Unicode.m @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -331,7 +332,8 @@ static void GSSetupEncodingTable(void) } } -static BOOL isEncodingSupported(NSStringEncoding enc) +BOOL +GSPrivateIsEncodingSupported(NSStringEncoding enc) { GSSetupEncodingTable(); @@ -1160,7 +1162,7 @@ tables: const char *estr = 0; BOOL done = NO; - if (isEncodingSupported(enc) == YES) + if (GSPrivateIsEncodingSupported(enc) == YES) { estr = encodingTable[enc]->iconv; } @@ -1181,7 +1183,7 @@ tables: if (cd == (iconv_t)-1) { NSLog(@"No iconv for encoding %@ tried to use %s", - [_GSPrivate encodingName: enc], estr); + GSPrivateEncodingName(enc), estr); result = NO; goto done; } @@ -1853,7 +1855,7 @@ iconv_start: const char *estr = 0; BOOL done = NO; - if (isEncodingSupported(enc) == YES) + if (GSPrivateIsEncodingSupported(enc) == YES) { if (strict == NO) { @@ -1886,7 +1888,7 @@ iconv_start: if (cd == (iconv_t)-1) { NSLog(@"No iconv for encoding %@ tried to use %s", - [_GSPrivate encodingName: enc], estr); + GSPrivateEncodingName(enc), estr); result = NO; goto done; } @@ -2043,9 +2045,10 @@ iconv_start: #undef GROW -@implementation GSPrivate (Unicode) -- (NSStringEncoding*) availableEncodings + +NSStringEncoding* +GSPrivateAvailableEncodings() { if (_availableEncodings == 0) { @@ -2068,7 +2071,7 @@ iconv_start: pos = 0; for (i = 0; i < encTableSize+1; i++) { - if (isEncodingSupported(i) == YES) + if (GSPrivateIsEncodingSupported(i) == YES) { encodings[pos++] = i; } @@ -2081,7 +2084,8 @@ iconv_start: return _availableEncodings; } -- (NSStringEncoding) defaultCStringEncoding +NSStringEncoding +GSPrivateDefaultCStringEncoding() { if (defEnc == GSUndefinedEncoding) { @@ -2233,7 +2237,7 @@ iconv_start: #endif defEnc = NSISOLatin1StringEncoding; } - else if (isEncodingSupported(defEnc) == NO) + else if (GSPrivateIsEncodingSupported(defEnc) == NO) { fprintf(stderr, "WARNING: %s - encoding not implemented as " "default c string encoding.\n", encoding); @@ -2246,28 +2250,24 @@ iconv_start: return defEnc; } -- (NSString*) encodingName: (NSStringEncoding)encoding +NSString* +GSPrivateEncodingName(NSStringEncoding encoding) { - if (isEncodingSupported(encoding) == NO) + if (GSPrivateIsEncodingSupported(encoding) == NO) { return @"Unknown encoding"; } return [NSString stringWithUTF8String: encodingTable[encoding]->ename]; } -- (BOOL) isByteEncoding: (NSStringEncoding)encoding +BOOL +GSPrivateIsByteEncoding(NSStringEncoding encoding) { - if (isEncodingSupported(encoding) == NO) + if (GSPrivateIsEncodingSupported(encoding) == NO) { return NO; } return encodingTable[encoding]->eightBit; } -- (BOOL) isEncodingSupported: (NSStringEncoding)encoding -{ - return isEncodingSupported(encoding); -} - -@end diff --git a/Source/GSConcreteValue.m b/Source/GSConcreteValue.m index f02b550fe..1665d1ee6 100644 --- a/Source/GSConcreteValue.m +++ b/Source/GSConcreteValue.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/GSConcreteValueTemplate.m b/Source/GSConcreteValueTemplate.m index 4a4596925..60e82fe6f 100644 --- a/Source/GSConcreteValueTemplate.m +++ b/Source/GSConcreteValueTemplate.m @@ -19,7 +19,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ diff --git a/Source/GSCountedSet.m b/Source/GSCountedSet.m index 7fa3a140f..ef96f00c7 100644 --- a/Source/GSCountedSet.m +++ b/Source/GSCountedSet.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/GSDictionary.m b/Source/GSDictionary.m index 07789b3ff..1e23a8118 100644 --- a/Source/GSDictionary.m +++ b/Source/GSDictionary.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ diff --git a/Source/GSFTPURLHandle.m b/Source/GSFTPURLHandle.m index 1f1122295..b029e8ec9 100644 --- a/Source/GSFTPURLHandle.m +++ b/Source/GSFTPURLHandle.m @@ -979,7 +979,7 @@ static NSLock *urlLock = nil; */ [self backgroundLoadDidFailWithReason: [NSString stringWithFormat: @"Unable to connect to %@:%@ ... %@", - host, port, [_GSPrivate error]]]; + host, port, [NSError _last]]]; return; } cHandle = [[GSTelnetHandle alloc] initWithHandle: sock isConnected: NO]; diff --git a/Source/GSFileHandle.m b/Source/GSFileHandle.m index 546c853b9..15df8ee60 100644 --- a/Source/GSFileHandle.m +++ b/Source/GSFileHandle.m @@ -798,7 +798,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1) { - NSLog(@"unable to create socket - %@", [_GSPrivate error: errno]); + NSLog(@"unable to create socket - %@", [NSError _last]); RELEASE(self); return nil; } @@ -813,7 +813,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == -1) { NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error: errno]); + GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -833,7 +833,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSLog(@"unable to make connection to %s:%d - %@", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]); + GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); RELEASE(self); return nil; } @@ -897,7 +897,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); RELEASE(self); return nil; } @@ -915,7 +915,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == -1) { NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]); + GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -923,7 +923,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (listen(net, 256) == -1) { - NSLog(@"unable to listen on port - %@", [_GSPrivate error]); + NSLog(@"unable to listen on port - %@", [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -931,7 +931,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getsockname(net, (struct sockaddr*)&sin, &size) == -1) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); (void) close(net); RELEASE(self); return nil; @@ -1097,7 +1097,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (fstat(desc, &sbuf) < 0) { NSLog(@"unable to get status of descriptor %d - %@", - desc, [_GSPrivate error]); + desc, [NSError _last]); } else { @@ -1319,7 +1319,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } return d; } @@ -1344,7 +1344,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } return d; } @@ -1370,7 +1370,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } [d setLength: got]; } @@ -1393,7 +1393,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } } while (len > 0 && got > 0); @@ -1439,7 +1439,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to write to descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } } @@ -1545,7 +1545,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %@", - [_GSPrivate error]]; + [NSError _last]]; } return (unsigned long long)result; } @@ -1569,7 +1569,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %@", - [_GSPrivate error]]; + [NSError _last]]; } return (unsigned long long)result; } @@ -1593,7 +1593,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %@", - [_GSPrivate error]]; + [NSError _last]]; } } @@ -1929,7 +1929,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Accept attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1997,7 +1997,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Read attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } @@ -2033,7 +2033,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Connect attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [info setObject: s forKey: GSFileHandleNotificationError]; } else @@ -2066,7 +2066,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: - @"Write attempt failed - %@", [_GSPrivate error]]; + @"Write attempt failed - %@", [NSError _last]]; [info setObject: s forKey: GSFileHandleNotificationError]; [self postWriteNotification]; } @@ -2143,7 +2143,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (fcntl(descriptor, F_SETFL, e) < 0) { NSLog(@"unable to set non-blocking mode for %d - %@", - descriptor, [_GSPrivate error]); + descriptor, [NSError _last]); } else { @@ -2153,7 +2153,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; else { NSLog(@"unable to get non-blocking mode for %d - %@", - descriptor, [_GSPrivate error]); + descriptor, [NSError _last]); } } } @@ -2171,7 +2171,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); } else { @@ -2188,7 +2188,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); } else { diff --git a/Source/GSFormat.h b/Source/GSFormat.h deleted file mode 100644 index 1c7b54f8e..000000000 --- a/Source/GSFormat.h +++ /dev/null @@ -1,37 +0,0 @@ -/* GSFormat - printf-style formatting - - Copyright (C) 2000 Free Software Foundation, Inc. - - Written by: Kai Henningsen - Created: Jan 2001 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. -*/ - -#ifndef __GSFormat_H_ -#define __GSFormat_H_ - -#include -#include "GSPrivate.h" - -@class NSDictionary; - -void -GSFormat(GSStr fb, const unichar *fmt, va_list ap, NSDictionary *loc); - -#endif - diff --git a/Source/GSFormat.m b/Source/GSFormat.m index 0bca9dda3..9448b4322 100644 --- a/Source/GSFormat.m +++ b/Source/GSFormat.m @@ -73,7 +73,8 @@ #include "Foundation/NSZone.h" #include "Foundation/NSDebug.h" #include "GNUstepBase/GSLocale.h" -#include "GSFormat.h" + +#include "GSPrivate.h" #include // for strstr() #include @@ -802,7 +803,7 @@ static unichar *group_number (unichar *, unichar *, const char *, NSString *); /* The function itself. */ void -GSFormat (GSStr s, const unichar *format, va_list ap, +GSPrivateFormat (GSStr s, const unichar *format, va_list ap, NSDictionary *locale) { /* The character used as thousands separator. */ @@ -1694,7 +1695,8 @@ NSDictionary *locale) LABEL (form_strerror): /* Print description of error ERRNO. */ - string = (unichar *)[[_GSPrivate error: save_errno] + errno = save_errno; + string = (unichar *)[[[NSError _last] localizedDescription] cStringUsingEncoding: NSUnicodeStringEncoding]; is_long = 1; /* This is a unicode string. */ goto LABEL (print_string); @@ -1762,7 +1764,7 @@ NSDictionary *locale) if (enc == GSUndefinedEncoding) { enc = [NSString defaultCStringEncoding]; - byteEncoding = [_GSPrivate isByteEncoding: enc]; + byteEncoding = GSPrivateIsByteEncoding(enc); } len = strlen(str); // Number of bytes to convert. diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index c57959d29..6ccb7d304 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -25,22 +25,22 @@ #include "config.h" #include "Foundation/NSArray.h" -#include "Foundation/NSString.h" -#include "Foundation/NSException.h" -#include "Foundation/NSValue.h" +#include "Foundation/NSByteOrder.h" #include "Foundation/NSData.h" +#include "Foundation/NSDebug.h" +#include "Foundation/NSException.h" +#include "Foundation/NSFileHandle.h" +#include "Foundation/NSHost.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSPathUtilities.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSString.h" #include "Foundation/NSURL.h" #include "Foundation/NSURLHandle.h" -#include "Foundation/NSNotification.h" -#include "Foundation/NSRunLoop.h" -#include "Foundation/NSByteOrder.h" -#include "Foundation/NSLock.h" -#include "Foundation/NSFileHandle.h" -#include "Foundation/NSDebug.h" -#include "Foundation/NSHost.h" -#include "Foundation/NSProcessInfo.h" -#include "Foundation/NSPathUtilities.h" -#include "Foundation/NSMapTable.h" +#include "Foundation/NSValue.h" #include "GNUstepBase/GSMime.h" #include "GNUstepBase/GSLock.h" #include "NSCallBacks.h" @@ -1269,7 +1269,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) */ [self backgroundLoadDidFailWithReason: [NSString stringWithFormat: @"Unable to connect to %@:%@ ... %@", - host, port, [_GSPrivate error]]]; + host, port, [NSError _last]]]; return; } RETAIN(sock); diff --git a/Source/GSPrivate.h b/Source/GSPrivate.h index 3ae92ae75..6136c1d2d 100644 --- a/Source/GSPrivate.h +++ b/Source/GSPrivate.h @@ -24,6 +24,8 @@ #ifndef _GSPrivate_h_ #define _GSPrivate_h_ +#include "Foundation/NSError.h" + @class NSNotification; #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) @@ -218,6 +220,72 @@ typedef enum { - (const char*) type; @end +/* Get error information. + */ +@interface NSError (GSCategories) ++ (NSError*) _last; +@end + +/* Used by NSException uncaught exception handler - must not call any + * methods/functions which might cause a recursive exception. + */ +const char* +GSPrivateArgZero() GS_ATTRIB_PRIVATE; + +/* get the available string encodings (nul terminated array) + */ +NSStringEncoding * +GSPrivateAvailableEncodings() GS_ATTRIB_PRIVATE; + +/* Initialise constant strings + */ +void +GSPrivateBuildStrings(void) GS_ATTRIB_PRIVATE; + +/* get the default C-string encoding. + */ +NSStringEncoding +GSPrivateDefaultCStringEncoding() GS_ATTRIB_PRIVATE; + +/* Get default locale quickly (usually from cache). + * External apps would cache the locale themselves. + */ +NSDictionary * +GSPrivateDefaultLocale() GS_ATTRIB_PRIVATE; + +/* Get one of several standard values. + */ +BOOL +GSPrivateDefaultsFlag(GSUserDefaultFlagType type) GS_ATTRIB_PRIVATE; + +/* get the name of a string encoding as an NSString. + */ +NSString * +GSPrivateEncodingName(NSStringEncoding encoding) GS_ATTRIB_PRIVATE; + +/* get a flag from an environment variable - return def if not defined. + */ +BOOL +GSPrivateEnvironmentFlag(const char *name, BOOL def) GS_ATTRIB_PRIVATE; + +/* Format arguments into an internal string. + */ +void +GSPrivateFormat(GSStr fb, const unichar *fmt, va_list ap, NSDictionary *loc) + GS_ATTRIB_PRIVATE; + +/* determine whether data in a particular encoding can + * generally be represented as 8-bit characters including ascii. + */ +BOOL +GSPrivateIsByteEncoding(NSStringEncoding encoding) GS_ATTRIB_PRIVATE; + +/* determine whether encoding is currently supported. + */ +BOOL +GSPrivateIsEncodingSupported(NSStringEncoding encoding) GS_ATTRIB_PRIVATE; + + /* * Functions used by the NSRunLoop and friends for processing * queued notifications and task completion events. @@ -227,74 +295,6 @@ void GSPrivateNotifyASAP(void) GS_ATTRIB_PRIVATE; void GSPrivateNotifyIdle(void) GS_ATTRIB_PRIVATE; BOOL GSPrivateNotifyMore(void) GS_ATTRIB_PRIVATE; -/* This class exists to encapsulate various otherwise unrelated functions - * so that we expose a single global symbol (the class) whose name marks it - * very clearly as for private/internal use only. Avoiding the exposure - * (and hence possible accidental use) of symbols for each function ... - * The formal implementation of the class is a near empty implementation - * (in Additions/GSPrivate.m), with most methods being provided by other - * categories in the files wishing to expose some functionality for use - * by other parts of the base library. - */ -@interface GSPrivate : NSObject -{ -} - -/* Return the text describing the last system error to have occurred. - */ -- (NSString*) error; -- (NSString*) error: (long)number; -@end - -extern GSPrivate *_GSPrivate; - -@interface GSPrivate (ProcessInfo) -/* Used by NSException uncaught exception handler - must not call any - * methods/functions which might cause a recursive exception. - */ -- (const char*) argZero; - -/* get a flag from an environment variable - return def if not defined. - */ -- (BOOL) environmentFlag: (const char *)name defaultValue: (BOOL)def; -@end - -@interface GSPrivate (Unicode) -/* get the available string encodings (nul terminated array) - */ -- (NSStringEncoding*) availableEncodings; - -/* get the default C-string encoding. - */ -- (NSStringEncoding) defaultCStringEncoding; - -/* get the name of a string encoding as an NSString. - */ -- (NSString*) encodingName: (NSStringEncoding)encoding; - -/* determine whether data in a particular encoding can - * generally be represented as 8-bit characters including ascii. - */ -- (BOOL) isByteEncoding: (NSStringEncoding)encoding; - -/* determine whether encoding is currently supported. - */ -- (BOOL) isEncodingSupported: (NSStringEncoding)encoding; - -@end - -@interface GSPrivate (UserDefaults) -/* - * Get one of several potentially useful flags. - */ -- (BOOL) userDefaultsFlag: (GSUserDefaultFlagType)type; -@end - -/* Get default locale quickly (usually from cache). - * External apps would cache the locale themselves. - */ -NSDictionary * -GSPrivateDefaultLocale() GS_ATTRIB_PRIVATE; #endif /* _GSPrivate_h_ */ diff --git a/Source/GSSet.m b/Source/GSSet.m index f4978142c..f9034fcf7 100644 --- a/Source/GSSet.m +++ b/Source/GSSet.m @@ -19,7 +19,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/GSStream.m b/Source/GSStream.m index ddaa3bb1f..e93e643e4 100644 --- a/Source/GSStream.m +++ b/Source/GSStream.m @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -365,7 +364,7 @@ static RunLoopEventType typeForStream(NSStream *aStream) theError = [NSError errorWithDomain: NSPOSIXErrorDomain code: errno userInfo: nil]; - NSLog(@"%@ error(%d): - %@", self, errno, [_GSPrivate error]); + NSLog(@"%@ error(%d): - %@", self, errno, [NSError _last]); ASSIGN(_lastError, theError); _currentStatus = NSStreamStatusError; } diff --git a/Source/GSString.m b/Source/GSString.m index 4a6acf133..6d2c57d0f 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -47,7 +47,6 @@ #include "Foundation/NSDebug.h" #include "Foundation/NSObjCRuntime.h" #include "GNUstepBase/GSObjCRuntime.h" -#include "GSFormat.h" #include #include "GSPrivate.h" @@ -58,7 +57,7 @@ static BOOL isByteEncoding(NSStringEncoding enc) { - return [_GSPrivate isByteEncoding: enc]; + return GSPrivateIsByteEncoding(enc); } #ifdef NeXT_RUNTIME @@ -258,7 +257,7 @@ setup(void) * Cache the default string encoding, and set the internal encoding * used by 8-bit character strings to match if possible. */ - externalEncoding = [_GSPrivate defaultCStringEncoding]; + externalEncoding = GSPrivateDefaultCStringEncoding(); if (isByteEncoding(externalEncoding) == YES) { internalEncoding = externalEncoding; @@ -451,7 +450,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree, void *chars = 0; BOOL flag = NO; - if ([_GSPrivate isEncodingSupported: encoding] == NO) + if (GSPrivateIsEncodingSupported(encoding) == NO) { return nil; // Invalid encoding } @@ -494,7 +493,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree, BOOL isLatin1 = NO; GSStr me; - if ([_GSPrivate isEncodingSupported: encoding] == NO) + if (GSPrivateIsEncodingSupported(encoding) == NO) { if (flag == YES && bytes != 0) { @@ -704,7 +703,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree, /* * Now set up 'f' as a GSMutableString object whose initial buffer is - * allocated on the stack. The GSFormat function can write into it. + * allocated on the stack. The GSPrivateFormat function can write into it. */ f.isa = GSMutableStringClass; f._zone = NSDefaultMallocZone(); @@ -713,7 +712,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree, f._count = 0; f._flags.wide = 0; f._flags.free = 0; - GSFormat(&f, fmt, argList, locale); + GSPrivateFormat(&f, fmt, argList, locale); if (fmt != fbuf) { objc_free(fmt); @@ -3435,8 +3434,9 @@ agree, create a new GSUnicodeInlineString otherwise. /* * Make sure we have the format string in a nul terminated array of - * unichars for passing to GSFormat. Use on-stack memory for performance - * unless the size of the format string is really big (a rare occurrence). + * unichars for passing to GSPrivateFormat. Use on-stack memory for + * performance unless the size of the format string is really big + * (a rare occurrence). */ len = [format length]; if (len >= 1024) @@ -3458,7 +3458,7 @@ agree, create a new GSUnicodeInlineString otherwise. _zone = GSObjCZone(self); #endif } - GSFormat((GSStr)self, fmt, ap, nil); + GSPrivateFormat((GSStr)self, fmt, ap, nil); _flags.hash = 0; // Invalidate the hash for this string. if (fmt != buf) { @@ -3950,7 +3950,7 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException); [format getCharacters: fmt]; fmt[len] = '\0'; - GSFormat((GSStr)self, fmt, argList, locale); + GSPrivateFormat((GSStr)self, fmt, argList, locale); if (fmt != fbuf) { objc_free(fmt); diff --git a/Source/GSURLPrivate.h b/Source/GSURLPrivate.h index ff2f22e43..6ab7ea57d 100644 --- a/Source/GSURLPrivate.h +++ b/Source/GSURLPrivate.h @@ -33,7 +33,6 @@ #include "Foundation/NSAutoreleasePool.h" #include "Foundation/NSData.h" #include "Foundation/NSDictionary.h" -#include "Foundation/NSError.h" #include "Foundation/NSException.h" #include "Foundation/NSHTTPCookie.h" #include "Foundation/NSHTTPCookieStorage.h" diff --git a/Source/GSValue.m b/Source/GSValue.m index 421714ced..225319dba 100644 --- a/Source/GSValue.m +++ b/Source/GSValue.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/NSArray.m b/Source/NSArray.m index e85871fea..d78765c7e 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -55,9 +55,9 @@ static BOOL GSMacOSXCompatiblePropertyLists(void) { #if defined(HAVE_LIBXML) - if ([_GSPrivate userDefaultsFlag: NSWriteOldStylePropertyLists] == YES) + if (GSPrivateDefaultsFlag(NSWriteOldStylePropertyLists) == YES) return NO; - return [_GSPrivate userDefaultsFlag: GSMacOSXCompatible]; + return GSPrivateDefaultsFlag(GSMacOSXCompatible); #else return NO; #endif diff --git a/Source/NSAssertionHandler.m b/Source/NSAssertionHandler.m index c8d153541..b4c4737a3 100644 --- a/Source/NSAssertionHandler.m +++ b/Source/NSAssertionHandler.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSAssertionHandler class reference $Date$ $Revision$ diff --git a/Source/NSBundle.m b/Source/NSBundle.m index a335fe7f2..4841d18cc 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -23,7 +23,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSBundle class reference diff --git a/Source/NSCallBacks.m b/Source/NSCallBacks.m index dd8ea6d9e..307240ba9 100644 --- a/Source/NSCallBacks.m +++ b/Source/NSCallBacks.m @@ -24,7 +24,8 @@ NSCallBacks class reference $Date$ $Revision$ - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. */ /**** Included Headers *******************************************************/ diff --git a/Source/NSClassDescription.m b/Source/NSClassDescription.m index c4d7d2e83..bcbe50d54 100644 --- a/Source/NSClassDescription.m +++ b/Source/NSClassDescription.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSClassDescription class reference $Date$ $Revision$ diff --git a/Source/NSConcreteNumber.m b/Source/NSConcreteNumber.m index 38818869b..4b8168cd3 100644 --- a/Source/NSConcreteNumber.m +++ b/Source/NSConcreteNumber.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/NSConcreteNumberTemplate.m b/Source/NSConcreteNumberTemplate.m index 49e08933e..019970626 100644 --- a/Source/NSConcreteNumberTemplate.m +++ b/Source/NSConcreteNumberTemplate.m @@ -22,7 +22,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ /* This file should be run through a preprocessor with the macro TYPE_ORDER diff --git a/Source/NSCopyObject.m b/Source/NSCopyObject.m index 331c371ee..190dcfc25 100644 --- a/Source/NSCopyObject.m +++ b/Source/NSCopyObject.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSCopyObject class reference $Date$ $Revision$ diff --git a/Source/NSCountedSet.m b/Source/NSCountedSet.m index 04ae4f170..61bcd9186 100644 --- a/Source/NSCountedSet.m +++ b/Source/NSCountedSet.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSCountedSet class reference $Date$ $Revision$ diff --git a/Source/NSData.m b/Source/NSData.m index e16bd489d..3b39f0d61 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -164,7 +164,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) if (theFile == 0) /* We failed to open the file. */ { - NSWarnFLog(@"Open (%@) attempt failed - %@", path, [_GSPrivate error]); + NSWarnFLog(@"Open (%@) attempt failed - %@", path, [NSError _last]); goto failure; } @@ -175,7 +175,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) if (c != 0) { NSWarnFLog(@"Seek to end of file (%@) failed - %@", path, - [_GSPrivate error]); + [NSError _last]); goto failure; } @@ -186,7 +186,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) fileLength = ftell(theFile); if (fileLength == -1) { - NSWarnFLog(@"Ftell on %@ failed - %@", path, [_GSPrivate error]); + NSWarnFLog(@"Ftell on %@ failed - %@", path, [NSError _last]); goto failure; } @@ -198,7 +198,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) if (c != 0) { NSWarnFLog(@"Fseek to start of file (%@) failed - %@", path, - [_GSPrivate error]); + [NSError _last]); goto failure; } @@ -224,7 +224,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) if (tmp == 0) { NSLog(@"Malloc failed for file (%@) of length %d - %@", path, - fileLength + c, [_GSPrivate error]); + fileLength + c, [NSError _last]); goto failure; } memcpy(tmp + fileLength, buf, c); @@ -237,7 +237,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) if (tmp == 0) { NSLog(@"Malloc failed for file (%@) of length %d - %@", path, - fileLength, [_GSPrivate error]); + fileLength, [NSError _last]); goto failure; } @@ -245,7 +245,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) if (c != (int)fileLength) { NSWarnFLog(@"read of file (%@) contents failed - %@", path, - [_GSPrivate error]); + [NSError _last]); goto failure; } } @@ -851,7 +851,7 @@ failure: strcat(thePath, "XXXXXX"); if ((desc = mkstemp(thePath)) < 0) { - NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [_GSPrivate error]); + NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [NSError _last]); goto failure; } mask = umask(0); @@ -880,7 +880,7 @@ failure: { NSWarnMLog(@"mktemp (%@) failed - %@", [NSString stringWithCharacters: wthePath length: wcslen(wthePath)], - [_GSPrivate error]); + [NSError _last]); goto failure; } #else @@ -888,7 +888,7 @@ failure: strcat(thePath, "XXXXXX"); if (mktemp(thePath) == 0) { - NSWarnMLog(@"mktemp (%s) failed - %@", thePath, [_GSPrivate error]); + NSWarnMLog(@"mktemp (%s) failed - %@", thePath, [NSError _last]); goto failure; } #endif @@ -917,9 +917,9 @@ failure: #if defined(__MINGW32__) NSWarnMLog(@"Open (%@) failed - %@", [NSString stringWithCharacters: wthePath length: wcslen(wthePath)], - [_GSPrivate error]); + [NSError _last]); #else - NSWarnMLog(@"Open (%s) failed - %@", thePath, [_GSPrivate error]); + NSWarnMLog(@"Open (%s) failed - %@", thePath, [NSError _last]); #endif goto failure; } @@ -935,9 +935,9 @@ failure: #if defined(__MINGW32__) NSWarnMLog(@"Fwrite (%@) failed - %@", [NSString stringWithCharacters: wthePath length: wcslen(wthePath)], - [_GSPrivate error]); + [NSError _last]); #else - NSWarnMLog(@"Fwrite (%s) failed - %@", thePath, [_GSPrivate error]); + NSWarnMLog(@"Fwrite (%s) failed - %@", thePath, [NSError _last]); #endif goto failure; } @@ -952,9 +952,9 @@ failure: #if defined(__MINGW32__) NSWarnMLog(@"Fclose (%@) failed - %@", [NSString stringWithCharacters: wthePath length: wcslen(wthePath)], - [_GSPrivate error]); + [NSError _last]); #else - NSWarnMLog(@"Fclose (%s) failed - %@", thePath, [_GSPrivate error]); + NSWarnMLog(@"Fclose (%s) failed - %@", thePath, [NSError _last]); #endif goto failure; } @@ -1040,10 +1040,10 @@ failure: length: wcslen(wthePath)], [NSString stringWithCharacters: wtheRealPath length: wcslen(wtheRealPath)], - [_GSPrivate error]); + [NSError _last]); #else NSWarnMLog(@"Rename ('%s' to '%s') failed - %@", - thePath, theRealPath, [_GSPrivate error]); + thePath, theRealPath, [NSError _last]); #endif goto failure; } @@ -2916,7 +2916,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) #endif if (fd < 0) { - NSWarnMLog(@"unable to open %@ - %@", path, [_GSPrivate error]); + NSWarnMLog(@"unable to open %@ - %@", path, [NSError _last]); RELEASE(self); return nil; } @@ -2924,7 +2924,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) length = lseek(fd, 0, SEEK_END); if (length < 0) { - NSWarnMLog(@"unable to seek to eof %@ - %@", path, [_GSPrivate error]); + NSWarnMLog(@"unable to seek to eof %@ - %@", path, [NSError _last]); close(fd); RELEASE(self); return nil; @@ -2932,7 +2932,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) /* Position at start of file. */ if (lseek(fd, 0, SEEK_SET) != 0) { - NSWarnMLog(@"unable to seek to sof %@ - %@", path, [_GSPrivate error]); + NSWarnMLog(@"unable to seek to sof %@ - %@", path, [NSError _last]); close(fd); RELEASE(self); return nil; @@ -2940,7 +2940,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0); if (bytes == MAP_FAILED) { - NSWarnMLog(@"mapping failed for %s - %@", path, [_GSPrivate error]); + NSWarnMLog(@"mapping failed for %s - %@", path, [NSError _last]); close(fd); RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -2968,14 +2968,14 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmctl(shmid, IPC_STAT, &buf) < 0) NSLog(@"[NSDataShared -dealloc] shared memory control failed - %@", - [_GSPrivate error]); + [NSError _last]); else if (buf.shm_nattch == 1) if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ NSLog(@"[NSDataShared -dealloc] shared memory delete failed - %@", - [_GSPrivate error]); + [NSError _last]); if (shmdt(bytes) < 0) NSLog(@"[NSDataShared -dealloc] shared memory detach failed - %@", - [_GSPrivate error]); + [NSError _last]); bytes = 0; length = 0; shmid = -1; @@ -2992,7 +2992,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmid == -1) /* Created memory? */ { NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %@", - bufferSize, [_GSPrivate error]); + bufferSize, [NSError _last]); RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; return [self initWithBytes: aBuffer length: bufferSize]; @@ -3002,7 +3002,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (bytes == (void*)-1) { NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %@", - bufferSize, [_GSPrivate error]); + bufferSize, [NSError _last]); bytes = 0; RELEASE(self); self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -3021,7 +3021,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmctl(shmid, IPC_STAT, &buf) < 0) { NSLog(@"[NSDataShared -initWithShmID:length:] shared memory " - @"control failed - %@", [_GSPrivate error]); + @"control failed - %@", [NSError _last]); RELEASE(self); /* Unable to access memory. */ return nil; } @@ -3036,7 +3036,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (bytes == (void*)-1) { NSLog(@"[NSDataShared -initWithShmID:length:] shared memory " - @"attach failed - %s", [_GSPrivate error]); + @"attach failed - %s", [NSError _last]); bytes = 0; RELEASE(self); /* Unable to attach to memory. */ return nil; @@ -3162,7 +3162,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, [_GSPrivate error]); + @"for %u bytes - %@", size, [NSError _last]); RELEASE(self); return nil; } @@ -3658,20 +3658,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmctl(shmid, IPC_STAT, &buf) < 0) { NSLog(@"[NSMutableDataShared -dealloc] shared memory " - @"control failed - %@", [_GSPrivate error]); + @"control failed - %@", [NSError _last]); } else if (buf.shm_nattch == 1) { if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ { NSLog(@"[NSMutableDataShared -dealloc] shared memory " - @"delete failed - %@", [_GSPrivate error]); + @"delete failed - %@", [NSError _last]); } } if (shmdt(bytes) < 0) { NSLog(@"[NSMutableDataShared -dealloc] shared memory " - @"detach failed - %@", [_GSPrivate error]); + @"detach failed - %@", [NSError _last]); } bytes = 0; length = 0; @@ -3699,7 +3699,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, [_GSPrivate error]); + @"get failed for %u - %@", bufferSize, [NSError _last]); RELEASE(self); self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; return [self initWithCapacity: bufferSize]; @@ -3709,7 +3709,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, [_GSPrivate error]); + @"attach failed for %u - %@", bufferSize, [NSError _last]); bytes = 0; RELEASE(self); self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; @@ -3729,7 +3729,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmctl(shmid, IPC_STAT, &buf) < 0) { NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " - @"control failed - %@", [_GSPrivate error]); + @"control failed - %@", [NSError _last]); RELEASE(self); /* Unable to access memory. */ return nil; } @@ -3744,7 +3744,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (bytes == (void*)-1) { NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " - @"attach failed - %@", [_GSPrivate error]); + @"attach failed - %@", [NSError _last]); bytes = 0; RELEASE(self); /* Unable to attach to memory. */ return nil; @@ -3767,7 +3767,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) { [NSException raise: NSMallocException format: @"Unable to create shared memory segment (size:%u) - %@.", - size, [_GSPrivate error]]; + size, [NSError _last]]; } tmp = shmat(newid, 0, 0); if ((intptr_t)tmp == -1) /* Attached memory? */ @@ -3783,20 +3783,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos) if (shmctl(shmid, IPC_STAT, &buf) < 0) { NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " - @"control failed - %@", [_GSPrivate error]); + @"control failed - %@", [NSError _last]); } else if (buf.shm_nattch == 1) { if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ { NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " - @"delete failed - %@", [_GSPrivate error]); + @"delete failed - %@", [NSError _last]); } } if (shmdt(bytes) < 0) /* Detach memory. */ { NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " - @"detach failed - %@", [_GSPrivate error]); + @"detach failed - %@", [NSError _last]); } } bytes = tmp; diff --git a/Source/NSDebug.m b/Source/NSDebug.m index 86c8295e5..2c64b97e6 100644 --- a/Source/NSDebug.m +++ b/Source/NSDebug.m @@ -20,7 +20,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSDebug utilities reference $Date$ $Revision$ diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index 2f351f9f9..b44deb26a 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -49,9 +49,9 @@ static BOOL GSMacOSXCompatiblePropertyLists(void) { #if defined(HAVE_LIBXML) - if ([_GSPrivate userDefaultsFlag: NSWriteOldStylePropertyLists] == YES) + if (GSPrivateDefaultsFlag(NSWriteOldStylePropertyLists) == YES) return NO; - return [_GSPrivate userDefaultsFlag: GSMacOSXCompatible]; + return GSPrivateDefaultsFlag(GSMacOSXCompatible); #else return NO; #endif diff --git a/Source/NSDistantObject.m b/Source/NSDistantObject.m index 2062f7fb7..18d22e923 100644 --- a/Source/NSDistantObject.m +++ b/Source/NSDistantObject.m @@ -19,8 +19,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSDistantObject class reference $Date$ $Revision$ diff --git a/Source/NSDistributedLock.m b/Source/NSDistributedLock.m index 8d136ee6f..d17e73e30 100644 --- a/Source/NSDistributedLock.m +++ b/Source/NSDistributedLock.m @@ -78,7 +78,7 @@ static NSFileManager *mgr = nil; if ([mgr removeFileAtPath: _lockPath handler: nil] == NO) { - NSString *err = [_GSPrivate error]; + NSString *err = [[NSError _last] localizedDescription]; attributes = [mgr fileAttributesAtPath: _lockPath traverseLink: YES]; if ([modDate isEqual: [attributes fileModificationDate]] == YES) @@ -204,7 +204,7 @@ static NSFileManager *mgr = nil; if (locked == NO) { NSLog(@"Failed to create lock directory '%@' - %@", - _lockPath, [_GSPrivate error]); + _lockPath, [NSError _last]); } } } @@ -260,7 +260,7 @@ static NSFileManager *mgr = nil; { [NSException raise: NSGenericException format: @"Failed to remove lock directory '%@' - %@", - _lockPath, [_GSPrivate error]]; + _lockPath, [NSError _last]]; } } else diff --git a/Source/NSEnumerator.m b/Source/NSEnumerator.m index 49b18d22c..88383db1d 100644 --- a/Source/NSEnumerator.m +++ b/Source/NSEnumerator.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSEnumerator class reference $Date$ $Revision$ diff --git a/Source/NSError.m b/Source/NSError.m index 67f3884bf..aa16b156d 100644 --- a/Source/NSError.m +++ b/Source/NSError.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include @@ -26,11 +27,25 @@ #include #include +NSString* const NSFilePathErrorKey = @"NSFilePathErrorKey"; NSString* const NSLocalizedDescriptionKey = @"NSLocalizedDescriptionKey"; +NSString* const NSStringEncodingErrorKey = @"NSStringEncodingErrorKey"; +NSString* const NSURLErrorKey = @"NSURLErrorKey"; NSString* const NSUnderlyingErrorKey = @"NSUnderlyingErrorKey"; + +NSString* const NSLocalizedFailureReasonErrorKey + = @"NSLocalizedFailureReasonErrorKey"; +NSString* const NSLocalizedRecoveryOptionsErrorKey + = @"NSLocalizedRecoveryOptionsErrorKey"; +NSString* const NSLocalizedRecoverySuggestionErrorKey + = @"NSLocalizedRecoverySuggestionErrorKey"; +NSString* const NSRecoveryAttempterErrorKey + = @"NSRecoveryAttempterErrorKey"; + NSString* const NSMACHErrorDomain = @"NSMACHErrorDomain"; NSString* const NSOSStatusErrorDomain = @"NSOSStatusErrorDomain"; NSString* const NSPOSIXErrorDomain = @"NSPOSIXErrorDomain"; +NSString* const NSCocoaErrorDomain = @"NSCocoaErrorDomain"; @implementation NSError @@ -64,6 +79,11 @@ NSString* const NSPOSIXErrorDomain = @"NSPOSIXErrorDomain"; [super dealloc]; } +- (NSString*) description +{ + return [self localizedDescription]; +} + - (NSString*) domain { return _domain; @@ -131,7 +151,7 @@ NSString* const NSPOSIXErrorDomain = @"NSPOSIXErrorDomain"; return self; } -- (NSString *)localizedDescription +- (NSString *) localizedDescription { NSString *desc = [_userInfo objectForKey: NSLocalizedDescriptionKey]; @@ -142,6 +162,26 @@ NSString* const NSPOSIXErrorDomain = @"NSPOSIXErrorDomain"; return desc; } +- (NSString *) localizedFailureReason +{ + return [_userInfo objectForKey: NSLocalizedFailureReasonErrorKey]; +} + +- (NSArray *) localizedRecoveryOptions +{ + return [_userInfo objectForKey: NSLocalizedRecoveryOptionsErrorKey]; +} + +- (NSString *) localizedRecoverySuggestion +{ + return [_userInfo objectForKey: NSLocalizedRecoverySuggestionErrorKey]; +} + +- (id) recoveryAttempter +{ + return [_userInfo objectForKey: NSRecoveryAttempterErrorKey]; +} + - (NSDictionary*) userInfo { return _userInfo; diff --git a/Source/NSException.m b/Source/NSException.m index a4516adcb..dd8f3ba79 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -585,8 +585,7 @@ static void _terminate() #else shouldAbort = NO; // exit() by default. #endif - shouldAbort = [_GSPrivate environmentFlag: "CRASH_ON_ABORT" - defaultValue: shouldAbort]; + shouldAbort = GSPrivateEnvironmentFlag("CRASH_ON_ABORT", shouldAbort); if (shouldAbort == YES) { abort(); @@ -601,7 +600,7 @@ static void _NSFoundationUncaughtExceptionHandler (NSException *exception) { fprintf(stderr, "%s: Uncaught exception %s, reason: %s\n", - [_GSPrivate argZero], + GSPrivateArgZero(), [[exception name] lossyCString], [[exception reason] lossyCString]); fflush(stderr); /* NEEDED UNDER MINGW */ diff --git a/Source/NSFileHandle.m b/Source/NSFileHandle.m index 6908637b8..a685ab0a8 100644 --- a/Source/NSFileHandle.m +++ b/Source/NSFileHandle.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSFileHandle class reference $Date$ $Revision$ diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index bd376d732..d5e188d32 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -30,7 +30,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSFileManager class reference $Date$ $Revision$ @@ -402,7 +403,7 @@ static NSStringEncoding defaultEncoding; allOk = NO; str = [NSString stringWithFormat: @"Unable to change NSFileOwnerAccountID to '%u' - %@", - num, [_GSPrivate error]]; + num, [NSError _last]]; ASSIGN(_lastError, str); } } @@ -426,7 +427,7 @@ static NSStringEncoding defaultEncoding; allOk = NO; str = [NSString stringWithFormat: @"Unable to change NSFileOwnerAccountName to '%@' - %@", - str, [_GSPrivate error]]; + str, [NSError _last]]; ASSIGN(_lastError, str); } } @@ -440,7 +441,7 @@ static NSStringEncoding defaultEncoding; allOk = NO; str = [NSString stringWithFormat: @"Unable to change NSFileGroupOwnerAccountID to '%u' - %@", - num, [_GSPrivate error]]; + num, [NSError _last]]; ASSIGN(_lastError, str); } } @@ -462,7 +463,7 @@ static NSStringEncoding defaultEncoding; allOk = NO; str = [NSString stringWithFormat: @"Unable to change NSFileGroupOwnerAccountName to '%@' - %@", - str, [_GSPrivate error]]; + str, [NSError _last]]; ASSIGN(_lastError, str); } } @@ -476,7 +477,7 @@ static NSStringEncoding defaultEncoding; allOk = NO; str = [NSString stringWithFormat: @"Unable to change NSFilePosixPermissions to '%o' - %@", - num, [_GSPrivate error]]; + num, [NSError _last]]; ASSIGN(_lastError, str); } } @@ -520,7 +521,7 @@ static NSStringEncoding defaultEncoding; allOk = NO; str = [NSString stringWithFormat: @"Unable to change NSFileModificationDate to '%@' - %@", - date, [_GSPrivate error]]; + date, [NSError _last]]; ASSIGN(_lastError, str); } } @@ -748,7 +749,7 @@ static NSStringEncoding defaultEncoding; NSString *s; s = [NSString stringWithFormat: @"Could not create '%s' - '%@'", - dirpath, [_GSPrivate error]]; + dirpath, [NSError _last]]; ASSIGN(_lastError, s); return NO; } @@ -1277,8 +1278,10 @@ static NSStringEncoding defaultEncoding; if (unlink(lpath) < 0) #endif { + NSString *message = [[NSError _last] localizedDescription]; + return [self _proceedAccordingToHandler: handler - forError: [_GSPrivate error] + forError: message inPath: path]; } else @@ -1311,8 +1314,10 @@ static NSStringEncoding defaultEncoding; if (_RMDIR([self fileSystemRepresentationWithPath: path]) < 0) { + NSString *message = [[NSError _last] localizedDescription]; + return [self _proceedAccordingToHandler: handler - forError: [_GSPrivate error] + forError: message inPath: path]; } else @@ -2032,7 +2037,7 @@ inline void gsedRelease(GSEnumeratedDirectory X) else { NSLog(@"Failed to recurse into directory '%@' - %@", path, - [_GSPrivate error]); + [NSError _last]); } return self; } @@ -2199,7 +2204,7 @@ inline void gsedRelease(GSEnumeratedDirectory X) else { NSLog(@"Failed to recurse into directory '%@' - %@", - _currentFilePath, [_GSPrivate error]); + _currentFilePath, [NSError _last]); } } } diff --git a/Source/NSFormatter.m b/Source/NSFormatter.m index 64f6575d7..e0ef202c8 100644 --- a/Source/NSFormatter.m +++ b/Source/NSFormatter.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSFormatter class reference $Date$ $Revision$ diff --git a/Source/NSGeometry.m b/Source/NSGeometry.m index 687e9dd24..820a2d828 100644 --- a/Source/NSGeometry.m +++ b/Source/NSGeometry.m @@ -73,9 +73,9 @@ setupCache(void) static BOOL GSMacOSXCompatibleGeometry(void) { - if ([_GSPrivate userDefaultsFlag: GSOldStyleGeometry] == YES) + if (GSPrivateDefaultsFlag(GSOldStyleGeometry) == YES) return NO; - return [_GSPrivate userDefaultsFlag: GSMacOSXCompatible]; + return GSPrivateDefaultsFlag(GSMacOSXCompatible); } /**** Function Implementations ***********************************************/ diff --git a/Source/NSHashTable.m b/Source/NSHashTable.m index 7be302240..6e88ea337 100644 --- a/Source/NSHashTable.m +++ b/Source/NSHashTable.m @@ -21,7 +21,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. * * NSHashTable class reference * $Date$ $Revision$ diff --git a/Source/NSHost.m b/Source/NSHost.m index af392e97e..2d0ad8c44 100644 --- a/Source/NSHost.m +++ b/Source/NSHost.m @@ -20,7 +20,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSHost class reference $Date$ $Revision$ diff --git a/Source/NSIndexPath.m b/Source/NSIndexPath.m index ff34d2251..a6b5ba420 100644 --- a/Source/NSIndexPath.m +++ b/Source/NSIndexPath.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, - Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ diff --git a/Source/NSIndexSet.m b/Source/NSIndexSet.m index e3eef9524..d6864d540 100644 --- a/Source/NSIndexSet.m +++ b/Source/NSIndexSet.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ diff --git a/Source/NSLock.m b/Source/NSLock.m index 11f2f4ca4..42be79457 100644 --- a/Source/NSLock.m +++ b/Source/NSLock.m @@ -19,7 +19,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSLock class reference $Date$ $Revision$ diff --git a/Source/NSLog.m b/Source/NSLog.m index 3a4d0c76b..03383c22b 100644 --- a/Source/NSLog.m +++ b/Source/NSLog.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSLog reference $Date$ $Revision$ @@ -144,7 +145,7 @@ _NSLog_standard_printf_handler (NSString* message) OutputDebugStringW(null_terminated_buf); - if (([_GSPrivate userDefaultsFlag: GSLogSyslog] == YES + if ((GSPrivateDefaultsFlag(GSLogSyslog) == YES || write(_NSLogDescriptor, buf, len) != (int)len) && !IsDebuggerPresent()) { static HANDLE eventloghandle = 0; @@ -170,7 +171,7 @@ _NSLog_standard_printf_handler (NSString* message) #else #if defined(HAVE_SYSLOG) - if ([_GSPrivate userDefaultsFlag: GSLogSyslog] == YES + if (GSPrivateDefaultsFlag(GSLogSyslog) == YES || write(_NSLogDescriptor, buf, len) != (int)len) { null_terminated_buf = objc_malloc (sizeof (char) * (len + 1)); @@ -302,9 +303,9 @@ NSLogv (NSString* format, va_list args) } #ifdef HAVE_SYSLOG - if ([_GSPrivate userDefaultsFlag: GSLogSyslog] == YES) + if (GSPrivateDefaultsFlag(GSLogSyslog) == YES) { - if ([_GSPrivate userDefaultsFlag: GSLogThread] == YES) + if (GSPrivateDefaultsFlag(GSLogThread) == YES) { prefix = [NSString stringWithFormat: @"[thread:%x] ", GSCurrentThread()]; @@ -317,7 +318,7 @@ NSLogv (NSString* format, va_list args) else #endif { - if ([_GSPrivate userDefaultsFlag: GSLogThread] == YES) + if (GSPrivateDefaultsFlag(GSLogThread) == YES) { prefix = [NSString stringWithFormat: @"%@ %@[%d,%x] ", diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index db0d02903..3b7dc34d9 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" @@ -304,14 +304,14 @@ static Class runLoopClass; if (fcntl(d, F_SETFL, e) < 0) { NSLog(@"unable to set non-blocking mode on %d - %@", - d, [_GSPrivate error]); + d, [NSError _last]); return nil; } } else { NSLog(@"unable to get non-blocking mode on %d - %@", - d, [_GSPrivate error]); + d, [NSError _last]); return nil; } handle = (GSMessageHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone()); @@ -381,7 +381,7 @@ static Class runLoopClass; if (errno != EINPROGRESS) { NSLog(@"unable to make connection to %s - %@", - sockAddr.sun_path, [_GSPrivate error]); + sockAddr.sun_path, [NSError _last]); M_UNLOCK(myLock); return NO; } @@ -607,7 +607,7 @@ static Class runLoopClass; else if (errno != EINTR && errno != EAGAIN) { NSDebugMLLog(@"NSMessagePort", - @"read failed - %@ on 0x%p", [_GSPrivate error], self); + @"read failed - %@ on 0x%p", [NSError _last], self); M_UNLOCK(myLock); [self invalidate]; return; @@ -906,7 +906,7 @@ static Class runLoopClass; && res != 0) { state = GS_H_UNCON; - NSLog(@"connect attempt failed - %@", [_GSPrivate error]); + NSLog(@"connect attempt failed - %@", [NSError _last]); } else { @@ -923,7 +923,7 @@ static Class runLoopClass; { state = GS_H_UNCON; NSLog(@"connect write attempt failed - %@", - [_GSPrivate error]); + [NSError _last]); } RELEASE(d); } @@ -957,7 +957,7 @@ static Class runLoopClass; { if (errno != EINTR && errno != EAGAIN) { - NSLog(@"write attempt failed - %@", [_GSPrivate error]); + NSLog(@"write attempt failed - %@", [NSError _last]); M_UNLOCK(myLock); [self invalidate]; return; @@ -1249,7 +1249,7 @@ typedef struct { sizeof(sockAddr.sun_path)); if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); desc = -1; } else if (bind(desc, (struct sockaddr *)&sockAddr, @@ -1264,14 +1264,14 @@ typedef struct { if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0) { NSLog(@"unable to create socket - %@", - [_GSPrivate error]); + [NSError _last]); desc = -1; } else if (bind(desc, (struct sockaddr *)&sockAddr, SUN_LEN(&sockAddr)) < 0) { NSLog(@"unable to bind to %s - %@", - sockAddr.sun_path, [_GSPrivate error]); + sockAddr.sun_path, [NSError _last]); (void) close(desc); desc = -1; } @@ -1279,7 +1279,7 @@ typedef struct { else { NSLog(@"unable to bind to %s - %@", - sockAddr.sun_path, [_GSPrivate error]); + sockAddr.sun_path, [NSError _last]); (void) close(desc); desc = -1; } @@ -1291,13 +1291,13 @@ typedef struct { } else if (listen(desc, 128) < 0) { - NSLog(@"unable to listen on port - %@", [_GSPrivate error]); + NSLog(@"unable to listen on port - %@", [NSError _last]); (void) close(desc); DESTROY(port); } else if (getsockname(desc, (struct sockaddr*)&sockAddr, &i) < 0) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); (void) close(desc); DESTROY(port); } @@ -1492,7 +1492,7 @@ typedef struct { sock = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC); if (sock < 0) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); } #ifndef BROKEN_SO_REUSEADDR /* @@ -1505,13 +1505,13 @@ typedef struct { sizeof(opt)) < 0) { (void)close(sock); - NSLog(@"unable to set reuse on socket - %@", [_GSPrivate error]); + NSLog(@"unable to set reuse on socket - %@", [NSError _last]); } #endif else if ((handle = [GSMessageHandle handleWithDescriptor: sock]) == nil) { (void)close(sock); - NSLog(@"unable to create GSMessageHandle - %@", [_GSPrivate error]); + NSLog(@"unable to create GSMessageHandle - %@", [NSError _last]); } else { diff --git a/Source/NSMessagePortNameServer.m b/Source/NSMessagePortNameServer.m index daf035e64..b00ec52f9 100644 --- a/Source/NSMessagePortNameServer.m +++ b/Source/NSMessagePortNameServer.m @@ -16,8 +16,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSMessagePortNameServer class reference $Date$ $Revision$ diff --git a/Source/NSMethodSignature.m b/Source/NSMethodSignature.m index 8a2a33641..81719e4ee 100644 --- a/Source/NSMethodSignature.m +++ b/Source/NSMethodSignature.m @@ -20,7 +20,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSMethodSignature class reference $Date$ $Revision$ diff --git a/Source/NSNotificationCenter.m b/Source/NSNotificationCenter.m index d3c9f0991..64f4df3d2 100644 --- a/Source/NSNotificationCenter.m +++ b/Source/NSNotificationCenter.m @@ -22,8 +22,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSNotificationCenter class reference $Date$ $Revision$ diff --git a/Source/NSNull.m b/Source/NSNull.m index 697093d3a..e432e07a9 100644 --- a/Source/NSNull.m +++ b/Source/NSNull.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSNull class reference $Date$ $Revision$ diff --git a/Source/NSNumberFormatter.m b/Source/NSNumberFormatter.m index 1b0d0ce1b..bb9ca9d85 100644 --- a/Source/NSNumberFormatter.m +++ b/Source/NSNumberFormatter.m @@ -20,7 +20,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSNumberFormatter class reference $Date$ $Revision$ diff --git a/Source/NSObject.m b/Source/NSObject.m index ab8bcd278..0a8445b45 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -161,7 +161,7 @@ static void GSLogZombie(id o, SEL sel) NSLog(@"Deallocated %@ (0x%x) sent %@", NSStringFromClass(c), o, NSStringFromSelector(sel)); } - if ([_GSPrivate environmentFlag: "CRASH_ON_ZOMBIE" defaultValue: NO] == YES) + if (GSPrivateEnvironmentFlag("CRASH_ON_ZOMBIE", NO) == YES) { abort(); } @@ -882,8 +882,6 @@ GSDescriptionForClassMethod(pcl self, SEL aSel) } #endif -GSPrivate *_GSPrivate = nil; - /** * This message is sent to a class once just before it is used for the first * time. If class has a superclass, its implementation of +initialize is @@ -895,10 +893,6 @@ GSPrivate *_GSPrivate = nil; { if (self == [NSObject class]) { - extern void GSBuildStrings(void); // See externs.m - - _GSPrivate = [GSPrivate new]; - #ifdef __MINGW32__ // See libgnustep-base-entry.m extern void gnustep_base_socket_init(void); @@ -972,10 +966,8 @@ GSPrivate *_GSPrivate = nil; zombieMap = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0); zombieClass = [NSZombie class]; - NSZombieEnabled = [_GSPrivate environmentFlag: "NSZombieEnabled" - defaultValue: NO]; - NSDeallocateZombies = [_GSPrivate environmentFlag: "NSDeallocateZombies" - defaultValue: NO]; + NSZombieEnabled = GSPrivateEnvironmentFlag("NSZombieEnabled", NO); + NSDeallocateZombies = GSPrivateEnvironmentFlag("NSDeallocateZombies", NO); autorelease_class = [NSAutoreleasePool class]; autorelease_sel = @selector(addObject:); @@ -987,7 +979,7 @@ GSPrivate *_GSPrivate = nil; #endif #endif NSConstantStringClass = [NSString constantStringClass]; - GSBuildStrings(); + GSPrivateBuildStrings(); [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_becomeMultiThreaded:) @@ -1301,7 +1293,7 @@ GSPrivate *_GSPrivate = nil; { if (aSelector == 0) { - if ([_GSPrivate userDefaultsFlag: GSMacOSXCompatible]) + if (GSPrivateDefaultsFlag(GSMacOSXCompatible)) { [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", @@ -1874,7 +1866,7 @@ GSPrivate *_GSPrivate = nil; { if (aSelector == 0) { - if ([_GSPrivate userDefaultsFlag: GSMacOSXCompatible]) + if (GSPrivateDefaultsFlag(GSMacOSXCompatible)) { [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", diff --git a/Source/NSPipe.m b/Source/NSPipe.m index d6d4925bd..139fdd1ac 100644 --- a/Source/NSPipe.m +++ b/Source/NSPipe.m @@ -79,7 +79,7 @@ } else { - NSLog(@"Failed to create pipe ... %@", [_GSPrivate error]); + NSLog(@"Failed to create pipe ... %@", [NSError _last]); DESTROY(self); } #else @@ -99,7 +99,7 @@ } else { - NSLog(@"Failed to create pipe ... %@", [_GSPrivate error]); + NSLog(@"Failed to create pipe ... %@", [NSError _last]); DESTROY(self); } #endif diff --git a/Source/NSPortNameServer.m b/Source/NSPortNameServer.m index a9745bd17..e23d1d35b 100644 --- a/Source/NSPortNameServer.m +++ b/Source/NSPortNameServer.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSPortNameServer class reference $Date$ $Revision$ diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 57ab73db0..31c104f01 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -317,7 +317,7 @@ _gnu_process_args(int argc, char *argv[], char *env[]) NSMutableSet *mySet; id obj_argv[argc]; int added = 1; - NSStringEncoding enc = [_GSPrivate defaultCStringEncoding]; + NSStringEncoding enc = GSPrivateDefaultCStringEncoding(); mySet = [NSMutableSet new]; @@ -346,7 +346,7 @@ _gnu_process_args(int argc, char *argv[], char *env[]) { NSMutableArray *keys = [NSMutableArray new]; NSMutableArray *values = [NSMutableArray new]; - NSStringEncoding enc = [_GSPrivate defaultCStringEncoding]; + NSStringEncoding enc = GSPrivateDefaultCStringEncoding(); #if defined(__MINGW32__) if (fallbackInitialisation == NO) @@ -1234,8 +1234,8 @@ BOOL GSDebugSet(NSString *level) return YES; } -@implementation GSPrivate (ProcessInfo) -- (BOOL) environmentFlag: (const char *)name defaultValue: (BOOL)def +BOOL +GSPrivateEnvironmentFlag(const char *name, BOOL def) { const char *c = getenv(name); BOOL a = def; @@ -1262,7 +1262,8 @@ BOOL GSDebugSet(NSString *level) return a; } -- (const char*) argZero +const char* +GSPrivateArgZero() { if (_gnu_arg_zero == 0) return ""; @@ -1270,5 +1271,3 @@ BOOL GSDebugSet(NSString *level) return _gnu_arg_zero; } -@end - diff --git a/Source/NSPropertyList.m b/Source/NSPropertyList.m index ac16e09ae..5934f8936 100644 --- a/Source/NSPropertyList.m +++ b/Source/NSPropertyList.m @@ -2170,7 +2170,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, { style = NSPropertyListXMLFormat_v1_0; } - else if ([_GSPrivate userDefaultsFlag: NSWriteOldStylePropertyLists] == YES) + else if (GSPrivateDefaultsFlag(NSWriteOldStylePropertyLists) == YES) { style = NSPropertyListOpenStepFormat; } diff --git a/Source/NSProtocolChecker.m b/Source/NSProtocolChecker.m index 641c26911..64a39c011 100644 --- a/Source/NSProtocolChecker.m +++ b/Source/NSProtocolChecker.m @@ -20,7 +20,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSProtocolChecker class reference $Date$ $Revision$ diff --git a/Source/NSProxy.m b/Source/NSProxy.m index 1a56166d8..872feb1e9 100644 --- a/Source/NSProxy.m +++ b/Source/NSProxy.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSProxy class reference $Date$ $Revision$ diff --git a/Source/NSRange.m b/Source/NSRange.m index 0957dc488..390b42aa9 100644 --- a/Source/NSRange.m +++ b/Source/NSRange.m @@ -18,7 +18,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02111 USA. NSRange class reference $Date$ $Revision$ diff --git a/Source/NSScanner.m b/Source/NSScanner.m index e351ecda6..b9d50eb94 100644 --- a/Source/NSScanner.m +++ b/Source/NSScanner.m @@ -141,7 +141,7 @@ typedef struct { NSConstantStringClass = [NSString constantStringClass]; _holder = (id)NSAllocateObject(GSPlaceholderStringClass, 0, 0); externalEncoding = [NSString defaultCStringEncoding]; - if ([_GSPrivate isByteEncoding: externalEncoding] == YES) + if (GSPrivateIsByteEncoding(externalEncoding) == YES) { internalEncoding = externalEncoding; } diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 0a334d9af..56ca5cc89 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSSerializer class reference $Date$ $Revision$ diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index ab271790b..c82fd0bc3 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -391,7 +391,7 @@ static Class runLoopClass; if (ioctlsocket(d, FIONBIO, &dummy) == SOCKET_ERROR) { NSLog(@"unable to set non-blocking mode on %d - %@", - d, [_GSPrivate error]); + d, [NSError _last]); return nil; } #else /* !__MINGW32__ */ @@ -401,14 +401,14 @@ static Class runLoopClass; if (fcntl(d, F_SETFL, e) < 0) { NSLog(@"unable to set non-blocking mode on %d - %@", - d, [_GSPrivate error]); + d, [NSError _last]); return nil; } } else { NSLog(@"unable to get non-blocking mode on %d - %@", - d, [_GSPrivate error]); + d, [NSError _last]); return nil; } #endif @@ -547,7 +547,7 @@ static Class runLoopClass; { NSLog(@"unable to make connection to %s:%d - %@", inet_ntoa(sockAddr.sin_addr), - GSSwapBigI16ToHost(sockAddr.sin_port), [_GSPrivate error]); + GSSwapBigI16ToHost(sockAddr.sin_port), [NSError _last]); if (addrNum < [addrs count]) { BOOL result; @@ -817,7 +817,7 @@ static Class runLoopClass; #endif /* !__MINGW32__ */ { NSDebugMLLog(@"GSTcpHandle", - @"read failed - %@ on 0x%p", [_GSPrivate error], self); + @"read failed - %@ on 0x%p", [NSError _last], self); [self invalidate]; return; } @@ -1108,7 +1108,7 @@ static Class runLoopClass; && res != 0) { state = GS_H_UNCON; - NSLog(@"connect attempt failed - %@", [_GSPrivate error]); + NSLog(@"connect attempt failed - %@", [NSError _last]); } else { @@ -1128,7 +1128,7 @@ static Class runLoopClass; { state = GS_H_UNCON; NSLog(@"connect write attempt failed - %@", - [_GSPrivate error]); + [NSError _last]); } RELEASE(d); } @@ -1166,7 +1166,7 @@ static Class runLoopClass; if (errno != EINTR && errno != EAGAIN) #endif /* !__MINGW32__ */ { - NSLog(@"write attempt failed - %@", [_GSPrivate error]); + NSLog(@"write attempt failed - %@", [NSError _last]); [self invalidate]; return; } @@ -1635,7 +1635,7 @@ static Class tcpPortClass; else if ((desc = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); DESTROY(port); } #ifndef BROKEN_SO_REUSEADDR @@ -1650,7 +1650,7 @@ static Class tcpPortClass; { (void) close(desc); NSLog(@"unable to set reuse on socket - %@", - [_GSPrivate error]); + [NSError _last]); DESTROY(port); } #endif @@ -1658,20 +1658,20 @@ static Class tcpPortClass; sizeof(sockaddr)) == SOCKET_ERROR) { NSLog(@"unable to bind to port %s:%d - %@", - inet_ntoa(sockaddr.sin_addr), number, [_GSPrivate error]); + inet_ntoa(sockaddr.sin_addr), number, [NSError _last]); (void) close(desc); DESTROY(port); } else if (listen(desc, 128) == SOCKET_ERROR) { - NSLog(@"unable to listen on port - %@", [_GSPrivate error]); + NSLog(@"unable to listen on port - %@", [NSError _last]); (void) close(desc); DESTROY(port); } else if (getsockname(desc, (struct sockaddr*)&sockaddr, &i) == SOCKET_ERROR) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); (void) close(desc); DESTROY(port); } @@ -1971,7 +1971,7 @@ static Class tcpPortClass; handle = nil; if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); } #ifndef BROKEN_SO_REUSEADDR /* @@ -1984,13 +1984,13 @@ static Class tcpPortClass; sizeof(opt)) < 0) { (void)close(sock); - NSLog(@"unable to set reuse on socket - %@", [_GSPrivate error]); + NSLog(@"unable to set reuse on socket - %@", [NSError _last]); } #endif else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil) { (void)close(sock); - NSLog(@"unable to create GSTcpHandle - %@", [_GSPrivate error]); + NSLog(@"unable to create GSTcpHandle - %@", [NSError _last]); } else { diff --git a/Source/NSSocketPortNameServer.m b/Source/NSSocketPortNameServer.m index cb5716209..64d9f112d 100644 --- a/Source/NSSocketPortNameServer.m +++ b/Source/NSSocketPortNameServer.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. $Date$ $Revision$ */ diff --git a/Source/NSString.m b/Source/NSString.m index 1bef06ae3..ce8fdeb3c 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -77,7 +77,6 @@ #include "Foundation/NSKeyedArchiver.h" #include "GNUstepBase/GSMime.h" #include "GSPrivate.h" -#include "GSFormat.h" #include #include #ifdef HAVE_UNISTD_H @@ -565,8 +564,8 @@ handle_printf_atsign (FILE *stream, gcrSel = @selector(getCharacters:range:); ranSel = @selector(rangeOfComposedCharacterSequenceAtIndex:); - _DefaultStringEncoding = [_GSPrivate defaultCStringEncoding]; - _ByteEncodingOk = [_GSPrivate isByteEncoding: _DefaultStringEncoding]; + _DefaultStringEncoding = GSPrivateDefaultCStringEncoding(); + _ByteEncodingOk = GSPrivateIsByteEncoding(_DefaultStringEncoding); NSStringClass = self; [self setVersion: 1]; @@ -1078,7 +1077,7 @@ handle_printf_atsign (FILE *stream, /* * Now set up 'f' as a GSMutableString object whose initial buffer is - * allocated on the stack. The GSFormat function can write into it. + * allocated on the stack. The GSPrivateFormat function can write into it. */ f.isa = GSMutableStringClass; f._zone = NSDefaultMallocZone(); @@ -1087,7 +1086,7 @@ handle_printf_atsign (FILE *stream, f._count = 0; f._flags.wide = 0; f._flags.free = 0; - GSFormat(&f, fmt, argList, locale); + GSPrivateFormat(&f, fmt, argList, locale); GSStrExternalize(&f); if (fmt != fbuf) { @@ -2683,7 +2682,7 @@ handle_printf_atsign (FILE *stream, */ + (NSStringEncoding*) availableStringEncodings { - return [_GSPrivate availableEncodings]; + return GSPrivateAvailableEncodings(); } /** @@ -2701,7 +2700,7 @@ handle_printf_atsign (FILE *stream, */ ourbundle = [NSBundle bundleForLibrary: @"gnustep-base"]; - ourname = [_GSPrivate encodingName: encoding]; + ourname = GSPrivateEncodingName(encoding); return [ourbundle localizedStringForKey: ourname value: ourname table: nil]; diff --git a/Source/NSTask.m b/Source/NSTask.m index eb28523b7..b7449f501 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -1563,7 +1563,7 @@ GSPrivateCheckTasks() if (result < 0) { NSLog(@"waitpid %d, result %d, error %@", - _taskId, result, [_GSPrivate error]); + _taskId, result, [NSError _last]); [self _terminatedChild: -1]; } else if (result == _taskId || (result > 0 && errno == 0)) @@ -1596,7 +1596,7 @@ GSPrivateCheckTasks() else { NSLog(@"waitpid %d, result %d, error %@", - _taskId, result, [_GSPrivate error]); + _taskId, result, [NSError _last]); } #endif } diff --git a/Source/NSThread.m b/Source/NSThread.m index 975ac756e..28e00badd 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -890,12 +890,12 @@ static NSDate *theFuture; #if defined(__MINGW32__) if (SetEvent(event) == 0) { - NSLog(@"Set event failed - %@", [_GSPrivate error]); + NSLog(@"Set event failed - %@", [NSError _last]); } #else if (write(outputFd, "0", 1) != 1) { - NSLog(@"Write to pipe failed - %@", [_GSPrivate error]); + NSLog(@"Write to pipe failed - %@", [NSError _last]); } #endif @@ -919,12 +919,12 @@ static NSDate *theFuture; #if defined(__MINGW32__) if (ResetEvent(event) == 0) { - NSLog(@"Reset event failed - %@", [_GSPrivate error]); + NSLog(@"Reset event failed - %@", [NSError _last]); } #else if (read(inputFd, &c, 1) != 1) { - NSLog(@"Read pipe failed - %@", [_GSPrivate error]); + NSLog(@"Read pipe failed - %@", [NSError _last]); } #endif diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index f09cda526..3231b7f78 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -21,7 +21,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSTimeZone class reference $Date$ $Revision$ diff --git a/Source/NSUndoManager.m b/Source/NSUndoManager.m index 0a40aa7b7..b7f82b8a5 100644 --- a/Source/NSUndoManager.m +++ b/Source/NSUndoManager.m @@ -17,7 +17,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSUndoManager class reference $Date$ $Revision$ diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index eb0020f9d..968b53179 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -1955,9 +1955,8 @@ static BOOL isLocked = NO; } @end -@implementation GSPrivate (UserDefaults) - -- (BOOL) userDefaultsFlag: (GSUserDefaultFlagType)type +BOOL +GSPrivateDefaultsFlag(GSUserDefaultFlagType type) { if (sharedDefaults == nil) { @@ -1965,7 +1964,6 @@ static BOOL isLocked = NO; } return flags[type]; } -@end /* FIXME ... Slightly faster than * [[NSUserDefaults standardUserDefaults] dictionaryRepresentation] @@ -1975,6 +1973,10 @@ NSDictionary *GSPrivateDefaultLocale() { NSDictionary *locale; + if (classLock == nil) + { + [NSUserDefaults standardUserDefaults]; + } [classLock lock]; if (sharedDefaults == nil) { diff --git a/Source/NSValue.m b/Source/NSValue.m index 4b559ef83..1e42866c6 100644 --- a/Source/NSValue.m +++ b/Source/NSValue.m @@ -20,7 +20,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSValue class reference $Date$ $Revision$ diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 0ade7f241..a2d612bd1 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ diff --git a/Source/NSZone.m b/Source/NSZone.m index 1a96cc1c0..6c7a84859 100644 --- a/Source/NSZone.m +++ b/Source/NSZone.m @@ -19,7 +19,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. NSZone class reference $Date$ $Revision$ diff --git a/Source/externs.m b/Source/externs.m index 2618924ed..9f5174993 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -25,7 +25,6 @@ #include "config.h" #include "Foundation/NSString.h" - #include "Foundation/NSArray.h" #include "Foundation/NSException.h" @@ -231,7 +230,7 @@ NSString *NSClassDescriptionNeededForClassNotification = @"NSClassDescriptionNee */ void -GSBuildStrings() +GSPrivateBuildStrings() { static Class NSStringClass = 0; diff --git a/Source/libgnustep-base-entry.m b/Source/libgnustep-base-entry.m index f6178c35b..93b970a19 100644 --- a/Source/libgnustep-base-entry.m +++ b/Source/libgnustep-base-entry.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/mframe.m b/Source/mframe.m index 00c708639..ffbaee1ca 100644 --- a/Source/mframe.m +++ b/Source/mframe.m @@ -18,8 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ /* These functions can be used for dissecting and making method calls diff --git a/Source/objc-gnu2next.m b/Source/objc-gnu2next.m index 08d322715..501c2f26c 100644 --- a/Source/objc-gnu2next.m +++ b/Source/objc-gnu2next.m @@ -19,7 +19,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include "config.h" diff --git a/Source/preface.m b/Source/preface.m index 615871923..2686d8a0d 100644 --- a/Source/preface.m +++ b/Source/preface.m @@ -18,7 +18,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include diff --git a/Source/unix/GSRunLoopCtxt.m b/Source/unix/GSRunLoopCtxt.m index 28221e492..28c70e6d7 100644 --- a/Source/unix/GSRunLoopCtxt.m +++ b/Source/unix/GSRunLoopCtxt.m @@ -9,13 +9,14 @@ #include "config.h" #include "GNUstepBase/preface.h" -#include "../GSRunLoopCtxt.h" -#include "../GSRunLoopWatcher.h" -#include "../GSPrivate.h" #include +#include #include #include #include +#include "../GSRunLoopCtxt.h" +#include "../GSRunLoopWatcher.h" +#include "../GSPrivate.h" #ifdef HAVE_SYS_TYPES_H #include @@ -418,7 +419,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) /* xxx We can do something with exception_fds, instead of aborting here. */ NSLog (@"poll() error in -acceptInputForMode:beforeDate: '%@'", - [_GSPrivate error]); + [NSError _last]); abort (); } } @@ -799,7 +800,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) /* xxx We can do something with exception_fds, instead of aborting here. */ NSLog (@"select() error in -acceptInputForMode:beforeDate: '%@'", - [_GSPrivate error]); + [NSError _last]); abort (); } } diff --git a/Source/win32/GSFileHandleWin32.m b/Source/win32/GSFileHandleWin32.m index d7fbcec68..798a9927f 100644 --- a/Source/win32/GSFileHandleWin32.m +++ b/Source/win32/GSFileHandleWin32.m @@ -793,7 +793,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); RELEASE(self); return nil; } @@ -808,7 +808,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR) { NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]); + GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); (void) closesocket(net); RELEASE(self); return nil; @@ -828,7 +828,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSLog(@"unable to make connection to %s:%d - %@", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]); + GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); RELEASE(self); return nil; } @@ -892,7 +892,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) { - NSLog(@"unable to create socket - %@", [_GSPrivate error]); + NSLog(@"unable to create socket - %@", [NSError _last]); RELEASE(self); return nil; } @@ -910,7 +910,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR) { NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr), - GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]); + GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); (void) closesocket(net); RELEASE(self); return nil; @@ -918,7 +918,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (listen(net, 256) == SOCKET_ERROR) { - NSLog(@"unable to listen on port - %@", [_GSPrivate error]); + NSLog(@"unable to listen on port - %@", [NSError _last]); (void) closesocket(net); RELEASE(self); return nil; @@ -926,7 +926,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getsockname(net, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); (void) closesocket(net); RELEASE(self); return nil; @@ -1094,7 +1094,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (_fstat(desc, &sbuf) != 0) { NSLog(@"unable to get status of descriptor %d - %@", - desc, [_GSPrivate error]); + desc, [NSError _last]); } else { @@ -1295,7 +1295,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } return d; } @@ -1320,7 +1320,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } return d; } @@ -1346,7 +1346,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } [d setLength: got]; } @@ -1369,7 +1369,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to read from descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } } while (len > 0 && got > 0); @@ -1416,7 +1416,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"unable to write to descriptor - %@", - [_GSPrivate error]]; + [NSError _last]]; } } @@ -1522,7 +1522,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %@", - [_GSPrivate error]]; + [NSError _last]]; } return (unsigned long long)result; } @@ -1546,7 +1546,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %@", - [_GSPrivate error]]; + [NSError _last]]; } return (unsigned long long)result; } @@ -1570,7 +1570,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [NSException raise: NSFileHandleOperationException format: @"failed to move to offset in file - %@", - [_GSPrivate error]]; + [NSError _last]]; } } @@ -1929,7 +1929,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Accept attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; } else @@ -1998,7 +1998,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Read attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } @@ -2007,7 +2007,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Read attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } @@ -2047,7 +2047,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: @"Connect attempt failed - %@", - [_GSPrivate error]]; + [NSError _last]]; [info setObject: s forKey: GSFileHandleNotificationError]; } else @@ -2081,7 +2081,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSString *s; s = [NSString stringWithFormat: - @"Write attempt failed - %@", [_GSPrivate error]]; + @"Write attempt failed - %@", [NSError _last]]; [info setObject: s forKey: GSFileHandleNotificationError]; [self postWriteNotification]; } @@ -2245,7 +2245,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; == SOCKET_ERROR) { NSLog(@"unable to set non-blocking mode - %@", - [_GSPrivate error]); + [NSError _last]); } else isNonBlocking = flag; @@ -2256,7 +2256,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy) == SOCKET_ERROR) { - NSLog(@"unable to set blocking mode - %@", [_GSPrivate error]); + NSLog(@"unable to set blocking mode - %@", [NSError _last]); } else isNonBlocking = flag; @@ -2277,7 +2277,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); } else { @@ -2294,7 +2294,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) { - NSLog(@"unable to get socket name - %@", [_GSPrivate error]); + NSLog(@"unable to get socket name - %@", [NSError _last]); } else { diff --git a/Source/win32/GSRunLoopCtxt.m b/Source/win32/GSRunLoopCtxt.m index b3b5f8a46..58d3f9aba 100644 --- a/Source/win32/GSRunLoopCtxt.m +++ b/Source/win32/GSRunLoopCtxt.m @@ -9,13 +9,14 @@ #include "config.h" #include "GNUstepBase/preface.h" -#include "../GSRunLoopCtxt.h" -#include "../GSRunLoopWatcher.h" -#include "../GSPrivate.h" #include +#include #include #include #include +#include "../GSRunLoopCtxt.h" +#include "../GSRunLoopWatcher.h" +#include "../GSPrivate.h" #if GS_WITH_GC == 0 static SEL wRelSel; @@ -434,7 +435,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = BOOL found = NO; NSDebugMLLog(@"NSRunLoop", @"WaitForMultipleObjects() error in " - @"-acceptInputForMode:beforeDate: %@", [_GSPrivate error]); + @"-acceptInputForMode:beforeDate: %@", [NSError _last]); /* * Check each handle in turn until either we find one which has an * event signalled, or we find the one which caused the original @@ -455,7 +456,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = if (found == NO) { NSLog(@"WaitForMultipleObjects() error in " - @"-acceptInputForMode:beforeDate: %@", [_GSPrivate error]); + @"-acceptInputForMode:beforeDate: %@", [NSError _last]); abort (); } } diff --git a/Source/win32/NSMessagePortWin32.m b/Source/win32/NSMessagePortWin32.m index 6094bbe10..556f9fe33 100644 --- a/Source/win32/NSMessagePortWin32.m +++ b/Source/win32/NSMessagePortWin32.m @@ -207,7 +207,7 @@ static Class messagePortClass = 0; if ([p _setupSendPort] == NO) { NSLog(@"unable to access mailslot '%@' - %@", - [p name], [_GSPrivate error]); + [p name], [NSError _last]); DESTROY(p); } return p; @@ -335,7 +335,7 @@ static Class messagePortClass = 0; if (this->rHandle == INVALID_HANDLE_VALUE) { NSLog(@"unable to create mailslot '%@' - %@", - this->name, [_GSPrivate error]); + this->name, [NSError _last]); DESTROY(self); } else @@ -507,7 +507,7 @@ static Class messagePortClass = 0; } else { - NSLog(@"GetOverlappedResult failed ... %@", [_GSPrivate error]); + NSLog(@"GetOverlappedResult failed ... %@", [NSError _last]); this->rState = RS_NONE; this->rLength = 0; } @@ -530,7 +530,7 @@ static Class messagePortClass = 0; 0) == 0) { NSLog(@"unable to get info from mailslot '%@' - %@", - this->name, [_GSPrivate error]); + this->name, [NSError _last]); [self invalidate]; return; } @@ -547,14 +547,14 @@ static Class messagePortClass = 0; NULL) == 0) { NSLog(@"unable to read from mailslot '%@' - %@", - this->name, [_GSPrivate error]); + this->name, [NSError _last]); [self invalidate]; return; } if (this->rSize != this->rWant) { NSLog(@"only read %d of %d bytes from mailslot '%@' - %@", - this->rSize, this->rWant, this->name, [_GSPrivate error]); + this->rSize, this->rWant, this->name, [NSError _last]); [self invalidate]; return; } @@ -749,7 +749,7 @@ static Class messagePortClass = 0; else { NSLog(@"unable to read from mailslot '%@' - %@", - this->name, [_GSPrivate error]); + this->name, [NSError _last]); [self invalidate]; } } @@ -803,7 +803,7 @@ static Class messagePortClass = 0; &this->wSize, TRUE) == 0) { - NSLog(@"GetOverlappedResult failed ... %@", [_GSPrivate error]); + NSLog(@"GetOverlappedResult failed ... %@", [NSError _last]); } else { @@ -856,7 +856,7 @@ again: else if ((errno = GetLastError()) != ERROR_IO_PENDING) { NSLog(@"unable to write to mailslot '%@' - %@", - this->name, [_GSPrivate error]); + this->name, [NSError _last]); [self invalidate]; } else diff --git a/Source/win32/NSStreamWin32.m b/Source/win32/NSStreamWin32.m index bef569299..c2c7ff4cc 100644 --- a/Source/win32/NSStreamWin32.m +++ b/Source/win32/NSStreamWin32.m @@ -269,7 +269,7 @@ static void setNonblocking(SOCKET fd) unsigned long dummy = 1; if (ioctlsocket(fd, FIONBIO, &dummy) == SOCKET_ERROR) - NSLog(@"unable to set non-blocking mode - %@", [_GSPrivate error]); + NSLog(@"unable to set non-blocking mode - %@", [NSError _last]); } @implementation GSFileInputStream @@ -1867,7 +1867,7 @@ static void setNonblocking(SOCKET fd) { [NSException raise: NSInternalInconsistencyException format: @"Unable to open named pipe '%@'... %@", - path, [_GSPrivate error]]; + path, [NSError _last]]; } // the type of the stream does not matter, since we are only using the fd