Upgrade allocsa module from GNU gettext.
[gnulib.git] / lib / copy-file.c
index a03047b..198a014 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <stddef.h>
 #include <sys/stat.h>
 
 #ifdef HAVE_UNISTD_H
@@ -57,7 +58,7 @@ copy_file_preserving (const char *src_filename, const char *dest_filename)
   int mode;
   int dest_fd;
   char buf[4096];
-  const int buf_size = sizeof (buf);
+  const size_t buf_size = sizeof (buf);
 
   src_fd = open (src_filename, O_RDONLY | O_BINARY);
   if (src_fd < 0 || fstat (src_fd, &statbuf) < 0)
@@ -108,8 +109,10 @@ copy_file_preserving (const char *src_filename, const char *dest_filename)
   }
 #endif
 
+#if HAVE_CHOWN
   /* Preserve the owner and group.  */
   chown (dest_filename, statbuf.st_uid, statbuf.st_gid);
+#endif
 
   /* Preserve the access permissions.  */
   chmod (dest_filename, mode);