Fix home directory

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@17288 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-07-22 05:34:14 +00:00
parent 85750bd41e
commit a86d2cd0eb
2 changed files with 46 additions and 39 deletions

View file

@ -1,3 +1,9 @@
2003-07-22 Richard Frith-Macdonald <rfm@gnu.org>
* user_home.c: Use HOMEPATH in preference to USERPROFILE for
OPENSTEP compatibility and because USERPROFILE generally doesn't
work due to the presence of spaces.
2003-07-21 Adam Fedor <fedor@gnu.org>
* target.make: Set thread library in AUXILIARY_OBJC_LIBS. Set

View file

@ -183,56 +183,57 @@ int main (int argc, char** argv)
}
strncpy(home, pw->pw_dir, sizeof(home));
#else
/* The environment variable USERPROFILE holds the home directory
for the user on modern versions of windoze. */
len0 = GetEnvironmentVariable("USERPROFILE", buf0, 1024);
if (len0 > 0 && len0 < 1024)
{
int i;
for (i = 0; i < len0; i++)
{
if (isspace((int)buf0[0]))
{
len0 = 0; /* Spaces not permitted! */
}
}
}
home[0] = '\0';
/*
* The environment variable HOMEPATH holds the home directory
* for the user on Windows NT; Win95 has no concept of home.
* For OPENSTEP compatibility (and because USERPROFILE is usually
* unusable because it contains spaces), we use HOMEPATH in
* preference to USERPROFILE.
*/
len0 = GetEnvironmentVariable("HOMEPATH", buf0, 1024);
if (len0 > 0 && len0 < 1024)
{
buf0[len0] = '\0';
strcpy(home, buf0);
/*
* Only use HOMEDRIVE is HOMEPATH does not already contain drive.
*/
if (len0 < 2 || buf0[1] != ':')
{
len1 = GetEnvironmentVariable("HOMEDRIVE", buf1, 128);
if (len1 > 0 && len1 < 128)
{
buf1[len1] = '\0';
sprintf(home, "%s%s", buf1, buf0);
}
else
{
sprintf(home, "C:%s", buf0);
}
}
}
else
{
/* The environment variable HOMEPATH holds the home directory
for the user on Windows NT; Win95 has no concept of home. */
len0 = GetEnvironmentVariable("HOMEPATH", buf0, 1024);
/* The environment variable USERPROFILE may hold the home directory
for the user on modern versions of windoze. */
len0 = GetEnvironmentVariable("USERPROFILE", buf0, 1024);
if (len0 > 0 && len0 < 1024)
{
buf0[len0] = '\0';
/*
* Only use HOMEDRIVE is HOMEPATH does not already contain drive.
*/
if (len0 < 2 || buf0[1] != ':')
{
len1 = GetEnvironmentVariable("HOMEDRIVE", buf1, 128);
if (len1 > 0 && len1 < 128)
{
buf1[len1] = '\0';
sprintf(home, "%s%s", buf1, buf0);
}
else
{
fprintf(stderr, "Unable to determine HOMEDRIVE\n");
return 1;
}
}
strcpy(home, buf0);
}
else
}
if (home[0] != '\0')
{
int i;
for (i = 0; i < strlen(home); i++)
{
fprintf(stderr, "Unable to determine HOMEPATH\n");
return 1;
if (isspace((int)home[0]))
{
home[0] = '\0'; /* Spaces not permitted! */
break;
}
}
}
#endif