Skip to content

Commit

Permalink
rename: use ul_basename()
Browse files Browse the repository at this point in the history
Fixes: util-linux#3071
Signed-off-by: Karel Zak <[email protected]>
  • Loading branch information
karelzak committed Jul 2, 2024
1 parent ff8ee29 commit 0309a6f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,7 @@ exe = executable(
'rename',
rename_sources,
include_directories : includes,
link_with : [lib_common],
install_dir : usrbin_exec_dir,
install : opt,
build_by_default : opt)
Expand Down
1 change: 1 addition & 0 deletions misc-utils/Makemodule.am
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,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
Expand Down
4 changes: 2 additions & 2 deletions misc-utils/rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 0309a6f

Please sign in to comment.