@implementation NSBitmapCharacterSet
-- init
+- (id)init
{
return [self initWithBitmapRepresentation:
[[NSCharacterSet emptyCharacterSet] bitmapRepresentation]
inverted:NO];
}
-- initWithBitmapRepresentation:(id)aData
+- (id)initWithBitmapRepresentation:(id)aData
{
return [self initWithBitmapRepresentation:aData inverted:NO];
}
-- initWithBitmapRepresentation:(id)aData inverted:(BOOL)inv
+- (id)initWithBitmapRepresentation:(id)aData inverted:(BOOL)inv
{
[super init];
- data = [aData copy];
- bytes = (char*)[data bytes];
- inverted = inv;
+ self->data = [aData copy];
+ self->bytes = (char *)[data bytes];
+ self->inverted = inv;
return self;
}
- (NSData *)bitmapRepresentation
{
- if (inverted) {
+ if (self->inverted) {
char* theBytes = CallocAtomic(1, BITMAPDATABYTES);
unsigned i;
- (BOOL)characterIsMember:(unichar)aCharacter
{
- return inverted ^ ISBITSET(bytes, aCharacter);
+#if 1 /* see OGo bug #1594 */
+ if (self->inverted) {
+ return ISBITSET(self->bytes, aCharacter) ? NO : YES;
+ }
+ else {
+ return ISBITSET(self->bytes, aCharacter);
+ }
+#else /* this is the original code, but it doesn't work (with gcc4?!) */
+ return self->inverted ^ ISBITSET(self->bytes, aCharacter);
+#endif
}
- (NSCharacterSet *)invertedSet
{
return AUTORELEASE([[NSBitmapCharacterSet alloc]
- initWithBitmapRepresentation:data
- inverted:!inverted]);
+ initWithBitmapRepresentation:self->data
+ inverted:!self->inverted]);
}
// NSCopying
-- copyWithZone:(NSZone*)zone
+- (id)copyWithZone:(NSZone *)zone
{
if ([self zone] == zone)
return RETAIN(self);
}
}
+/* description */
+
+- (NSString *)description
+{
+ NSMutableString *ms;
+ unsigned int i;
+
+ ms = [NSMutableString stringWithCapacity:128];
+ [ms appendFormat:@"<0x%p[%@]: chars-in-latin1-range:",
+ self, NSStringFromClass([self class])];
+
+ for (i = 0; i < 256; i++) {
+ if (ISBITSET(bytes, i))
+ [ms appendFormat:@" %i", i];
+ }
+
+ if (self->inverted)
+ [ms appendString:@" inverted"];
+
+ [ms appendString:@">"];
+ return ms;
+}
+
@end /* NSBitmapCharacterSet */
/*