From 0d63463512976ffd4244a6b3ed966dba9a11e5f9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 9 Dec 2016 08:16:13 -0800 Subject: [PATCH] same-inode: port to MinGW MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 10 ++++++++++ doc/posix-headers/sys_stat.texi | 4 ++-- lib/same-inode.h | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8103ebd36a..fd3e9d8d71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2016-12-09 Paul Eggert + + 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 javacomp: Support Java 7 and 8. diff --git a/doc/posix-headers/sys_stat.texi b/doc/posix-headers/sys_stat.texi index bd644f6007..4c176aa7cd 100644 --- a/doc/posix-headers/sys_stat.texi +++ b/doc/posix-headers/sys_stat.texi @@ -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 diff --git a/lib/same-inode.h b/lib/same-inode.h index bf45635d11..c7a8fb5ca9 100644 --- a/lib/same-inode.h +++ b/lib/same-inode.h @@ -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. @@ -24,6 +24,10 @@ && (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 \ -- 2.39.5