Skip to content

Commit 94e62b2

Browse files
committed
Is #752 - Add windows tilde expansion
1 parent 86b52dc commit 94e62b2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/config.c

+19-1
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,26 @@ static ctmbstr ExpandTilde( TidyDocImpl* doc, ctmbstr filename )
877877
if (filename[1] == '/')
878878
{
879879
home_dir = getenv("HOME");
880-
if ( home_dir )
880+
if (home_dir) {
881881
++filename;
882+
}
883+
#ifdef _MSC_VER
884+
else if (strlen(filename) >= 3) { /* at least '~/+1' */
885+
/* no HOME env in Windows - got for HOMEDRIVE=C: HOMEPATH=\Users\user */
886+
char * hd = getenv("HOMEDRIVE");
887+
char * hp = getenv("HOMEPATH");
888+
if (hd && hp) {
889+
ctmbstr s = TidyDocAlloc(doc, _MAX_PATH);
890+
strcpy(s, hd);
891+
strcat(s, hp);
892+
strcat(s, "\\");
893+
strcat(s, &filename[2]);
894+
return s;
895+
}
896+
897+
}
898+
#endif /* _MSC_VER */
899+
882900
}
883901
#ifdef SUPPORT_GETPWNAM
884902
else

0 commit comments

Comments
 (0)