backport fixes from trunk

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/stable@26761 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-07-12 13:30:27 +00:00
parent 095870cf41
commit 218dc07e77
12 changed files with 7403 additions and 7348 deletions

View file

@ -1,3 +1,27 @@
2008-07-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/Unicode.m: Add support for byte order specific
unicode (including 32bit) via iconv. Change encoding lookup
mechanism to cope with new Mac-OS-X encoding values.
* Source/NSRunLoop.m:
* Source/NSArray.m:
* Source/NSSortDescriptor.m:
* Source/Additions/GSCompatibility.m:
* Source/NSDictionary.m:
* Source/NSSerializer.m:
* Source/NSSet.m:
Wherever ([-getObjects:]) is called, check to see if the receiver is
a proxy, and if so we populate the buffer by calling ([-objectAtIndex:])
instead. This because a proxy via DO does not know how many itesm are
in the buffer and assumes it's only one.
* configure.ac: use libffi in preference to ffcall as it doesn't mess
up the stack.
* configure: regenerate
Changes backported from trunk
2008-07-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSIndexSet.m: Implement ([-countOfIndexesInRange:])
2008-07-02 Richard Frith-Macdonald <rfm@gnu.org>
* Version 1.16.2

View file

@ -102,7 +102,19 @@ GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt)
unsigned c = [array count];
id objects[c];
[array getObjects: objects];
if ([array isProxy])
{
unsigned i;
for (i = 0; i < c; i++)
{
objects[i] = [array objectAtIndex: i];
}
}
else
{
[array getObjects: objects];
}
if (shouldCopy == YES)
{
unsigned i;

View file

@ -85,9 +85,11 @@ typedef struct {unichar from; unsigned char to;} _ucc_;
*/
#ifdef WORDS_BIGENDIAN
#define UNICODE_UTF16 "UTF-16BE"
#define UNICODE_UTF32 "UTF-32BE"
#define UNICODE_INT "UNICODEBIG"
#else
#define UNICODE_UTF16 "UTF-16LE"
#define UNICODE_UTF32 "UTF-32LE"
#define UNICODE_INT "UNICODELITTLE"
#endif
@ -250,6 +252,19 @@ static struct _strenc_ str_encoding_table[] = {
{NSKoreanEUCStringEncoding,
"NSKoreanEUCStringEncoding","EUC-KR",0,0,0},
/* Now Apple encodings which have high numeric values.
*/
{NSUTF16BigEndianStringEncoding,
"NSUTF16BigEndianStringEncoding","UTF-16BE",0,0,0},
{NSUTF16LittleEndianStringEncoding,
"NSUTF16LittleEndianStringEncoding","UTF-16LE",0,0,0},
{NSUTF32StringEncoding,
"NSUTF32StringEncoding",UNICODE_UTF32,0,0,0},
{NSUTF32BigEndianStringEncoding,
"NSUTF32BigEndianStringEncoding","UTF-32BE",0,0,0},
{NSUTF32LittleEndianStringEncoding,
"NSUTF32LittleEndianStringEncoding","UTF-32LE",0,0,0},
{0,"Unknown encoding","",0,0,0}
};
@ -264,8 +279,8 @@ static void GSSetupEncodingTable(void)
if (encodingTable == 0)
{
static struct _strenc_ **encTable = 0;
unsigned count;
unsigned i;
unsigned count;
unsigned i;
/*
* We want to store pointers to our string encoding info in a
@ -283,14 +298,12 @@ static void GSSetupEncodingTable(void)
{
unsigned tmp = str_encoding_table[i].enc;
if (tmp >= MAX_ENCODING)
if (tmp > encTableSize)
{
fprintf(stderr, "ERROR ... illegal NSStringEncoding "
"value in str_encoding_table. Ignored\n");
}
else if (tmp > encTableSize)
{
encTableSize = tmp;
if (tmp < MAX_ENCODING)
{
encTableSize = tmp;
}
}
}
encTable = objc_malloc((encTableSize+1)*sizeof(struct _strenc_ *));
@ -301,36 +314,37 @@ static void GSSetupEncodingTable(void)
*/
for (i = 0; i < count; i++)
{
unsigned tmp = str_encoding_table[i].enc;
struct _strenc_ *entry = &str_encoding_table[i];
unsigned tmp = entry->enc;
if (tmp < MAX_ENCODING)
{
encTable[tmp] = &str_encoding_table[i];
#ifdef HAVE_ICONV
if (encTable[tmp]->iconv != 0 && *(encTable[tmp]->iconv) != 0)
{
iconv_t c;
char *lossy;
/*
* See if we can do a lossy conversion.
*/
lossy = objc_malloc(strlen(encTable[tmp]->iconv) + 12);
strcpy(lossy, encTable[tmp]->iconv);
strcat(lossy, "//TRANSLIT");
c = iconv_open(UNICODE_ENC, encTable[tmp]->iconv);
if (c == (iconv_t)-1)
{
objc_free(lossy);
}
else
{
encTable[tmp]->lossy = lossy;
iconv_close(c);
}
}
#endif
encTable[tmp] = entry;
}
#ifdef HAVE_ICONV
if (entry->iconv != 0 && *(entry->iconv) != 0)
{
iconv_t c;
char *lossy;
/*
* See if we can do a lossy conversion.
*/
lossy = objc_malloc(strlen(entry->iconv) + 12);
strcpy(lossy, entry->iconv);
strcat(lossy, "//TRANSLIT");
c = iconv_open(UNICODE_ENC, entry->iconv);
if (c == (iconv_t)-1)
{
objc_free(lossy);
}
else
{
entry->lossy = lossy;
iconv_close(c);
}
}
#endif
}
encodingTable = encTable;
}
@ -338,61 +352,101 @@ static void GSSetupEncodingTable(void)
}
}
BOOL
GSPrivateIsEncodingSupported(NSStringEncoding enc)
static struct _strenc_ *
EntryForEncoding(NSStringEncoding enc)
{
GSSetupEncodingTable();
struct _strenc_ *entry = 0;
if (enc == 0 || enc > encTableSize || encodingTable[enc] == 0)
if (enc > 0)
{
GSSetupEncodingTable();
if (enc <= encTableSize)
{
entry = encodingTable[enc];
}
else
{
unsigned i = 0;
while (i < sizeof(str_encoding_table) / sizeof(struct _strenc_))
{
if (str_encoding_table[i].enc == enc)
{
entry = &str_encoding_table[i];
break;
}
i++;
}
}
}
return entry;
}
static struct _strenc_ *
EntrySupported(NSStringEncoding enc)
{
struct _strenc_ *entry = EntryForEncoding(enc);
if (entry == 0)
{
return NO;
}
#ifdef HAVE_ICONV
if (encodingTable[enc]->iconv != 0 && encodingTable[enc]->supported == 0)
if (entry->iconv != 0 && entry->supported == 0)
{
if (enc == NSUnicodeStringEncoding)
{
encodingTable[enc]->iconv = UNICODE_ENC;
encodingTable[enc]->supported = 1;
entry->iconv = UNICODE_ENC;
entry->supported = 1;
}
else if (encodingTable[enc]->iconv[0] == 0)
else if (entry->iconv[0] == 0)
{
/* explicitly check for empty encoding name since some systems
* have buggy iconv_open() code which succeeds on an empty name.
*/
encodingTable[enc]->supported = -1;
entry->supported = -1;
}
else
{
iconv_t c;
c = iconv_open(UNICODE_ENC, encodingTable[enc]->iconv);
c = iconv_open(UNICODE_ENC, entry->iconv);
if (c == (iconv_t)-1)
{
encodingTable[enc]->supported = -1;
entry->supported = -1;
}
else
{
iconv_close(c);
c = iconv_open(encodingTable[enc]->iconv, UNICODE_ENC);
c = iconv_open(entry->iconv, UNICODE_ENC);
if (c == (iconv_t)-1)
{
encodingTable[enc]->supported = -1;
entry->supported = -1;
}
else
{
iconv_close(c);
encodingTable[enc]->supported = 1;
entry->supported = 1;
}
}
}
}
#endif
if (encodingTable[enc]->supported == 1)
if (entry->supported == 1)
{
return YES;
return entry;
}
return NO;
return 0;
}
BOOL
GSPrivateIsEncodingSupported(NSStringEncoding enc)
{
if (EntrySupported(enc) == 0)
{
return NO;
}
return YES;
}
/** Returns the NSStringEncoding that matches the specified
@ -982,7 +1036,6 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
break;
case NSISOLatin1StringEncoding:
case NSUnicodeStringEncoding:
while (spos < slen)
{
if (dpos >= bsize)
@ -1081,6 +1134,7 @@ tables:
default:
#ifdef HAVE_ICONV
{
struct _strenc_ *encInfo;
unsigned char *inbuf;
unsigned char *outbuf;
size_t inbytesleft;
@ -1090,9 +1144,9 @@ tables:
const char *estr = 0;
BOOL done = NO;
if (GSPrivateIsEncodingSupported(enc) == YES)
if ((encInfo = EntrySupported(enc)) != 0)
{
estr = encodingTable[enc]->iconv;
estr = encInfo->iconv;
}
/* explicitly check for empty encoding name since some systems
* have buggy iconv_open() code which succeeds on an empty name.
@ -1770,6 +1824,7 @@ tables:
#ifdef HAVE_ICONV
iconv_start:
{
struct _strenc_ *encInfo;
iconv_t cd;
unsigned char *inbuf;
unsigned char *outbuf;
@ -1779,7 +1834,7 @@ iconv_start:
const char *estr = 0;
BOOL done = NO;
if (GSPrivateIsEncodingSupported(enc) == YES)
if ((encInfo = EntrySupported(enc)) != 0)
{
if (strict == NO)
{
@ -1787,11 +1842,11 @@ iconv_start:
* Try to transliterate where no direct conversion
* is available.
*/
estr = encodingTable[enc]->lossy;
estr = encInfo->lossy;
}
if (estr == 0)
{
estr = encodingTable[enc]->iconv;
estr = encInfo->iconv;
}
}
@ -2199,21 +2254,25 @@ GSPrivateDefaultCStringEncoding()
NSString*
GSPrivateEncodingName(NSStringEncoding encoding)
{
if (GSPrivateIsEncodingSupported(encoding) == NO)
struct _strenc_ *encInfo;
if ((encInfo = EntrySupported(encoding)) == NO)
{
return @"Unknown encoding";
}
return [NSString stringWithUTF8String: encodingTable[encoding]->ename];
return [NSString stringWithUTF8String: encInfo->ename];
}
BOOL
GSPrivateIsByteEncoding(NSStringEncoding encoding)
{
if (GSPrivateIsEncodingSupported(encoding) == NO)
struct _strenc_ *encInfo;
if ((encInfo = EntrySupported(encoding)) == NO)
{
return NO;
}
return encodingTable[encoding]->eightBit;
return encInfo->eightBit;
}
NSStringEncoding

View file

@ -315,17 +315,33 @@ static SEL rlSel;
- (NSArray*) arrayByAddingObjectsFromArray: (NSArray*)anotherArray
{
id na;
unsigned c, l;
unsigned c;
unsigned l;
unsigned e;
c = [self count];
l = [anotherArray count];
e = c + l;
{
GS_BEGINIDBUF(objects, c+l);
GS_BEGINIDBUF(objects, e);
[self getObjects: objects];
[anotherArray getObjects: &objects[c]];
na = [NSArrayClass arrayWithObjects: objects count: c+l];
if ([anotherArray isProxy])
{
unsigned i = c;
unsigned j = 0;
while (i < e)
{
objects[i++] = [anotherArray objectAtIndex: j++];
}
}
else
{
[anotherArray getObjects: &objects[c]];
}
na = [NSArrayClass arrayWithObjects: objects count: e];
GS_ENDIDBUF();
}
@ -582,7 +598,19 @@ static SEL rlSel;
unsigned c = [array count];
GS_BEGINIDBUF(objects, c);
[array getObjects: objects];
if ([array isProxy])
{
unsigned i;
for (i = 0; i < c; i++)
{
objects[i] = [array objectAtIndex: i];
}
}
else
{
[array getObjects: objects];
}
if (shouldCopy == YES)
{
unsigned i;
@ -617,7 +645,19 @@ static SEL rlSel;
unsigned c = [array count];
GS_BEGINIDBUF(objects, c);
[array getObjects: objects];
if ([array isProxy])
{
unsigned i;
for (i = 0; i < c; i++)
{
objects[i] = [array objectAtIndex: i];
}
}
else
{
[array getObjects: objects];
}
self = [self initWithObjects: objects count: c];
GS_ENDIDBUF();
return self;

View file

@ -437,8 +437,32 @@ static SEL appSel;
{
GS_BEGINIDBUF(o, objectCount*2);
[objects getObjects: o];
[keys getObjects: o + objectCount];
if ([objects isProxy])
{
unsigned i;
for (i = 0; i < objectCount; i++)
{
o[i] = [objects objectAtIndex: i];
}
}
else
{
[objects getObjects: o];
}
if ([keys isProxy])
{
unsigned i;
for (i = 0; i < objectCount; i++)
{
o[objectCount + i] = [keys objectAtIndex: i];
}
}
else
{
[keys getObjects: o + objectCount];
}
self = [self initWithObjects: o
forKeys: o + objectCount
count: objectCount];
@ -899,7 +923,17 @@ compareIt(id o1, id o2, void* context)
id result;
GS_BEGINIDBUF(obuf, c);
[keys getObjects: obuf];
if ([keys isProxy])
{
for (i = 0; i < c; i++)
{
obuf[i] = [keys objectAtIndex: i];
}
}
else
{
[keys getObjects: obuf];
}
for (i = 0; i < c; i++)
{
id o = (*myObj)(self, objSel, obuf[i]);
@ -1245,7 +1279,19 @@ compareIt(id o1, id o2, void* context)
IMP remObj = [self methodForSelector: remSel];
GS_BEGINIDBUF(keys, c);
[keyArray getObjects: keys];
if ([keyArray isProxy])
{
unsigned i;
for (i = 0; i < c; i++)
{
keys[i] = [keyArray objectAtIndex: i];
}
}
else
{
[keyArray getObjects: keys];
}
while (c--)
{
(*remObj)(self, remSel, keys[c]);

View file

@ -234,7 +234,26 @@ static unsigned posForIndex(GSIArray array, unsigned index)
- (NSUInteger) countOfIndexesInRange: (NSRange)range
{
return 0;
if (_array == 0 || GSIArrayCount(_array) == 0)
{
return 0;
}
else
{
unsigned count = GSIArrayCount(_array);
unsigned total = 0;
unsigned i = 0;
while (i < count)
{
NSRange r = GSIArrayItemAtIndex(_array, i).ext;
r = NSIntersectionRange(r, range);
total += r.length;
i++;
}
return total;
}
}
- (void) dealloc

View file

@ -360,7 +360,17 @@ static inline BOOL timerInvalidated(NSTimer *t)
delay: seconds];
[[loop _timedPerformers] addObject: item];
RELEASE(item);
[modes getObjects: marray];
if ([modes isProxy])
{
for (i = 0; i < count; i++)
{
marray[i] = [modes objectAtIndex: i];
}
}
else
{
[modes getObjects: marray];
}
for (i = 0; i < count; i++)
{
[loop addTimer: item->timer forMode: marray[i]];
@ -1405,7 +1415,19 @@ static inline BOOL timerInvalidated(NSTimer *t)
argument: argument
order: order];
[modes getObjects: array];
if ([modes isProxy])
{
unsigned i;
for (i = 0; i < count; i++)
{
array[i] = [modes objectAtIndex: i];
}
}
else
{
[modes getObjects: array];
}
while (count-- > 0)
{
NSString *mode = array[count];

View file

@ -280,7 +280,17 @@ serializeToInfo(id object, _NSSerializerInfo* info)
id objects[count];
unsigned int i;
[object getObjects: objects];
if ([object isProxy])
{
for (i = 0; i < count; i++)
{
objects[i] = [object objectAtIndex: i];
}
}
else
{
[object getObjects: objects];
}
for (i = 0; i < count; i++)
{
serializeToInfo(objects[i], info);

View file

@ -381,7 +381,19 @@ static Class NSMutableSet_concrete_class;
{
GS_BEGINIDBUF(objs, count);
[other getObjects: objs];
if ([other isProxy])
{
unsigned i;
for (i = 0; i < count; i++)
{
objs[i] = [other objectAtIndex: i];
}
}
else
{
[other getObjects: objs];
}
self = [self initWithObjects: objs count: count];
GS_ENDIDBUF();
return self;

View file

@ -312,7 +312,19 @@ SortRange(id *objects, NSRange range, id *descriptors,
GS_BEGINIDBUF(objects, count);
[self getObjects: objects];
[sortDescriptors getObjects: descriptors];
if ([sortDescriptors isProxy])
{
unsigned i;
for (i = 0; i < numDescriptors; i++)
{
descriptors[i] = [sortDescriptors objectAtIndex: i];
}
}
else
{
[sortDescriptors getObjects: descriptors];
}
SortRange(objects, NSMakeRange(0, count), descriptors, numDescriptors);
a = [[NSArray alloc] initWithObjects: objects count: count];
[self setArray: a];
@ -333,7 +345,19 @@ SortRange(id *objects, NSRange range, id *descriptors,
{
GS_BEGINIDBUF(descriptors, dCount);
[sortDescriptors getObjects: descriptors];
if ([sortDescriptors isProxy])
{
unsigned i;
for (i = 0; i < dCount; i++)
{
descriptors[i] = [sortDescriptors objectAtIndex: i];
}
}
else
{
[sortDescriptors getObjects: descriptors];
}
SortRange(_contents_array, NSMakeRange(0, _count), descriptors, dCount);
GS_ENDIDBUF();

14309
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1876,13 +1876,15 @@ fi
#--------------------------------------------------------------------
# Check for FFI interface libraries for invocations
# We enable ffcall by default now, except on sparc64 (where we think
# it's broken).
# We enable ffi by default now, as it's fixed for some previouly bad
# platforms, and it has the advantage over ffcall that it does not
# mess up the stack, so stacktraces and native exception handling
# work better with it.
#--------------------------------------------------------------------
do_broken_libffi=no
do_broken_libffcall=no
do_enable_libffi=no
do_enable_libffcall=yes
do_enable_libffi=yes
do_enable_libffcall=no
case "$target_cpu" in
sparc64*)
case "$target_os" in
@ -1939,6 +1941,10 @@ if test $have_ffcall = no; then
fi
if test $have_libffi = no; then
enable_libffi=no
# If we don't have libffi but do have ffcall, use ffcall
if test $have_ffcall = yes; then
enable_ffcall=yes
fi
fi
have_forward_hook=yes