guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 03/04: basename: drop last_component null check


From: Rob Browning
Subject: [Guile-commits] 03/04: basename: drop last_component null check
Date: Sat, 3 Aug 2024 15:42:22 -0400 (EDT)

rlb pushed a commit to branch main
in repository guile.

commit 9a57c237d27ed146158cd92e2883f7110b8f2e43
Author: Rob Browning <rlb@defaultvalue.org>
AuthorDate: Sat Aug 3 13:32:09 2024 -0500

    basename: drop last_component null check
    
    Prepare for fixes to the suffix pruning.  Since last_component doesn't
    document a possible null result in lib/basename-lgpl.h, and the current
    code also doesn't appear capable of producing one, drop the check.
    
    libguile/filesys.c (basename): drop check for last_component null result.
---
 libguile/filesys.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 70a6ef6eb..5b1453bf6 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -2043,7 +2043,7 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
            "@var{filename}, it is removed also.")
 #define FUNC_NAME s_scm_basename
 {
-  char *c_filename, *c_last_component;
+  char *c_filename;
   SCM res;
 
   scm_dynwind_begin (0);
@@ -2057,13 +2057,8 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
        "/" 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);
-    }
+    res = scm_from_utf8_string (last_component (c_filename));
+
   scm_dynwind_end ();
 
   if (!SCM_UNBNDP (suffix) &&



reply via email to

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