diff --git a/ChangeLog b/ChangeLog index 26c607f15..a50972fe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,10 @@ worked as expected and moved getpwnam() call to where it works. * Source/Additions/GSMime.m: ([GSMimeDocument-rawMimeData:]) bugfix to remove mjime version header from inner documents. + * Source/NSBundle.m: Fixup for windows. + * Source/NSFileManager.m: Fixup for windows. + * Source/NSString.m: Fixup for windows. + Windows fixups adapted from patch by 2003-10-07 Richard Frith-Macdonald diff --git a/Source/NSBundle.m b/Source/NSBundle.m index d49419ae5..5c7ff555e 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -603,8 +603,13 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory) #endif if (_executable_path == nil || [_executable_path length] == 0) { + const char *tmp; + _executable_path = [[[NSProcessInfo processInfo] arguments] objectAtIndex: 0]; + tmp = [_executable_path UTF8String]; + _executable_path = [[NSFileManager defaultManager] + stringWithFileSystemRepresentation: tmp length: strlen(tmp)]; _executable_path = [self _absolutePathOfExecutable: _executable_path]; NSAssert(_executable_path, NSInternalInconsistencyException); diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index df4cb6a04..0e9c61826 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -1823,7 +1823,8 @@ static NSFileManager* defaultManager = nil; { return @""; } - if (len >= 2 && ptr[1] == '/' && ptr[0] == '/') + if (len >= 2 + && ((ptr[1] == '/' && ptr[0] == '/') || (ptr[1] == '\\' && ptr[0] == '\\')) { /* * Convert '///' to '~@/' sequences. diff --git a/Source/NSString.m b/Source/NSString.m index b98a660d9..25433f564 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -3099,8 +3099,9 @@ handle_printf_atsign (FILE *stream, { NSString *homedir; NSRange first_slash_range; + unsigned length; - if ([self length] == 0) + if ((length = [self length]) == 0) { return self; } @@ -3109,6 +3110,15 @@ handle_printf_atsign (FILE *stream, return self; } + /* + * Anything beginning '~@' is assumed to be a windows path specification + * which can't be expanded. + */ + if (length > 1 && [self characterAtIndex: 1] == 0x0040) + { + return self; + } + first_slash_range = [self rangeOfCharacterFromSet: pathSeps()]; if (first_slash_range.location != 1) @@ -3137,7 +3147,7 @@ handle_printf_atsign (FILE *stream, } if (homedir != nil) { - return [NSStringClass stringWithFormat: @"%@%@", homedir, + return [homedir stringByAppendingPathComponent: [self substringFromIndex: first_slash_range.location]]; } else @@ -3163,7 +3173,7 @@ handle_printf_atsign (FILE *stream, { return @"~"; } - return [NSStringClass stringWithFormat: @"~/%@", + return [@"~" stringByAppendingPathComponent: [self substringFromIndex: [homedir length] + 1]]; }