On 08/02/2017 10:43 AM, Gisle Vanem wrote:
Compiling this new file (using MSVC-2015), give me these errors:

  renameat2.c(55): error C2079: 'st' uses undefined struct 'stat' ...

Thanks for catching those typos. I installed the attached, slightly different patch.
>From 4aad1aed6d19ca73527ab1819aae75f2b5813c8c Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 2 Aug 2017 11:06:33 -0700
Subject: [PATCH] renameat2: port to non-renameat platforms

Problem reported for MSVC-2015 by Gisle Vanem in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00001.html
* lib/renameat2.c [!HAVE_RENAMEAT]: Include <sys/stat.h> here too.
(renameat2) [!HAVE_RENAMEAT]: Fix typo in arg passing.
---
 ChangeLog       | 8 ++++++++
 lib/renameat2.c | 5 ++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 44bdf7971..07d6d9976 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-08-02  Paul Eggert  <egg...@cs.ucla.edu>
+
+	renameat2: port to non-renameat platforms
+	Problem reported for MSVC-2015 by Gisle Vanem in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00001.html
+	* lib/renameat2.c [!HAVE_RENAMEAT]: Include <sys/stat.h> here too.
+	(renameat2) [!HAVE_RENAMEAT]: Fix typo in arg passing.
+
 2017-08-01  Paul Eggert  <egg...@cs.ucla.edu>
 
 	manywarnings: port to 32-bit GCC bug
diff --git a/lib/renameat2.c b/lib/renameat2.c
index 60b721c40..9369dbfb0 100644
--- a/lib/renameat2.c
+++ b/lib/renameat2.c
@@ -22,6 +22,7 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #ifdef __linux__
@@ -40,7 +41,6 @@ errno_fail (int e)
 # include <stdbool.h>
 # include <stdlib.h>
 # include <string.h>
-# include <sys/stat.h>
 
 # include "dirname.h"
 # include "openat.h"
@@ -209,8 +209,7 @@ renameat2 (int fd1, char const *src, int fd2, char const *dst,
   /* RENAME_NOREPLACE is the only flag currently supported.  */
   if (flags & ~RENAME_NOREPLACE)
     return errno_fail (ENOTSUP);
-  return at_func2 (fd1, file1, fd2, file2,
-                   flags ? rename_noreplace : rename);
+  return at_func2 (fd1, src, fd2, dst, flags ? rename_noreplace : rename);
 
 #endif /* !HAVE_RENAMEAT */
 }
-- 
2.13.3

Reply via email to