[Ecls-list] Patch proposal for user-homedir-pathname on Windows
Claus Brod
claus_brod at cocreate.com
Mon Aug 25 09:08:44 UTC 2008
Hi all,
I noticed that user-homedir-pathname only works under Windows if the
user happens to set the HOME environment variable. In a Cygwin type of
environment, this is usually the case, but not for ordinary users. Hence
my following patch proposal for src/c/unixfsys.d. The patch checks the
HOMEDRIVE and HOMEPATH environment variables on Windows which the OS
conveniently sets for us. If HOME is set, it takes priority.
I'm a newbie, and I've never made any changes to ECL before, so please
take this with a boatload of salt, and flame away 8-)
Claus (now trying to figure out how to run the test suite using
msvc/Makefile)
===================================================================
RCS file: /cvsroot/ecls/ecl/src/c/unixfsys.d,v
retrieving revision 1.73
diff -c -r1.73 unixfsys.d
*** unixfsys.d 19 May 2008 07:44:10 -0000 1.73
--- unixfsys.d 25 Aug 2008 08:48:42 -0000
***************
*** 486,493 ****
--- 486,512 ----
if (Null(user)) {
char *h = getenv("HOME");
+ #ifdef _MSC_VER
+ bool free_home = FALSE;
+ if (h == NULL || !*h) {
+ char *homedrive_env = getenv("HOMEDRIVE");
+ char *homepath_env = getenv("HOMEPATH");
+ if (homedrive_env && homepath_env) {
+ size_t len = strlen(homedrive_env);
+ h = (char *)malloc(len + strlen(homepath_env) + 1);
+ strcpy(h, homedrive_env);
+ strcpy(h+len, homepath_env);
+ free_home = TRUE;
+ }
+ }
+ #endif
namestring = (h == NULL)? make_constant_base_string("/")
: make_base_string_copy(h);
+ #ifdef _MSC_VER
+ if (free_home) {
+ free(h);
+ }
+ #endif
} else {
#ifdef HAVE_PWD_H
struct passwd *pwent = NULL;
--
--claus_brod at cocreate.com-----------------------------------------------
Claus Brod, CoCreate R&D Have you hugged your manager today?
CoCreate Software GmbH Phone: +49 7031 951 2152
http://www.cocreate.com Fax: +49 7031 951 6152
--http://clausbrod.com --------------------------#include <disclaimer>--
More information about the ecl-devel
mailing list