2009-09-23 Eric Blake <ebb9@byu.net>
+ same-inode: make SAME_INODE tri-state, to port to mingw
+ * NEWS: Mention this change.
+ * lib/same-inode.h (same-inode.h): Recognize mingw limitation of
+ st_ino always being 0.
+ * lib/cycle-check.h (CYCLE_CHECK_REFLECT_CHDIR_UP): Update caller.
+ * lib/cycle-check.c (cycle_check): Likewise.
+ * lib/same.c (same_name): Likewise.
+
lstat: avoid mingw compilation error
* m4/lstat.m4 (gl_FUNC_LSTAT): Avoid duplicate calls to
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, and deal with missing
Date Modules Changes
+2009-09-23 same-inode The macro SAME_INODE is now tri-state, adding -1
+ for unknown.
+
2009-09-16 canonicalize-lgpl
The include file is changed from "canonicalize.h"
to <stdlib.h>.
/* help detect directory cycles efficiently
- Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software
+ Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* If the current directory ever happens to be the same
as the one we last recorded for the cycle detection,
then it's obviously part of a cycle. */
- if (state->chdir_counter && SAME_INODE (*sb, state->dev_ino))
+ if (state->chdir_counter && SAME_INODE (*sb, state->dev_ino) == 1)
return true;
/* If the number of `descending' chdir calls is a power of two,
/* help detect directory cycles efficiently
- Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2006, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* You must call cycle_check at least once before using this macro. */ \
if ((State)->chdir_counter == 0) \
abort (); \
- if (SAME_INODE ((State)->dev_ino, SB_subdir)) \
+ if (SAME_INODE ((State)->dev_ino, SB_subdir) == 1) \
{ \
(State)->dev_ino.st_dev = (SB_dir).st_dev; \
(State)->dev_ino.st_ino = (SB_dir).st_ino; \
/* Determine whether two stat buffers refer to the same file.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#ifndef SAME_INODE_H
# define SAME_INODE_H 1
+/* Perform a tri-state query on whether STAT_BUF_1 and STAT_BUF_2
+ represent the same file. Return 1 for equal, 0 for distinct, and
+ -1 for indeterminate (the latter is generally possible only on
+ mingw). Algorithms that use this macro must be prepared to handle
+ the indeterminate case without wrong results. For example, if an
+ optimization is possible if two files are the same but unsafe if
+ distinct, use SAME_INODE()==1; whereas for an optimization that is
+ possible only for distinct files, use !SAME_INODE(). */
+
# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
- ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
- && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
+ (((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
+ && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev) \
+ ? 1 - 2 * !(Stat_buf_1).st_ino : 0)
#endif
/* Determine whether two file names refer to the same file.
- Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free
- Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+ 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
same = SAME_INODE (source_dir_stats, dest_dir_stats);
+ if (same < 0)
+ same = (identical_basenames
+ && strcmp (source_basename, dest_basename) == 0);
#if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX
if (same && ! identical_basenames)