Add support for code plane 16 in character sets.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22914 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-05-12 15:13:12 +00:00
parent 8891b7e197
commit bc30035fa1
15 changed files with 16408 additions and 8200 deletions

View file

@ -1,6 +1,8 @@
2006-05-12 Richard Frith-Macdonald <rfm@gnu.org> 2006-05-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSString.m: validate UTF-16 data when producing a Cstring * Source/GSString.m: validate UTF-16 data when producing a Cstring
* Source/NSCharacterSetData.h: Add code plane 16 (private use)
* Source/NSCharacterSet.m: Fix to support code plane 16
2006-05-11 Richard Frith-Macdonald <rfm@gnu.org> 2006-05-11 Richard Frith-Macdonald <rfm@gnu.org>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -42,10 +42,10 @@
#include "NSCharacterSetData.h" #include "NSCharacterSetData.h"
//PENDING: may want to make these less likely to conflict //PENDING: may want to make these less likely to conflict
#define UNICODE_SIZE 65536 #define UNICODE_SIZE 63336
#define UNICODE_MAX 1048576 #define UNICODE_MAX 1114112
#define BITMAP_SIZE 8192 #define BITMAP_SIZE 8192
#define BITMAP_MAX 131072 #define BITMAP_MAX 139264
#ifndef SETBIT #ifndef SETBIT
#define SETBIT(a,i) ((a) |= 1<<(i)) #define SETBIT(a,i) ((a) |= 1<<(i))
@ -83,7 +83,7 @@
- (NSData*) bitmapRepresentation - (NSData*) bitmapRepresentation
{ {
unsigned i = 16; unsigned i = 17;
while (i > 0 && [self hasMemberInPlane: i-1] == NO) while (i > 0 && [self hasMemberInPlane: i-1] == NO)
{ {
@ -128,7 +128,7 @@
{ {
unsigned bit; unsigned bit;
if (aPlane >= 16) if (aPlane > 16)
{ {
return NO; return NO;
} }
@ -203,6 +203,13 @@
{ {
unsigned byte = aCharacter/8; unsigned byte = aCharacter/8;
if (aCharacter >= UNICODE_MAX)
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] argument (0x%08x) is too large",
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
aCharacter];
}
if (byte < _length && ISSET(_data[byte], aCharacter % 8)) if (byte < _length && ISSET(_data[byte], aCharacter % 8))
{ {
return YES; return YES;
@ -298,7 +305,7 @@
- (NSData*) bitmapRepresentation - (NSData*) bitmapRepresentation
{ {
unsigned i = 16; unsigned i = 17;
while (i > 0 && [self hasMemberInPlane: i-1] == NO) while (i > 0 && [self hasMemberInPlane: i-1] == NO)
{ {
@ -824,7 +831,7 @@ static Class abstractMutableClass = nil;
oImp = (BOOL (*)(id,SEL,unichar)) oImp = (BOOL (*)(id,SEL,unichar))
[anObject methodForSelector: @selector(characterIsMember:)]; [anObject methodForSelector: @selector(characterIsMember:)];
for (p = 0; p < 16; p++) for (p = 0; p <= 16; p++)
{ {
if ([self hasMemberInPlane: p] == YES) if ([self hasMemberInPlane: p] == YES)
{ {
@ -872,6 +879,13 @@ static Class abstractMutableClass = nil;
{ {
int plane = (aCharacter >> 16); int plane = (aCharacter >> 16);
if (aCharacter >= UNICODE_MAX)
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] argument (0x%08x) is too large",
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
aCharacter];
}
if (plane == 0) if (plane == 0)
{ {
unichar u = (unichar)(aCharacter & 0xffff); unichar u = (unichar)(aCharacter & 0xffff);

File diff suppressed because it is too large Load diff