Updates to reduce global namespace pollution. Plenty more remaining.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23795 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-10-09 14:00:01 +00:00
parent 9d71af9cbf
commit eae859d1c7
85 changed files with 1090 additions and 1277 deletions

View file

@ -1,3 +1,89 @@
2006-10-09 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepBase/unicode:
Moved to Source/Additions/unicode
* Source/NSSocketPortNameServer.m:
* Source/GSLocale.m:
* Source/NSTimeZone.m:
* Source/GSCompatibility.m:
* Source/NSCalendarDate.m:
* Source/NSBundle.m:
* Source/NSPropertyList.m:
* Source/NSPathUtilities.m:
* Source/NSScanner.m:
* Source/NSProcessInfo.m:
* Source/GNUmakefile:
* Source/NSSocketPort.m:
* Source/NSUserDefaults.m:
* Source/GSFFCallInvocation.m:
* Source/NSArray.m:
* Source/GSStream.m:
* Source/NSKeyedArchiver.m:
* Source/NSDebug.m:
* Source/unix/GSRunLoopCtxt.m:
* Source/NSDistributedLock.m:
* Source/GSHTTPURLHandle.m:
* Source/NSMessagePort.m:
* Source/GSPrivate.h:
* Source/win32/NSMessagePortNameServerWin32.m:
* Source/win32/GSFileHandleWin32.m:
* Source/win32/NSUserDefaultsWin32.m:
* Source/win32/GSRunLoopCtxt.m:
* Source/win32/NSMessagePortWin32.m:
* Source/win32/NSStreamWin32.m:
* Source/NSInvocation.m:
* Source/NSFileManager.m:
* Source/objc-load.m:
* Source/NSException.m:
* Source/NSString.m:
* Source/NSObject.m:
* Source/NSDecimalNumber.m:
* Source/Additions/Unicode.m:
* Source/Additions/GSXML.m:
* Source/Additions/GSFunctions.m:
* Source/Additions/GSCompatibility.m:
* Source/Additions/GSCategories.m:
* Source/NSDecimal.m:
* Source/GSString.m:
* Source/NSDateFormatter.m:
* Source/NSThread.m:
* Source/NSData.m:
* Source/NSHost.m:
* Source/NSDate.m:
* Source/NSObjCRuntime.m:
* Source/NSPipe.m:
* Source/NSDictionary.m:
* Source/NSLog.m:
* Source/GSFormat.m:
* Source/GSFileHandle.m:
* Source/NSTask.m:
* Source/NSArchiver.m:
* Source/GSFTPURLHandle.m:
* SSL/GSSSLHandle.m:
* Headers/Foundation/NSException.h:
* Headers/Additions/GNUstepBase/GSFunctions.h:
* Headers/Additions/GNUstepBase/GSObjCRuntime.h:
* Headers/Additions/GNUstepBase/Unicode.h:
* Tools/xmlparse.m:
* Tools/defaults.m:
* Tools/locale_alias.m:
* Tools/Makefile.preamble:
* Tools/AGSParser.m:
* Tools/make_strings/make_strings.m:
* Tools/pl.m:
* Testing/tcpport-server.m:
* Testing/exported-strings.m:
* Testing/call.m:
* Testing/nsconnection_server.m:
* Testing/benchmark.m:
* Testing/tcpport-client.m:
Continuing effort to reduce global namespace pollution ... made many
external variables static (particuarly unicode tables). Changed
several global functions to be methods of a private internal class.
Also updated several usages of deprecated cString methods to use
either UTF8 methods or cString...encoding methods as seemed most
appropriate and/or simplest.
2006-10-06 Fred Kiefer <FredKiefer@gmx.de> 2006-10-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/Additions/GSMime.m(GSMimeDocument +initialize): Corrected * Source/Additions/GSMime.m(GSMimeDocument +initialize): Corrected

View file

@ -31,6 +31,8 @@
#include "GNUstepBase/GSObjCRuntime.h" #include "GNUstepBase/GSObjCRuntime.h"
#include "GNUstepBase/GNUstep.h" #include "GNUstepBase/GNUstep.h"
#warning "deprecated header ... will be removed in a later release"
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif

View file

@ -673,11 +673,6 @@ GSAutoreleasedBuffer(unsigned size);
GS_EXPORT void GS_EXPORT void
GSAllocateMutexAt(objc_mutex_t *request); GSAllocateMutexAt(objc_mutex_t *request);
/** Returns a system error message on a variety of systems
*/
GS_EXPORT const char *
GSLastErrorStr(long error_id);
/** /**
* <p>Prints a message to fptr using the format string provided and any * <p>Prints a message to fptr using the format string provided and any
* additional arguments. The format string is interpreted as by * additional arguments. The format string is interpreted as by
@ -699,6 +694,9 @@ GSPrintf (FILE *fptr, NSString *format, ...);
#ifndef NO_DEPRECATED #ifndef NO_DEPRECATED
GS_EXPORT const char *
GSLastErrorStr(long error_id) GS_ATTRIB_DEPRECATED;
GS_EXPORT BOOL GS_EXPORT BOOL
GSFindInstanceVariable(id obj, const char *name, GSFindInstanceVariable(id obj, const char *name,
const char **type, const char **type,

View file

@ -44,19 +44,17 @@
extern "C" { extern "C" {
#endif #endif
#if GS_API_VERSION(GS_API_NONE,011500)
GS_EXPORT NSStringEncoding *GetAvailableEncodings(void); /* Deprecated functions */
GS_EXPORT NSStringEncoding GetDefEncoding(void);
GS_EXPORT NSStringEncoding GSEncodingFromLocale(const char *clocale); GS_EXPORT NSStringEncoding GSEncodingFromLocale(const char *clocale);
GS_EXPORT NSStringEncoding GSEncodingForRegistry(NSString *registry, GS_EXPORT NSStringEncoding GSEncodingForRegistry(NSString *registry,
NSString *encoding); NSString *encoding);
GS_EXPORT NSString* GSEncodingName(NSStringEncoding encoding);
GS_EXPORT unichar uni_tolower(unichar ch); GS_EXPORT unichar uni_tolower(unichar ch);
GS_EXPORT unichar uni_toupper(unichar ch); GS_EXPORT unichar uni_toupper(unichar ch);
GS_EXPORT unsigned char uni_cop(unichar u); GS_EXPORT unsigned char uni_cop(unichar u);
GS_EXPORT BOOL uni_isnonsp(unichar u); GS_EXPORT BOOL uni_isnonsp(unichar u);
GS_EXPORT unichar *uni_is_decomp(unichar u); GS_EXPORT unichar *uni_is_decomp(unichar u);
#endif
/* /*
@ -77,22 +75,6 @@ GS_EXPORT BOOL GSToUnicode(unichar **dst, unsigned int *size,
const unsigned char *src, unsigned int slen, NSStringEncoding enc, const unsigned char *src, unsigned int slen, NSStringEncoding enc,
NSZone *zone, unsigned int options); NSZone *zone, unsigned int options);
/*
* The next functions are deprecated and will be removed in a future
* release. Use GSFromUnicode() and GSToUnicode() instead.
*/
GS_EXPORT NSString* GetEncodingName(NSStringEncoding encoding);
GS_EXPORT unichar chartouni(unsigned char c);
GS_EXPORT unsigned char unitochar(unichar u);
GS_EXPORT unichar encode_chartouni(unsigned char c, NSStringEncoding enc);
GS_EXPORT unsigned char encode_unitochar(unichar u, NSStringEncoding enc);
GS_EXPORT unsigned encode_unitochar_strict(unichar u, NSStringEncoding enc);
GS_EXPORT int encode_ustrtocstr(char *dst, int dl, const unichar *src, int sl,
NSStringEncoding enc, BOOL strict);
GS_EXPORT int encode_cstrtoustr(unichar *dst, int dl, const char *src, int sl,
NSStringEncoding enc);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif

View file

@ -335,7 +335,7 @@ GS_EXPORT void _NSRemoveHandler( NSHandler *handler );
[[NSAssertionHandler currentHandler] \ [[NSAssertionHandler currentHandler] \
handleFailureInMethod: _cmd \ handleFailureInMethod: _cmd \
object: self \ object: self \
file: [NSString stringWithCString: __FILE__] \ file: [NSString stringWithUTF8String: __FILE__] \
lineNumber: __LINE__ \ lineNumber: __LINE__ \
description: (desc) , ## args]; \ description: (desc) , ## args]; \
} \ } \
@ -345,8 +345,8 @@ GS_EXPORT void _NSRemoveHandler( NSHandler *handler );
do { \ do { \
if (!(condition)) { \ if (!(condition)) { \
[[NSAssertionHandler currentHandler] \ [[NSAssertionHandler currentHandler] \
handleFailureInFunction: [NSString stringWithCString: __PRETTY_FUNCTION__] \ handleFailureInFunction: [NSString stringWithUTF8String: __PRETTY_FUNCTION__] \
file: [NSString stringWithCString: __FILE__] \ file: [NSString stringWithUTF8String: __FILE__] \
lineNumber: __LINE__ \ lineNumber: __LINE__ \
description: (desc) , ## args]; \ description: (desc) , ## args]; \
} \ } \

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
*/ */
@ -53,6 +54,7 @@
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include <GNUstepBase/GSFileHandle.h> #include <GNUstepBase/GSFileHandle.h>
#include "GSPrivate.h"
#if defined(__MINGW32__) #if defined(__MINGW32__)
#include <winsock2.h> #include <winsock2.h>
@ -105,8 +107,8 @@ sslError(int err, int e)
str = @"Want X509 Lookup Error"; str = @"Want X509 Lookup Error";
break; break;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
str = [NSString stringWithFormat: @"Syscall error %d - %s", str = [NSString stringWithFormat: @"Syscall error %d - %@",
e, GSLastErrorStr(e)]; e, [_GSPrivate error: e]];
break; break;
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
str = @"SSL Error: really helpful"; str = @"SSL Error: really helpful";

View file

@ -27,10 +27,57 @@
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include "GNUstepBase/GSCategories.h" #include "GNUstepBase/GSCategories.h"
#include "GNUstepBase/GSLock.h" #include "GNUstepBase/GSLock.h"
#include "GSPrivate.h"
/* Test for ASCII whitespace which is safe for unicode characters */ /* Test for ASCII whitespace which is safe for unicode characters */
#define space(C) ((C) > 127 ? NO : isspace(C)) #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, nuymber, 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
@implementation NSArray (GSCategories) @implementation NSArray (GSCategories)
- (unsigned) insertionPosition: (id)item - (unsigned) insertionPosition: (id)item

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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" #include "config.h"
@ -260,7 +261,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -277,8 +278,8 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0) if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0)
{ {
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr), NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
NSSwapBigShortToHost(sin.sin_port), GSLastErrorStr(errno)); NSSwapBigShortToHost(sin.sin_port), [_GSPrivate error]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -286,7 +287,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
if (listen(net, 5) < 0) if (listen(net, 5) < 0)
{ {
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); NSLog(@"unable to listen on port - %@", [_GSPrivate error]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -294,7 +295,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
if (getsockname(net, (struct sockaddr*)&sin, &size) < 0) if (getsockname(net, (struct sockaddr*)&sin, &size) < 0)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -323,7 +324,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0) if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
return nil; return nil;
} }

View file

@ -40,6 +40,8 @@ GSFindNamedFile(NSArray *paths, NSString *aName, NSString *anExtension)
NSCParameterAssert(aName != nil); NSCParameterAssert(aName != nil);
NSCParameterAssert(paths != nil); NSCParameterAssert(paths != nil);
GSOnceFLog(@"deprecated ... trivial to code directly");
/* make up the name with extension if given */ /* make up the name with extension if given */
if (anExtension != nil) if (anExtension != nil)
{ {

View file

@ -122,14 +122,12 @@ UTF8Str(const unsigned char *bytes)
inline static NSString* inline static NSString*
UTF8StrLen(const unsigned char *bytes, unsigned length) UTF8StrLen(const unsigned char *bytes, unsigned length)
{ {
unsigned char *buf = NSZoneMalloc(NSDefaultMallocZone(), length+1);
NSString *str; NSString *str;
memcpy(buf, bytes, length); str = [[NSString_class alloc] initWithBytes: bytes
buf[length] = '\0'; length: length
str = UTF8Str(buf); encoding: NSUTF8StringEncoding];
NSZoneFree(NSDefaultMallocZone(), buf); return AUTORELEASE(str);
return str;
} }
static BOOL cacheDone = NO; static BOOL cacheDone = NO;

View file

@ -24,7 +24,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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" #include "config.h"
@ -42,6 +43,7 @@
#include "GNUstepBase/GSLock.h" #include "GNUstepBase/GSLock.h"
#include "GNUstepBase/GSCategories.h" #include "GNUstepBase/GSCategories.h"
#include "GNUstepBase/Unicode.h" #include "GNUstepBase/Unicode.h"
#include "../GSPrivate.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -52,15 +54,15 @@
typedef struct {unichar from; unsigned char to;} _ucc_; typedef struct {unichar from; unsigned char to;} _ucc_;
#include "GNUstepBase/unicode/cyrillic.h" #include "unicode/cyrillic.h"
#include "GNUstepBase/unicode/latin2.h" #include "unicode/latin2.h"
#include "GNUstepBase/unicode/latin9.h" #include "unicode/latin9.h"
#include "GNUstepBase/unicode/nextstep.h" #include "unicode/nextstep.h"
#include "GNUstepBase/unicode/caseconv.h" #include "unicode/caseconv.h"
#include "GNUstepBase/unicode/cop.h" #include "unicode/cop.h"
#include "GNUstepBase/unicode/decomp.h" #include "unicode/decomp.h"
#include "GNUstepBase/unicode/gsm0338.h" #include "unicode/gsm0338.h"
#include "GNUstepBase/unicode/thai.h" #include "unicode/thai.h"
#ifdef HAVE_ICONV #ifdef HAVE_ICONV
#ifdef HAVE_GICONV_H #ifdef HAVE_GICONV_H
@ -329,7 +331,7 @@ static void GSSetupEncodingTable(void)
} }
} }
BOOL GSEncodingSupported(NSStringEncoding enc) static BOOL isEncodingSupported(NSStringEncoding enc)
{ {
GSSetupEncodingTable(); GSSetupEncodingTable();
@ -385,9 +387,6 @@ BOOL GSEncodingSupported(NSStringEncoding enc)
return NO; return NO;
} }
/**
* Returns a nul terminated array of the available string encodings.
*/
NSStringEncoding * NSStringEncoding *
GetAvailableEncodings() GetAvailableEncodings()
{ {
@ -412,7 +411,7 @@ GetAvailableEncodings()
pos = 0; pos = 0;
for (i = 0; i < encTableSize+1; i++) for (i = 0; i < encTableSize+1; i++)
{ {
if (GSEncodingSupported(i) == YES) if (isEncodingSupported(i) == YES)
{ {
encodings[pos++] = i; encodings[pos++] = i;
} }
@ -532,7 +531,7 @@ GSEncodingForRegistry (NSString *registry, NSString *encoding)
* deduced from the clocale string itself. If clocale isn't set or * deduced from the clocale string itself. If clocale isn't set or
* no match can be found, returns GSUndefinedEncoding. * no match can be found, returns GSUndefinedEncoding.
*/ */
/* It would be really nice if this could be used in GetDefEncoding, but /* It would be really nice if this could be used in +defaultCStringEncoding, but
* there are too many dependancies on other parts of the library to * there are too many dependancies on other parts of the library to
* make this practical (even if everything possible was written in C, * make this practical (even if everything possible was written in C,
* we'd still need some way to find the Locale.encodings file). * we'd still need some way to find the Locale.encodings file).
@ -559,7 +558,7 @@ GSEncodingFromLocale(const char *clocale)
char *s; char *s;
s = strchr (clocale, '.'); s = strchr (clocale, '.');
registry = [[NSString stringWithCString: s+1] lowercaseString]; registry = [[NSString stringWithUTF8String: s+1] lowercaseString];
array = [registry componentsSeparatedByString: @"-"]; array = [registry componentsSeparatedByString: @"-"];
registry = [array objectAtIndex: 0]; registry = [array objectAtIndex: 0];
if ([array count] > 1) if ([array count] > 1)
@ -594,7 +593,7 @@ GSEncodingFromLocale(const char *clocale)
dict = [NSDictionary dictionaryWithContentsOfFile: table]; dict = [NSDictionary dictionaryWithContentsOfFile: table];
encodstr = [dict objectForKey: encodstr = [dict objectForKey:
[NSString stringWithCString: clocale]]; [NSString stringWithUTF8String: clocale]];
if (encodstr == nil) if (encodstr == nil)
return GSUndefinedEncoding; return GSUndefinedEncoding;
@ -620,299 +619,6 @@ GSEncodingFromLocale(const char *clocale)
return encoding; return encoding;
} }
/**
* Return the default encoding
*/
NSStringEncoding
GetDefEncoding(void)
{
if (defEnc == GSUndefinedEncoding)
{
char *encoding;
unsigned int count;
GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
if (defEnc != GSUndefinedEncoding)
{
[local_lock unlock];
return defEnc;
}
encoding = getenv("GNUSTEP_STRING_ENCODING");
if (encoding != 0)
{
count = 0;
while (str_encoding_table[count].enc
&& strcasecmp(str_encoding_table[count].ename, encoding)
&& strcasecmp(str_encoding_table[count].iconv, encoding))
{
count++;
}
if (str_encoding_table[count].enc)
{
defEnc = str_encoding_table[count].enc;
}
else
{
fprintf(stderr,
"WARNING: %s - encoding not supported.\n", encoding);
fprintf(stderr,
" NSISOLatin1StringEncoding set as default.\n");
defEnc = NSISOLatin1StringEncoding;
}
}
if (defEnc == GSUndefinedEncoding)
{
/* Encoding not set */
#if HAVE_LANGINFO_CODESET
/* Take it from the system locale information. */
encoding = nl_langinfo(CODESET);
/*
* First handle the fallback response from nl_langinfo() ...
* if we are getting the default value we can't assume that
* the user has set anything up at all, so we must use the
* OpenStep/GNUstep default encopding ... latin1, even though
* the nl_langinfo() stuff would say default is ascii.
*/
if (strcmp(encoding, "ANSI_X3.4-1968") == 0 /* glibc */
|| strcmp(encoding, "ISO_646.IRV:1983") == 0 /* glibc */
|| strcmp(encoding, "646") == 0 /* Solaris NetBSD */)
defEnc = NSISOLatin1StringEncoding;
else if (strcmp(encoding, "EUC-JP") == 0 /* glibc */
/* HP-UX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "eucJP") == 0
|| strcmp(encoding, "IBM-eucJP") == 0 /* AIX */)
defEnc = NSJapaneseEUCStringEncoding;
else if (strcmp(encoding, "UTF-8") == 0 /* glibc AIX OSF/1 Solaris */
|| strcmp(encoding, "utf8") == 0 /* HP-UX */)
defEnc = NSUTF8StringEncoding;
else if (strcmp(encoding, "ISO-8859-1") == 0 /* glibc */
/* AIX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-1") == 0
|| strcmp(encoding, "iso88591") == 0 /* HP-UX */)
defEnc = NSISOLatin1StringEncoding;
else if (strcmp(encoding, "IBM-932") == 0 /* AIX */
|| strcmp(encoding, "SJIS") == 0 /* HP-UX OSF/1 NetBSD */
|| strcmp(encoding, "PCK") == 0 /* Solaris */)
defEnc = NSShiftJISStringEncoding;
else if (strcmp(encoding, "ISO-8859-2") == 0 /* glibc */
/* AIX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-2") == 0
|| strcmp(encoding, "iso88592") == 0 /* HP-UX */)
defEnc = NSISOLatin2StringEncoding;
else if (strcmp(encoding, "CP1251") == 0 /* glibc */
|| strcmp(encoding, "ansi-1251") == 0 /* Solaris */)
defEnc = NSWindowsCP1251StringEncoding;
else if (strcmp(encoding, "CP1252") == 0 /* */
|| strcmp(encoding, "IBM-1252") == 0 /* AIX */)
defEnc = NSWindowsCP1252StringEncoding;
else if (strcmp(encoding, "ISO-8859-5") == 0 /* glibc */
/* AIX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-5") == 0
|| strcmp(encoding, "iso88595") == 0 /* HP-UX */)
defEnc = NSISOCyrillicStringEncoding;
else if (strcmp(encoding, "KOI8-R") == 0 /* glibc */
|| strcmp(encoding, "koi8-r") == 0 /* Solaris */)
defEnc = NSKOI8RStringEncoding;
else if (strcmp(encoding, "ISO-8859-3") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-3") == 0 /* Solaris */)
defEnc = NSISOLatin3StringEncoding;
else if (strcmp(encoding, "ISO-8859-4") == 0 /* */
|| strcmp(encoding, "ISO8859-4") == 0 /* OSF/1 Solaris NetBSD */)
defEnc = NSISOLatin4StringEncoding;
else if (strcmp(encoding, "ISO-8859-6") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-6") == 0 /* AIX Solaris */
|| strcmp(encoding, "iso88596") == 0 /* HP-UX */)
defEnc = NSISOArabicStringEncoding;
else if (strcmp(encoding, "ISO-8859-7") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-7") == 0 /* AIX IRIX OSF/1 Solaris */
|| strcmp(encoding, "iso88597") == 0 /* HP-UX */)
defEnc = NSISOGreekStringEncoding;
else if (strcmp(encoding, "ISO-8859-8") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-8") == 0 /* AIX OSF/1 Solaris */
|| strcmp(encoding, "iso88598") == 0 /* HP-UX */)
defEnc = NSISOHebrewStringEncoding;
else if (strcmp(encoding, "ISO-8859-9") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-9") == 0 /* AIX IRIX OSF/1 Solaris */
|| strcmp(encoding, "iso88599") == 0 /* HP-UX */)
defEnc = NSISOLatin5StringEncoding;
else if (strcmp(encoding, "ISO-8859-10") == 0 /* */
|| strcmp(encoding, "ISO8859-10") == 0 /* */)
defEnc = NSISOLatin6StringEncoding;
else if (strcmp(encoding, "TIS-620") == 0 /* glibc AIX */
|| strcmp(encoding, "tis620") == 0 /* HP-UX */
|| strcmp(encoding, "TIS620.2533") == 0 /* Solaris */
|| strcmp(encoding, "TACTIS") == 0 /* OSF/1 */)
defEnc = NSISOThaiStringEncoding;
else if (strcmp(encoding, "ISO-8859-13") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-13") == 0 /* */
|| strcmp(encoding, "IBM-921") == 0 /* AIX */)
defEnc = NSISOLatin7StringEncoding;
else if (strcmp(encoding, "ISO-8859-14") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-14") == 0 /* */)
defEnc = NSISOLatin8StringEncoding;
else if (strcmp(encoding, "ISO-8859-15") == 0 /* glibc */
/* AIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-15") == 0
|| strcmp(encoding, "iso885915") == 0 /* HP-UX */)
defEnc = NSISOLatin9StringEncoding;
else if (strcmp(encoding, "GB2312") == 0 /* glibc */
|| strcmp(encoding, "gb2312") == 0 /* Solaris */
|| strcmp(encoding, "eucCN") == 0 /* IRIX NetBSD */
|| strcmp(encoding, "IBM-eucCN") == 0 /* AIX */
|| strcmp(encoding, "hp15CN") == 0 /* HP-UX */)
defEnc = NSGB2312StringEncoding;
else if (strcmp(encoding, "BIG5") == 0 /* glibc Solaris NetBSD */
|| strcmp(encoding, "big5") == 0 /* AIX HP-UX OSF/1 */)
defEnc = NSBIG5StringEncoding;
else if (strcmp(encoding, "EUC-KR") == 0 /* glibc */
|| strcmp(encoding, "eucKR") == 0 /* HP-UX IRIX OSF/1 NetBSD */
|| strcmp(encoding, "IBM-eucKR") == 0 /* AIX */
|| strcmp(encoding, "5601") == 0 /* Solaris */)
defEnc = NSKoreanEUCStringEncoding;
else
#endif
defEnc = NSISOLatin1StringEncoding;
}
else if (GSEncodingSupported(defEnc) == NO)
{
fprintf(stderr, "WARNING: %s - encoding not implemented as "
"default c string encoding.\n", encoding);
fprintf(stderr,
" NSISOLatin1StringEncoding set as default.\n");
defEnc = NSISOLatin1StringEncoding;
}
[local_lock unlock];
}
return defEnc;
}
BOOL
GSIsByteEncoding(NSStringEncoding encoding)
{
if (GSEncodingSupported(encoding) == NO)
{
return NO;
}
return encodingTable[encoding]->eightBit;
}
/**
* Returns the standard name for the specified encoding.
*/
#ifndef NeXT_Foundation_LIBRARY
NSString*
GSEncodingName(NSStringEncoding encoding)
{
if (GSEncodingSupported(encoding) == NO)
{
return @"Unknown encoding";
}
return [NSString stringWithCString: encodingTable[encoding]->ename];
}
#endif
/**
* <strong>deprecated</strong> Use GSEncodingName()
*/
#ifndef NeXT_Foundation_LIBRARY
NSString*
GetEncodingName(NSStringEncoding encoding)
{
return GSEncodingName(encoding);
}
#endif
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
unichar
encode_chartouni(unsigned char c, NSStringEncoding enc)
{
BOOL result;
unsigned int size = 1;
unichar u = 0;
unichar *dst = &u;
result = GSToUnicode(&dst, &size, &c, 1, enc, 0, 0);
if (result == NO)
{
return 0;
}
return u;
}
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
unsigned char
encode_unitochar(unichar u, NSStringEncoding enc)
{
BOOL result;
unsigned int size = 1;
unsigned char c = 0;
unsigned char *dst = &c;
result = GSFromUnicode(&dst, &size, &u, 1, enc, 0, 0);
if (result == NO)
{
return 0;
}
return c;
}
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
unsigned
encode_unitochar_strict(unichar u, NSStringEncoding enc)
{
BOOL result;
unsigned int size = 1;
unsigned char c = 0;
unsigned char *dst = &c;
result = GSFromUnicode(&dst, &size, &u, 1, enc, 0, GSUniStrict);
if (result == NO)
{
return 0;
}
return c;
}
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
unichar
chartouni(unsigned char c)
{
if (defEnc == GSUndefinedEncoding)
{
defEnc = GetDefEncoding();
}
return encode_chartouni(c, defEnc);
}
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
unsigned char
unitochar(unichar u)
{
if (defEnc == GSUndefinedEncoding)
{
defEnc = GetDefEncoding();
}
return encode_unitochar(u, defEnc);
}
/** /**
* Uses direct access into a two-level table to map cases.<br /> * Uses direct access into a two-level table to map cases.<br />
* The two-level table method is less space efficient (but still not bad) than * The two-level table method is less space efficient (but still not bad) than
@ -1050,46 +756,6 @@ uni_is_decomp(unichar u)
} }
} }
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
int encode_ustrtocstr(char *dst, int dl, const unichar *src, int sl,
NSStringEncoding enc, BOOL strict)
{
BOOL result;
unsigned int options = (strict == YES) ? GSUniStrict : 0;
unsigned int old = dl;
result = GSFromUnicode((unsigned char**)&dst, (unsigned int*)&dl,
src, sl, enc, 0, options);
if (result == NO)
{
return 0;
}
return old - dl; // Number of characters.
}
/**
* <strong>deprecated</strong>
* See GSToUnicode() and GSFromUnicode()
*/
int encode_cstrtoustr(unichar *dst, int dl, const char *src, int sl,
NSStringEncoding enc)
{
BOOL result;
unsigned int old = dl;
result = GSToUnicode(&dst, (unsigned int*)&dl, (unsigned char*)src,
sl, enc, 0, 0);
if (result == NO)
{
return 0;
}
return old - dl;
}
/** /**
* Function to check a block of data for validity as a unicode string and * Function to check a block of data for validity as a unicode string and
* say whether it contains solely ASCII or solely Latin1 data.<br /> * say whether it contains solely ASCII or solely Latin1 data.<br />
@ -1531,7 +1197,7 @@ tables:
const char *estr = 0; const char *estr = 0;
BOOL done = NO; BOOL done = NO;
if (GSEncodingSupported(enc) == YES) if (isEncodingSupported(enc) == YES)
{ {
estr = encodingTable[enc]->iconv; estr = encodingTable[enc]->iconv;
} }
@ -1552,7 +1218,7 @@ tables:
if (cd == (iconv_t)-1) if (cd == (iconv_t)-1)
{ {
NSLog(@"No iconv for encoding %@ tried to use %s", NSLog(@"No iconv for encoding %@ tried to use %s",
GetEncodingName(enc), estr); [_GSPrivate encodingName: enc], estr);
result = NO; result = NO;
goto done; goto done;
} }
@ -2224,7 +1890,7 @@ iconv_start:
const char *estr = 0; const char *estr = 0;
BOOL done = NO; BOOL done = NO;
if (GSEncodingSupported(enc) == YES) if (isEncodingSupported(enc) == YES)
{ {
if (strict == NO) if (strict == NO)
{ {
@ -2257,7 +1923,7 @@ iconv_start:
if (cd == (iconv_t)-1) if (cd == (iconv_t)-1)
{ {
NSLog(@"No iconv for encoding %@ tried to use %s", NSLog(@"No iconv for encoding %@ tried to use %s",
GetEncodingName(enc), estr); [_GSPrivate encodingName: enc], estr);
result = NO; result = NO;
goto done; goto done;
} }
@ -2414,3 +2080,231 @@ iconv_start:
#undef GROW #undef GROW
@implementation _GSPrivate (Unicode)
+ (NSStringEncoding*) availableEncodings
{
if (_availableEncodings == 0)
{
GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
if (_availableEncodings == 0)
{
NSStringEncoding *encodings;
unsigned pos;
unsigned i;
/*
* Now build up a list of supported encodings ... in the
* format needed to support [NSString+availableStringEncodings]
* Check to see what iconv support we have as we go along.
* This is also the place where we determine the name we use
* for iconv to support unicode.
*/
encodings = objc_malloc(sizeof(NSStringEncoding) * (encTableSize+1));
pos = 0;
for (i = 0; i < encTableSize+1; i++)
{
if (isEncodingSupported(i) == YES)
{
encodings[pos++] = i;
}
}
encodings[pos] = 0;
_availableEncodings = encodings;
}
[local_lock unlock];
}
return _availableEncodings;
}
+ (NSStringEncoding) defaultCStringEncoding
{
if (defEnc == GSUndefinedEncoding)
{
char *encoding;
unsigned int count;
GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
if (defEnc != GSUndefinedEncoding)
{
[local_lock unlock];
return defEnc;
}
encoding = getenv("GNUSTEP_STRING_ENCODING");
if (encoding != 0)
{
count = 0;
while (str_encoding_table[count].enc
&& strcasecmp(str_encoding_table[count].ename, encoding)
&& strcasecmp(str_encoding_table[count].iconv, encoding))
{
count++;
}
if (str_encoding_table[count].enc)
{
defEnc = str_encoding_table[count].enc;
}
else
{
fprintf(stderr,
"WARNING: %s - encoding not supported.\n", encoding);
fprintf(stderr,
" NSISOLatin1StringEncoding set as default.\n");
defEnc = NSISOLatin1StringEncoding;
}
}
if (defEnc == GSUndefinedEncoding)
{
/* Encoding not set */
#if HAVE_LANGINFO_CODESET
/* Take it from the system locale information. */
encoding = nl_langinfo(CODESET);
/*
* First handle the fallback response from nl_langinfo() ...
* if we are getting the default value we can't assume that
* the user has set anything up at all, so we must use the
* OpenStep/GNUstep default encopding ... latin1, even though
* the nl_langinfo() stuff would say default is ascii.
*/
if (strcmp(encoding, "ANSI_X3.4-1968") == 0 /* glibc */
|| strcmp(encoding, "ISO_646.IRV:1983") == 0 /* glibc */
|| strcmp(encoding, "646") == 0 /* Solaris NetBSD */)
defEnc = NSISOLatin1StringEncoding;
else if (strcmp(encoding, "EUC-JP") == 0 /* glibc */
/* HP-UX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "eucJP") == 0
|| strcmp(encoding, "IBM-eucJP") == 0 /* AIX */)
defEnc = NSJapaneseEUCStringEncoding;
else if (strcmp(encoding, "UTF-8") == 0 /* glibc AIX OSF/1 Solaris */
|| strcmp(encoding, "utf8") == 0 /* HP-UX */)
defEnc = NSUTF8StringEncoding;
else if (strcmp(encoding, "ISO-8859-1") == 0 /* glibc */
/* AIX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-1") == 0
|| strcmp(encoding, "iso88591") == 0 /* HP-UX */)
defEnc = NSISOLatin1StringEncoding;
else if (strcmp(encoding, "IBM-932") == 0 /* AIX */
|| strcmp(encoding, "SJIS") == 0 /* HP-UX OSF/1 NetBSD */
|| strcmp(encoding, "PCK") == 0 /* Solaris */)
defEnc = NSShiftJISStringEncoding;
else if (strcmp(encoding, "ISO-8859-2") == 0 /* glibc */
/* AIX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-2") == 0
|| strcmp(encoding, "iso88592") == 0 /* HP-UX */)
defEnc = NSISOLatin2StringEncoding;
else if (strcmp(encoding, "CP1251") == 0 /* glibc */
|| strcmp(encoding, "ansi-1251") == 0 /* Solaris */)
defEnc = NSWindowsCP1251StringEncoding;
else if (strcmp(encoding, "CP1252") == 0 /* */
|| strcmp(encoding, "IBM-1252") == 0 /* AIX */)
defEnc = NSWindowsCP1252StringEncoding;
else if (strcmp(encoding, "ISO-8859-5") == 0 /* glibc */
/* AIX IRIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-5") == 0
|| strcmp(encoding, "iso88595") == 0 /* HP-UX */)
defEnc = NSISOCyrillicStringEncoding;
else if (strcmp(encoding, "KOI8-R") == 0 /* glibc */
|| strcmp(encoding, "koi8-r") == 0 /* Solaris */)
defEnc = NSKOI8RStringEncoding;
else if (strcmp(encoding, "ISO-8859-3") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-3") == 0 /* Solaris */)
defEnc = NSISOLatin3StringEncoding;
else if (strcmp(encoding, "ISO-8859-4") == 0 /* */
|| strcmp(encoding, "ISO8859-4") == 0 /* OSF/1 Solaris NetBSD */)
defEnc = NSISOLatin4StringEncoding;
else if (strcmp(encoding, "ISO-8859-6") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-6") == 0 /* AIX Solaris */
|| strcmp(encoding, "iso88596") == 0 /* HP-UX */)
defEnc = NSISOArabicStringEncoding;
else if (strcmp(encoding, "ISO-8859-7") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-7") == 0 /* AIX IRIX OSF/1 Solaris */
|| strcmp(encoding, "iso88597") == 0 /* HP-UX */)
defEnc = NSISOGreekStringEncoding;
else if (strcmp(encoding, "ISO-8859-8") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-8") == 0 /* AIX OSF/1 Solaris */
|| strcmp(encoding, "iso88598") == 0 /* HP-UX */)
defEnc = NSISOHebrewStringEncoding;
else if (strcmp(encoding, "ISO-8859-9") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-9") == 0 /* AIX IRIX OSF/1 Solaris */
|| strcmp(encoding, "iso88599") == 0 /* HP-UX */)
defEnc = NSISOLatin5StringEncoding;
else if (strcmp(encoding, "ISO-8859-10") == 0 /* */
|| strcmp(encoding, "ISO8859-10") == 0 /* */)
defEnc = NSISOLatin6StringEncoding;
else if (strcmp(encoding, "TIS-620") == 0 /* glibc AIX */
|| strcmp(encoding, "tis620") == 0 /* HP-UX */
|| strcmp(encoding, "TIS620.2533") == 0 /* Solaris */
|| strcmp(encoding, "TACTIS") == 0 /* OSF/1 */)
defEnc = NSISOThaiStringEncoding;
else if (strcmp(encoding, "ISO-8859-13") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-13") == 0 /* */
|| strcmp(encoding, "IBM-921") == 0 /* AIX */)
defEnc = NSISOLatin7StringEncoding;
else if (strcmp(encoding, "ISO-8859-14") == 0 /* glibc */
|| strcmp(encoding, "ISO8859-14") == 0 /* */)
defEnc = NSISOLatin8StringEncoding;
else if (strcmp(encoding, "ISO-8859-15") == 0 /* glibc */
/* AIX OSF/1 Solaris NetBSD */
|| strcmp(encoding, "ISO8859-15") == 0
|| strcmp(encoding, "iso885915") == 0 /* HP-UX */)
defEnc = NSISOLatin9StringEncoding;
else if (strcmp(encoding, "GB2312") == 0 /* glibc */
|| strcmp(encoding, "gb2312") == 0 /* Solaris */
|| strcmp(encoding, "eucCN") == 0 /* IRIX NetBSD */
|| strcmp(encoding, "IBM-eucCN") == 0 /* AIX */
|| strcmp(encoding, "hp15CN") == 0 /* HP-UX */)
defEnc = NSGB2312StringEncoding;
else if (strcmp(encoding, "BIG5") == 0 /* glibc Solaris NetBSD */
|| strcmp(encoding, "big5") == 0 /* AIX HP-UX OSF/1 */)
defEnc = NSBIG5StringEncoding;
else if (strcmp(encoding, "EUC-KR") == 0 /* glibc */
|| strcmp(encoding, "eucKR") == 0 /* HP-UX IRIX OSF/1 NetBSD */
|| strcmp(encoding, "IBM-eucKR") == 0 /* AIX */
|| strcmp(encoding, "5601") == 0 /* Solaris */)
defEnc = NSKoreanEUCStringEncoding;
else
#endif
defEnc = NSISOLatin1StringEncoding;
}
else if (isEncodingSupported(defEnc) == NO)
{
fprintf(stderr, "WARNING: %s - encoding not implemented as "
"default c string encoding.\n", encoding);
fprintf(stderr,
" NSISOLatin1StringEncoding set as default.\n");
defEnc = NSISOLatin1StringEncoding;
}
[local_lock unlock];
}
return defEnc;
}
+ (NSString*) encodingName: (NSStringEncoding)encoding
{
if (isEncodingSupported(encoding) == NO)
{
return @"Unknown encoding";
}
return [NSString stringWithUTF8String: encodingTable[encoding]->ename];
}
+ (BOOL) isByteEncoding: (NSStringEncoding)encoding
{
if (isEncodingSupported(encoding) == NO)
{
return NO;
}
return encodingTable[encoding]->eightBit;
}
+ (BOOL) isEncodingSupported: (NSStringEncoding)encoding
{
return isEncodingSupported(encoding);
}
@end

View file

@ -8,7 +8,7 @@
are permitted in any medium without royalty provided the copyright are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. notice and this notice are preserved.
*/ */
unichar gs_casemap_empty_table[] = { static unichar gs_casemap_empty_table[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -267,7 +267,7 @@ unichar gs_casemap_empty_table[] = {
0x0, 0x0,
}; };
unichar gs_tolower_map_table_0[] = { static unichar gs_tolower_map_table_0[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -525,7 +525,8 @@ unichar gs_tolower_map_table_0[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_1[] = {
static unichar gs_tolower_map_table_1[] = {
0x101, /* 0 */ 0x101, /* 0 */
0x0, 0x0,
0x103, /* 2 */ 0x103, /* 2 */
@ -783,7 +784,8 @@ unichar gs_tolower_map_table_1[] = {
0x1ff, /* fe */ 0x1ff, /* fe */
0x0, 0x0,
}; };
unichar gs_tolower_map_table_2[] = {
static unichar gs_tolower_map_table_2[] = {
0x201, /* 0 */ 0x201, /* 0 */
0x0, 0x0,
0x203, /* 2 */ 0x203, /* 2 */
@ -1041,7 +1043,8 @@ unichar gs_tolower_map_table_2[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_3[] = {
static unichar gs_tolower_map_table_3[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -1299,7 +1302,8 @@ unichar gs_tolower_map_table_3[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_4[] = {
static unichar gs_tolower_map_table_4[] = {
0x450, /* 0 */ 0x450, /* 0 */
0x451, /* 1 */ 0x451, /* 1 */
0x452, /* 2 */ 0x452, /* 2 */
@ -1557,7 +1561,8 @@ unichar gs_tolower_map_table_4[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_5[] = {
static unichar gs_tolower_map_table_5[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -1815,7 +1820,8 @@ unichar gs_tolower_map_table_5[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_1e[] = {
static unichar gs_tolower_map_table_1e[] = {
0x1e01, /* 0 */ 0x1e01, /* 0 */
0x0, 0x0,
0x1e03, /* 2 */ 0x1e03, /* 2 */
@ -2073,7 +2079,8 @@ unichar gs_tolower_map_table_1e[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_1f[] = {
static unichar gs_tolower_map_table_1f[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -2331,7 +2338,8 @@ unichar gs_tolower_map_table_1f[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_21[] = {
static unichar gs_tolower_map_table_21[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -2589,7 +2597,8 @@ unichar gs_tolower_map_table_21[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_24[] = {
static unichar gs_tolower_map_table_24[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -2847,7 +2856,8 @@ unichar gs_tolower_map_table_24[] = {
0x0, 0x0,
0x0, 0x0,
}; };
unichar gs_tolower_map_table_ff[] = {
static unichar gs_tolower_map_table_ff[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -3106,7 +3116,7 @@ unichar gs_tolower_map_table_ff[] = {
0x0, 0x0,
}; };
unichar *gs_tolower_map[] = { static unichar *gs_tolower_map[] = {
gs_tolower_map_table_0, gs_tolower_map_table_0,
gs_tolower_map_table_1, gs_tolower_map_table_1,
gs_tolower_map_table_2, gs_tolower_map_table_2,
@ -3365,7 +3375,7 @@ unichar *gs_tolower_map[] = {
gs_tolower_map_table_ff, gs_tolower_map_table_ff,
}; };
unichar gs_toupper_map_table_0[] = { static unichar gs_toupper_map_table_0[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -3624,7 +3634,7 @@ unichar gs_toupper_map_table_0[] = {
0x178, /* ff */ 0x178, /* ff */
}; };
unichar gs_toupper_map_table_1[] = { static unichar gs_toupper_map_table_1[] = {
0x0, 0x0,
0x100, /* 1 */ 0x100, /* 1 */
0x0, 0x0,
@ -3883,7 +3893,7 @@ unichar gs_toupper_map_table_1[] = {
0x1fe, /* ff */ 0x1fe, /* ff */
}; };
unichar gs_toupper_map_table_2[] = { static unichar gs_toupper_map_table_2[] = {
0x0, 0x0,
0x200, /* 1 */ 0x200, /* 1 */
0x0, 0x0,
@ -4142,7 +4152,7 @@ unichar gs_toupper_map_table_2[] = {
0x0, 0x0,
}; };
unichar gs_toupper_map_table_3[] = { static unichar gs_toupper_map_table_3[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -4401,7 +4411,7 @@ unichar gs_toupper_map_table_3[] = {
0x0, 0x0,
}; };
unichar gs_toupper_map_table_4[] = { static unichar gs_toupper_map_table_4[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -4660,7 +4670,7 @@ unichar gs_toupper_map_table_4[] = {
0x0, 0x0,
}; };
unichar gs_toupper_map_table_5[] = { static unichar gs_toupper_map_table_5[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -4919,31 +4929,7 @@ unichar gs_toupper_map_table_5[] = {
0x0, 0x0,
}; };
static unichar gs_toupper_map_table_1e[] = {
unichar gs_toupper_map_table_1e[] = {
0x0, 0x0,
0x1e00, /* 1 */ 0x1e00, /* 1 */
0x0, 0x0,
@ -5202,7 +5188,7 @@ unichar gs_toupper_map_table_1e[] = {
0x0, 0x0,
}; };
unichar gs_toupper_map_table_1f[] = { static unichar gs_toupper_map_table_1f[] = {
0x1f08, /* 0 */ 0x1f08, /* 0 */
0x1f09, /* 1 */ 0x1f09, /* 1 */
0x1f0a, /* 2 */ 0x1f0a, /* 2 */
@ -5461,8 +5447,7 @@ unichar gs_toupper_map_table_1f[] = {
0x0, 0x0,
}; };
static unichar gs_toupper_map_table_21[] = {
unichar gs_toupper_map_table_21[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -5721,9 +5706,7 @@ unichar gs_toupper_map_table_21[] = {
0x0, 0x0,
}; };
static unichar gs_toupper_map_table_24[] = {
unichar gs_toupper_map_table_24[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -5982,225 +5965,7 @@ unichar gs_toupper_map_table_24[] = {
0x0, 0x0,
}; };
static unichar gs_toupper_map_table_ff[] = {
unichar gs_toupper_map_table_ff[] = {
0x0, 0x0,
0x0, 0x0,
0x0, 0x0,
@ -6459,8 +6224,7 @@ unichar gs_toupper_map_table_ff[] = {
0x0, 0x0,
}; };
static unichar *gs_toupper_map[] = {
unichar *gs_toupper_map[] = {
gs_toupper_map_table_0, gs_toupper_map_table_0,
gs_toupper_map_table_1, gs_toupper_map_table_1,
gs_toupper_map_table_2, gs_toupper_map_table_2,

View file

@ -9,9 +9,9 @@
struct _cop_ {unichar code; unsigned char cop;}; struct _cop_ {unichar code; unsigned char cop;};
const unsigned int uni_cop_table_size = 355;
struct _cop_ uni_cop_table[]= static const unsigned int uni_cop_table_size = 355;
static struct _cop_ uni_cop_table[]=
{ {
{0x0300,230}, {0x0300,230},
{0x0301,230}, {0x0301,230},

View file

@ -8,9 +8,8 @@
*/ */
const unsigned int Cyrillic_conv_base = 0x80; static const unsigned int Cyrillic_conv_base = 0x80;
static unichar Cyrillic_char_to_uni_table[] =
unichar Cyrillic_char_to_uni_table[] =
{ {
0x0080, 0x0080,
0x0081, 0x0081,
@ -144,9 +143,8 @@ unichar Cyrillic_char_to_uni_table[] =
// Unicode to ISO_8859-5,1988 maping // Unicode to ISO_8859-5,1988 maping
const unsigned int Cyrillic_uni_to_char_table_size = 128; static const unsigned int Cyrillic_uni_to_char_table_size = 128;
static _ucc_ Cyrillic_uni_to_char_table[]=
_ucc_ Cyrillic_uni_to_char_table[]=
{ {
{0x0080,0x80}, {0x0080,0x80},
{0x0081,0x81}, {0x0081,0x81},

View file

@ -9,9 +9,9 @@
struct _dec_ {unichar code; unichar decomp[5];}; struct _dec_ {unichar code; unichar decomp[5];};
const unsigned int uni_dec_table_size = 1052;
struct _dec_ uni_dec_table[]= static const unsigned int uni_dec_table_size = 1052;
static struct _dec_ uni_dec_table[]=
{ {
{0x00C0, {0x0041, 0x0300, 0}}, {0x00C0, {0x0041, 0x0300, 0}},
{0x00C1, {0x0041, 0x0301, 0}}, {0x00C1, {0x0041, 0x0301, 0}},

View file

@ -10,9 +10,8 @@
// GSM0338 to Unicode maping // GSM0338 to Unicode maping
const unsigned int GSM0338_conv_base = 0x00; static const unsigned int GSM0338_conv_base = 0x00;
static unichar GSM0338_char_to_uni_table[] =
unichar GSM0338_char_to_uni_table[] =
{ {
0x0040, 0x0040,
0x00A3, 0x00A3,
@ -144,7 +143,7 @@ unichar GSM0338_char_to_uni_table[] =
0x00E0 0x00E0
}; };
_ucc_ GSM0338_uni_to_char_table[] = static _ucc_ GSM0338_uni_to_char_table[] =
{ {
{0x000A,0x0A,}, {0x000A,0x0A,},
{0x000D,0x0D,}, {0x000D,0x0D,},
@ -277,7 +276,7 @@ _ucc_ GSM0338_uni_to_char_table[] =
}; };
#define GSM0338_tsize (sizeof(GSM0338_uni_to_char_table)/sizeof(_ucc_)) #define GSM0338_tsize (sizeof(GSM0338_uni_to_char_table)/sizeof(_ucc_))
_ucc_ GSM0338_escapes[] = static _ucc_ GSM0338_escapes[] =
{ {
{0x000C,0x0A}, /* Form feed */ {0x000C,0x0A}, /* Form feed */
{0x005B,0x3C}, /* '[' */ {0x005B,0x3C}, /* '[' */
@ -300,7 +299,7 @@ _ucc_ GSM0338_escapes[] =
* a cut down version suitable for use when delivering data to phones * a cut down version suitable for use when delivering data to phones
* which don't support escape sequences. * which don't support escape sequences.
*/ */
_ucc_ GSM0338_lossy[] = static _ucc_ GSM0338_lossy[] =
{ {
{0x005B,0x3C}, /* '[' => '<' */ {0x005B,0x3C}, /* '[' => '<' */
{0x005C,0x2F}, /* '\\' => '/' */ {0x005C,0x2F}, /* '\\' => '/' */

View file

@ -10,9 +10,8 @@
// ISO_8859-2 to Unicode maping // ISO_8859-2 to Unicode maping
const unsigned int Latin2_conv_base = 0x80; static const unsigned int Latin2_conv_base = 0x80;
static unichar Latin2_char_to_uni_table[] =
unichar Latin2_char_to_uni_table[] =
{ {
0x0080, 0x0080,
0x0081, 0x0081,
@ -146,9 +145,8 @@ unichar Latin2_char_to_uni_table[] =
// Unicode to ISO_8859-2 maping // Unicode to ISO_8859-2 maping
const unsigned int Latin2_uni_to_char_table_size = 128; static const unsigned int Latin2_uni_to_char_table_size = 128;
static _ucc_ Latin2_uni_to_char_table[]=
_ucc_ Latin2_uni_to_char_table[]=
{ {
{0x0080,0x80}, {0x0080,0x80},
{0x0081,0x81}, {0x0081,0x81},

View file

@ -10,9 +10,8 @@
// ISO_8859-15 to Unicode maping // ISO_8859-15 to Unicode maping
const unsigned int Latin9_conv_base = 0x80; static const unsigned int Latin9_conv_base = 0x80;
static unichar Latin9_char_to_uni_table[] =
unichar Latin9_char_to_uni_table[] =
{ {
0x0080, 0x0080,
0x0081, 0x0081,
@ -146,9 +145,8 @@ unichar Latin9_char_to_uni_table[] =
// Unicode to ISO_8859-15 maping // Unicode to ISO_8859-15 maping
const unsigned int Latin9_uni_to_char_table_size = 128; static const unsigned int Latin9_uni_to_char_table_size = 128;
static _ucc_ Latin9_uni_to_char_table[]=
_ucc_ Latin9_uni_to_char_table[]=
{ {
{0x0080, 0x80}, {0x0080, 0x80},
{0x0081, 0x81}, {0x0081, 0x81},

View file

@ -7,8 +7,8 @@
notice and this notice are preserved. notice and this notice are preserved.
*/ */
const unsigned int Next_conv_base = 0x80; static const unsigned int Next_conv_base = 0x80;
unichar Next_char_to_uni_table[] = static unichar Next_char_to_uni_table[] =
{ {
0x00A0, 0x00A0,
0x00C0, 0x00C0,
@ -135,9 +135,8 @@ unichar Next_char_to_uni_table[] =
// Unicode to NextStep maping // Unicode to NextStep maping
const unsigned int Next_uni_to_char_table_size = 128; static const unsigned int Next_uni_to_char_table_size = 128;
static _ucc_ Next_uni_to_char_table[]=
_ucc_ Next_uni_to_char_table[]=
{ {
{0x00A0,0x80}, {0x00A0,0x80},
{0x00A1,0xA1}, {0x00A1,0xA1},

View file

@ -8,9 +8,8 @@
*/ */
const unsigned int Thai_conv_base = 0xA0; static const unsigned int Thai_conv_base = 0xA0;
static unichar Thai_char_to_uni_table[] =
unichar Thai_char_to_uni_table[] =
{ {
0x00A0, 0x00A0,
0x0E01, 0x0E01,
@ -112,9 +111,8 @@ unichar Thai_char_to_uni_table[] =
/* Unicode to ISO_8859-11 maping */ /* Unicode to ISO_8859-11 maping */
const unsigned int Thai_uni_to_char_table_size = 88; static const unsigned int Thai_uni_to_char_table_size = 88;
static _ucc_ Thai_uni_to_char_table[]=
_ucc_ Thai_uni_to_char_table[]=
{ {
{0x00A0,0xA0}, {0x00A0,0xA0},
{0x0E01,0xA1}, {0x0E01,0xA1},

View file

@ -370,17 +370,8 @@ NSValue.h \
NSXMLParser.h \ NSXMLParser.h \
NSZone.h NSZone.h
UNICODE_HEADERS = \
unicode/caseconv.h \
unicode/cop.h \
unicode/cyrillic.h \
unicode/latin2.h \
unicode/decomp.h \
unicode/nextstep.h
HEADERS_INSTALL = $(GNU_HEADERS) \ HEADERS_INSTALL = $(GNU_HEADERS) \
$(FOUNDATION_HEADERS) \ $(FOUNDATION_HEADERS)
$(UNICODE_HEADERS)
GENERATED_HFILES = \ GENERATED_HFILES = \
dynamic-load.h \ dynamic-load.h \

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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" #include "config.h"
@ -43,17 +44,17 @@ static double rint(double a)
BOOL GSMacOSXCompatibleGeometry(void) BOOL GSMacOSXCompatibleGeometry(void)
{ {
if (GSUserDefaultsFlag(GSOldStyleGeometry) == YES) if ([_GSPrivate userDefaultsFlag: GSOldStyleGeometry] == YES)
return NO; return NO;
return GSUserDefaultsFlag(GSMacOSXCompatible); return [_GSPrivate userDefaultsFlag: GSMacOSXCompatible];
} }
BOOL GSMacOSXCompatiblePropertyLists(void) BOOL GSMacOSXCompatiblePropertyLists(void)
{ {
#if defined(HAVE_LIBXML) #if defined(HAVE_LIBXML)
if (GSUserDefaultsFlag(NSWriteOldStylePropertyLists) == YES) if ([_GSPrivate userDefaultsFlag: NSWriteOldStylePropertyLists] == YES)
return NO; return NO;
return GSUserDefaultsFlag(GSMacOSXCompatible); return [_GSPrivate userDefaultsFlag: GSMacOSXCompatible];
#else #else
return NO; return NO;
#endif #endif

View file

@ -168,7 +168,7 @@ gs_offset(const char *type, int index)
/* Determines if the structure type can be returned entirely in registers. /* Determines if the structure type can be returned entirely in registers.
See the avcall or vacall man pages for more info. FIXME: I'm betting See the avcall or vacall man pages for more info. FIXME: I'm betting
this won't work if a structure contains another structure */ this won't work if a structure contains another structure */
int static int
gs_splittable (const char *type) gs_splittable (const char *type)
{ {
int i, numtypes; int i, numtypes;
@ -297,7 +297,7 @@ gs_find_by_receiver_best_typed_sel (id receiver, SEL sel)
Only passes the first part. Is used for determining Only passes the first part. Is used for determining
the return type for the vacall macros. the return type for the vacall macros.
*/ */
void static void
gs_sel_type_to_callback_type (const char *sel_type, gs_sel_type_to_callback_type (const char *sel_type,
vacallReturnTypeInfo *vatype) vacallReturnTypeInfo *vatype)
{ {

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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" #include "config.h"
@ -36,6 +37,7 @@
#include "Foundation/NSFileHandle.h" #include "Foundation/NSFileHandle.h"
#include "Foundation/NSDebug.h" #include "Foundation/NSDebug.h"
#include "GNUstepBase/GSMime.h" #include "GNUstepBase/GSMime.h"
#include "GSPrivate.h"
GS_EXPORT NSString * const GSTelnetNotification; GS_EXPORT NSString * const GSTelnetNotification;
GS_EXPORT NSString * const GSTelnetErrorKey; GS_EXPORT NSString * const GSTelnetErrorKey;
@ -972,14 +974,12 @@ static NSLock *urlLock = nil;
protocol: @"tcp"]; protocol: @"tcp"];
if (sock == nil) if (sock == nil)
{ {
extern int errno;
/* /*
* Tell superclass that the load failed - let it do housekeeping. * Tell superclass that the load failed - let it do housekeeping.
*/ */
[self backgroundLoadDidFailWithReason: [NSString stringWithFormat: [self backgroundLoadDidFailWithReason: [NSString stringWithFormat:
@"Unable to connect to %@:%@ ... %s", @"Unable to connect to %@:%@ ... %@",
host, port, GSLastErrorStr(errno)]]; host, port, [_GSPrivate error]]];
return; return;
} }
cHandle = [[GSTelnetHandle alloc] initWithHandle: sock isConnected: NO]; cHandle = [[GSTelnetHandle alloc] initWithHandle: sock isConnected: NO];

View file

@ -42,6 +42,7 @@
#include "Foundation/NSProcessInfo.h" #include "Foundation/NSProcessInfo.h"
#include "Foundation/NSUserDefaults.h" #include "Foundation/NSUserDefaults.h"
#include "Foundation/NSDebug.h" #include "Foundation/NSDebug.h"
#include "GSPrivate.h"
#include "../Tools/gdomap.h" #include "../Tools/gdomap.h"
@ -797,7 +798,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error: errno]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -811,8 +812,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == -1) if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == -1)
{ {
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(lsin.sin_addr), NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr),
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error: errno]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -830,9 +831,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (errno != EINPROGRESS) if (errno != EINPROGRESS)
{ {
NSLog(@"unable to make connection to %s:%d - %s", NSLog(@"unable to make connection to %s:%d - %@",
inet_ntoa(sin.sin_addr), inet_ntoa(sin.sin_addr),
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -896,7 +897,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -913,8 +914,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == -1) if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == -1)
{ {
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr), NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -922,7 +923,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (listen(net, 256) == -1) if (listen(net, 256) == -1)
{ {
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); NSLog(@"unable to listen on port - %@", [_GSPrivate error]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -930,7 +931,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (getsockname(net, (struct sockaddr*)&sin, &size) == -1) if (getsockname(net, (struct sockaddr*)&sin, &size) == -1)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
(void) close(net); (void) close(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -1095,8 +1096,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (fstat(desc, &sbuf) < 0) if (fstat(desc, &sbuf) < 0)
{ {
NSLog(@"unable to get status of descriptor %d - %s", NSLog(@"unable to get status of descriptor %d - %@",
desc, GSLastErrorStr(errno)); desc, [_GSPrivate error]);
} }
else else
{ {
@ -1317,8 +1318,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (len < 0) if (len < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return d; return d;
} }
@ -1342,8 +1343,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (len < 0) if (len < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return d; return d;
} }
@ -1368,8 +1369,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (got < 0) if (got < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
[d setLength: got]; [d setLength: got];
} }
@ -1391,8 +1392,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else if (got < 0) else if (got < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
} }
while (len > 0 && got > 0); while (len > 0 && got > 0);
@ -1437,8 +1438,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (rval < 0) if (rval < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to write to descriptor - %s", format: @"unable to write to descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
} }
@ -1543,8 +1544,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (result < 0) if (result < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"failed to move to offset in file - %s", format: @"failed to move to offset in file - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return (unsigned long long)result; return (unsigned long long)result;
} }
@ -1567,8 +1568,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (result < 0) if (result < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"failed to move to offset in file - %s", format: @"failed to move to offset in file - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return (unsigned long long)result; return (unsigned long long)result;
} }
@ -1591,8 +1592,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (result < 0) if (result < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"failed to move to offset in file - %s", format: @"failed to move to offset in file - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
} }
@ -1927,8 +1928,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Accept attempt failed - %s", s = [NSString stringWithFormat: @"Accept attempt failed - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
[readInfo setObject: s forKey: GSFileHandleNotificationError]; [readInfo setObject: s forKey: GSFileHandleNotificationError];
} }
else else
@ -1995,8 +1996,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Read attempt failed - %s", s = [NSString stringWithFormat: @"Read attempt failed - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
[readInfo setObject: s forKey: GSFileHandleNotificationError]; [readInfo setObject: s forKey: GSFileHandleNotificationError];
[self postReadNotification]; [self postReadNotification];
} }
@ -2031,8 +2032,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Connect attempt failed - %s", s = [NSString stringWithFormat: @"Connect attempt failed - %@",
GSLastErrorStr(result)]; [_GSPrivate error]];
[info setObject: s forKey: GSFileHandleNotificationError]; [info setObject: s forKey: GSFileHandleNotificationError];
} }
else else
@ -2065,7 +2066,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
NSString *s; NSString *s;
s = [NSString stringWithFormat: s = [NSString stringWithFormat:
@"Write attempt failed - %s", GSLastErrorStr(errno)]; @"Write attempt failed - %@", [_GSPrivate error]];
[info setObject: s forKey: GSFileHandleNotificationError]; [info setObject: s forKey: GSFileHandleNotificationError];
[self postWriteNotification]; [self postWriteNotification];
} }
@ -2141,8 +2142,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
} }
if (fcntl(descriptor, F_SETFL, e) < 0) if (fcntl(descriptor, F_SETFL, e) < 0)
{ {
NSLog(@"unable to set non-blocking mode for %d - %s", NSLog(@"unable to set non-blocking mode for %d - %@",
descriptor, GSLastErrorStr(errno)); descriptor, [_GSPrivate error]);
} }
else else
{ {
@ -2151,8 +2152,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
} }
else else
{ {
NSLog(@"unable to get non-blocking mode for %d - %s", NSLog(@"unable to get non-blocking mode for %d - %@",
descriptor, GSLastErrorStr(errno)); descriptor, [_GSPrivate error]);
} }
} }
} }
@ -2170,11 +2171,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1) if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
} }
else else
{ {
str = [NSString stringWithCString: (char*)inet_ntoa(sin.sin_addr)]; str = [NSString stringWithUTF8String: (char*)inet_ntoa(sin.sin_addr)];
} }
return str; return str;
} }
@ -2187,7 +2188,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1) if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == -1)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
} }
else else
{ {

View file

@ -758,6 +758,10 @@ parse_one_spec (const unichar *format, size_t posn, struct printf_spec *spec,
return nargs; return nargs;
} }
static inline void GSStrAppendUnichar(GSStr s, unichar u)
{
GSStrAppendUnichars(s, &u, 1);
}
#define outchar(Ch) GSStrAppendUnichar(s, Ch) #define outchar(Ch) GSStrAppendUnichar(s, Ch)
#define outstring(String, Len) GSStrAppendUnichars(s, String, Len) #define outstring(String, Len) GSStrAppendUnichars(s, String, Len)
@ -1690,9 +1694,9 @@ NSDictionary *locale)
LABEL (form_strerror): LABEL (form_strerror):
/* Print description of error ERRNO. */ /* Print description of error ERRNO. */
string = string = (unichar *)[[_GSPrivate error: save_errno]
(unichar *) GSLastErrorStr(save_errno); cStringUsingEncoding: NSUnicodeStringEncoding];
is_long = 0; /* This is no wide-char string. */ is_long = 1; /* This is a unicode string. */
goto LABEL (print_string); goto LABEL (print_string);
LABEL (form_character): LABEL (form_character):
/* Character. */ /* Character. */
@ -1735,7 +1739,7 @@ NSDictionary *locale)
{ {
/* Write "(null)" if there's space. */ /* Write "(null)" if there's space. */
if (prec == -1 if (prec == -1
|| prec >= (int) (sizeof (null) / sizeof (null[0])) - 1) || prec >= (int) (sizeof (null) / sizeof (null[0])) - 1)
{ {
string = (unichar *) null; string = (unichar *) null;
len = (sizeof (null) / sizeof (null[0])) - 1; len = (sizeof (null) / sizeof (null[0])) - 1;
@ -1757,8 +1761,8 @@ NSDictionary *locale)
if (enc == GSUndefinedEncoding) if (enc == GSUndefinedEncoding)
{ {
enc = GetDefEncoding(); enc = [NSString defaultCStringEncoding];
byteEncoding = GSIsByteEncoding(enc); byteEncoding = [_GSPrivate isByteEncoding: enc];
} }
len = strlen(str); // Number of bytes to convert. len = strlen(str); // Number of bytes to convert.

View file

@ -45,6 +45,7 @@
#include "GNUstepBase/GSLock.h" #include "GNUstepBase/GSLock.h"
#include "NSCallBacks.h" #include "NSCallBacks.h"
#include "GSURLPrivate.h" #include "GSURLPrivate.h"
#include "GSPrivate.h"
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -1267,8 +1268,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
* Tell superclass that the load failed - let it do housekeeping. * Tell superclass that the load failed - let it do housekeeping.
*/ */
[self backgroundLoadDidFailWithReason: [self backgroundLoadDidFailWithReason:
[NSString stringWithFormat: @"Unable to connect to %@:%@ ... %s", [NSString stringWithFormat: @"Unable to connect to %@:%@ ... %@",
host, port, GSLastErrorStr(errno)]]; host, port, [_GSPrivate error]]];
return; return;
} }
RETAIN(sock); RETAIN(sock);

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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" #include "config.h"
#include "GNUstepBase/GSLocale.h" #include "GNUstepBase/GSLocale.h"
@ -75,12 +76,12 @@ GSSetLocale(int category, NSString *locale)
locale = nil; locale = nil;
if (clocale != 0) if (clocale != 0)
{ {
locale = [NSString stringWithCString: clocale]; locale = [NSString stringWithUTF8String: clocale];
} }
return locale; return locale;
} }
#define GSLanginfo(value) [NSString stringWithCString: nl_langinfo (value)] #define GSLanginfo(value) [NSString stringWithUTF8String: nl_langinfo (value)]
/* Creates a locale dictionary from information provided by i18n functions. /* Creates a locale dictionary from information provided by i18n functions.
Many, but not all, of the keys are filled in or inferred from the Many, but not all, of the keys are filled in or inferred from the
@ -154,33 +155,33 @@ GSDomainFromDefaultLocale(void)
/* Currency Information */ /* Currency Information */
if (lconv->currency_symbol) if (lconv->currency_symbol)
{ {
[dict setObject: [NSString stringWithCString: lconv->currency_symbol] [dict setObject: [NSString stringWithUTF8String: lconv->currency_symbol]
forKey: NSCurrencySymbol]; forKey: NSCurrencySymbol];
} }
if (lconv->int_curr_symbol) if (lconv->int_curr_symbol)
{ {
[dict setObject: [NSString stringWithCString: lconv->int_curr_symbol] [dict setObject: [NSString stringWithUTF8String: lconv->int_curr_symbol]
forKey: NSInternationalCurrencyString]; forKey: NSInternationalCurrencyString];
} }
if (lconv->mon_decimal_point) if (lconv->mon_decimal_point)
{ {
[dict setObject: [NSString stringWithCString: lconv->mon_decimal_point] [dict setObject: [NSString stringWithUTF8String: lconv->mon_decimal_point]
forKey: NSInternationalCurrencyString]; forKey: NSInternationalCurrencyString];
} }
if (lconv->mon_thousands_sep) if (lconv->mon_thousands_sep)
{ {
[dict setObject: [NSString stringWithCString: lconv->mon_thousands_sep] [dict setObject: [NSString stringWithUTF8String: lconv->mon_thousands_sep]
forKey: NSInternationalCurrencyString]; forKey: NSInternationalCurrencyString];
} }
if (lconv->decimal_point) if (lconv->decimal_point)
{ {
[dict setObject: [NSString stringWithCString: lconv->decimal_point] [dict setObject: [NSString stringWithUTF8String: lconv->decimal_point]
forKey: NSDecimalSeparator]; forKey: NSDecimalSeparator];
} }
if (lconv->thousands_sep) if (lconv->thousands_sep)
{ {
[dict setObject: [NSString stringWithCString: lconv->thousands_sep] [dict setObject: [NSString stringWithUTF8String: lconv->thousands_sep]
forKey: NSThousandsSeparator]; forKey: NSThousandsSeparator];
} }

View file

@ -38,6 +38,7 @@
#include "GNUstepBase/GSObjCRuntime.h" #include "GNUstepBase/GSObjCRuntime.h"
#include "Foundation/NSString.h"
/** /**
* Macro to manage memory for chunks of code that need to work with * Macro to manage memory for chunks of code that need to work with
@ -100,17 +101,6 @@
because NXConstantString returns a pointer because NXConstantString returns a pointer
to it's internal pointer. */ to it's internal pointer. */
/*
* Function to get the name of a string encoding as an NSString.
*/
GS_EXPORT NSString *GSEncodingName(NSStringEncoding encoding);
/*
* Function to determine whether data in a particular encoding can
* generally be represented as 8-bit characters including ascii.
*/
GS_EXPORT BOOL GSIsByteEncoding(NSStringEncoding encoding);
/* /*
* Type to hold either UTF-16 (unichar) or 8-bit encodings, * Type to hold either UTF-16 (unichar) or 8-bit encodings,
* while satisfying alignment constraints. * while satisfying alignment constraints.
@ -173,10 +163,15 @@ typedef struct {
typedef GSStr_t *GSStr; typedef GSStr_t *GSStr;
/* /*
* Functions to append to GSStr * Function to append to GSStr
*/ */
extern void GSStrAppendUnichar(GSStr s, unichar);
extern void GSStrAppendUnichars(GSStr s, const unichar *u, unsigned l); extern void GSStrAppendUnichars(GSStr s, const unichar *u, unsigned l);
/*
* Make the content of this string into unicode if it is not in
* the external defaults C string encoding.
*/
void GSStrExternalize(GSStr s);
/* /*
* Enumeration for MacOS-X compatibility user defaults settings. * Enumeration for MacOS-X compatibility user defaults settings.
@ -192,21 +187,6 @@ typedef enum {
GSUserDefaultMaxFlag // End marker. GSUserDefaultMaxFlag // End marker.
} GSUserDefaultFlagType; } GSUserDefaultFlagType;
/*
* Get the dictionary representation.
*/
NSDictionary *GSUserDefaultsDictionaryRepresentation(void);
/*
* Get one of several potentially useful flags.
*/
BOOL GSUserDefaultsFlag(GSUserDefaultFlagType type);
/**
* Get a flag from an environment variable - return def if not defined.
*/
BOOL GSEnvironmentFlag(const char *name, BOOL def);
/** /**
@ -238,5 +218,68 @@ extern void GSNotifyASAP(void);
extern void GSNotifyIdle(void); extern void GSNotifyIdle(void);
extern BOOL GSNotifyMore(void); extern BOOL GSNotifyMore(void);
/* 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/GSCategories.h), 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
@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 the dictionary representation.
*/
+ (NSDictionary*) userDefaultsDictionaryRepresentation;
/*
* Get one of several potentially useful flags.
*/
+ (BOOL) userDefaultsFlag: (GSUserDefaultFlagType)type;
@end
#endif /* __GSPrivate_h_ */ #endif /* __GSPrivate_h_ */

View file

@ -34,6 +34,7 @@
#include <Foundation/NSDebug.h> #include <Foundation/NSDebug.h>
#include "GSStream.h" #include "GSStream.h"
#include "GSPrivate.h"
NSString * const NSStreamDataWrittenToMemoryStreamKey NSString * const NSStreamDataWrittenToMemoryStreamKey
= @"NSStreamDataWrittenToMemoryStreamKey"; = @"NSStreamDataWrittenToMemoryStreamKey";
@ -364,7 +365,7 @@ static RunLoopEventType typeForStream(NSStream *aStream)
theError = [NSError errorWithDomain: NSPOSIXErrorDomain theError = [NSError errorWithDomain: NSPOSIXErrorDomain
code: errno code: errno
userInfo: nil]; userInfo: nil];
NSLog(@"%@ error(%d): - %s", self, errno, GSLastErrorStr(errno)); NSLog(@"%@ error(%d): - %@", self, errno, [_GSPrivate error]);
ASSIGN(_lastError, theError); ASSIGN(_lastError, theError);
_currentStatus = NSStreamStatusError; _currentStatus = NSStreamStatusError;
} }

View file

@ -52,12 +52,15 @@
#include "GSPrivate.h" #include "GSPrivate.h"
extern BOOL GSEncodingSupported(NSStringEncoding enc);
/* memcpy(), strlen(), strcmp() are gcc builtin's */ /* memcpy(), strlen(), strcmp() are gcc builtin's */
#include "GNUstepBase/Unicode.h" #include "GNUstepBase/Unicode.h"
static BOOL isByteEncoding(NSStringEncoding enc)
{
return [_GSPrivate isByteEncoding: enc];
}
#ifdef NeXT_RUNTIME #ifdef NeXT_RUNTIME
/* Used by the Darwin/NeXT ObjC Runtime /* Used by the Darwin/NeXT ObjC Runtime
until Apple Radar 2870817 is fixed. */ until Apple Radar 2870817 is fixed. */
@ -249,10 +252,18 @@ setup(void)
if (beenHere == NO) if (beenHere == NO)
{ {
extern NSStringEncoding GetDefEncoding(void);
beenHere = YES; beenHere = YES;
/*
* Cache the default string encoding, and set the internal encoding
* used by 8-bit character strings to match if possible.
*/
externalEncoding = [_GSPrivate defaultCStringEncoding];
if (isByteEncoding(externalEncoding) == YES)
{
internalEncoding = externalEncoding;
}
/* /*
* Cache pointers to classes to work round misfeature in * Cache pointers to classes to work round misfeature in
* GNU compiler/runtime system where class lookup is very slow. * GNU compiler/runtime system where class lookup is very slow.
@ -290,16 +301,6 @@ setup(void)
caiSel = @selector(characterAtIndex:); caiSel = @selector(characterAtIndex:);
gcrSel = @selector(getCharacters:range:); gcrSel = @selector(getCharacters:range:);
ranSel = @selector(rangeOfComposedCharacterSequenceAtIndex:); ranSel = @selector(rangeOfComposedCharacterSequenceAtIndex:);
/*
* Cache the default string encoding, and set the internal encoding
* used by 8-bit character strings to match if possible.
*/
externalEncoding = GetDefEncoding();
if (GSIsByteEncoding(externalEncoding) == YES)
{
internalEncoding = externalEncoding;
}
} }
} }
@ -450,7 +451,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
void *chars = 0; void *chars = 0;
BOOL flag = NO; BOOL flag = NO;
if (GSEncodingSupported(encoding) == NO) if ([_GSPrivate isEncodingSupported: encoding] == NO)
{ {
return nil; // Invalid encoding return nil; // Invalid encoding
} }
@ -493,7 +494,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
BOOL isLatin1 = NO; BOOL isLatin1 = NO;
GSStr me; GSStr me;
if (GSEncodingSupported(encoding) == NO) if ([_GSPrivate isEncodingSupported: encoding] == NO)
{ {
if (flag == YES && bytes != 0) if (flag == YES && bytes != 0)
{ {
@ -535,7 +536,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
encoding = internalEncoding; encoding = internalEncoding;
} }
} }
else if (encoding != internalEncoding && GSIsByteEncoding(encoding) == YES) else if (encoding != internalEncoding && isByteEncoding(encoding) == YES)
{ {
unsigned i; unsigned i;
@ -1025,7 +1026,7 @@ canBeConvertedToEncoding_c(GSStr self, NSStringEncoding enc)
&& enc != internalEncoding && enc != internalEncoding
&& enc != NSUTF8StringEncoding && enc != NSUTF8StringEncoding
&& enc != NSUnicodeStringEncoding && enc != NSUnicodeStringEncoding
&& ((internalEncoding != NSASCIIStringEncoding) || !GSIsByteEncoding(enc))) && ((internalEncoding != NSASCIIStringEncoding) || !isByteEncoding(enc)))
{ {
unsigned l = 0; unsigned l = 0;
unichar *r = 0; unichar *r = 0;
@ -1403,7 +1404,7 @@ dataUsingEncoding_c(GSStr self, NSStringEncoding encoding, BOOL lossy)
if ((encoding == internalEncoding) if ((encoding == internalEncoding)
|| ((internalEncoding == NSASCIIStringEncoding) || ((internalEncoding == NSASCIIStringEncoding)
&& (encoding == NSUTF8StringEncoding || GSIsByteEncoding(encoding)))) && (encoding == NSUTF8StringEncoding || isByteEncoding(encoding))))
{ {
unsigned char *buff; unsigned char *buff;
@ -1787,7 +1788,7 @@ getCStringE_c(GSStr self, char *buffer, unsigned int maxLength,
} }
if (enc == NSUTF8StringEncoding if (enc == NSUTF8StringEncoding
&& GSIsByteEncoding(internalEncoding)) && isByteEncoding(internalEncoding))
{ {
unsigned i; unsigned i;
@ -1822,7 +1823,7 @@ getCStringE_c(GSStr self, char *buffer, unsigned int maxLength,
} }
if (enc == NSASCIIStringEncoding if (enc == NSASCIIStringEncoding
&& GSIsByteEncoding(internalEncoding)) && isByteEncoding(internalEncoding))
{ {
unsigned i; unsigned i;
@ -3759,7 +3760,7 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
encoding = internalEncoding; encoding = internalEncoding;
} }
} }
else if (encoding != internalEncoding && GSIsByteEncoding(encoding) == YES) else if (encoding != internalEncoding && isByteEncoding(encoding) == YES)
{ {
unsigned i; unsigned i;
@ -5078,44 +5079,7 @@ void GSStrAppendUnichars(GSStr s, const unichar *u, unsigned l)
} }
} }
void GSStrAppendUnichar(GSStr s, unichar u)
{
/*
* Make the string wide if necessary.
*/
if (s->_flags.wide == 0)
{
if (u > 255 || (u > 127 && internalEncoding != NSISOLatin1StringEncoding))
{
GSStrWiden(s);
}
}
/*
* Make room for the characters we are appending.
*/
if (s->_count + 2 >= s->_capacity)
{
GSStrMakeSpace(s, 1);
}
/*
* Copy the characters into place.
*/
if (s->_flags.wide == 1)
{
s->_contents.u[s->_count++] = u;
}
else
{
s->_contents.c[s->_count++] = u;
}
}
/*
* Make the content of this string into unicode if it is not in
* the external defaults C string encoding.
*/
void GSStrExternalize(GSStr s) void GSStrExternalize(GSStr s)
{ {
if (s->_flags.wide == 0 && internalEncoding != externalEncoding) if (s->_flags.wide == 0 && internalEncoding != externalEncoding)

View file

@ -858,7 +858,7 @@ static Class NSMutableDataMallocClass;
if (node) if (node)
{ {
c = (Class)node->value.ptr; c = (Class)node->value.ptr;
return [NSString stringWithCString: GSNameFromClass(c)]; return [NSString stringWithUTF8String: GSNameFromClass(c)];
} }
} }
return trueName; return trueName;

View file

@ -1202,7 +1202,7 @@ compare(id elem1, id elem2, void* context)
*/ */
- (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile - (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
{ {
NSDictionary *loc = GSUserDefaultsDictionaryRepresentation(); NSDictionary *loc = [_GSPrivate userDefaultsDictionaryRepresentation];
NSString *desc = nil; NSString *desc = nil;
NSData *data; NSData *data;
@ -1228,7 +1228,7 @@ compare(id elem1, id elem2, void* context)
*/ */
- (BOOL) writeToURL: (NSURL *)url atomically: (BOOL)useAuxiliaryFile - (BOOL) writeToURL: (NSURL *)url atomically: (BOOL)useAuxiliaryFile
{ {
NSDictionary *loc = GSUserDefaultsDictionaryRepresentation(); NSDictionary *loc = [_GSPrivate userDefaultsDictionaryRepresentation];
NSString *desc = nil; NSString *desc = nil;
NSData *data; NSData *data;

View file

@ -50,7 +50,7 @@
#include "Foundation/NSPathUtilities.h" #include "Foundation/NSPathUtilities.h"
#include "Foundation/NSData.h" #include "Foundation/NSData.h"
#include "Foundation/NSValue.h" #include "Foundation/NSValue.h"
#include "GNUstepBase/GSFunctions.h"
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -226,7 +226,7 @@ static NSString *ExecutablePath()
#ifdef PROCFS_EXE_LINK #ifdef PROCFS_EXE_LINK
executablePath = [[NSFileManager defaultManager] executablePath = [[NSFileManager defaultManager]
pathContentOfSymbolicLinkAtPath: pathContentOfSymbolicLinkAtPath:
[NSString stringWithCString: PROCFS_EXE_LINK]]; [NSString stringWithUTF8String: PROCFS_EXE_LINK]];
/* /*
On some systems, the link is of the form "[device]:inode", which On some systems, the link is of the form "[device]:inode", which
@ -377,11 +377,29 @@ _bundle_name_first_match(NSString* directory, NSString* name)
static inline NSString * static inline NSString *
_find_framework(NSString *name) _find_framework(NSString *name)
{ {
NSArray *paths; NSArray *paths;
NSFileManager *file_mgr = [NSFileManager defaultManager];
NSString *file_name;
NSString *file_path;
NSString *path;
NSEnumerator *enumerator;
NSCParameterAssert(name != nil);
paths = NSSearchPathForDirectoriesInDomains(GSFrameworksDirectory, paths = NSSearchPathForDirectoriesInDomains(GSFrameworksDirectory,
NSAllDomainsMask,YES); NSAllDomainsMask,YES);
return GSFindNamedFile(paths, name, @"framework");
enumerator = [paths objectEnumerator];
while ((path = [enumerator nextObject]))
{
file_path = [path stringByAppendingPathComponent: file_name];
if ([file_mgr fileExistsAtPath: file_path] == YES)
{
return file_path; // Found it!
}
}
return nil;
} }
@interface NSBundle (Private) @interface NSBundle (Private)
@ -464,8 +482,9 @@ _find_framework(NSString *name)
&& !strncmp ("NSFramework_", frameworkClass->name, 12)) && !strncmp ("NSFramework_", frameworkClass->name, 12))
{ {
/* The name of the framework. */ /* The name of the framework. */
NSString *name = [NSString stringWithCString: &frameworkClass->name[12]]; NSString *name;
name = [NSString stringWithUTF8String: &frameworkClass->name[12]];
/* Important - gnustep-make mangles framework names to encode /* Important - gnustep-make mangles framework names to encode
* them as ObjC class names. Here we need to demangle them. We * them as ObjC class names. Here we need to demangle them. We
* apply the reverse transformations in the reverse order. * apply the reverse transformations in the reverse order.

View file

@ -653,7 +653,7 @@ static inline int getDigits(const char *from, char *to, int limit)
sourceLen = strlen(source); sourceLen = strlen(source);
if (locale == nil) if (locale == nil)
{ {
locale = GSUserDefaultsDictionaryRepresentation(); locale = [_GSPrivate userDefaultsDictionaryRepresentation];
} }
if (fmt == nil) if (fmt == nil)
{ {
@ -1064,7 +1064,7 @@ static inline int getDigits(const char *from, char *to, int limit)
NSString *currAMPM; NSString *currAMPM;
NSArray *amPMNames; NSArray *amPMNames;
currAMPM = [NSString stringWithCString: tmpStr]; currAMPM = [NSString stringWithUTF8String: tmpStr];
amPMNames = [locale objectForKey: NSAMPMDesignation]; amPMNames = [locale objectForKey: NSAMPMDesignation];
/* /*
@ -1170,7 +1170,7 @@ static inline int getDigits(const char *from, char *to, int limit)
tmpStr[tmpIdx - sourceIdx] = '\0'; tmpStr[tmpIdx - sourceIdx] = '\0';
sourceIdx += tmpIdx - sourceIdx; sourceIdx += tmpIdx - sourceIdx;
{ {
NSString *z = [NSString stringWithCString: tmpStr]; NSString *z = [NSString stringWithUTF8String: tmpStr];
/* Abbreviations aren't one-to-one with time zone names /* Abbreviations aren't one-to-one with time zone names
so just look for the zone named after the abbreviation, so just look for the zone named after the abbreviation,
@ -2191,7 +2191,7 @@ static void Grow(DescriptionInfo *info, unsigned size)
DescriptionInfo info; DescriptionInfo info;
if (locale == nil) if (locale == nil)
locale = GSUserDefaultsDictionaryRepresentation(); locale = [_GSPrivate userDefaultsDictionaryRepresentation];
if (format == nil) if (format == nil)
format = [locale objectForKey: NSTimeDateFormatString]; format = [locale objectForKey: NSTimeDateFormatString];

View file

@ -80,6 +80,7 @@
#include "Foundation/NSRange.h" #include "Foundation/NSRange.h"
#include "Foundation/NSURL.h" #include "Foundation/NSURL.h"
#include "Foundation/NSZone.h" #include "Foundation/NSZone.h"
#include "GSPrivate.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> /* for memset() */ #include <string.h> /* for memset() */
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -163,8 +164,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
if (theFile == 0) /* We failed to open the file. */ if (theFile == 0) /* We failed to open the file. */
{ {
NSWarnFLog(@"Open (%@) attempt failed - %s", path, NSWarnFLog(@"Open (%@) attempt failed - %@", path, [_GSPrivate error]);
GSLastErrorStr(errno));
goto failure; goto failure;
} }
@ -174,8 +174,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
c = fseek(theFile, 0L, SEEK_END); c = fseek(theFile, 0L, SEEK_END);
if (c != 0) if (c != 0)
{ {
NSWarnFLog(@"Seek to end of file (%@) failed - %s", path, NSWarnFLog(@"Seek to end of file (%@) failed - %@", path,
GSLastErrorStr(errno)); [_GSPrivate error]);
goto failure; goto failure;
} }
@ -186,8 +186,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
fileLength = ftell(theFile); fileLength = ftell(theFile);
if (fileLength == -1) if (fileLength == -1)
{ {
NSWarnFLog(@"Ftell on %@ failed - %s", path, NSWarnFLog(@"Ftell on %@ failed - %@", path, [_GSPrivate error]);
GSLastErrorStr(errno));
goto failure; goto failure;
} }
@ -198,8 +197,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
c = fseek(theFile, 0L, SEEK_SET); c = fseek(theFile, 0L, SEEK_SET);
if (c != 0) if (c != 0)
{ {
NSWarnFLog(@"Fseek to start of file (%@) failed - %s", path, NSWarnFLog(@"Fseek to start of file (%@) failed - %@", path,
GSLastErrorStr(errno)); [_GSPrivate error]);
goto failure; goto failure;
} }
@ -224,8 +223,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
} }
if (tmp == 0) if (tmp == 0)
{ {
NSLog(@"Malloc failed for file (%@) of length %d - %s", path, NSLog(@"Malloc failed for file (%@) of length %d - %@", path,
fileLength + c, GSLastErrorStr(errno)); fileLength + c, [_GSPrivate error]);
goto failure; goto failure;
} }
memcpy(tmp + fileLength, buf, c); memcpy(tmp + fileLength, buf, c);
@ -237,16 +236,16 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
tmp = NSZoneMalloc(zone, fileLength); tmp = NSZoneMalloc(zone, fileLength);
if (tmp == 0) if (tmp == 0)
{ {
NSLog(@"Malloc failed for file (%@) of length %d - %s", path, NSLog(@"Malloc failed for file (%@) of length %d - %@", path,
fileLength, GSLastErrorStr(errno)); fileLength, [_GSPrivate error]);
goto failure; goto failure;
} }
c = fread(tmp, 1, fileLength, theFile); c = fread(tmp, 1, fileLength, theFile);
if (c != (int)fileLength) if (c != (int)fileLength)
{ {
NSWarnFLog(@"read of file (%@) contents failed - %s", path, NSWarnFLog(@"read of file (%@) contents failed - %@", path,
GSLastErrorStr(errno)); [_GSPrivate error]);
goto failure; goto failure;
} }
} }
@ -852,8 +851,7 @@ failure:
strcat(thePath, "XXXXXX"); strcat(thePath, "XXXXXX");
if ((desc = mkstemp(thePath)) < 0) if ((desc = mkstemp(thePath)) < 0)
{ {
NSWarnMLog(@"mkstemp (%s) failed - %s", thePath, NSWarnMLog(@"mkstemp (%s) failed - %@", thePath, [_GSPrivate error]);
GSLastErrorStr(errno));
goto failure; goto failure;
} }
mask = umask(0); mask = umask(0);
@ -880,9 +878,9 @@ failure:
wcscat(wthePath, L"XXXXXX"); wcscat(wthePath, L"XXXXXX");
if (_wmktemp(wthePath) == 0) if (_wmktemp(wthePath) == 0)
{ {
NSWarnMLog(@"mktemp (%@) failed - %s", NSWarnMLog(@"mktemp (%@) failed - %@",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)], [NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
GSLastErrorStr(errno)); [_GSPrivate error]);
goto failure; goto failure;
} }
#else #else
@ -890,8 +888,7 @@ failure:
strcat(thePath, "XXXXXX"); strcat(thePath, "XXXXXX");
if (mktemp(thePath) == 0) if (mktemp(thePath) == 0)
{ {
NSWarnMLog(@"mktemp (%s) failed - %s", thePath, NSWarnMLog(@"mktemp (%s) failed - %@", thePath, [_GSPrivate error]);
GSLastErrorStr(errno));
goto failure; goto failure;
} }
#endif #endif
@ -918,11 +915,11 @@ failure:
/* Something went wrong; we weren't /* Something went wrong; we weren't
* even able to open the file. */ * even able to open the file. */
#if defined(__MINGW32__) #if defined(__MINGW32__)
NSWarnMLog(@"Open (%@) failed - %s", NSWarnMLog(@"Open (%@) failed - %@",
[NSString stringWithCharacters: wthePath length: wcslen(wthePath)], [NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
GSLastErrorStr(errno)); [_GSPrivate error]);
#else #else
NSWarnMLog(@"Open (%s) failed - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"Open (%s) failed - %@", thePath, [_GSPrivate error]);
#endif #endif
goto failure; goto failure;
} }
@ -936,11 +933,11 @@ failure:
* some reason. */ * some reason. */
{ {
#if defined(__MINGW32__) #if defined(__MINGW32__)
NSWarnMLog(@"Fwrite (%@) failed - %s", NSWarnMLog(@"Fwrite (%@) failed - %@",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)], [NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
GSLastErrorStr(errno)); [_GSPrivate error]);
#else #else
NSWarnMLog(@"Fwrite (%s) failed - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"Fwrite (%s) failed - %@", thePath, [_GSPrivate error]);
#endif #endif
goto failure; goto failure;
} }
@ -953,11 +950,11 @@ failure:
* so we need to deal with it. */ * so we need to deal with it. */
{ {
#if defined(__MINGW32__) #if defined(__MINGW32__)
NSWarnMLog(@"Fclose (%@) failed - %s", NSWarnMLog(@"Fclose (%@) failed - %@",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)], [NSString stringWithCharacters: wthePath length: wcslen(wthePath)],
GSLastErrorStr(errno)); [_GSPrivate error]);
#else #else
NSWarnMLog(@"Fclose (%s) failed - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"Fclose (%s) failed - %@", thePath, [_GSPrivate error]);
#endif #endif
goto failure; goto failure;
} }
@ -1038,14 +1035,15 @@ failure:
if (c != 0) /* Many things could go wrong, I guess. */ if (c != 0) /* Many things could go wrong, I guess. */
{ {
#if defined(__MINGW32__) #if defined(__MINGW32__)
NSWarnMLog(@"Rename ('%@' to '%@') failed - %s", NSWarnMLog(@"Rename ('%@' to '%@') failed - %@",
[NSString stringWithCharacters: wthePath length:wcslen(wthePath)], [NSString stringWithCharacters: wthePath
[NSString stringWithCharacters: length: wcslen(wthePath)],
wtheRealPath length:wcslen(wtheRealPath)], [NSString stringWithCharacters: wtheRealPath
GSLastErrorStr(errno)); length: wcslen(wtheRealPath)],
[_GSPrivate error]);
#else #else
NSWarnMLog(@"Rename ('%s' to '%s') failed - %s", NSWarnMLog(@"Rename ('%s' to '%s') failed - %@",
thePath, theRealPath, GSLastErrorStr(errno)); thePath, theRealPath, [_GSPrivate error]);
#endif #endif
goto failure; goto failure;
} }
@ -2918,7 +2916,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
#endif #endif
if (fd < 0) if (fd < 0)
{ {
NSWarnMLog(@"unable to open %@ - %s", path, GSLastErrorStr(errno)); NSWarnMLog(@"unable to open %@ - %@", path, [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -2926,7 +2924,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
length = lseek(fd, 0, SEEK_END); length = lseek(fd, 0, SEEK_END);
if (length < 0) if (length < 0)
{ {
NSWarnMLog(@"unable to seek to eof %@ - %s", path, GSLastErrorStr(errno)); NSWarnMLog(@"unable to seek to eof %@ - %@", path, [_GSPrivate error]);
close(fd); close(fd);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -2934,7 +2932,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
/* Position at start of file. */ /* Position at start of file. */
if (lseek(fd, 0, SEEK_SET) != 0) if (lseek(fd, 0, SEEK_SET) != 0)
{ {
NSWarnMLog(@"unable to seek to sof %@ - %s", path, GSLastErrorStr(errno)); NSWarnMLog(@"unable to seek to sof %@ - %@", path, [_GSPrivate error]);
close(fd); close(fd);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -2942,7 +2940,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0); bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0);
if (bytes == MAP_FAILED) if (bytes == MAP_FAILED)
{ {
NSWarnMLog(@"mapping failed for %s - %s", path, GSLastErrorStr(errno)); NSWarnMLog(@"mapping failed for %s - %@", path, [_GSPrivate error]);
close(fd); close(fd);
RELEASE(self); RELEASE(self);
self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
@ -2969,15 +2967,15 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
struct shmid_ds buf; struct shmid_ds buf;
if (shmctl(shmid, IPC_STAT, &buf) < 0) if (shmctl(shmid, IPC_STAT, &buf) < 0)
NSLog(@"[NSDataShared -dealloc] shared memory control failed - %s", NSLog(@"[NSDataShared -dealloc] shared memory control failed - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
else if (buf.shm_nattch == 1) else if (buf.shm_nattch == 1)
if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */
NSLog(@"[NSDataShared -dealloc] shared memory delete failed - %s", NSLog(@"[NSDataShared -dealloc] shared memory delete failed - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
if (shmdt(bytes) < 0) if (shmdt(bytes) < 0)
NSLog(@"[NSDataShared -dealloc] shared memory detach failed - %s", NSLog(@"[NSDataShared -dealloc] shared memory detach failed - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
bytes = 0; bytes = 0;
length = 0; length = 0;
shmid = -1; shmid = -1;
@ -2993,8 +2991,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_RDONLY); shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_RDONLY);
if (shmid == -1) /* Created memory? */ if (shmid == -1) /* Created memory? */
{ {
NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %s", NSLog(@"[-initWithBytes:length:] shared mem get failed for %u - %@",
bufferSize, GSLastErrorStr(errno)); bufferSize, [_GSPrivate error]);
RELEASE(self); RELEASE(self);
self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithBytes: aBuffer length: bufferSize]; return [self initWithBytes: aBuffer length: bufferSize];
@ -3003,8 +3001,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
bytes = shmat(shmid, 0, 0); bytes = shmat(shmid, 0, 0);
if (bytes == (void*)-1) if (bytes == (void*)-1)
{ {
NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %s", NSLog(@"[-initWithBytes:length:] shared mem attach failed for %u - %@",
bufferSize, GSLastErrorStr(errno)); bufferSize, [_GSPrivate error]);
bytes = 0; bytes = 0;
RELEASE(self); RELEASE(self);
self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];
@ -3022,21 +3020,23 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
shmid = anId; shmid = anId;
if (shmctl(shmid, IPC_STAT, &buf) < 0) if (shmctl(shmid, IPC_STAT, &buf) < 0)
{ {
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory control failed - %s", GSLastErrorStr(errno)); NSLog(@"[NSDataShared -initWithShmID:length:] shared memory "
@"control failed - %@", [_GSPrivate error]);
RELEASE(self); /* Unable to access memory. */ RELEASE(self); /* Unable to access memory. */
return nil; return nil;
} }
if (buf.shm_segsz < bufferSize) if (buf.shm_segsz < bufferSize)
{ {
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory segment too small"); NSLog(@"[NSDataShared -initWithShmID:length:] shared memory "
@"segment too small");
RELEASE(self); /* Memory segment too small. */ RELEASE(self); /* Memory segment too small. */
return nil; return nil;
} }
bytes = shmat(shmid, 0, 0); bytes = shmat(shmid, 0, 0);
if (bytes == (void*)-1) if (bytes == (void*)-1)
{ {
NSLog(@"[NSDataShared -initWithShmID:length:] shared memory attach failed - %s", NSLog(@"[NSDataShared -initWithShmID:length:] shared memory "
GSLastErrorStr(errno)); @"attach failed - %s", [_GSPrivate error]);
bytes = 0; bytes = 0;
RELEASE(self); /* Unable to attach to memory. */ RELEASE(self); /* Unable to attach to memory. */
return nil; return nil;
@ -3162,7 +3162,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (bytes == 0) if (bytes == 0)
{ {
NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory " NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory "
@"for %u bytes - %s", size, GSLastErrorStr(errno)); @"for %u bytes - %@", size, [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -3658,20 +3658,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (shmctl(shmid, IPC_STAT, &buf) < 0) if (shmctl(shmid, IPC_STAT, &buf) < 0)
{ {
NSLog(@"[NSMutableDataShared -dealloc] shared memory " NSLog(@"[NSMutableDataShared -dealloc] shared memory "
@"control failed - %s", GSLastErrorStr(errno)); @"control failed - %@", [_GSPrivate error]);
} }
else if (buf.shm_nattch == 1) else if (buf.shm_nattch == 1)
{ {
if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */
{ {
NSLog(@"[NSMutableDataShared -dealloc] shared memory " NSLog(@"[NSMutableDataShared -dealloc] shared memory "
@"delete failed - %s", GSLastErrorStr(errno)); @"delete failed - %@", [_GSPrivate error]);
} }
} }
if (shmdt(bytes) < 0) if (shmdt(bytes) < 0)
{ {
NSLog(@"[NSMutableDataShared -dealloc] shared memory " NSLog(@"[NSMutableDataShared -dealloc] shared memory "
@"detach failed - %s", GSLastErrorStr(errno)); @"detach failed - %@", [_GSPrivate error]);
} }
bytes = 0; bytes = 0;
length = 0; length = 0;
@ -3695,24 +3695,21 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (id) initWithCapacity: (unsigned int)bufferSize - (id) initWithCapacity: (unsigned int)bufferSize
{ {
int e;
shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_ACCESS); shmid = shmget(IPC_PRIVATE, bufferSize, IPC_CREAT|VM_ACCESS);
if (shmid == -1) /* Created memory? */ if (shmid == -1) /* Created memory? */
{ {
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory " NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory "
@"get failed for %u - %s", bufferSize, GSLastErrorStr(errno)); @"get failed for %u - %@", bufferSize, [_GSPrivate error]);
RELEASE(self); RELEASE(self);
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
return [self initWithCapacity: bufferSize]; return [self initWithCapacity: bufferSize];
} }
bytes = shmat(shmid, 0, 0); bytes = shmat(shmid, 0, 0);
e = errno;
if (bytes == (void*)-1) if (bytes == (void*)-1)
{ {
NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory " NSLog(@"[NSMutableDataShared -initWithCapacity:] shared memory "
@"attach failed for %u - %s", bufferSize, GSLastErrorStr(e)); @"attach failed for %u - %@", bufferSize, [_GSPrivate error]);
bytes = 0; bytes = 0;
RELEASE(self); RELEASE(self);
self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()]; self = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
@ -3732,7 +3729,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (shmctl(shmid, IPC_STAT, &buf) < 0) if (shmctl(shmid, IPC_STAT, &buf) < 0)
{ {
NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory "
@"control failed - %s", GSLastErrorStr(errno)); @"control failed - %@", [_GSPrivate error]);
RELEASE(self); /* Unable to access memory. */ RELEASE(self); /* Unable to access memory. */
return nil; return nil;
} }
@ -3747,7 +3744,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (bytes == (void*)-1) if (bytes == (void*)-1)
{ {
NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory " NSLog(@"[NSMutableDataShared -initWithShmID:length:] shared memory "
@"attach failed - %s", GSLastErrorStr(errno)); @"attach failed - %@", [_GSPrivate error]);
bytes = 0; bytes = 0;
RELEASE(self); /* Unable to attach to memory. */ RELEASE(self); /* Unable to attach to memory. */
return nil; return nil;
@ -3769,8 +3766,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (newid == -1) /* Created memory? */ if (newid == -1) /* Created memory? */
{ {
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"Unable to create shared memory segment (size:%u) - %s.", format: @"Unable to create shared memory segment (size:%u) - %@.",
size, GSLastErrorStr(errno)]; size, [_GSPrivate error]];
} }
tmp = shmat(newid, 0, 0); tmp = shmat(newid, 0, 0);
if ((intptr_t)tmp == -1) /* Attached memory? */ if ((intptr_t)tmp == -1) /* Attached memory? */
@ -3786,20 +3783,20 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
if (shmctl(shmid, IPC_STAT, &buf) < 0) if (shmctl(shmid, IPC_STAT, &buf) < 0)
{ {
NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " NSLog(@"[NSMutableDataShared -setCapacity:] shared memory "
@"control failed - %s", GSLastErrorStr(errno)); @"control failed - %@", [_GSPrivate error]);
} }
else if (buf.shm_nattch == 1) else if (buf.shm_nattch == 1)
{ {
if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */ if (shmctl(shmid, IPC_RMID, &buf) < 0) /* Mark for deletion. */
{ {
NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " NSLog(@"[NSMutableDataShared -setCapacity:] shared memory "
@"delete failed - %s", GSLastErrorStr(errno)); @"delete failed - %@", [_GSPrivate error]);
} }
} }
if (shmdt(bytes) < 0) /* Detach memory. */ if (shmdt(bytes) < 0) /* Detach memory. */
{ {
NSLog(@"[NSMutableDataShared -setCapacity:] shared memory " NSLog(@"[NSMutableDataShared -setCapacity:] shared memory "
@"detach failed - %s", GSLastErrorStr(errno)); @"detach failed - %@", [_GSPrivate error]);
} }
} }
bytes = tmp; bytes = tmp;

View file

@ -264,7 +264,7 @@ otherTime(NSDate* other)
if (locale == nil) if (locale == nil)
{ {
locale = GSUserDefaultsDictionaryRepresentation(); locale = [_GSPrivate userDefaultsDictionaryRepresentation];
} }
ws = [NSCharacterSet whitespaceAndNewlineCharacterSet]; ws = [NSCharacterSet whitespaceAndNewlineCharacterSet];
digits = [NSCharacterSet decimalDigitCharacterSet]; digits = [NSCharacterSet decimalDigitCharacterSet];

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
<title>NSDateFormatter class reference</title> <title>NSDateFormatter class reference</title>
$Date$ $Revision$ $Date$ $Revision$

View file

@ -957,6 +957,7 @@ const char *_NSPrintForDebugger(id object)
NSString *_NSNewStringFromCString(const char *cstring) NSString *_NSNewStringFromCString(const char *cstring)
{ {
return [NSString stringWithCString: cstring]; return [NSString stringWithCString: cstring
encoding: [NSString defaultCStringEncoding]];
} }

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
<title>NSDecimal class reference</title> <title>NSDecimal class reference</title>
$Date$ $Revision$ $Date$ $Revision$

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
<title>NSDecimalNumber class reference</title> <title>NSDecimalNumber class reference</title>
$Date$ $Revision$ $Date$ $Revision$
@ -260,7 +261,7 @@ static NSDecimalNumber *one;
- (id) initWithString: (NSString*)numberValue - (id) initWithString: (NSString*)numberValue
{ {
return [self initWithString: numberValue return [self initWithString: numberValue
locale: GSUserDefaultsDictionaryRepresentation()]; locale: [_GSPrivate userDefaultsDictionaryRepresentation]];
} }
- (id) initWithString: (NSString*)numberValue - (id) initWithString: (NSString*)numberValue

View file

@ -929,7 +929,7 @@ compareIt(id o1, id o2, void* context)
*/ */
- (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile - (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
{ {
NSDictionary *loc = GSUserDefaultsDictionaryRepresentation(); NSDictionary *loc = [_GSPrivate userDefaultsDictionaryRepresentation];
NSString *desc = nil; NSString *desc = nil;
NSData *data; NSData *data;
@ -954,7 +954,7 @@ compareIt(id o1, id o2, void* context)
*/ */
- (BOOL) writeToURL: (NSURL *)url atomically: (BOOL)useAuxiliaryFile - (BOOL) writeToURL: (NSURL *)url atomically: (BOOL)useAuxiliaryFile
{ {
NSDictionary *loc = GSUserDefaultsDictionaryRepresentation(); NSDictionary *loc = [_GSPrivate userDefaultsDictionaryRepresentation];
NSString *desc = nil; NSString *desc = nil;
NSData *data; NSData *data;

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
<title>NSDistributedLock class reference</title> <title>NSDistributedLock class reference</title>
$Date$ $Revision$ $Date$ $Revision$
@ -31,6 +32,7 @@
#include "Foundation/NSException.h" #include "Foundation/NSException.h"
#include "Foundation/NSValue.h" #include "Foundation/NSValue.h"
#include "Foundation/NSDebug.h" #include "Foundation/NSDebug.h"
#include "GSPrivate.h"
#include <fcntl.h> #include <fcntl.h>
@ -76,13 +78,13 @@ static NSFileManager *mgr = nil;
if ([mgr removeFileAtPath: _lockPath handler: nil] == NO) if ([mgr removeFileAtPath: _lockPath handler: nil] == NO)
{ {
const char *err = GSLastErrorStr(errno); NSString *err = [_GSPrivate error];
attributes = [mgr fileAttributesAtPath: _lockPath traverseLink: YES]; attributes = [mgr fileAttributesAtPath: _lockPath traverseLink: YES];
if ([modDate isEqual: [attributes fileModificationDate]] == YES) if ([modDate isEqual: [attributes fileModificationDate]] == YES)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"Failed to remove lock directory '%@' - %s", format: @"Failed to remove lock directory '%@' - %@",
_lockPath, err]; _lockPath, err];
} }
} }
@ -201,8 +203,8 @@ static NSFileManager *mgr = nil;
attributes: attributesToSet]; attributes: attributesToSet];
if (locked == NO) if (locked == NO)
{ {
NSLog(@"Failed to create lock directory '%@' - %s", NSLog(@"Failed to create lock directory '%@' - %@",
_lockPath, GSLastErrorStr(errno)); _lockPath, [_GSPrivate error]);
} }
} }
} }
@ -257,8 +259,8 @@ static NSFileManager *mgr = nil;
if ([mgr removeFileAtPath: _lockPath handler: nil] == NO) if ([mgr removeFileAtPath: _lockPath handler: nil] == NO)
{ {
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"Failed to remove lock directory '%@' - %s", format: @"Failed to remove lock directory '%@' - %@",
_lockPath, GSLastErrorStr(errno)]; _lockPath, [_GSPrivate error]];
} }
} }
else else

View file

@ -353,8 +353,9 @@ static void find_address (bfd *abfd, asection *section,
fi = [GSFunctionInfo alloc]; fi = [GSFunctionInfo alloc];
fi = [fi initWithModule: info->module fi = [fi initWithModule: info->module
address: info->theAddress address: info->theAddress
file: [NSString stringWithCString: fileName] file: [NSString stringWithCString: fileName
function: [NSString stringWithCString: functionName] encoding: [NSString defaultCStringEncoding]]
function: [NSString stringWithUTF8String: functionName]
line: line]; line: line];
[fi autorelease]; [fi autorelease];
info->theInfo = fi; info->theInfo = fi;
@ -584,7 +585,8 @@ static void _terminate()
#else #else
shouldAbort = NO; // exit() by default. shouldAbort = NO; // exit() by default.
#endif #endif
shouldAbort = GSEnvironmentFlag("CRASH_ON_ABORT", shouldAbort); shouldAbort = [_GSPrivate environmentFlag: "CRASH_ON_ABORT"
defaultValue: shouldAbort];
if (shouldAbort == YES) if (shouldAbort == YES)
{ {
abort(); abort();
@ -598,9 +600,8 @@ static void _terminate()
static void static void
_NSFoundationUncaughtExceptionHandler (NSException *exception) _NSFoundationUncaughtExceptionHandler (NSException *exception)
{ {
extern const char* GSArgZero(void); fprintf(stderr, "%s: Uncaught exception %s, reason: %s\n",
[_GSPrivate argZero],
fprintf(stderr, "%s: Uncaught exception %s, reason: %s\n", GSArgZero(),
[[exception name] lossyCString], [[exception reason] lossyCString]); [[exception name] lossyCString], [[exception reason] lossyCString]);
fflush(stderr); /* NEEDED UNDER MINGW */ fflush(stderr); /* NEEDED UNDER MINGW */

View file

@ -401,8 +401,8 @@ static NSStringEncoding defaultEncoding;
{ {
allOk = NO; allOk = NO;
str = [NSString stringWithFormat: str = [NSString stringWithFormat:
@"Unable to change NSFileOwnerAccountID to '%u' - %s", @"Unable to change NSFileOwnerAccountID to '%u' - %@",
num, GSLastErrorStr(errno)]; num, [_GSPrivate error]];
ASSIGN(_lastError, str); ASSIGN(_lastError, str);
} }
} }
@ -425,8 +425,8 @@ static NSStringEncoding defaultEncoding;
{ {
allOk = NO; allOk = NO;
str = [NSString stringWithFormat: str = [NSString stringWithFormat:
@"Unable to change NSFileOwnerAccountName to '%@' - %s", @"Unable to change NSFileOwnerAccountName to '%@' - %@",
str, GSLastErrorStr(errno)]; str, [_GSPrivate error]];
ASSIGN(_lastError, str); ASSIGN(_lastError, str);
} }
} }
@ -439,8 +439,8 @@ static NSStringEncoding defaultEncoding;
{ {
allOk = NO; allOk = NO;
str = [NSString stringWithFormat: str = [NSString stringWithFormat:
@"Unable to change NSFileGroupOwnerAccountID to '%u' - %s", @"Unable to change NSFileGroupOwnerAccountID to '%u' - %@",
num, GSLastErrorStr(errno)]; num, [_GSPrivate error]];
ASSIGN(_lastError, str); ASSIGN(_lastError, str);
} }
} }
@ -461,8 +461,8 @@ static NSStringEncoding defaultEncoding;
{ {
allOk = NO; allOk = NO;
str = [NSString stringWithFormat: str = [NSString stringWithFormat:
@"Unable to change NSFileGroupOwnerAccountName to '%@' - %s", @"Unable to change NSFileGroupOwnerAccountName to '%@' - %@",
str, GSLastErrorStr(errno)]; str, [_GSPrivate error]];
ASSIGN(_lastError, str); ASSIGN(_lastError, str);
} }
} }
@ -475,8 +475,8 @@ static NSStringEncoding defaultEncoding;
{ {
allOk = NO; allOk = NO;
str = [NSString stringWithFormat: str = [NSString stringWithFormat:
@"Unable to change NSFilePosixPermissions to '%o' - %s", @"Unable to change NSFilePosixPermissions to '%o' - %@",
num, GSLastErrorStr(errno)]; num, [_GSPrivate error]];
ASSIGN(_lastError, str); ASSIGN(_lastError, str);
} }
} }
@ -519,8 +519,8 @@ static NSStringEncoding defaultEncoding;
{ {
allOk = NO; allOk = NO;
str = [NSString stringWithFormat: str = [NSString stringWithFormat:
@"Unable to change NSFileModificationDate to '%@' - %s", @"Unable to change NSFileModificationDate to '%@' - %@",
date, GSLastErrorStr(errno)]; date, [_GSPrivate error]];
ASSIGN(_lastError, str); ASSIGN(_lastError, str);
} }
} }
@ -747,8 +747,8 @@ static NSStringEncoding defaultEncoding;
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Could not create '%s' - '%s'", s = [NSString stringWithFormat: @"Could not create '%s' - '%@'",
dirpath, GSLastErrorStr(errno)]; dirpath, [_GSPrivate error]];
ASSIGN(_lastError, s); ASSIGN(_lastError, s);
return NO; return NO;
} }
@ -1278,8 +1278,8 @@ static NSStringEncoding defaultEncoding;
#endif #endif
{ {
return [self _proceedAccordingToHandler: handler return [self _proceedAccordingToHandler: handler
forError: [NSString stringWithCString: GSLastErrorStr (errno)] forError: [_GSPrivate error]
inPath: path]; inPath: path];
} }
else else
{ {
@ -1312,8 +1312,8 @@ static NSStringEncoding defaultEncoding;
if (_RMDIR([self fileSystemRepresentationWithPath: path]) < 0) if (_RMDIR([self fileSystemRepresentationWithPath: path]) < 0)
{ {
return [self _proceedAccordingToHandler: handler return [self _proceedAccordingToHandler: handler
forError: [NSString stringWithCString: GSLastErrorStr (errno)] forError: [_GSPrivate error]
inPath: path]; inPath: path];
} }
else else
{ {
@ -2031,8 +2031,8 @@ inline void gsedRelease(GSEnumeratedDirectory X)
} }
else else
{ {
NSLog(@"Failed to recurse into directory '%@' - %s", path, NSLog(@"Failed to recurse into directory '%@' - %@", path,
GSLastErrorStr(errno)); [_GSPrivate error]);
} }
return self; return self;
} }
@ -2198,8 +2198,8 @@ inline void gsedRelease(GSEnumeratedDirectory X)
} }
else else
{ {
NSLog(@"Failed to recurse into directory '%@' - %s", NSLog(@"Failed to recurse into directory '%@' - %@",
_currentFilePath, GSLastErrorStr(errno)); _currentFilePath, [_GSPrivate error]);
} }
} }
} }
@ -2940,7 +2940,8 @@ static NSSet *fileKeys = nil;
gp = getgrgid(statbuf.st_gid); gp = getgrgid(statbuf.st_gid);
if (gp != 0) if (gp != 0)
{ {
group = [NSString stringWithCString: gp->gr_name]; group = [NSString stringWithCString: gp->gr_name
encoding: defaultEncoding];
} }
#endif #endif
#endif #endif
@ -3081,7 +3082,8 @@ static NSSet *fileKeys = nil;
if (pw != 0) if (pw != 0)
{ {
owner = [NSString stringWithCString: pw->pw_name]; owner = [NSString stringWithCString: pw->pw_name
encoding: defaultEncoding];
} }
#endif /* HAVE_PWD_H */ #endif /* HAVE_PWD_H */
#endif #endif

View file

@ -204,7 +204,7 @@ static NSMutableDictionary *_hostCache = nil;
break; break;
} }
h_name = [NSString stringWithCString: entry->h_name]; h_name = [NSString stringWithUTF8String: entry->h_name];
[names addObject: h_name]; [names addObject: h_name];
if (entry->h_aliases != 0) if (entry->h_aliases != 0)
@ -212,7 +212,7 @@ static NSMutableDictionary *_hostCache = nil;
i = 0; i = 0;
while ((ptr = entry->h_aliases[i++]) != 0) while ((ptr = entry->h_aliases[i++]) != 0)
{ {
[names addObject: [NSString stringWithCString: ptr]]; [names addObject: [NSString stringWithUTF8String: ptr]];
} }
} }
if (entry->h_addr_list != 0) if (entry->h_addr_list != 0)
@ -223,7 +223,7 @@ static NSMutableDictionary *_hostCache = nil;
NSString *addr; NSString *addr;
memcpy((void*)&in.s_addr, (const void*)ptr, entry->h_length); memcpy((void*)&in.s_addr, (const void*)ptr, entry->h_length);
addr = [NSString stringWithCString: (char*)inet_ntoa(in)]; addr = [NSString stringWithUTF8String: (char*)inet_ntoa(in)];
[addresses addObject: addr]; [addresses addObject: addr];
} }
} }

View file

@ -648,13 +648,13 @@ _arg_addr(NSInvocation *inv, int index)
char buffer[1024]; char buffer[1024];
snprintf (buffer, 1024, "<%s %p selector: %s target: %s>", \ snprintf (buffer, 1024, "<%s %p selector: %s target: %s>", \
GSClassNameFromObject(self), \ GSClassNameFromObject(self), \
self, \ self, \
_selector ? GSNameFromSelector(_selector) : "nil", \ _selector ? GSNameFromSelector(_selector) : "nil", \
_target ? GSNameFromClass([_target class]) : "nil" \ _target ? GSNameFromClass([_target class]) : "nil" \
); );
return [NSString stringWithCString: buffer]; return [NSString stringWithUTF8String: buffer];
} }
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder

View file

@ -669,7 +669,7 @@ static NSDictionary *makeReference(unsigned ref)
* Bizzarely MacOS-X seems to encode char* values by creating * Bizzarely MacOS-X seems to encode char* values by creating
* string objects and encoding those objects! * string objects and encoding those objects!
*/ */
o = [NSString stringWithCString: (char*)address]; o = [NSString stringWithUTF8String: (char*)address];
[self encodeObject: o]; [self encodeObject: o];
} }
return; return;

View file

@ -144,7 +144,7 @@ _NSLog_standard_printf_handler (NSString* message)
OutputDebugStringW(null_terminated_buf); OutputDebugStringW(null_terminated_buf);
if ((GSUserDefaultsFlag(GSLogSyslog) == YES if (([_GSPrivate userDefaultsFlag: GSLogSyslog] == YES
|| write(_NSLogDescriptor, buf, len) != (int)len) && !IsDebuggerPresent()) || write(_NSLogDescriptor, buf, len) != (int)len) && !IsDebuggerPresent())
{ {
static HANDLE eventloghandle = 0; static HANDLE eventloghandle = 0;
@ -170,7 +170,7 @@ _NSLog_standard_printf_handler (NSString* message)
#else #else
#if defined(HAVE_SYSLOG) #if defined(HAVE_SYSLOG)
if (GSUserDefaultsFlag(GSLogSyslog) == YES if ([_GSPrivate userDefaultsFlag: GSLogSyslog] == YES
|| write(_NSLogDescriptor, buf, len) != (int)len) || write(_NSLogDescriptor, buf, len) != (int)len)
{ {
null_terminated_buf = objc_malloc (sizeof (char) * (len + 1)); null_terminated_buf = objc_malloc (sizeof (char) * (len + 1));
@ -302,9 +302,9 @@ NSLogv (NSString* format, va_list args)
} }
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG
if (GSUserDefaultsFlag(GSLogSyslog) == YES) if ([_GSPrivate userDefaultsFlag: GSLogSyslog] == YES)
{ {
if (GSUserDefaultsFlag(GSLogThread) == YES) if ([_GSPrivate userDefaultsFlag: GSLogThread] == YES)
{ {
prefix = [NSString stringWithFormat: @"[thread:%x] ", prefix = [NSString stringWithFormat: @"[thread:%x] ",
GSCurrentThread()]; GSCurrentThread()];
@ -317,7 +317,7 @@ NSLogv (NSString* format, va_list args)
else else
#endif #endif
{ {
if (GSUserDefaultsFlag(GSLogThread) == YES) if ([_GSPrivate userDefaultsFlag: GSLogThread] == YES)
{ {
prefix = [NSString prefix = [NSString
stringWithFormat: @"%@ %@[%d,%x] ", stringWithFormat: @"%@ %@[%d,%x] ",

View file

@ -44,6 +44,7 @@
#include "Foundation/NSFileManager.h" #include "Foundation/NSFileManager.h"
#include "Foundation/NSProcessInfo.h" #include "Foundation/NSProcessInfo.h"
#include "GSPrivate.h"
#include "GSPortPrivate.h" #include "GSPortPrivate.h"
#include <stdio.h> #include <stdio.h>
@ -302,15 +303,15 @@ static Class runLoopClass;
e |= NBLK_OPT; e |= NBLK_OPT;
if (fcntl(d, F_SETFL, e) < 0) if (fcntl(d, F_SETFL, e) < 0)
{ {
NSLog(@"unable to set non-blocking mode on %d - %s", NSLog(@"unable to set non-blocking mode on %d - %@",
d, GSLastErrorStr(errno)); d, [_GSPrivate error]);
return nil; return nil;
} }
} }
else else
{ {
NSLog(@"unable to get non-blocking mode on %d - %s", NSLog(@"unable to get non-blocking mode on %d - %@",
d, GSLastErrorStr(errno)); d, [_GSPrivate error]);
return nil; return nil;
} }
handle = (GSMessageHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone()); handle = (GSMessageHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
@ -379,9 +380,8 @@ static Class runLoopClass;
{ {
if (errno != EINPROGRESS) if (errno != EINPROGRESS)
{ {
NSLog(@"unable to make connection to %s - %s", NSLog(@"unable to make connection to %s - %@",
sockAddr.sun_path, sockAddr.sun_path, [_GSPrivate error]);
GSLastErrorStr(errno));
M_UNLOCK(myLock); M_UNLOCK(myLock);
return NO; return NO;
} }
@ -607,7 +607,7 @@ static Class runLoopClass;
else if (errno != EINTR && errno != EAGAIN) else if (errno != EINTR && errno != EAGAIN)
{ {
NSDebugMLLog(@"NSMessagePort", NSDebugMLLog(@"NSMessagePort",
@"read failed - %s on 0x%x", GSLastErrorStr(errno), self); @"read failed - %@ on 0x%p", [_GSPrivate error], self);
M_UNLOCK(myLock); M_UNLOCK(myLock);
[self invalidate]; [self invalidate];
return; return;
@ -906,7 +906,7 @@ static Class runLoopClass;
&& res != 0) && res != 0)
{ {
state = GS_H_UNCON; state = GS_H_UNCON;
NSLog(@"connect attempt failed - %s", GSLastErrorStr(res)); NSLog(@"connect attempt failed - %@", [_GSPrivate error]);
} }
else else
{ {
@ -922,8 +922,8 @@ static Class runLoopClass;
else else
{ {
state = GS_H_UNCON; state = GS_H_UNCON;
NSLog(@"connect write attempt failed - %s", NSLog(@"connect write attempt failed - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
} }
RELEASE(d); RELEASE(d);
} }
@ -957,7 +957,7 @@ static Class runLoopClass;
{ {
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)
{ {
NSLog(@"write attempt failed - %s", GSLastErrorStr(errno)); NSLog(@"write attempt failed - %@", [_GSPrivate error]);
M_UNLOCK(myLock); M_UNLOCK(myLock);
[self invalidate]; [self invalidate];
return; return;
@ -1249,7 +1249,7 @@ typedef struct {
sizeof(sockAddr.sun_path)); sizeof(sockAddr.sun_path));
if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0) if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
desc = -1; desc = -1;
} }
else if (bind(desc, (struct sockaddr *)&sockAddr, else if (bind(desc, (struct sockaddr *)&sockAddr,
@ -1263,23 +1263,23 @@ typedef struct {
close(desc); close(desc);
if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0) if ((desc = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC)) < 0)
{ {
NSLog(@"unable to create socket - %s", NSLog(@"unable to create socket - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
desc = -1; desc = -1;
} }
else if (bind(desc, (struct sockaddr *)&sockAddr, else if (bind(desc, (struct sockaddr *)&sockAddr,
SUN_LEN(&sockAddr)) < 0) SUN_LEN(&sockAddr)) < 0)
{ {
NSLog(@"unable to bind to %s - %s", NSLog(@"unable to bind to %s - %@",
sockAddr.sun_path, GSLastErrorStr(errno)); sockAddr.sun_path, [_GSPrivate error]);
(void) close(desc); (void) close(desc);
desc = -1; desc = -1;
} }
} }
else else
{ {
NSLog(@"unable to bind to %s - %s", NSLog(@"unable to bind to %s - %@",
sockAddr.sun_path, GSLastErrorStr(errno)); sockAddr.sun_path, [_GSPrivate error]);
(void) close(desc); (void) close(desc);
desc = -1; desc = -1;
} }
@ -1291,13 +1291,13 @@ typedef struct {
} }
else if (listen(desc, 128) < 0) else if (listen(desc, 128) < 0)
{ {
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); NSLog(@"unable to listen on port - %@", [_GSPrivate error]);
(void) close(desc); (void) close(desc);
DESTROY(port); DESTROY(port);
} }
else if (getsockname(desc, (struct sockaddr*)&sockAddr, &i) < 0) else if (getsockname(desc, (struct sockaddr*)&sockAddr, &i) < 0)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
(void) close(desc); (void) close(desc);
DESTROY(port); DESTROY(port);
} }
@ -1492,7 +1492,7 @@ typedef struct {
sock = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC); sock = socket(PF_LOCAL, SOCK_STREAM, PF_UNSPEC);
if (sock < 0) if (sock < 0)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
} }
#ifndef BROKEN_SO_REUSEADDR #ifndef BROKEN_SO_REUSEADDR
/* /*
@ -1505,13 +1505,13 @@ typedef struct {
sizeof(opt)) < 0) sizeof(opt)) < 0)
{ {
(void)close(sock); (void)close(sock);
NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to set reuse on socket - %@", [_GSPrivate error]);
} }
#endif #endif
else if ((handle = [GSMessageHandle handleWithDescriptor: sock]) == nil) else if ((handle = [GSMessageHandle handleWithDescriptor: sock]) == nil)
{ {
(void)close(sock); (void)close(sock);
NSLog(@"unable to create GSMessageHandle - %s", GSLastErrorStr(errno)); NSLog(@"unable to create GSMessageHandle - %@", [_GSPrivate error]);
} }
else else
{ {

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
<title>NSObjCRuntime class reference</title> <title>NSObjCRuntime class reference</title>
$Date$ $Revision$ $Date$ $Revision$
@ -40,7 +41,7 @@ NSString *
NSStringFromSelector(SEL aSelector) NSStringFromSelector(SEL aSelector)
{ {
if (aSelector != (SEL)0) if (aSelector != (SEL)0)
return [NSString stringWithCString: GSNameFromSelector(aSelector)]; return [NSString stringWithUTF8String: GSNameFromSelector(aSelector)];
return nil; return nil;
} }
@ -92,7 +93,7 @@ NSString *
NSStringFromClass(Class aClass) NSStringFromClass(Class aClass)
{ {
if (aClass != (Class)0) if (aClass != (Class)0)
return [NSString stringWithCString: (char*)GSNameFromClass(aClass)]; return [NSString stringWithUTF8String: (char*)GSNameFromClass(aClass)];
return nil; return nil;
} }

View file

@ -161,7 +161,7 @@ static void GSLogZombie(id o, SEL sel)
NSLog(@"Deallocated %@ (0x%x) sent %@", NSLog(@"Deallocated %@ (0x%x) sent %@",
NSStringFromClass(c), o, NSStringFromSelector(sel)); NSStringFromClass(c), o, NSStringFromSelector(sel));
} }
if (GSEnvironmentFlag("CRASH_ON_ZOMBIE", NO) == YES) if ([_GSPrivate environmentFlag: "CRASH_ON_ZOMBIE" defaultValue: NO] == YES)
{ {
abort(); abort();
} }
@ -968,8 +968,10 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
zombieMap = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, zombieMap = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0); NSNonOwnedPointerMapValueCallBacks, 0);
zombieClass = [NSZombie class]; zombieClass = [NSZombie class];
NSZombieEnabled = GSEnvironmentFlag("NSZombieEnabled", NO); NSZombieEnabled = [_GSPrivate environmentFlag: "NSZombieEnabled"
NSDeallocateZombies = GSEnvironmentFlag("NSDeallocateZombies", NO); defaultValue: NO];
NSDeallocateZombies = [_GSPrivate environmentFlag: "NSDeallocateZombies"
defaultValue: NO];
autorelease_class = [NSAutoreleasePool class]; autorelease_class = [NSAutoreleasePool class];
autorelease_sel = @selector(addObject:); autorelease_sel = @selector(addObject:);
@ -1295,7 +1297,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
{ {
if (aSelector == 0) if (aSelector == 0)
{ {
if (GSUserDefaultsFlag(GSMacOSXCompatible)) if ([_GSPrivate userDefaultsFlag: GSMacOSXCompatible])
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", format: @"%@ null selector given",
@ -1868,7 +1870,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
{ {
if (aSelector == 0) if (aSelector == 0)
{ {
if (GSUserDefaultsFlag(GSMacOSXCompatible)) if ([_GSPrivate userDefaultsFlag: GSMacOSXCompatible])
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"%@ null selector given", format: @"%@ null selector given",

View file

@ -1082,7 +1082,7 @@ NSHomeDirectoryForUser(NSString *loginName)
pw = getpwnam ([loginName cString]); pw = getpwnam ([loginName cString]);
if (pw != 0 && pw->pw_dir != NULL) if (pw != 0 && pw->pw_dir != NULL)
{ {
s = [NSString stringWithCString: pw->pw_dir]; s = [NSString stringWithUTF8String: pw->pw_dir];
} }
[gnustep_global_lock unlock]; [gnustep_global_lock unlock];
#else #else
@ -1152,7 +1152,7 @@ NSFullUserName(void)
struct passwd *pw; struct passwd *pw;
pw = getpwnam([NSUserName() cString]); pw = getpwnam([NSUserName() cString]);
userName = [NSString stringWithCString: pw->pw_gecos]; userName = [NSString stringWithUTF8String: pw->pw_gecos];
#else #else
NSLog(@"Warning: NSFullUserName not implemented\n"); NSLog(@"Warning: NSFullUserName not implemented\n");
userName = NSUserName(); userName = NSUserName();

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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$ $Date$ $Revision$
*/ */
@ -28,6 +29,7 @@
#include "Foundation/NSObject.h" #include "Foundation/NSObject.h"
#include "Foundation/NSFileHandle.h" #include "Foundation/NSFileHandle.h"
#include "Foundation/NSDebug.h" #include "Foundation/NSDebug.h"
#include "GSPrivate.h"
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -77,7 +79,7 @@
} }
else else
{ {
NSLog(@"Failed to create pipe ... %s", GSLastErrorStr(errno)); NSLog(@"Failed to create pipe ... %@", [_GSPrivate error]);
DESTROY(self); DESTROY(self);
} }
#else #else
@ -95,6 +97,11 @@
writeHandle = [[NSFileHandle alloc] initWithNativeHandle: writeh writeHandle = [[NSFileHandle alloc] initWithNativeHandle: writeh
closeOnDealloc: YES]; closeOnDealloc: YES];
} }
else
{
NSLog(@"Failed to create pipe ... %@", [_GSPrivate error]);
DESTROY(self);
}
#endif #endif
} }
return self; return self;

View file

@ -262,7 +262,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
objc_free(buffer); objc_free(buffer);
} }
} }
tmp = [arg0 UTF8String]; tmp = [arg0 cStringUsingEncoding: [NSString defaultCStringEncoding]];
_gnu_arg_zero = (char*)objc_malloc(strlen(tmp) + 1); _gnu_arg_zero = (char*)objc_malloc(strlen(tmp) + 1);
strcpy(_gnu_arg_zero, tmp); strcpy(_gnu_arg_zero, tmp);
#else #else
@ -317,6 +317,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
NSMutableSet *mySet; NSMutableSet *mySet;
id obj_argv[argc]; id obj_argv[argc];
int added = 1; int added = 1;
NSStringEncoding enc = [_GSPrivate defaultCStringEncoding];
mySet = [NSMutableSet new]; mySet = [NSMutableSet new];
@ -325,7 +326,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
str = [NSString stringWithCString: argv[i]]; str = [NSString stringWithCString: argv[i] encoding: enc];
if ([str hasPrefix: @"--GNU-Debug="]) if ([str hasPrefix: @"--GNU-Debug="])
[mySet addObject: [str substringFromIndex: 12]]; [mySet addObject: [str substringFromIndex: 12]];
@ -345,6 +346,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
{ {
NSMutableArray *keys = [NSMutableArray new]; NSMutableArray *keys = [NSMutableArray new];
NSMutableArray *values = [NSMutableArray new]; NSMutableArray *values = [NSMutableArray new];
NSStringEncoding enc = [_GSPrivate defaultCStringEncoding];
#if defined(__MINGW32__) #if defined(__MINGW32__)
if (fallbackInitialisation == NO) if (fallbackInitialisation == NO)
@ -408,8 +410,10 @@ _gnu_process_args(int argc, char *argv[], char *env[])
strcpy(buf, env[i]); strcpy(buf, env[i]);
cp = &buf[cp - env[i]]; cp = &buf[cp - env[i]];
*cp++ = '\0'; *cp++ = '\0';
[keys addObject: [NSString stringWithCString: buf]]; [keys addObject:
[values addObject: [NSString stringWithCString: cp]]; [NSString stringWithCString: buf encoding: enc]];
[values addObject:
[NSString stringWithCString: cp encoding: enc]];
} }
i++; i++;
} }
@ -1230,11 +1234,8 @@ BOOL GSDebugSet(NSString *level)
return YES; return YES;
} }
/** @implementation _GSPrivate (ProcessInfo)
* Internal function for GNUstep base library + (BOOL) environmentFlag: (const char *)name defaultValue: (BOOL)def
*/
BOOL
GSEnvironmentFlag(const char *name, BOOL def)
{ {
const char *c = getenv(name); const char *c = getenv(name);
BOOL a = def; BOOL a = def;
@ -1261,13 +1262,7 @@ GSEnvironmentFlag(const char *name, BOOL def)
return a; return a;
} }
/** + (const char*) argZero
* Internal function for GNUstep base library.
* Used by NSException uncaught exception handler - must not call any
* methods/functions which might cause a recursive exception.
*/
const char*
GSArgZero(void)
{ {
if (_gnu_arg_zero == 0) if (_gnu_arg_zero == 0)
return ""; return "";
@ -1275,4 +1270,5 @@ GSArgZero(void)
return _gnu_arg_zero; return _gnu_arg_zero;
} }
@end

View file

@ -2168,7 +2168,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
{ {
style = NSPropertyListXMLFormat_v1_0; style = NSPropertyListXMLFormat_v1_0;
} }
else if (GSUserDefaultsFlag(NSWriteOldStylePropertyLists)) else if ([_GSPrivate userDefaultsFlag: NSWriteOldStylePropertyLists] == YES)
{ {
style = NSPropertyListOpenStepFormat; style = NSPropertyListOpenStepFormat;
} }

View file

@ -140,8 +140,8 @@ typedef struct {
GSPlaceholderStringClass = [GSPlaceholderString class]; GSPlaceholderStringClass = [GSPlaceholderString class];
NSConstantStringClass = [NSString constantStringClass]; NSConstantStringClass = [NSString constantStringClass];
_holder = (id)NSAllocateObject(GSPlaceholderStringClass, 0, 0); _holder = (id)NSAllocateObject(GSPlaceholderStringClass, 0, 0);
externalEncoding = GetDefEncoding(); externalEncoding = [NSString defaultCStringEncoding];
if (GSIsByteEncoding(externalEncoding) == YES) if ([_GSPrivate isByteEncoding: externalEncoding] == YES)
{ {
internalEncoding = externalEncoding; internalEncoding = externalEncoding;
} }
@ -169,7 +169,7 @@ typedef struct {
if (scanner != nil) if (scanner != nil)
{ {
[scanner setLocale: GSUserDefaultsDictionaryRepresentation()]; [scanner setLocale: [_GSPrivate userDefaultsDictionaryRepresentation]];
} }
return scanner; return scanner;
} }

View file

@ -269,7 +269,7 @@ decodePort(NSData *data, NSString *defaultAddress)
pi->addr, pnum); pi->addr, pnum);
return nil; return nil;
} }
addr = [NSString stringWithCString: pi->addr]; addr = [NSString stringWithUTF8String: pi->addr];
NSDebugFLLog(@"NSPort", @"Decoded port as '%@:%d'", addr, pnum); NSDebugFLLog(@"NSPort", @"Decoded port as '%@:%d'", addr, pnum);
@ -390,8 +390,8 @@ static Class runLoopClass;
dummy = 1; dummy = 1;
if (ioctlsocket(d, FIONBIO, &dummy) == SOCKET_ERROR) if (ioctlsocket(d, FIONBIO, &dummy) == SOCKET_ERROR)
{ {
NSLog(@"unable to set non-blocking mode on %d - %s", NSLog(@"unable to set non-blocking mode on %d - %@",
d, GSLastErrorStr(errno)); d, [_GSPrivate error]);
return nil; return nil;
} }
#else /* !__MINGW32__ */ #else /* !__MINGW32__ */
@ -400,15 +400,15 @@ static Class runLoopClass;
e |= NBLK_OPT; e |= NBLK_OPT;
if (fcntl(d, F_SETFL, e) < 0) if (fcntl(d, F_SETFL, e) < 0)
{ {
NSLog(@"unable to set non-blocking mode on %d - %s", NSLog(@"unable to set non-blocking mode on %d - %@",
d, GSLastErrorStr(errno)); d, [_GSPrivate error]);
return nil; return nil;
} }
} }
else else
{ {
NSLog(@"unable to get non-blocking mode on %d - %s", NSLog(@"unable to get non-blocking mode on %d - %@",
d, GSLastErrorStr(errno)); d, [_GSPrivate error]);
return nil; return nil;
} }
#endif #endif
@ -545,9 +545,9 @@ static Class runLoopClass;
if (errno != EINPROGRESS) if (errno != EINPROGRESS)
#endif #endif
{ {
NSLog(@"unable to make connection to %s:%d - %s", NSLog(@"unable to make connection to %s:%d - %@",
inet_ntoa(sockAddr.sin_addr), inet_ntoa(sockAddr.sin_addr),
GSSwapBigI16ToHost(sockAddr.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sockAddr.sin_port), [_GSPrivate error]);
if (addrNum < [addrs count]) if (addrNum < [addrs count])
{ {
BOOL result; BOOL result;
@ -817,7 +817,7 @@ static Class runLoopClass;
#endif /* !__MINGW32__ */ #endif /* !__MINGW32__ */
{ {
NSDebugMLLog(@"GSTcpHandle", NSDebugMLLog(@"GSTcpHandle",
@"read failed - %s on 0x%x", GSLastErrorStr(errno), self); @"read failed - %@ on 0x%p", [_GSPrivate error], self);
[self invalidate]; [self invalidate];
return; return;
} }
@ -1108,7 +1108,7 @@ static Class runLoopClass;
&& res != 0) && res != 0)
{ {
state = GS_H_UNCON; state = GS_H_UNCON;
NSLog(@"connect attempt failed - %s", GSLastErrorStr(res)); NSLog(@"connect attempt failed - %@", [_GSPrivate error]);
} }
else else
{ {
@ -1118,7 +1118,7 @@ static Class runLoopClass;
if (len == (int)[d length]) if (len == (int)[d length])
{ {
RELEASE(defaultAddress); RELEASE(defaultAddress);
defaultAddress = RETAIN([NSString stringWithCString: defaultAddress = RETAIN([NSString stringWithUTF8String:
inet_ntoa(sockAddr.sin_addr)]); inet_ntoa(sockAddr.sin_addr)]);
NSDebugMLLog(@"GSTcpHandle", NSDebugMLLog(@"GSTcpHandle",
@"wrote %d bytes on 0x%x", len, self); @"wrote %d bytes on 0x%x", len, self);
@ -1127,8 +1127,8 @@ static Class runLoopClass;
else else
{ {
state = GS_H_UNCON; state = GS_H_UNCON;
NSLog(@"connect write attempt failed - %s", NSLog(@"connect write attempt failed - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
} }
RELEASE(d); RELEASE(d);
} }
@ -1166,7 +1166,7 @@ static Class runLoopClass;
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)
#endif /* !__MINGW32__ */ #endif /* !__MINGW32__ */
{ {
NSLog(@"write attempt failed - %s", GSLastErrorStr(errno)); NSLog(@"write attempt failed - %@", [_GSPrivate error]);
[self invalidate]; [self invalidate];
return; return;
} }
@ -1635,7 +1635,7 @@ static Class tcpPortClass;
else if ((desc = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) else if ((desc = socket(AF_INET, SOCK_STREAM, PF_UNSPEC))
== INVALID_SOCKET) == INVALID_SOCKET)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
DESTROY(port); DESTROY(port);
} }
#ifndef BROKEN_SO_REUSEADDR #ifndef BROKEN_SO_REUSEADDR
@ -1649,29 +1649,29 @@ static Class tcpPortClass;
sizeof(reuse)) < 0) sizeof(reuse)) < 0)
{ {
(void) close(desc); (void) close(desc);
NSLog(@"unable to set reuse on socket - %s", NSLog(@"unable to set reuse on socket - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
DESTROY(port); DESTROY(port);
} }
#endif #endif
else if (bind(desc, (struct sockaddr *)&sockaddr, else if (bind(desc, (struct sockaddr *)&sockaddr,
sizeof(sockaddr)) == SOCKET_ERROR) sizeof(sockaddr)) == SOCKET_ERROR)
{ {
NSLog(@"unable to bind to port %s:%d - %s", NSLog(@"unable to bind to port %s:%d - %@",
inet_ntoa(sockaddr.sin_addr), number, GSLastErrorStr(errno)); inet_ntoa(sockaddr.sin_addr), number, [_GSPrivate error]);
(void) close(desc); (void) close(desc);
DESTROY(port); DESTROY(port);
} }
else if (listen(desc, 128) == SOCKET_ERROR) else if (listen(desc, 128) == SOCKET_ERROR)
{ {
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); NSLog(@"unable to listen on port - %@", [_GSPrivate error]);
(void) close(desc); (void) close(desc);
DESTROY(port); DESTROY(port);
} }
else if (getsockname(desc, (struct sockaddr*)&sockaddr, &i) else if (getsockname(desc, (struct sockaddr*)&sockaddr, &i)
== SOCKET_ERROR) == SOCKET_ERROR)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
(void) close(desc); (void) close(desc);
DESTROY(port); DESTROY(port);
} }
@ -1971,7 +1971,7 @@ static Class tcpPortClass;
handle = nil; handle = nil;
if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) if ((sock = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
} }
#ifndef BROKEN_SO_REUSEADDR #ifndef BROKEN_SO_REUSEADDR
/* /*
@ -1984,13 +1984,13 @@ static Class tcpPortClass;
sizeof(opt)) < 0) sizeof(opt)) < 0)
{ {
(void)close(sock); (void)close(sock);
NSLog(@"unable to set reuse on socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to set reuse on socket - %@", [_GSPrivate error]);
} }
#endif #endif
else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil) else if ((handle = [GSTcpHandle handleWithDescriptor: sock]) == nil)
{ {
(void)close(sock); (void)close(sock);
NSLog(@"unable to create GSTcpHandle - %s", GSLastErrorStr(errno)); NSLog(@"unable to create GSTcpHandle - %@", [_GSPrivate error]);
} }
else else
{ {
@ -2179,7 +2179,7 @@ static Class tcpPortClass;
*/ */
handle = [GSTcpHandle handleWithDescriptor: desc]; handle = [GSTcpHandle handleWithDescriptor: desc];
memcpy(&handle->sockAddr, &sockAddr, sizeof(sockAddr)); memcpy(&handle->sockAddr, &sockAddr, sizeof(sockAddr));
handle->defaultAddress = RETAIN([NSString stringWithCString: handle->defaultAddress = RETAIN([NSString stringWithUTF8String:
inet_ntoa(sockAddr.sin_addr)]); inet_ntoa(sockAddr.sin_addr)]);
[handle setState: GS_H_ACCEPT]; [handle setState: GS_H_ACCEPT];

View file

@ -554,7 +554,7 @@ typedef enum {
serverLock = [NSRecursiveLock new]; serverLock = [NSRecursiveLock new];
modes = [[NSArray alloc] initWithObjects: &mode count: 1]; modes = [[NSArray alloc] initWithObjects: &mode count: 1];
#ifdef GDOMAP_PORT_OVERRIDE #ifdef GDOMAP_PORT_OVERRIDE
serverPort = RETAIN([NSString stringWithCString: serverPort = RETAIN([NSString stringWithUTF8String:
make_gdomap_port(GDOMAP_PORT_OVERRIDE)]); make_gdomap_port(GDOMAP_PORT_OVERRIDE)]);
#endif #endif
portClass = [NSSocketPort class]; portClass = [NSSocketPort class];
@ -738,7 +738,7 @@ typedef enum {
[array addObject: com]; [array addObject: com];
RELEASE(com); RELEASE(com);
[com setAddr: svrs[count]]; [com setAddr: svrs[count]];
addr = [NSString stringWithCString: addr = [NSString stringWithUTF8String:
(char*)inet_ntoa(svrs[count])]; (char*)inet_ntoa(svrs[count])];
[com startPortLookup: name onHost: addr]; [com startPortLookup: name onHost: addr];
count++; count++;
@ -802,7 +802,7 @@ typedef enum {
if (*port) if (*port)
{ {
*addr = [NSString stringWithCString: inet_ntoa(singleServer)]; *addr = [NSString stringWithUTF8String: inet_ntoa(singleServer)];
return YES; return YES;
} }
else else

View file

@ -566,8 +566,8 @@ handle_printf_atsign (FILE *stream,
gcrSel = @selector(getCharacters:range:); gcrSel = @selector(getCharacters:range:);
ranSel = @selector(rangeOfComposedCharacterSequenceAtIndex:); ranSel = @selector(rangeOfComposedCharacterSequenceAtIndex:);
_DefaultStringEncoding = GetDefEncoding(); _DefaultStringEncoding = [_GSPrivate defaultCStringEncoding];
_ByteEncodingOk = GSIsByteEncoding(_DefaultStringEncoding); _ByteEncodingOk = [_GSPrivate isByteEncoding: _DefaultStringEncoding];
NSStringClass = self; NSStringClass = self;
[self setVersion: 1]; [self setVersion: 1];
@ -1057,7 +1057,6 @@ handle_printf_atsign (FILE *stream,
locale: (NSDictionary*)locale locale: (NSDictionary*)locale
arguments: (va_list)argList arguments: (va_list)argList
{ {
extern void GSStrExternalize();
unsigned char buf[2048]; unsigned char buf[2048];
GSStr_t f; GSStr_t f;
unichar fbuf[1024]; unichar fbuf[1024];
@ -2685,7 +2684,7 @@ handle_printf_atsign (FILE *stream,
*/ */
+ (NSStringEncoding*) availableStringEncodings + (NSStringEncoding*) availableStringEncodings
{ {
return GetAvailableEncodings(); return [_GSPrivate availableEncodings];
} }
/** /**
@ -2703,7 +2702,7 @@ handle_printf_atsign (FILE *stream,
*/ */
ourbundle = [NSBundle bundleForLibrary: @"gnustep-base"]; ourbundle = [NSBundle bundleForLibrary: @"gnustep-base"];
ourname = GetEncodingName(encoding); ourname = [_GSPrivate encodingName: encoding];
return [ourbundle localizedStringForKey: ourname return [ourbundle localizedStringForKey: ourname
value: ourname value: ourname
table: nil]; table: nil];
@ -4151,7 +4150,7 @@ static NSFileManager *fm = nil;
} }
else else
{ {
dict = GSUserDefaultsDictionaryRepresentation(); dict = [_GSPrivate userDefaultsDictionaryRepresentation];
ret = AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] ret = AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithFormat: format locale: dict arguments: ap]); initWithFormat: format locale: dict arguments: ap]);
} }
@ -4203,7 +4202,7 @@ static NSFileManager *fm = nil;
*/ */
- (NSComparisonResult) localizedCompare: (NSString *)string - (NSComparisonResult) localizedCompare: (NSString *)string
{ {
NSDictionary *dict = GSUserDefaultsDictionaryRepresentation(); NSDictionary *dict = [_GSPrivate userDefaultsDictionaryRepresentation];
return [self compare: string return [self compare: string
options: 0 options: 0
@ -4217,7 +4216,7 @@ static NSFileManager *fm = nil;
*/ */
- (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string - (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string
{ {
NSDictionary *dict = GSUserDefaultsDictionaryRepresentation(); NSDictionary *dict = [_GSPrivate userDefaultsDictionaryRepresentation];
return [self compare: string return [self compare: string
options: NSCaseInsensitiveSearch options: NSCaseInsensitiveSearch

View file

@ -47,6 +47,7 @@
#include "Foundation/NSTimer.h" #include "Foundation/NSTimer.h"
#include "Foundation/NSLock.h" #include "Foundation/NSLock.h"
#include "Foundation/NSDebug.h" #include "Foundation/NSDebug.h"
#include "GSPrivate.h"
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -1561,8 +1562,8 @@ GSCheckTasks()
result = waitpid(_taskId, &_terminationStatus, WNOHANG); result = waitpid(_taskId, &_terminationStatus, WNOHANG);
if (result < 0) if (result < 0)
{ {
NSLog(@"waitpid %d, result %d, error %s", NSLog(@"waitpid %d, result %d, error %@",
_taskId, result, GSLastErrorStr(errno)); _taskId, result, [_GSPrivate error]);
[self _terminatedChild: -1]; [self _terminatedChild: -1];
} }
else if (result == _taskId || (result > 0 && errno == 0)) else if (result == _taskId || (result > 0 && errno == 0))
@ -1594,8 +1595,8 @@ GSCheckTasks()
#ifdef WAITDEBUG #ifdef WAITDEBUG
else else
{ {
NSLog(@"waitpid %d, result %d, error %s", NSLog(@"waitpid %d, result %d, error %@",
_taskId, result, GSLastErrorStr(errno)); _taskId, result, [_GSPrivate error]);
} }
#endif #endif
} }

View file

@ -54,6 +54,7 @@
#include "Foundation/NSConnection.h" #include "Foundation/NSConnection.h"
#include "Foundation/NSInvocation.h" #include "Foundation/NSInvocation.h"
#include "GSPrivate.h"
#include "GSRunLoopCtxt.h" #include "GSRunLoopCtxt.h"
@interface NSAutoreleasePool (NSThread) @interface NSAutoreleasePool (NSThread)
@ -889,12 +890,12 @@ static NSDate *theFuture;
#if defined(__MINGW32__) #if defined(__MINGW32__)
if (SetEvent(event) == 0) if (SetEvent(event) == 0)
{ {
NSLog(@"Set event failed - %@", GSLastErrorStr(errno)); NSLog(@"Set event failed - %@", [_GSPrivate error]);
} }
#else #else
if (write(outputFd, "0", 1) != 1) if (write(outputFd, "0", 1) != 1)
{ {
NSLog(@"Write to pipe failed - %@", GSLastErrorStr(errno)); NSLog(@"Write to pipe failed - %@", [_GSPrivate error]);
} }
#endif #endif
@ -918,12 +919,12 @@ static NSDate *theFuture;
#if defined(__MINGW32__) #if defined(__MINGW32__)
if (ResetEvent(event) == 0) if (ResetEvent(event) == 0)
{ {
NSLog(@"Reset event failed - %@", GSLastErrorStr(errno)); NSLog(@"Reset event failed - %@", [_GSPrivate error]);
} }
#else #else
if (read(inputFd, &c, 1) != 1) if (read(inputFd, &c, 1) != 1)
{ {
NSLog(@"Read pipe failed - %@", GSLastErrorStr(errno)); NSLog(@"Read pipe failed - %@", [_GSPrivate error]);
} }
#endif #endif

View file

@ -1487,7 +1487,7 @@ static NSMapTable *absolutes = 0;
bufsize--; bufsize--;
} }
localZoneString localZoneString
= [NSString stringWithCString: buf length: bufsize]; = [NSString stringWithUTF8String: buf length: bufsize];
} }
RegCloseKey(regkey); RegCloseKey(regkey);
} }

View file

@ -1955,8 +1955,9 @@ static BOOL isLocked = NO;
} }
@end @end
NSDictionary* @implementation _GSPrivate (UserDefaults)
GSUserDefaultsDictionaryRepresentation()
+ (NSDictionary*) userDefaultsDictionaryRepresentation
{ {
NSDictionary *defs; NSDictionary *defs;
@ -1970,11 +1971,7 @@ GSUserDefaultsDictionaryRepresentation()
return defs; return defs;
} }
/* + (BOOL) userDefaultsFlag: (GSUserDefaultFlagType)type
* Get one of several potentially useful flags.
*/
BOOL
GSUserDefaultsFlag(GSUserDefaultFlagType type)
{ {
if (sharedDefaults == nil) if (sharedDefaults == nil)
{ {
@ -1982,4 +1979,5 @@ GSUserDefaultsFlag(GSUserDefaultFlagType type)
} }
return flags[type]; return flags[type];
} }
@end

View file

@ -385,7 +385,7 @@ objc_get_symbol_path(Class theClass, Category *theCategory)
if (ret) if (ret)
{ {
return [NSString stringWithCString: ret]; return [NSString stringWithUTF8String: ret];
} }
return nil; return nil;

View file

@ -419,8 +419,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
/* Some exceptional condition happened. */ /* Some exceptional condition happened. */
/* xxx We can do something with exception_fds, instead of /* xxx We can do something with exception_fds, instead of
aborting here. */ aborting here. */
NSLog (@"poll() error in -acceptInputForMode:beforeDate: '%s'", NSLog (@"poll() error in -acceptInputForMode:beforeDate: '%@'",
GSLastErrorStr(errno)); [_GSPrivate error]);
abort (); abort ();
} }
} }
@ -800,8 +800,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
/* Some exceptional condition happened. */ /* Some exceptional condition happened. */
/* xxx We can do something with exception_fds, instead of /* xxx We can do something with exception_fds, instead of
aborting here. */ aborting here. */
NSLog (@"select() error in -acceptInputForMode:beforeDate: '%s'", NSLog (@"select() error in -acceptInputForMode:beforeDate: '%@'",
GSLastErrorStr(errno)); [_GSPrivate error]);
abort (); abort ();
} }
} }

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free 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.
*/ */
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
@ -792,7 +793,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -806,8 +807,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR) if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR)
{ {
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(lsin.sin_addr), NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr),
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]);
(void) closesocket(net); (void) closesocket(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -825,9 +826,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
if (WSAGetLastError() != WSAEWOULDBLOCK) if (WSAGetLastError() != WSAEWOULDBLOCK)
{ {
NSLog(@"unable to make connection to %s:%d - %s", NSLog(@"unable to make connection to %s:%d - %@",
inet_ntoa(sin.sin_addr), inet_ntoa(sin.sin_addr),
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -891,7 +892,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET)
{ {
NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); NSLog(@"unable to create socket - %@", [_GSPrivate error]);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -908,8 +909,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR) if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) == SOCKET_ERROR)
{ {
NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr), NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
GSSwapBigI16ToHost(sin.sin_port), GSLastErrorStr(errno)); GSSwapBigI16ToHost(sin.sin_port), [_GSPrivate error]);
(void) closesocket(net); (void) closesocket(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -917,7 +918,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (listen(net, 256) == SOCKET_ERROR) if (listen(net, 256) == SOCKET_ERROR)
{ {
NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); NSLog(@"unable to listen on port - %@", [_GSPrivate error]);
(void) closesocket(net); (void) closesocket(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -925,7 +926,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (getsockname(net, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) if (getsockname(net, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
(void) closesocket(net); (void) closesocket(net);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -1092,8 +1093,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (_fstat(desc, &sbuf) != 0) if (_fstat(desc, &sbuf) != 0)
{ {
NSLog(@"unable to get status of descriptor %d - %s", NSLog(@"unable to get status of descriptor %d - %@",
desc, GSLastErrorStr(errno)); desc, [_GSPrivate error]);
} }
else else
{ {
@ -1293,8 +1294,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (len < 0) if (len < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return d; return d;
} }
@ -1318,8 +1319,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (len < 0) if (len < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return d; return d;
} }
@ -1344,8 +1345,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (got < 0) if (got < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
[d setLength: got]; [d setLength: got];
} }
@ -1367,8 +1368,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else if (got < 0) else if (got < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to read from descriptor - %s", format: @"unable to read from descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
} }
while (len > 0 && got > 0); while (len > 0 && got > 0);
@ -1414,8 +1415,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (rval < 0) if (rval < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"unable to write to descriptor - %s", format: @"unable to write to descriptor - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
} }
@ -1520,8 +1521,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (result < 0) if (result < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"failed to move to offset in file - %s", format: @"failed to move to offset in file - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return (unsigned long long)result; return (unsigned long long)result;
} }
@ -1544,8 +1545,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (result < 0) if (result < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"failed to move to offset in file - %s", format: @"failed to move to offset in file - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
return (unsigned long long)result; return (unsigned long long)result;
} }
@ -1568,8 +1569,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (result < 0) if (result < 0)
{ {
[NSException raise: NSFileHandleOperationException [NSException raise: NSFileHandleOperationException
format: @"failed to move to offset in file - %s", format: @"failed to move to offset in file - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
} }
} }
@ -1927,8 +1928,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Accept attempt failed - %s", s = [NSString stringWithFormat: @"Accept attempt failed - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
[readInfo setObject: s forKey: GSFileHandleNotificationError]; [readInfo setObject: s forKey: GSFileHandleNotificationError];
} }
else else
@ -1996,8 +1997,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Read attempt failed - %s", s = [NSString stringWithFormat: @"Read attempt failed - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
[readInfo setObject: s forKey: GSFileHandleNotificationError]; [readInfo setObject: s forKey: GSFileHandleNotificationError];
[self postReadNotification]; [self postReadNotification];
} }
@ -2005,8 +2006,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Read attempt failed - %s", s = [NSString stringWithFormat: @"Read attempt failed - %@",
GSLastErrorStr(errno)]; [_GSPrivate error]];
[readInfo setObject: s forKey: GSFileHandleNotificationError]; [readInfo setObject: s forKey: GSFileHandleNotificationError];
[self postReadNotification]; [self postReadNotification];
} }
@ -2045,8 +2046,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
{ {
NSString *s; NSString *s;
s = [NSString stringWithFormat: @"Connect attempt failed - %s", s = [NSString stringWithFormat: @"Connect attempt failed - %@",
GSLastErrorStr(result)]; [_GSPrivate error]];
[info setObject: s forKey: GSFileHandleNotificationError]; [info setObject: s forKey: GSFileHandleNotificationError];
} }
else else
@ -2080,7 +2081,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
NSString *s; NSString *s;
s = [NSString stringWithFormat: s = [NSString stringWithFormat:
@"Write attempt failed - %s", GSLastErrorStr(errno)]; @"Write attempt failed - %@", [_GSPrivate error]];
[info setObject: s forKey: GSFileHandleNotificationError]; [info setObject: s forKey: GSFileHandleNotificationError];
[self postWriteNotification]; [self postWriteNotification];
} }
@ -2193,7 +2194,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (void) setAddr: (struct sockaddr_in *)sin - (void) setAddr: (struct sockaddr_in *)sin
{ {
address = [[NSString alloc] initWithCString: (char*)inet_ntoa(sin->sin_addr)]; address = [[NSString alloc] initWithUTF8String:
(char*)inet_ntoa(sin->sin_addr)];
service = [[NSString alloc] initWithFormat: @"%d", service = [[NSString alloc] initWithFormat: @"%d",
(int)GSSwapBigI16ToHost(sin->sin_port)]; (int)GSSwapBigI16ToHost(sin->sin_port)];
protocol = @"tcp"; protocol = @"tcp";
@ -2239,8 +2241,8 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy) if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy)
== SOCKET_ERROR) == SOCKET_ERROR)
{ {
NSLog(@"unable to set non-blocking mode - %s", NSLog(@"unable to set non-blocking mode - %@",
GSLastErrorStr(errno)); [_GSPrivate error]);
} }
else else
isNonBlocking = flag; isNonBlocking = flag;
@ -2251,8 +2253,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy) if (ioctlsocket((SOCKET)_get_osfhandle(descriptor), FIONBIO, &dummy)
== SOCKET_ERROR) == SOCKET_ERROR)
{ {
NSLog(@"unable to set blocking mode - %s", NSLog(@"unable to set blocking mode - %@", [_GSPrivate error]);
GSLastErrorStr(errno));
} }
else else
isNonBlocking = flag; isNonBlocking = flag;
@ -2273,11 +2274,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
} }
else else
{ {
str = [NSString stringWithCString: (char*)inet_ntoa(sin.sin_addr)]; str = [NSString stringWithUTF8String: (char*)inet_ntoa(sin.sin_addr)];
} }
return str; return str;
} }
@ -2290,7 +2291,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
{ {
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); NSLog(@"unable to get socket name - %@", [_GSPrivate error]);
} }
else else
{ {

View file

@ -436,8 +436,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
BOOL found = NO; BOOL found = NO;
NSDebugMLLog(@"NSRunLoop", @"WaitForMultipleObjects() error in " NSDebugMLLog(@"NSRunLoop", @"WaitForMultipleObjects() error in "
@"-acceptInputForMode:beforeDate: %s", @"-acceptInputForMode:beforeDate: %@", [_GSPrivate error]);
GSLastErrorStr(GetLastError()));
/* /*
* Check each handle in turn until either we find one which has an * Check each handle in turn until either we find one which has an
* event signalled, or we find the one which caused the original * event signalled, or we find the one which caused the original
@ -458,8 +457,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
if (found == NO) if (found == NO)
{ {
NSLog(@"WaitForMultipleObjects() error in " NSLog(@"WaitForMultipleObjects() error in "
@"-acceptInputForMode:beforeDate: %s", @"-acceptInputForMode:beforeDate: %@", [_GSPrivate error]);
GSLastErrorStr(GetLastError()));
abort (); abort ();
} }
} }

View file

@ -311,8 +311,8 @@ OutputDebugStringW(L"");
} }
else else
{ {
NSLog(@"Failed to insert HKEY_CURRENT_USER\\%@\\%@ (%x) %s", NSLog(@"Failed to insert HKEY_CURRENT_USER\\%@\\%@ (%x) %@",
registry, n, rc, GSLastErrorStr(rc)); registry, n, rc, [_GSPrivate error: rc]);
return NO; return NO;
} }

View file

@ -206,8 +206,8 @@ static Class messagePortClass = 0;
M_UNLOCK(messagePortLock); M_UNLOCK(messagePortLock);
if ([p _setupSendPort] == NO) if ([p _setupSendPort] == NO)
{ {
NSLog(@"unable to access mailslot '%@' - %s", NSLog(@"unable to access mailslot '%@' - %@",
[p name], GSLastErrorStr(errno)); [p name], [_GSPrivate error]);
DESTROY(p); DESTROY(p);
} }
return p; return p;
@ -334,8 +334,8 @@ static Class messagePortClass = 0;
if (this->rHandle == INVALID_HANDLE_VALUE) if (this->rHandle == INVALID_HANDLE_VALUE)
{ {
NSLog(@"unable to create mailslot '%@' - %s", NSLog(@"unable to create mailslot '%@' - %@",
this->name, GSLastErrorStr(errno)); this->name, [_GSPrivate error]);
DESTROY(self); DESTROY(self);
} }
else else
@ -507,14 +507,14 @@ static Class messagePortClass = 0;
} }
else else
{ {
NSLog(@"GetOverlappedResult failed ...%s", GSLastErrorStr(errno)); NSLog(@"GetOverlappedResult failed ... %@", [_GSPrivate error]);
this->rState = RS_NONE; this->rState = RS_NONE;
this->rLength = 0; this->rLength = 0;
} }
} }
else else
{ {
NSLog(@"GetOverlappedResult success ...%u", this->rSize); NSLog(@"GetOverlappedResult success ... %u", this->rSize);
this->rState = RS_NONE; this->rState = RS_NONE;
this->rLength = 0; this->rLength = 0;
} }
@ -529,8 +529,8 @@ static Class messagePortClass = 0;
0, 0,
0) == 0) 0) == 0)
{ {
NSLog(@"unable to get info from mailslot '%@' - %s", NSLog(@"unable to get info from mailslot '%@' - %@",
this->name, GSLastErrorStr(errno)); this->name, [_GSPrivate error]);
[self invalidate]; [self invalidate];
return; return;
} }
@ -546,16 +546,15 @@ static Class messagePortClass = 0;
&this->rSize, &this->rSize,
NULL) == 0) NULL) == 0)
{ {
NSLog(@"unable to read from mailslot '%@' - %s", NSLog(@"unable to read from mailslot '%@' - %@",
this->name, GSLastErrorStr(errno)); this->name, [_GSPrivate error]);
[self invalidate]; [self invalidate];
return; return;
} }
if (this->rSize != this->rWant) if (this->rSize != this->rWant)
{ {
NSLog(@"only read %d of %d bytes from mailslot '%@' - %s", NSLog(@"only read %d of %d bytes from mailslot '%@' - %@",
this->rSize, this->rWant, this->name, this->rSize, this->rWant, this->name, [_GSPrivate error]);
GSLastErrorStr(errno));
[self invalidate]; [self invalidate];
return; return;
} }
@ -749,8 +748,8 @@ static Class messagePortClass = 0;
} }
else else
{ {
NSLog(@"unable to read from mailslot '%@' - %s", NSLog(@"unable to read from mailslot '%@' - %@",
this->name, GSLastErrorStr(errno)); this->name, [_GSPrivate error]);
[self invalidate]; [self invalidate];
} }
} }
@ -804,7 +803,7 @@ static Class messagePortClass = 0;
&this->wSize, &this->wSize,
TRUE) == 0) TRUE) == 0)
{ {
NSLog(@"GetOverlappedResult failed ...%s", GSLastErrorStr(errno)); NSLog(@"GetOverlappedResult failed ... %@", [_GSPrivate error]);
} }
else else
{ {
@ -856,8 +855,8 @@ again:
} }
else if ((errno = GetLastError()) != ERROR_IO_PENDING) else if ((errno = GetLastError()) != ERROR_IO_PENDING)
{ {
NSLog(@"unable to write to mailslot '%@' - %s", NSLog(@"unable to write to mailslot '%@' - %@",
this->name, GSLastErrorStr(errno)); this->name, [_GSPrivate error]);
[self invalidate]; [self invalidate];
} }
else else

View file

@ -269,7 +269,7 @@ static void setNonblocking(SOCKET fd)
unsigned long dummy = 1; unsigned long dummy = 1;
if (ioctlsocket(fd, FIONBIO, &dummy) == SOCKET_ERROR) if (ioctlsocket(fd, FIONBIO, &dummy) == SOCKET_ERROR)
NSLog(@"unable to set non-blocking mode - %s",GSLastErrorStr(errno)); NSLog(@"unable to set non-blocking mode - %@", [_GSPrivate error]);
} }
@implementation GSFileInputStream @implementation GSFileInputStream
@ -1866,8 +1866,8 @@ static void setNonblocking(SOCKET fd)
if (handle == INVALID_HANDLE_VALUE) if (handle == INVALID_HANDLE_VALUE)
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"Unable to open named pipe '%@'... %s", format: @"Unable to open named pipe '%@'... %@",
path, GSLastErrorStr(GetLastError())]; path, [_GSPrivate error]];
} }
// the type of the stream does not matter, since we are only using the fd // the type of the stream does not matter, since we are only using the fd

View file

@ -228,30 +228,35 @@ struct NSUserDefaultsWin32_DomainInfo
id v; id v;
NSString *k; NSString *k;
switch (type) { switch (type)
case REG_SZ: { {
int datacharlen = datalen / 2; case REG_SZ:
if (datacharlen > 0 && data[datacharlen-1] == 0) {
datacharlen--; int datacharlen = datalen / 2;
if (datacharlen > 0 && data[datacharlen-1] == 0)
datacharlen--;
v = [NSString stringWithCharacters:data length:datacharlen]; v = [NSString stringWithCharacters: data
} length: datacharlen];
break; }
case REG_BINARY: { break;
v = [NSString stringWithCString: (char*)data case REG_BINARY:
encoding: NSASCIIStringEncoding]; {
} v = [NSString stringWithCString: (char*)data
break; encoding: NSASCIIStringEncoding];
default: }
NSLog(@"Bad registry type %d for '%S'", type, name); break;
v = 0; default:
} NSLog(@"Bad registry type %d for '%S'", type, name);
v = 0;
}
v = [v propertyList]; v = [v propertyList];
if (v) if (v)
{ {
k = [NSString stringWithCharacters: name length: namelen]; k = [NSString stringWithCharacters: name
[domainDict setObject: v forKey: k]; length: namelen];
} [domainDict setObject: v forKey: k];
}
} }
NS_HANDLER NS_HANDLER
NSLog(@"Bad registry value for '%S'", name); NSLog(@"Bad registry value for '%S'", name);
@ -319,30 +324,35 @@ struct NSUserDefaultsWin32_DomainInfo
id v; id v;
NSString *k; NSString *k;
switch (type) { switch (type)
case REG_SZ: { {
int datacharlen = datalen / 2; case REG_SZ:
if (datacharlen > 0 && data[datacharlen-1] == 0) {
datacharlen--; int datacharlen = datalen / 2;
if (datacharlen > 0 && data[datacharlen-1] == 0)
datacharlen--;
v = [NSString stringWithCharacters:data length:datacharlen]; v = [NSString stringWithCharacters: data
} length: datacharlen];
break; }
case REG_BINARY: { break;
v = [NSString stringWithCString: (char*)data case REG_BINARY:
encoding: NSASCIIStringEncoding]; {
} v = [NSString stringWithCString: (char*)data
break; encoding: NSASCIIStringEncoding];
default: }
NSLog(@"Bad registry type %d for '%S'", type, name); break;
v = 0; default:
} NSLog(@"Bad registry type %d for '%S'", type, name);
v = 0;
}
v = [v propertyList]; v = [v propertyList];
if (v) if (v)
{ {
k = [NSString stringWithCharacters: name length: namelen]; k = [NSString stringWithCharacters: name
[domainDict setObject: v forKey: k]; length: namelen];
} [domainDict setObject: v forKey: k];
}
} }
NS_HANDLER NS_HANDLER
NSLog(@"Bad registry value for '%S'", name); NSLog(@"Bad registry value for '%S'", name);

View file

@ -263,7 +263,7 @@ bench_array()
{ {
char buf1[100]; char buf1[100];
sprintf(buf1, "str%0d", i); sprintf(buf1, "str%0d", i);
strings[i] = [stringClass stringWithCString: buf1]; strings[i] = [stringClass stringWithUTF8String: buf1];
} }
printf("NSArray\n"); printf("NSArray\n");
array = [NSMutableArray arrayWithCapacity: 16]; array = [NSMutableArray arrayWithCapacity: 16];
@ -316,8 +316,8 @@ bench_dict()
char buf1[100], buf2[100]; char buf1[100], buf2[100];
sprintf(buf1, "key%0d", i); sprintf(buf1, "key%0d", i);
sprintf(buf2, "val%0d", i); sprintf(buf2, "val%0d", i);
keys[i] = [stringClass stringWithCString: buf1]; keys[i] = [stringClass stringWithUTF8String: buf1];
vals[i] = [stringClass stringWithCString: buf2]; vals[i] = [stringClass stringWithUTF8String: buf2];
} }
printf("NSDictionary\n"); printf("NSDictionary\n");
dict = [NSMutableDictionary dictionaryWithCapacity: 16]; dict = [NSMutableDictionary dictionaryWithCapacity: 16];
@ -487,7 +487,7 @@ bench_str()
START_TIMER; START_TIMER;
for (i = 0; i < MAX_COUNT; i++) for (i = 0; i < MAX_COUNT; i++)
{ {
str = [stringClass stringWithCString: "hello world"]; str = [stringClass stringWithUTF8String: "hello world"];
} }
END_TIMER; END_TIMER;
PRINT_TIMER("NSString (1 cstring:) \t\t"); PRINT_TIMER("NSString (1 cstring:) \t\t");

View file

@ -72,11 +72,11 @@ GS_EXPORT NSString * const GSTelnetTextKey;
if (i > 0 && ptr[i-1] == '\r') if (i > 0 && ptr[i-1] == '\r')
{ {
s = [NSString stringWithCString: ptr length: i-1]; s = [NSString stringWithUTF8String: ptr length: i-1];
} }
else else
{ {
s = [NSString stringWithCString: ptr length: i]; s = [NSString stringWithUTF8String: ptr length: i];
} }
len -= (i + 1); len -= (i + 1);
if (len > 0) if (len > 0)

View file

@ -31,7 +31,7 @@
#define MyAssert2(IDENT) do { \ #define MyAssert2(IDENT) do { \
NSCAssert2([IDENT isEqual: \ NSCAssert2([IDENT isEqual: \
[NSString stringWithCString: #IDENT]], \ [NSString stringWithUTF8String: #IDENT]], \
@"Invalid value: %@ for: %s", \ @"Invalid value: %@ for: %s", \
IDENT, #IDENT); \ IDENT, #IDENT); \
NSCAssert2([cache[i++] isEqual: IDENT], \ NSCAssert2([cache[i++] isEqual: IDENT], \

View file

@ -522,7 +522,7 @@ int main(int argc, char *argv[], char **env)
[c setRootObject: l]; [c setRootObject: l];
if (optind < argc) if (optind < argc)
[c registerName: [NSString stringWithCString: argv[optind]]]; [c registerName: [NSString stringWithUTF8String: argv[optind]]];
else else
[c registerName: @"test2server"]; [c registerName: @"test2server"];

View file

@ -33,7 +33,7 @@ int main (int argc, char *argv[])
if (argc > 1) if (argc > 1)
out_port = [TcpOutPort newForSendingToRegisteredName: out_port = [TcpOutPort newForSendingToRegisteredName:
[NSString stringWithCString: argv[1]] [NSString stringWithUTF8String: argv[1]]
onHost: @"localhost"]; onHost: @"localhost"];
else else
out_port = [TcpOutPort newForSendingToRegisteredName: @"tcpport-test" out_port = [TcpOutPort newForSendingToRegisteredName: @"tcpport-test"

View file

@ -72,7 +72,7 @@ int main (int argc, char *argv[])
{ {
if (argc > 1) if (argc > 1)
port = [TcpInPort newForReceivingFromRegisteredName: port = [TcpInPort newForReceivingFromRegisteredName:
[NSString stringWithCString: argv[1]]]; [NSString stringWithUTF8String: argv[1]]];
else else
port = [TcpInPort newForReceivingFromRegisteredName: @"tcpport-test"]; port = [TcpInPort newForReceivingFromRegisteredName: @"tcpport-test"];

View file

@ -2333,11 +2333,11 @@ fail:
method = [[NSMutableDictionary alloc] initWithCapacity: 4]; method = [[NSMutableDictionary alloc] initWithCapacity: 4];
if (buffer[pos++] == '-') if (buffer[pos++] == '-')
{ {
mname = [NSMutableString stringWithCString: "-"]; mname = [NSMutableString stringWithUTF8String: "-"];
} }
else else
{ {
mname = [NSMutableString stringWithCString: "+"]; mname = [NSMutableString stringWithUTF8String: "+"];
} }
[method setObject: sels forKey: @"Sels"]; // Parts of selector. [method setObject: sels forKey: @"Sels"]; // Parts of selector.

View file

@ -19,7 +19,8 @@
# #
# You should have received a copy of the GNU General Public # You should have received a copy of the GNU General Public
# License along with this library; if not, write to the Free # 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.
# #
# #

View file

@ -62,7 +62,7 @@ static NSString *input(char **ptr)
{ {
tmp[-1] = '\0'; tmp[-1] = '\0';
*ptr = tmp; *ptr = tmp;
result = [NSString stringWithCString: start]; result = [NSString stringWithUTF8String: start];
break; break;
} }
} }
@ -76,7 +76,7 @@ static NSString *input(char **ptr)
} }
*tmp++ = '\0'; *tmp++ = '\0';
*ptr = tmp; *ptr = tmp;
result = [NSString stringWithCString: start]; result = [NSString stringWithUTF8String: start];
} }
return result; return result;
} }

View file

@ -64,12 +64,12 @@ loc_read_file(const char *dir, const char *file)
if (strlen(country) > 0 && strcmp(country, language) != 0) if (strlen(country) > 0 && strcmp(country, language) != 0)
{ {
strcat(country, language); strcat(country, language);
[dict setObject: [NSString stringWithCString: country] [dict setObject: [NSString stringWithUTF8String: country]
forKey: [NSString stringWithCString: locale]]; forKey: [NSString stringWithUTF8String: locale]];
} }
locale[2] = '\0'; locale[2] = '\0';
[dict setObject: [NSString stringWithCString: language] [dict setObject: [NSString stringWithUTF8String: language]
forKey: [NSString stringWithCString: locale]]; forKey: [NSString stringWithUTF8String: locale]];
fclose(fp); fclose(fp);
return 0; return 0;
} }

View file

@ -135,13 +135,14 @@ static int ParseFile(const char *filename,NSMutableDictionary *tables)
} }
filenamestr=[NSString stringWithCString: filename]; filenamestr = [NSString stringWithCString: filename
encoding: [NSString defaultCStringEncoding]];
if (verbose) if (verbose)
printf("Parsing '%s'.\n", [filenamestr cString]); printf("Parsing '%s'.\n", filename);
f=fopen(filename,"rt"); f=fopen(filename,"rt");
if (!f) if (!f)
{ {
NSLog(@"Unable to open '%s': %m\n",filename); NSLog(@"Unable to open '%@': %m\n",filenamestr);
return 1; return 1;
} }

View file

@ -69,7 +69,7 @@ id process_plist(NSData *inputData)
NSString *string = nil; NSString *string = nil;
// Initialize a string with the contents of the file. // Initialize a string with the contents of the file.
string = [NSString stringWithCString: (char *)[inputData bytes]]; string = [NSString stringWithUTF8String: (char *)[inputData bytes]];
// Convert the string into a property list. If there is a parsing error // Convert the string into a property list. If there is a parsing error
// the property list interpreter will throw an exception. // the property list interpreter will throw an exception.

View file

@ -55,7 +55,7 @@
{ {
buf[--len] = '\0'; buf[--len] = '\0';
} }
str = [NSString stringWithCString: buf]; str = [NSString stringWithUTF8String: buf];
return str; return str;
} }
@end @end