]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: remove ASSIGN_BASENAME_STRDUPA
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jan 2018 06:55:47 +0000 (22:55 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Jan 2018 06:57:21 +0000 (22:57 -0800)
* src/cp.c (do_copy): Just use ASSIGN_STRDUPA, as this simplifies
the code and uses less memory.

src/cp.c

index d81d41859711f1b59ae54466e3440c2b5f2d0641..04ceb8687fd543c6dc1a9c0560be1583c9c709dc 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
 # define lchown(name, uid, gid) chown (name, uid, gid)
 #endif
 
-#define ASSIGN_BASENAME_STRDUPA(Dest, File_name)       \
-  do                                                   \
-    {                                                  \
-      char *tmp_abns_;                                 \
-      ASSIGN_STRDUPA (tmp_abns_, (File_name));         \
-      Dest = last_component (tmp_abns_);               \
-      strip_trailing_slashes (Dest);                   \
-    }                                                  \
-  while (0)
-
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "cp"
 
@@ -693,8 +683,8 @@ do_copy (int n_files, char **file, const char *target_directory,
             {
               char *arg_base;
               /* Append the last component of 'arg' to 'target_directory'.  */
-
-              ASSIGN_BASENAME_STRDUPA (arg_base, arg);
+              ASSIGN_STRDUPA (arg_base, last_component (arg));
+              strip_trailing_slashes (arg_base);
               /* For 'cp -R source/.. dest', don't copy into 'dest/..'. */
               dst_name = (STREQ (arg_base, "..")
                           ? xstrdup (target_directory)