mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixing c-string encodings
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/mswin-ng@23901 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1d9ddad989
commit
58e065b674
19 changed files with 65 additions and 41 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,8 +1,24 @@
|
|||
2006-10-06 Sheldon Gill <sheldon@westnet.net.au>
|
||||
2006-10-18 Sheldon Gill <sheldon@westnet.net.au>
|
||||
|
||||
* Headers/Foundation/NSError.h
|
||||
* Source/NSError.m
|
||||
Updated to Tiger specifications
|
||||
* Source/NSSocketPortNameServer.m
|
||||
* Source/NSTimeZone.m
|
||||
* Source/NSProcessInfo.m
|
||||
* Source/NSSocketPort.m
|
||||
* Source/NSKeyedArchiver.m
|
||||
* Source/NSDebug.m
|
||||
* Source/NSPort.m
|
||||
* Source/NSMessagePort.m
|
||||
* Source/win32/NSMessagePortWin32.m
|
||||
* Source/NSInvocation.m
|
||||
* Source/NSFileManager.m
|
||||
* Source/objc-load.m
|
||||
* Source/NSHTTPCookieStorage.m
|
||||
* Source/NSException.m
|
||||
* Source/Additions/Unicode.m
|
||||
* Source/Additions/GSCompatibility.m
|
||||
* Source/NSHost.m
|
||||
* Source/NSObjCRuntime.m
|
||||
Fixing c-strings so that they use specific encodings
|
||||
|
||||
2006-10-03 Sheldon Gill <sheldon@westnet.net.au>
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
|
||||
NSSwapBigShortToHost(sin.sin_port), GSLastSocketError());
|
||||
NSSwapBigShortToHost(sin.sin_port), GSLastSocketError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -286,7 +286,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (listen(net, 5) < 0)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %@", GSLastSocketError());
|
||||
NSLog(@"unable to listen on port - %@", GSLastSocketError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -294,7 +294,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (getsockname(net, (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
|
@ -323,7 +323,7 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
|
||||
if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
NSLog(@"unable to get socket name - %@", GSLastSocketError());
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -594,7 +594,7 @@ GSEncodingFromLocale(const char *clocale)
|
|||
|
||||
dict = [NSDictionary dictionaryWithContentsOfFile: table];
|
||||
encodstr = [dict objectForKey:
|
||||
[NSString stringWithCString: clocale]];
|
||||
[NSString stringWithUTF8String: clocale]];
|
||||
if (encodstr == nil)
|
||||
return GSUndefinedEncoding;
|
||||
|
||||
|
|
|
@ -957,6 +957,7 @@ const char *_NSPrintForDebugger(id object)
|
|||
|
||||
NSString *_NSNewStringFromCString(const char *cstring)
|
||||
{
|
||||
return [NSString stringWithCString: cstring];
|
||||
return [NSString stringWithCString: cstring
|
||||
encoding: [NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
|
|
|
@ -353,8 +353,9 @@ static void find_address (bfd *abfd, asection *section,
|
|||
fi = [GSFunctionInfo alloc];
|
||||
fi = [fi initWithModule: info->module
|
||||
address: info->theAddress
|
||||
file: [NSString stringWithCString: fileName]
|
||||
function: [NSString stringWithCString: functionName]
|
||||
file: [NSString stringWithCString: fileName
|
||||
encoding: [NSString defaultCStringEncoding]]
|
||||
function: [NSString stringWithUTF8String: functionName]
|
||||
line: line];
|
||||
[fi autorelease];
|
||||
info->theInfo = fi;
|
||||
|
|
|
@ -2946,7 +2946,8 @@ static NSSet *fileKeys = nil;
|
|||
gp = getgrgid(statbuf.st_gid);
|
||||
if (gp != 0)
|
||||
{
|
||||
group = [NSString stringWithCString: gp->gr_name];
|
||||
group = [NSString stringWithCString: gp->gr_name
|
||||
encoding: defaultEncoding];
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -3087,7 +3088,8 @@ static NSSet *fileKeys = nil;
|
|||
|
||||
if (pw != 0)
|
||||
{
|
||||
owner = [NSString stringWithCString: pw->pw_name];
|
||||
owner = [NSString stringWithCString: pw->pw_name
|
||||
encoding: defaultEncoding];
|
||||
}
|
||||
#endif /* HAVE_PWD_H */
|
||||
#endif
|
||||
|
|
|
@ -111,6 +111,8 @@ static NSHTTPCookieStorage *storage = nil;
|
|||
|
||||
- (void) setCookie: (NSHTTPCookie *)cookie
|
||||
{
|
||||
NSAssert([cookie isKindOfClass: [NSHTTPCookie class]] == YES,
|
||||
NSInvalidArgumentException);
|
||||
[this->_cookies addObject: cookie];
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ static NSMutableDictionary *_hostCache = nil;
|
|||
break;
|
||||
}
|
||||
|
||||
h_name = [NSString stringWithCString: entry->h_name];
|
||||
h_name = [NSString stringWithUTF8String: entry->h_name];
|
||||
[names addObject: h_name];
|
||||
|
||||
if (entry->h_aliases != 0)
|
||||
|
@ -212,7 +212,7 @@ static NSMutableDictionary *_hostCache = nil;
|
|||
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)
|
||||
|
@ -223,7 +223,7 @@ static NSMutableDictionary *_hostCache = nil;
|
|||
NSString *addr;
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -654,7 +654,7 @@ _arg_addr(NSInvocation *inv, int index)
|
|||
_target ? GSNameFromClass([_target class]) : "nil" \
|
||||
);
|
||||
|
||||
return [NSString stringWithCString: buffer];
|
||||
return [NSString stringWithUTF8String: buffer];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
|
|
|
@ -669,7 +669,7 @@ static NSDictionary *makeReference(unsigned ref)
|
|||
* Bizzarely MacOS-X seems to encode char* values by creating
|
||||
* string objects and encoding those objects!
|
||||
*/
|
||||
o = [NSString stringWithCString: (char*)address];
|
||||
o = [NSString stringWithUTF8String: (char*)address];
|
||||
[self encodeObject: o];
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -381,8 +381,7 @@ static Class runLoopClass;
|
|||
if (errno != EINPROGRESS)
|
||||
{
|
||||
NSLog(@"unable to make connection to %s - %@",
|
||||
sockAddr.sun_path,
|
||||
GSLastError());
|
||||
sockAddr.sun_path, GSLastError());
|
||||
M_UNLOCK(myLock);
|
||||
return NO;
|
||||
}
|
||||
|
@ -608,7 +607,7 @@ static Class runLoopClass;
|
|||
else if (errno != EINTR && errno != EAGAIN)
|
||||
{
|
||||
NSDebugMLLog(@"NSMessagePort",
|
||||
@"read failed - %s on 0x%x", GSLastError(), self);
|
||||
@"read failed - %@ on 0x%x", GSLastError(), self);
|
||||
M_UNLOCK(myLock);
|
||||
[self invalidate];
|
||||
return;
|
||||
|
|
|
@ -40,7 +40,7 @@ NSString *
|
|||
NSStringFromSelector(SEL aSelector)
|
||||
{
|
||||
if (aSelector != (SEL)0)
|
||||
return [NSString stringWithCString: GSNameFromSelector(aSelector)];
|
||||
return [NSString stringWithUTF8String: GSNameFromSelector(aSelector)];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ NSString *
|
|||
NSStringFromClass(Class aClass)
|
||||
{
|
||||
if (aClass != (Class)0)
|
||||
return [NSString stringWithCString: (char*)GSNameFromClass(aClass)];
|
||||
return [NSString stringWithUTF8String: (char*)GSNameFromClass(aClass)];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@
|
|||
*/
|
||||
NSString * const NSPortTimeoutException = @"NSPortTimeoutException";
|
||||
|
||||
Class NSPort_abstract_class;
|
||||
Class NSPort_concrete_class;
|
||||
static Class NSPort_abstract_class;
|
||||
static Class NSPort_concrete_class;
|
||||
|
||||
+ (id) allocWithZone: (NSZone*)aZone
|
||||
{
|
||||
|
|
|
@ -252,7 +252,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
|
|||
objc_free(buffer);
|
||||
}
|
||||
}
|
||||
tmp = [arg0 UTF8String];
|
||||
tmp = [arg0 cStringUsingEncoding: [NSString defaultCStringEncoding]];
|
||||
_gnu_arg_zero = (char*)objc_malloc(strlen(tmp) + 1);
|
||||
strcpy(_gnu_arg_zero, tmp);
|
||||
#else
|
||||
|
@ -315,7 +315,8 @@ _gnu_process_args(int argc, char *argv[], char *env[])
|
|||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
str = [NSString stringWithCString: argv[i]];
|
||||
str = [NSString stringWithCString: argv[i]
|
||||
encoding: [NSString defaultCStringEncoding]];
|
||||
|
||||
if ([str hasPrefix: @"--GNU-Debug="])
|
||||
[mySet addObject: [str substringFromIndex: 12]];
|
||||
|
@ -398,8 +399,10 @@ _gnu_process_args(int argc, char *argv[], char *env[])
|
|||
strcpy(buf, env[i]);
|
||||
cp = &buf[cp - env[i]];
|
||||
*cp++ = '\0';
|
||||
[keys addObject: [NSString stringWithCString: buf]];
|
||||
[values addObject: [NSString stringWithCString: cp]];
|
||||
[keys addObject: [NSString stringWithCString: buf
|
||||
encoding: [NSString defaultCStringEncoding]]];
|
||||
[values addObject: [NSString stringWithCString: cp
|
||||
encoding: [NSString defaultCStringEncoding]]];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -522,7 +525,7 @@ static char **_gnu_noobjc_env = NULL;
|
|||
psinfo_t pinfo;
|
||||
char **vectors;
|
||||
int i, count;
|
||||
|
||||
|
||||
// Read commandline
|
||||
proc_file_name = (char*)objc_malloc(sizeof(char) * 2048);
|
||||
sprintf(proc_file_name, "/proc/%d/psinfo", (int) getpid());
|
||||
|
@ -1032,7 +1035,7 @@ int main(int argc, char *argv[], char *env[])
|
|||
if (uname(&uns) != -1)
|
||||
{
|
||||
os = [NSString stringWithCString: uts.sysname
|
||||
encoding: NSDefaultEncoding];
|
||||
encoding: [NSString defaultCStringEncoding]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ decodePort(NSData *data, NSString *defaultAddress)
|
|||
pi->addr, pnum);
|
||||
return nil;
|
||||
}
|
||||
addr = [NSString stringWithCString: pi->addr];
|
||||
addr = [NSString stringWithUTF8String: pi->addr];
|
||||
|
||||
NSDebugFLLog(@"NSPort", @"Decoded port as '%@:%d'", addr, pnum);
|
||||
|
||||
|
@ -1123,7 +1123,7 @@ static Class runLoopClass;
|
|||
if (len == (int)[d length])
|
||||
{
|
||||
RELEASE(defaultAddress);
|
||||
defaultAddress = RETAIN([NSString stringWithCString:
|
||||
defaultAddress = RETAIN([NSString stringWithUTF8String:
|
||||
inet_ntoa(sockAddr.sin_addr)]);
|
||||
NSDebugMLLog(@"GSTcpHandle",
|
||||
@"wrote %d bytes on 0x%x", len, self);
|
||||
|
@ -2184,7 +2184,7 @@ static Class tcpPortClass;
|
|||
*/
|
||||
handle = [GSTcpHandle handleWithDescriptor: desc];
|
||||
memcpy(&handle->sockAddr, &sockAddr, sizeof(sockAddr));
|
||||
handle->defaultAddress = RETAIN([NSString stringWithCString:
|
||||
handle->defaultAddress = RETAIN([NSString stringWithUTF8String:
|
||||
inet_ntoa(sockAddr.sin_addr)]);
|
||||
|
||||
[handle setState: GS_H_ACCEPT];
|
||||
|
|
|
@ -554,7 +554,7 @@ typedef enum {
|
|||
serverLock = [NSRecursiveLock new];
|
||||
modes = [[NSArray alloc] initWithObjects: &mode count: 1];
|
||||
#ifdef GDOMAP_PORT_OVERRIDE
|
||||
serverPort = RETAIN([NSString stringWithCString:
|
||||
serverPort = RETAIN([NSString stringWithUTF8String:
|
||||
make_gdomap_port(GDOMAP_PORT_OVERRIDE)]);
|
||||
#endif
|
||||
portClass = [NSSocketPort class];
|
||||
|
@ -738,7 +738,7 @@ typedef enum {
|
|||
[array addObject: com];
|
||||
RELEASE(com);
|
||||
[com setAddr: svrs[count]];
|
||||
addr = [NSString stringWithCString:
|
||||
addr = [NSString stringWithUTF8String:
|
||||
(char*)inet_ntoa(svrs[count])];
|
||||
[com startPortLookup: name onHost: addr];
|
||||
count++;
|
||||
|
@ -802,7 +802,7 @@ typedef enum {
|
|||
|
||||
if (*port)
|
||||
{
|
||||
*addr = [NSString stringWithCString: inet_ntoa(singleServer)];
|
||||
*addr = [NSString stringWithUTF8String: inet_ntoa(singleServer)];
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1487,7 +1487,7 @@ static NSMapTable *absolutes = 0;
|
|||
bufsize--;
|
||||
}
|
||||
localZoneString
|
||||
= [NSString stringWithCString: buf length: bufsize];
|
||||
= [NSString stringWithUTF8String: buf length: bufsize];
|
||||
}
|
||||
RegCloseKey(regkey);
|
||||
}
|
||||
|
|
|
@ -385,7 +385,7 @@ objc_get_symbol_path(Class theClass, Category *theCategory)
|
|||
|
||||
if (ret)
|
||||
{
|
||||
return [NSString stringWithCString: ret];
|
||||
return [NSString stringWithUTF8String: ret];
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
|
|
@ -508,7 +508,7 @@ static Class messagePortClass = 0;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"GetOverlappedResult failed ...%s", GSLastError());
|
||||
NSLog(@"GetOverlappedResult failed ...%@", GSLastError());
|
||||
this->rState = RS_NONE;
|
||||
this->rLength = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue