1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-23 20:05:32 +02:00

Merge from stable-2.2

This commit is contained in:
Andy Wingo 2019-08-02 14:31:46 +02:00
commit 0a78d39b77
2 changed files with 20 additions and 5 deletions

View file

@ -1608,11 +1608,20 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
c_filename = scm_to_utf8_string (filename);
scm_dynwind_free (c_filename);
c_last_component = last_component (c_filename);
if (!c_last_component)
res = 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
res = scm_from_utf8_string (c_last_component);
{
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) &&