This diff fixes it. I've tested it with this program:
#import <Foundation/Foundation.h> void objc_enumerationMutation(id obj) { NSLog(@"%@ changed during enumeration", obj); } int main(void) { [NSAutoreleasePool new];id array = [NSArray arrayWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", @ "13", @"14", @"15", @"16", @"17", @"18", @"19", nil];
NSLog(@"Starting enumeration fish"); for (id i in array) { NSLog(@"i: %@", i); } array = [array mutableCopy]; for (id i in array) { NSLog(@"i: %@", i); } for (id i in [array objectEnumerator]) { NSLog(@"i: %@", i); } NSLog(@"finished enumeration"); return 0; }And it prints 0..19 three times. Note that objc_enumerationMutation() needs to be set. Ideally this would be a symbol defined in GNU libobjc and the function pointer provided by Foundation, but for now we can probably just define it ourselves. The correct definition for Apple compatibility would be:
void objc_enumerationMutation(id obj) {[NSException raise: NSGenericException format: @"Collection %@ was mutated while being enumerated", objc];
} DavidP.S. In most of the world it is considered bad form to commit other people's patches without acknowledging them in the commit message. For those of us in the EU, it is also illegal.
fastenumeration.diff
Description: Binary data
_______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org http://lists.gnu.org/mailman/listinfo/gnustep-dev