Is #752 - Add windows tilde expansion

This commit is contained in:
Geoff McLane 2018-09-02 20:07:11 +02:00
parent 86b52dc108
commit 94e62b24ff

View file

@ -877,8 +877,26 @@ static ctmbstr ExpandTilde( TidyDocImpl* doc, ctmbstr filename )
if (filename[1] == '/')
{
home_dir = getenv("HOME");
if ( home_dir )
if (home_dir) {
++filename;
}
#ifdef _MSC_VER
else if (strlen(filename) >= 3) { /* at least '~/+1' */
/* no HOME env in Windows - got for HOMEDRIVE=C: HOMEPATH=\Users\user */
char * hd = getenv("HOMEDRIVE");
char * hp = getenv("HOMEPATH");
if (hd && hp) {
ctmbstr s = TidyDocAlloc(doc, _MAX_PATH);
strcpy(s, hd);
strcat(s, hp);
strcat(s, "\\");
strcat(s, &filename[2]);
return s;
}
}
#endif /* _MSC_VER */
}
#ifdef SUPPORT_GETPWNAM
else