guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix 'dirname' and 'basename' on MS-Windows


From: Ludovic Courtès
Subject: Re: Fix 'dirname' and 'basename' on MS-Windows
Date: Wed, 09 Jul 2014 16:22:02 +0200
User-agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux)

Eli Zaretskii <address@hidden> skribis:

> These 2 functions don't deal correctly with Windows file names with
> drive letters and with UNCs.  The patch below fixes that.
>
> Incidentally, isn't the line in scm_basename marked below wrong?
>
>   if (i == end)
>     {
>       if (len > 0 && is_file_name_separator (scm_c_string_ref (filename, 0)))
>         return scm_c_substring (filename, 0, 1);
>       else
>       return scm_dot_string;  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>     }
>   else
>     return scm_c_substring (filename, i+1, end+1);
>
> It is responsible for the following strange results:
>
>    (basename ".foo" ".foo")  => "."
>    (basename "_foo" "_foo")  => "."
>
> Also, isn't the following result wrong as well?
>
>    (basename "/")  => "/"
>
> I think all of these should return the empty string, "".

(I think I forgot about this message, sorry.)

It seems that Gnulib’s dirname-lgpl and basename-lgpl modules do what
you want.  Could you confirm?

If that’s the case, I’ll import them.  If you want to commit
Window-specific tests, that’s even better.

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]