Hello,
This is my first post to any guile list. I write because I am using
Guile 1.6.8 on mingw, and the dirname and basename procedures don't
work properly. I tried a few variations:
(dirname "abc/def") returns "."
(dirname "abc\\def") returns "."
(dirname "c:/abc/def") returns "."
(dirname "c:\\abc\\def") returns "."
(dirname "/c/abc/def") returns "/"
So I had a look at the source code in libguile/filesys.c and I think
I've found the bug - and it's definitely of the "oops!" variety. I've
attached a patch that should fix the problem for 1.6.8. If you agree,
please take a look at whether this affects other versions too.
Cheers,
Charles
--- filesys.c.old Thu Jun 9 15:42:54 2005
+++ filesys.c Mon Jan 21 14:34:47 2008
@@ -1413,7 +1413,7 @@
i = len - 1;
#ifdef __MINGW32__
while (i >= 0 && (s[i] == '/' || s[i] == '\\')) --i;
- while (i >= 0 && (s[i] != '/' || s[i] != '\\')) --i;
+ while (i >= 0 && s[i] != '/' && s[i] != '\\') --i;
while (i >= 0 && (s[i] == '/' || s[i] == '\\')) --i;
#else
while (i >= 0 && s[i] == '/') --i;
@@ -1470,7 +1470,7 @@
if (j == -1)
end = i;
#ifdef __MINGW32__
- while (i >= 0 && (f[i] != '/' || f[i] != '\\')) --i;
+ while (i >= 0 && f[i] != '/' && f[i] != '\\') --i;
#else
while (i >= 0 && f[i] != '/') --i;
#endif /* ndef __MINGW32__ */