diff --git a/NEWS b/NEWS index ac7a75e..79517f2 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,13 @@ GNU diffutils NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + Unless the --ignore-file-name-case option is used, diff now + considers file names to be equal only if they are byte-for-byte + equivalent. This fixes a bug where diff in an English locale might + consider two Asian file names to be the same merely because they + contain no English characters. * Noteworthy changes in release 3.3 (2013-03-24) [stable] diff --git a/src/dir.c b/src/dir.c index 21b1935..d3b0a2d 100644 --- a/src/dir.c +++ b/src/dir.c @@ -166,7 +166,11 @@ static int compare_names (char const *name1, char const *name2) { if (locale_specific_sorting) - return compare_collated (name1, name2); + { + int diff = compare_collated (name1, name2); + if (diff || ignore_file_name_case) + return diff; + } return file_name_cmp (name1, name2); } @@ -271,7 +275,7 @@ diff_dirs (struct comparison const *cmp, O(N**2), where N is the number of names in a directory that compare_names says are all equal, but in practice N is so small it's not worth tuning. */ - if (nameorder == 0) + if (nameorder == 0 && ignore_file_name_case) { int raw_order = file_name_cmp (*names[0], *names[1]); if (raw_order != 0) diff --git a/tests/Makefile.am b/tests/Makefile.am index 5cbcfb4..dd2d514 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,7 @@ TESTS = \ no-dereference \ no-newline-at-eof \ stdin \ + strcoll-0-names \ filename-quoting EXTRA_DIST = \ diff --git a/tests/strcoll-0-names b/tests/strcoll-0-names new file mode 100755 index 0000000..33c4a3c --- /dev/null +++ b/tests/strcoll-0-names @@ -0,0 +1,25 @@ +#!/bin/sh +# Check that diff responds well with two different file names +# that compare equal with strcoll. See: +# http://lists.gnu.org/archive/html/bug-diffutils/2013-03/msg00012.html + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +# These two names compare equal in the en_US.UTF-8 locale +# in current (2013) versions of glibc. +# On systems where the names do not compare equal, +# this diff test should still do the right thing. +LC_ALL=en_US.UTF-8 +export LC_ALL +name1='エンドカード1' +name2='ブックレット1' + +mkdir d1 d2 || fail=1 +echo x >d1/"$name1" || fail=1 +echo x >d2/"$name2" || fail=1 + +# This should report a difference, but on the affected systems +# diffutils 3.3 does not. +diff d1 d2 && fail=1 + +Exit $fail