same-inode: port to MinGW
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 9 Dec 2016 16:16:13 +0000 (08:16 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 9 Dec 2016 16:17:09 +0000 (08:17 -0800)
Here st_ino is always 0, so change the definition of SAME_INODE so
that 1 means the two files are the same, 0 with st_ino != 0 means
they differ, and 0 with st_ino == 0 means we don’t know.  Problem
reported by Bruno Haible (Bug#25146).
* doc/posix-headers/sys_stat.texi (sys/stat.h): Update.
* lib/same-inode.h (SAME_INODE): Return 0 on MinGW.

ChangeLog
doc/posix-headers/sys_stat.texi
lib/same-inode.h

index 8103ebd36a1494e09f15230b5e6f0a830f280b43..fd3e9d8d711128f1d1f83935d33669efe5048ffd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-12-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       same-inode: port to MinGW
+       Here st_ino is always 0, so change the definition of SAME_INODE so
+       that 1 means the two files are the same, 0 with st_ino != 0 means
+       they differ, and 0 with st_ino == 0 means we don’t know.  Problem
+       reported by Bruno Haible (Bug#25146).
+       * doc/posix-headers/sys_stat.texi (sys/stat.h): Update.
+       * lib/same-inode.h (SAME_INODE): Return 0 on MinGW.
+
 2016-12-04  Bruno Haible  <bruno@clisp.org>
 
        javacomp: Support Java 7 and 8.
index bd644f6007116dad9f0839894d5335053aae1c3d..4c176aa7cd68cbeb7df8fce7d5e942a9268e1059 100644 (file)
@@ -44,8 +44,8 @@ not a single value.
 @item
 To partially work around the previous two problems, you can test for
 nonzero @code{st_ino} and use the Gnulib @code{same-inode} module to
-compare nonzero values.  For example, @code{(a.st_ino && SAME_INODE
-(a, b))} is true if the @code{struct stat} values @code{a} and
+compare nonzero values.  For example, @code{SAME_INODE (a, b)}
+is true if the @code{struct stat} values @code{a} and
 @code{b} are known to represent the same file, @code{(a.st_ino &&
 !SAME_INODE (a, b))} is true if they are known to represent different
 files, and @code{!a.st_ino} is true if it is not known whether they
index bf45635d11b108b358c3ff0a400dc971e35ab7bb..c7a8fb5ca9a93dab382be2c89517a4b1b198966b 100644 (file)
@@ -1,4 +1,4 @@
-/* Determine whether two stat buffers refer to the same file.
+/* Determine whether two stat buffers are known to refer to the same file.
 
    Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc.
 
      && (a).st_ino[1] == (b).st_ino[1] \
      && (a).st_ino[2] == (b).st_ino[2] \
      && (a).st_dev == (b).st_dev)
+# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* On MinGW, struct stat lacks necessary info, so always return 0.
+   Callers can use !a.st_ino to deduce that the information is unknown.  */
+#  define SAME_INODE(a, b) 0
 # else
 #  define SAME_INODE(a, b)    \
     ((a).st_ino == (b).st_ino \