From: Eli Zaretskii <eliz@gnu.org>
To: Mark H Weaver <mhw@netris.org>
Cc: ludo@gnu.org, guile-devel@gnu.org
Subject: Windows file names snafu
Date: Sun, 29 Jun 2014 19:23:48 +0300 [thread overview]
Message-ID: <83k37z65wr.fsf@gnu.org> (raw)
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)
next reply other threads:[~2014-06-29 16:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-29 16:23 Eli Zaretskii [this message]
2014-06-30 11:12 ` Windows file names snafu Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83k37z65wr.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
--cc=mhw@netris.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).