From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.lisp.guile.devel Subject: Windows file names snafu Date: Sun, 29 Jun 2014 19:23:48 +0300 Message-ID: <83k37z65wr.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1404059064 23625 80.91.229.3 (29 Jun 2014 16:24:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Jun 2014 16:24:24 +0000 (UTC) Cc: ludo@gnu.org, guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jun 29 18:24:17 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X1Htn-0006Qb-K7 for guile-devel@m.gmane.org; Sun, 29 Jun 2014 18:24:15 +0200 Original-Received: from localhost ([::1]:58277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1Htn-0008BP-6R for guile-devel@m.gmane.org; Sun, 29 Jun 2014 12:24:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1Hte-0008AB-2n for guile-devel@gnu.org; Sun, 29 Jun 2014 12:24:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1HtW-00014I-E9 for guile-devel@gnu.org; Sun, 29 Jun 2014 12:24:06 -0400 Original-Received: from mtaout28.012.net.il ([80.179.55.184]:43489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1HtW-00014A-13; Sun, 29 Jun 2014 12:23:58 -0400 Original-Received: from conversion-daemon.mtaout28.012.net.il by mtaout28.012.net.il (HyperSendmail v2007.08) id <0N7X00O00UG02L00@mtaout28.012.net.il>; Sun, 29 Jun 2014 19:22:56 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout28.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N7X00NPDUU71U20@mtaout28.012.net.il>; Sun, 29 Jun 2014 19:22:55 +0300 (IDT) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.184 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17244 Archived-At: This issue is caused by code that treats file names like strings. That fails when the compared strings differ by their directory separators ('/' vs '\'). I bumped into this in a couple of tests that failed or even aborted with backtrace. A related issue is the file names passed to Bash via open-pipe and friends: Bash treats backslashes as escape characters, so commands start to fail in mysterious ways. For these two reasons, I think Guile should strive to keep file names in Unix-compatible form, i.e. using forward slashes as directory separators. I originally tried to find some place in the code where this could be done once and for all, but I see no such place (did I miss something?). So instead I propose a small number of changes to make sure %load-path and the value returned by getcwd use forward slashes no matter what. This fixed all the problems related to this issue in the test suite. The patch below is just to show what I modified; if this approach is accepted, I think it would be better, at least for the C parts of the patch below, to have a function to do the job, and call it from each of the few places which I identified. --- libguile/load.c~1 2014-06-09 13:12:59 +0300 +++ libguile/load.c 2014-06-29 18:56:47 +0300 @@ -290,6 +290,19 @@ scm_init_load_path () #ifdef SCM_LIBRARY_DIR env = getenv ("GUILE_SYSTEM_PATH"); +#ifdef __MINGW32__ + if (env) + { + char *p = env; + + while (*p) + { + if (*p == '\\') + *p = '/'; + p++; + } + } +#endif if (env && strcmp (env, "") == 0) /* special-case interpret system-path=="" as meaning no system path instead of '("") */ @@ -303,6 +316,19 @@ scm_init_load_path () scm_from_locale_string (SCM_PKGDATA_DIR)); env = getenv ("GUILE_SYSTEM_COMPILED_PATH"); +#ifdef __MINGW32__ + if (env) + { + char *p = env; + + while (*p) + { + if (*p == '\\') + *p = '/'; + p++; + } + } +#endif if (env && strcmp (env, "") == 0) /* like above */ ; @@ -349,10 +375,36 @@ scm_init_load_path () } env = getenv ("GUILE_LOAD_PATH"); +#ifdef __MINGW32__ + if (env) + { + char *p = env; + + while (*p) + { + if (*p == '\\') + *p = '/'; + p++; + } + } +#endif if (env) path = scm_parse_path_with_ellipsis (scm_from_locale_string (env), path); env = getenv ("GUILE_LOAD_COMPILED_PATH"); +#ifdef __MINGW32__ + if (env) + { + char *p = env; + + while (*p) + { + if (*p == '\\') + *p = '/'; + p++; + } + } +#endif if (env) cpath = scm_parse_path_with_ellipsis (scm_from_locale_string (env), cpath); --- libguile/filesys.c~0 2014-02-28 23:01:27 +0200 +++ libguile/filesys.c 2014-06-29 18:13:30 +0300 @@ -1235,6 +1235,19 @@ SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, errno = save_errno; SCM_SYSERROR; } +#ifdef __MINGW32__ + if (rv) + { + char *p = wd; + + while (*p) + { + if (*p == '\\') + *p = '/'; + p++; + } + } +#endif result = scm_from_locale_stringn (wd, strlen (wd)); free (wd); return result; --- module/ice-9/boot-9.scm~ 2014-02-15 01:00:33 +0200 +++ module/ice-9/boot-9.scm 2014-06-29 18:15:07 +0300 @@ -1657,7 +1657,7 @@ (or (char=? c #\/) (char=? c #\\))) - (define file-name-separator-string "\\") + (define file-name-separator-string "/") (define (absolute-file-name? file-name) (define (file-name-separator-at-index? idx)