From 94e62b24ffeca95978579e55753f206e04fa2e04 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sun, 2 Sep 2018 20:07:11 +0200 Subject: [PATCH] Is #752 - Add windows tilde expansion --- src/config.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index f5e8379..085f4b6 100644 --- a/src/config.c +++ b/src/config.c @@ -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