mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Various bugfixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13045 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dbfd116cbf
commit
8c0d705d47
6 changed files with 66 additions and 26 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2002-03-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GNUmakefile: Include ../../base.make
|
||||
* SSL/GNUmakefile: Include ../base.make
|
||||
from the makefiles directory for builting standalone.
|
||||
* Source/Unicode.m: Added some standard string handling for iconv.
|
||||
* Source/NSString.m: ([-initWithData:encoding:]) return nil on
|
||||
failure to handle encoding.
|
||||
Reports by Alexander Malmberg
|
||||
|
||||
2002-03-07 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
|
||||
* Source/NSRunLoop.m ([NSRunLoop -acceptInputForMode:]):
|
||||
|
|
|
@ -28,6 +28,9 @@ GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
|||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
-include config.mak
|
||||
|
||||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
srcdir = .
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <openssl/ssl.h>
|
||||
#undef id
|
||||
|
||||
#include <GSConfig.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include <gnustep/base/UnixFileHandle.h>
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../base.make
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
SUBPROJECT_NAME=Additions
|
||||
|
|
|
@ -1066,59 +1066,60 @@ handle_printf_atsign (FILE *stream,
|
|||
- (id) initWithData: (NSData*)data
|
||||
encoding: (NSStringEncoding)encoding
|
||||
{
|
||||
if (encoding == NSASCIIStringEncoding
|
||||
unsigned len = [data length];
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
self = [self initWithCStringNoCopy: "" length: 0 freeWhenDone: NO];
|
||||
}
|
||||
else if (encoding == NSASCIIStringEncoding
|
||||
|| encoding == _DefaultStringEncoding)
|
||||
{
|
||||
unsigned len = [data length];
|
||||
char *s = NSZoneMalloc(GSObjCZone(self), len);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
char *s = NSZoneMalloc(GSObjCZone(self), len);
|
||||
|
||||
[data getBytes: s];
|
||||
self = [self initWithCStringNoCopy: s length: len freeWhenDone: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
self = [self initWithCStringNoCopy: "" length: 0 freeWhenDone: NO];
|
||||
}
|
||||
return self;
|
||||
[data getBytes: s];
|
||||
self = [self initWithCStringNoCopy: s length: len freeWhenDone: YES];
|
||||
}
|
||||
else if (encoding == NSUTF8StringEncoding)
|
||||
{
|
||||
unsigned length = [data length];
|
||||
const char *bytes = [data bytes];
|
||||
unsigned i;
|
||||
|
||||
/*
|
||||
* Check to see if we have in fact got an ascii string
|
||||
*/
|
||||
for (i = 0; i < length; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (((unsigned char*)bytes)[i] > 127)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == length)
|
||||
if (i == len)
|
||||
{
|
||||
self = [self initWithCString: bytes length: length];
|
||||
self = [self initWithCString: bytes length: len];
|
||||
}
|
||||
else
|
||||
{
|
||||
unichar *u;
|
||||
|
||||
u = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length);
|
||||
length = encode_cstrtoustr(u, length, bytes, length,
|
||||
u = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len);
|
||||
len = encode_cstrtoustr(u, len, bytes, len,
|
||||
NSUTF8StringEncoding);
|
||||
self = [self initWithCharactersNoCopy: u
|
||||
length: length
|
||||
freeWhenDone: YES];
|
||||
if (len > 0)
|
||||
{
|
||||
self = [self initWithCharactersNoCopy: u
|
||||
length: len
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
DESTROY(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned len = [data length];
|
||||
unichar *u;
|
||||
unsigned count;
|
||||
const unsigned char *b;
|
||||
|
@ -1147,13 +1148,24 @@ handle_printf_atsign (FILE *stream,
|
|||
}
|
||||
}
|
||||
count = count/2 - 1;
|
||||
self = [self initWithCharactersNoCopy: u
|
||||
length: count
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
count = encode_cstrtoustr(u, len, b, len, encoding);
|
||||
if (count < 1)
|
||||
{
|
||||
DESTROY(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
self = [self initWithCharactersNoCopy: u
|
||||
length: count
|
||||
freeWhenDone: YES];
|
||||
}
|
||||
}
|
||||
|
||||
self = [self initWithCharactersNoCopy: u length: count freeWhenDone: YES];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -364,6 +364,18 @@ iconv_stringforencoding(NSStringEncoding enc)
|
|||
return "ISO-8859-7";
|
||||
case NSISOHebrewStringEncoding:
|
||||
return "ISO-8859-8";
|
||||
|
||||
case NSISOLatin5StringEncoding:
|
||||
return "ISO-8859-9";
|
||||
case NSISOLatin6StringEncoding:
|
||||
return "ISO-8859-10";
|
||||
case NSISOLatin7StringEncoding:
|
||||
return "ISO-8859-13";
|
||||
case NSISOLatin8StringEncoding:
|
||||
return "ISO-8859-14";
|
||||
case NSISOLatin9StringEncoding:
|
||||
return "ISO-8859-15";
|
||||
|
||||
case NSGB2312StringEncoding:
|
||||
return "EUC-CN";
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue