]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rename: use ul_basename()
authorKarel Zak <kzak@redhat.com>
Tue, 2 Jul 2024 09:23:13 +0000 (11:23 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 2 Jul 2024 12:08:20 +0000 (14:08 +0200)
Fixes: https://github.com/util-linux/util-linux/issues/3071
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 0309a6f5ca018d83420e49e0f9d046fecdb29261)

meson.build
misc-utils/Makemodule.am
misc-utils/rename.c

index e3a2780ad1a18b5b7464806977f54e803a25d5d7..b9e3eb59f116cec1c040dd4d09e18c3651447075 100644 (file)
@@ -2992,6 +2992,7 @@ exe = executable(
   'rename',
   rename_sources,
   include_directories : includes,
+  link_with : [lib_common],
   install_dir : usrbin_exec_dir,
   install : opt,
   build_by_default : opt)
index 6104c648aea4fb8aea3efe4ea95f3f7c48fb40db..bb6f13b8e9cc43b8e0a3acd984253a47c634ea4a 100644 (file)
@@ -232,6 +232,7 @@ usrbin_exec_PROGRAMS += rename
 MANPAGES += misc-utils/rename.1
 dist_noinst_DATA += misc-utils/rename.1.adoc
 rename_SOURCES = misc-utils/rename.c
+rename_LDADD = $(LDADD) libcommon.la
 endif
 
 if BUILD_GETOPT
index 9ab38695f2ce03ecbf69c5d36fc02d4755dbf976..bb2e3103dba8eb61f8444201caa3cedd917e90e9 100644 (file)
@@ -28,7 +28,6 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
 #include <errno.h>
 #include <getopt.h>
 #include <fcntl.h>
-#include <libgen.h>
 #include <unistd.h>
 #include <termios.h>
 #include <sys/types.h>
@@ -40,6 +39,7 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done
 #include "closestream.h"
 #include "optutils.h"
 #include "rpmatch.h"
+#include "fileutils.h"
 
 #define RENAME_EXIT_SOMEOK     2
 #define RENAME_EXIT_NOTHING    4
@@ -59,7 +59,7 @@ static char *find_initial_replace(char *from, char *to, char *orig)
                /* We only want to search in the final path component. Don't
                   include the final '/' in that component; if `from` is empty,
                   we want it to first match after the '/', not before. */
-               search_start = basename(orig);
+               search_start = ul_basename(orig);
        }
 
        return strstr(search_start, from);