unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* dirname & basename not working on mingw
@ 2008-01-21 23:01 Charles Day
  2008-01-24 22:23 ` Neil Jerram
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Day @ 2008-01-21 23:01 UTC (permalink / raw)
  To: bug-guile

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

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

[-- Attachment #2: filesys.txt --]
[-- Type: text/plain, Size: 665 bytes --]

--- 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__ */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dirname & basename not working on mingw
  2008-01-21 23:01 dirname & basename not working on mingw Charles Day
@ 2008-01-24 22:23 ` Neil Jerram
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Jerram @ 2008-01-24 22:23 UTC (permalink / raw)
  To: Charles Day; +Cc: bug-guile

"Charles Day" <cedayiv@gmail.com> writes:

> Hello,

Hi Charles!

> 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.

Many thanks for this.  I do agree, and in fact this is already fixed
in the 1.8.x series.  I've applied your patch now to 1.6.x CVS, so if
and when we do a 1.6.9 release, it will be fixed there too.

Regards,
        Neil





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-24 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 23:01 dirname & basename not working on mingw Charles Day
2008-01-24 22:23 ` Neil Jerram

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).