diff --git a/ChangeLog b/ChangeLog index 712fa7897..b25001691 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,15 @@ +2005-07-12 Nicola Pero + + * Source/NSBundle.m ([+_addFrameworkFromClass:]), + ([-executablePath]): Mangle/demangle framework names so that we + can support '-' (and '+') in framework names. Requires latest + gnustep-make if you have a framework with '_', '-' or '+' in the + name. + 2005-07-08 Adam Fedor * Testing/GNUmakefile, Testing/nsfilehandle.m: Minor fixes. - + 2005-07-08 Richard Frith-Macdonald * Source/objc-load.m: Under mingw print filenames for debug using diff --git a/Source/NSBundle.m b/Source/NSBundle.m index e09728295..80599236d 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -303,11 +303,19 @@ _find_framework(NSString *name) len = strlen (frameworkClass->name); if (len > 12 * sizeof(char) - && !strncmp("NSFramework_", frameworkClass->name, 12)) + && !strncmp ("NSFramework_", frameworkClass->name, 12)) { /* The name of the framework. */ NSString *name = [NSString stringWithCString: &frameworkClass->name[12]]; + /* Important - gnustep-make mangles framework names to encode + * them as ObjC class names. Here we need to demangle them. We + * apply the reverse transformations in the reverse order. + */ + name = [name stringByReplacingString: @"_1" withString: @"+"]; + name = [name stringByReplacingString: @"_0" withString: @"-"]; + name = [name stringByReplacingString: @"__" withString: @"_"]; + /* Try getting the path to the framework using the dynamic * linker. When it works it's really cool :-) This is the only * really universal way of getting the framework path ... we can @@ -1561,11 +1569,22 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory) } if (_bundleType == NSBUNDLE_FRAMEWORK) { + /* Mangle the name before building the _currentFrameworkName, + * which really is a class name. + */ + NSString *mangledName = object; + mangledName = [mangledName stringByReplacingString: @"_" + withString: @"__"]; + mangledName = [mangledName stringByReplacingString: @"-" + withString: @"_0"]; + mangledName = [mangledName stringByReplacingString: @"+" + withString: @"_1"]; + path = [_path stringByAppendingPathComponent:@"Versions/Current"]; _currentFrameworkName = RETAIN(([NSString stringWithFormat: @"NSFramework_%@", - object])); + mangledName])); } else {