commit:     11a307a97c737a9942ef14de3ce160058bfac11e
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jan  9 23:35:01 2026 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Fri Jan  9 23:40:40 2026 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=11a307a9

Compare both device and inode in is_eq_file()

Presently, the is_eq_file() subroutine determines whether any two
pathnames or file handles are equivalent by comparing their inode
numbers. This is insufficient, for it should also compare their device
numbers. Have it do so.

Further, adjust the names of the parameters so as not to imply that the
subroutine is restricted to operating on pathnames.

Fixes: a2a247b76c7fc7956ceffb96d8b34d1cd886f9eb
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 locale-gen | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/locale-gen b/locale-gen
index b92ac18..daa3067 100644
--- a/locale-gen
+++ b/locale-gen
@@ -11,7 +11,7 @@ use Errno qw(ENOENT);
 use File::Spec::Functions qw(canonpath catfile catdir path splitpath);
 use File::Temp qw(tempdir);
 use Getopt::Long ();
-use List::Util qw(any first min);
+use List::Util qw(all any first min);
 use Term::ANSIColor qw(colored);
 
 # Formally stable as of v5.40; sufficiently functional in both v5.36 and v5.38.
@@ -751,11 +751,11 @@ sub print_warning ($warning) {
        }
 }
 
-sub is_eq_file ($path1, $path2) {
-       # Compare the inode numbers, just as the test(1) -ef operator does.
-       my @stat1 = stat $path1;
-       my @stat2 = stat $path2;
-       return @stat1 && @stat2 && $stat1[1] == $stat2[1];
+sub is_eq_file ($file1, $file2) {
+       # Compare the "dev" and "ino" fields, like the test(1) -ef operator.
+       my @stat1 = stat $file1;
+       my @stat2 = stat $file2;
+       return @stat1 && @stat2 && all(sub { $stat1[$_] == $stat2[$_] }, 0..1);
 }
 
 sub trim_line ($line) {

Reply via email to