mingw tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13603 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-05-07 11:06:22 +00:00
parent ff202496f3
commit 1db427f190
3 changed files with 41 additions and 13 deletions

View file

@ -1,3 +1,8 @@
2002-05-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUser.m: mingw path fixes and debugging
* Source/NSFileManager.m: ditto
2002-05-06 Adam Fedor <fedor@gnu.org>
* Source/NSMethodSignature.m (-isEqual:): Implemented (from

View file

@ -1339,10 +1339,11 @@ static NSFileManager* defaultManager = nil;
{
return 0;
}
if (l >= 3 && c_path[0] == '~' && c_path[2] == '/' && isalpha(c_path[1]))
if (l >= 2 && c_path[0] == '~' && isalpha(c_path[1])
&& (l == 2 || c_path[2] == '/'))
{
newpath = [NSString stringWithFormat: @"%c:%s", c_path[1],
&c_path[2]];
&c_path[2]];
}
else if (l >= 3 && c_path[0] == '/' && c_path[1] == '/' && isalpha(c_path[2]))
{
@ -1390,7 +1391,9 @@ static NSFileManager* defaultManager = nil;
}
}
#else
if (l >= 3 && c_path[0] == '/' && c_path[2] == '/' && isalpha(c_path[1]))
if (l >= 2 && c_path[0] == '/' && isalpha(c_path[1])
&& (l == 2 || c_path[2] == '/'))
{
/* Mingw /drive/... format */
newpath = [NSString stringWithFormat: @"%c:%s", c_path[1],
@ -1425,6 +1428,7 @@ static NSFileManager* defaultManager = nil;
length: (unsigned int)len
{
#ifdef __MINGW__
const char *ptr = string;
char buf[len + 20];
unsigned i;
unsigned j;
@ -1437,26 +1441,36 @@ static NSFileManager* defaultManager = nil;
{
return @"";
}
if (len >= 2 && string[1] == ':' && isalpha(string[0]))
if (len >= 2 && ptr[1] == ':' && isalpha(ptr[0]))
{
/*
* Convert '<driveletter>:' to '~<driveletter>/' sequences.
*/
buf[0] = '~';
buf[1] = string[0];
buf[1] = ptr[0];
buf[2] = '/';
string--;
ptr -= 1;
len++;
i = 3;
}
#ifdef __CYGWIN__
else if (len > 9 && strncmp(string, "/cygdrive/", 10) == 0)
else if (len > 9 && strncmp(ptr, "/cygdrive/", 10) == 0)
{
buf[0] = '~';
string += 9;
ptr += 9;
len -= 9;
i = 1;
}
#else
else if (len >= 2 && ptr[0] == '/' && isalpha(ptr[1])
&& (len == 2 || ptr[2] == '/'))
{
/*
* Convert '/<driveletter>' to '~<driveletter>' sequences.
*/
buf[0] = '~';
i = 1;
}
#endif
else
{
@ -1469,7 +1483,7 @@ static NSFileManager* defaultManager = nil;
j = i;
while (i < len)
{
if (string[i] == '\\')
if (ptr[i] == '\\')
{
if (j == 0 || buf[j-1] != '/')
{
@ -1485,10 +1499,12 @@ static NSFileManager* defaultManager = nil;
}
else
{
buf[j++] = string[i];
buf[j++] = ptr[i];
}
i++;
}
buf[j] = '\0';
// NSLog(@"Map '%s' to '%s'", string, buf);
return [NSString stringWithCString: buf length: j];
#endif
return [NSString stringWithCString: string length: len];

View file

@ -144,9 +144,9 @@ NSUserName(void)
char buf[1024];
DWORD n = 1024;
if (GetEnvironmentVariable("LOGNAME", buf, 1024))
if (GetEnvironmentVariable("LOGNAME", buf, 1024) != 0 && buf[0] != '\0')
loginName = buf;
else if (GetUserName(buf, &n))
else if (GetUserName(buf, &n) != 0 && buf[0] != '\0')
loginName = buf;
#else
loginName = getenv("LOGNAME");
@ -268,8 +268,15 @@ NSHomeDirectoryForUser(NSString *loginName)
}
[gnustep_global_lock unlock];
}
if ([s length] == 0 && [loginName length] != 1)
{
s = nil;
NSLog(@"NSHomeDirectoryForUser(%@) failed", loginName);
}
#endif
return ImportPath(s, 0);
s = ImportPath(s, 0);
// NSLog(@"Home for %@ is %@", loginName, s);
return s;
}
/**