diff --git a/ChangeLog b/ChangeLog index ad886965f..2237aa2e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ * Source/GNUmakefile: ditto * Source/Additions/GNUmakefile: Build GSFunctions.m * Source/Additions/GSFunctions.m: New file for extra functions. + * Source/NSString.m: ([stringByExpandingTildeInPath]) Improve handling + of paths containing mingw drives. 2005-03-14 Adam Fedor diff --git a/Source/NSString.m b/Source/NSString.m index c15870eda..2bfe7de59 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -3586,10 +3586,23 @@ static NSFileManager *fm = nil; first_slash_range = [self rangeOfCharacterFromSet: pathSeps() options: NSLiteralSearch range: ((NSRange){0, length})]; + if (first_slash_range.length == 0) + { + first_slash_range.location = length; + } + + /* + * Anything beginning '~' followed by a single letter is assumed + * to be a windows drive specification. + */ + if (first_slash_range.location == 2 && isalpha([self characterAtIndex: 1])) + { + return IMMUTABLE(self); + } if (first_slash_range.location != 1) { - /* It is of the form `~username/blah/...' */ + /* It is of the form `~username/blah/...' or '~username' */ int uname_len; NSString *uname; @@ -3608,13 +3621,21 @@ static NSFileManager *fm = nil; } else { - /* It is of the form `~/blah/...' */ + /* It is of the form `~/blah/...' or is '~' */ homedir = NSHomeDirectory (); } + if (homedir != nil) { - return [homedir stringByAppendingPathComponent: - [self substringFromIndex: first_slash_range.location]]; + if (first_slash_range.location < length) + { + return [homedir stringByAppendingPathComponent: + [self substringFromIndex: first_slash_range.location]]; + } + else + { + return IMMUTABLE(homedir); + } } else { diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 954fac692..978b3e128 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -723,8 +723,9 @@ static NSString *pathForUser(NSString *user) */ - (id) initWithUser: (NSString*)userName { - NSString *path = pathForUser(userName); + NSString *path; + path = pathForUser(userName); return [self initWithContentsOfFile: path]; } diff --git a/Source/win32/Win32_Utilities.m b/Source/win32/Win32_Utilities.m index bab389b5d..4db8dde75 100644 --- a/Source/win32/Win32_Utilities.m +++ b/Source/win32/Win32_Utilities.m @@ -130,6 +130,7 @@ NSString * Win32GetUserProfileDirectory(NSString *loginName) { NSString *s; + if ([loginName isEqual: NSUserName()] == YES) { [gnustep_global_lock lock]; @@ -161,7 +162,8 @@ Win32GetUserProfileDirectory(NSString *loginName) else { s = nil; - NSLog(@"Not implemented! Can't determine other user home directories in Win32."); + NSLog(@"Trying to get home for '%@' when user is '%@'", loginName, NSUserName()); + NSLog(@"Can't determine other user home directories in Win32."); } if ([s length] == 0 && [loginName length] != 1)