summaryrefslogtreecommitdiff
path: root/src/cp.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-02-07 16:01:20 +0000
committerJim Meyering <jim@meyering.net>2004-02-07 16:01:20 +0000
commitd9e9327b09e6d2fe12a3c1fdafb0ff1d4f38359b (patch)
tree6adde85c84b98dfff4a463ba1a49d733d18e9bc6 /src/cp.c
parente80f7332e2d4522b44041f2add6d64e905f99589 (diff)
downloadcoreutils-d9e9327b09e6d2fe12a3c1fdafb0ff1d4f38359b.tar.xz
(re_protect): Use `XSTAT (x, ...)' in place of `*(x->xstat) (...)'.
(do_copy): Declare/use local xstat rather than x->xstat. (main): Remove code that set x.xstat.
Diffstat (limited to 'src/cp.c')
-rw-r--r--src/cp.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/cp.c b/src/cp.c
index 89ec89cde..739cc5f48 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -291,7 +291,7 @@ re_protect (const char *const_dst_path, int src_offset,
dst_path[p->slash_offset] = '\0';
- if ((*(x->xstat)) (src_path, &src_sb))
+ if (XSTAT (x, src_path, &src_sb))
{
error (0, errno, _("failed to get attributes of %s"),
quote (src_path));
@@ -552,6 +552,10 @@ do_copy (int n_files, char **file, const char *target_directory,
Copy the files `file1' through `filen'
to the existing directory `edir'. */
int i;
+ int (*xstat)() = (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS
+ || x->dereference == DEREF_ALWAYS
+ ? stat
+ : lstat);
for (i = 0; i < n_files; i++)
{
@@ -593,7 +597,7 @@ do_copy (int n_files, char **file, const char *target_directory,
(x->verbose
? "%s -> %s\n" : NULL),
&attr_list, &new_dst,
- x->xstat);
+ xstat);
}
else
{
@@ -1022,16 +1026,6 @@ main (int argc, char **argv)
/* The key difference between -d (--no-dereference) and not is the version
of `stat' to call. */
- if (x.dereference == DEREF_NEVER)
- x.xstat = lstat;
- else
- {
- /* For DEREF_COMMAND_LINE_ARGUMENTS, x.xstat must be stat for
- each command line argument, but must later be `lstat' for
- any symlinks that are found via recursive traversal. */
- x.xstat = stat;
- }
-
if (x.recursive)
x.copy_as_regular = copy_contents;