sed-devel
[Top][All Lists]
Advanced

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

Re: bootstrapping SED-4.5, circular dependency?


From: Ludovic Courtès
Subject: Re: bootstrapping SED-4.5, circular dependency?
Date: Sun, 09 Dec 2018 14:42:07 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi!

Jan Nieuwenhuizen <address@hidden> skribis:

> Ludovic Courtès writes:
>
> Hello,
>
>> Jan, could it be that the ‘basename’ and ‘dirname’ implementations in
>> Gash fail this test?  It might be that sed is not needed if you get
>> these right.
>
> Ah, yes!  I have added some test to Gash and this
>
>     basename -- /
>
> failed, producing the empty string, where coreutils' basename returns
> `/'.
>
> Gash "simply" (there is som if'ing involved) calls Guile's basename,
> which disagrees here and returns "" for "/".
>
> I'm assuming that this is expected behaviour for Guile?... so I
> special-cased this for Gash' basename.

Looking at
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html>,
I think it’s a bug of Guile’s ‘basename’ (which is not implemented in
terms of libc’s ‘basename’.)

The fix might be as simple as the patch below, WDYT?

In the meantime Gash should work around the bug.

Thanks,
Ludo’.

diff --git a/libguile/filesys.c b/libguile/filesys.c
index e1aeeed1b..c1cd50e21 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1602,11 +1602,20 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
   c_filename = scm_to_utf8_string (filename);
   scm_dynwind_free (c_filename);
 
+  if (strcmp (c_filename, "/") == 0
+      || strcmp (c_filename, "//") == 0)
+    /* As per
+       
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html>,
+       "/" and "//" are treated specially.  */
+    res = scm_from_utf8_string ("/");
+  else
+    {
       c_last_component = last_component (c_filename);
       if (!c_last_component)
         res = filename;
       else
         res = scm_from_utf8_string (c_last_component);
+    }
   scm_dynwind_end ();
 
   if (!SCM_UNBNDP (suffix) &&

reply via email to

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