From MAILER-DAEMON Sun Jan 01 03:40:05 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RhGxZ-0004DF-5C
	for mharc-bug-diffutils@gnu.org; Sun, 01 Jan 2012 03:40:05 -0500
Received: from eggs.gnu.org ([140.186.70.92]:33877)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RhGxW-0004BD-GR
	for bug-diffutils@gnu.org; Sun, 01 Jan 2012 03:40:03 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RhGxV-0004DU-Hn
	for bug-diffutils@gnu.org; Sun, 01 Jan 2012 03:40:02 -0500
Received: from mx.meyering.net ([88.168.87.75]:40887)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RhGxV-0004Cl-Bj
	for bug-diffutils@gnu.org; Sun, 01 Jan 2012 03:40:01 -0500
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id 82735601A8
	for <bug-diffutils@gnu.org>; Sun,  1 Jan 2012 09:40:00 +0100 (CET)
From: Jim Meyering <jim@meyering.net>
To: bug-diffutils@gnu.org
Date: Sun, 01 Jan 2012 09:40:00 +0100
Message-ID: <87pqf33jfj.fsf@rho.meyering.net>
Lines: 5
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 88.168.87.75
Subject: [bug-diffutils] FYI copyright updates for 2012
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 01 Jan 2012 08:40:03 -0000

I've done this:

    maint: update all copyright year number ranges

    Run "make update-copyright".


From MAILER-DAEMON Sat Jan 07 13:28:36 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Rjb0O-0001w6-RY
	for mharc-bug-diffutils@gnu.org; Sat, 07 Jan 2012 13:28:36 -0500
Received: from eggs.gnu.org ([140.186.70.92]:36277)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjJmQ-0006HV-Ms
	for bug-diffutils@gnu.org; Fri, 06 Jan 2012 19:05:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjJmN-0004NB-L5
	for bug-diffutils@gnu.org; Fri, 06 Jan 2012 19:05:02 -0500
Received: from mo-p00-ob.rzone.de ([81.169.146.160]:33365)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjJmM-0004N5-NN
	for bug-diffutils@gnu.org; Fri, 06 Jan 2012 19:04:59 -0500
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1325894697; l=27849;
	s=domk; d=haible.de;
	h=Content-Transfer-Encoding:Content-Type:MIME-Version:Date:Subject:To:
	From:X-RZG-CLASS-ID:X-RZG-AUTH;
	bh=L2fs4VY1lylj4VTm8fhHTOpxG0Y=;
	b=jJLBgEQQirU3klRcx9cklLkcCapdBsOldIEkZ+ye7J7D7FpOBFZqgvOgb/PS7E4fmk3
	GK21WCdwLAbU7LRvDPX2FKRoyvHPfBQTrsButCk0DM8P8ebrHNZ7Fa3+bAhejQZdcdJiD
	Clzeyb1yIieDsvKG6ZX+V0ahsvwOi3sUuE4=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvc44/6LjQ==
X-RZG-CLASS-ID: mo00
Received: from linuix.haible.de
	(dslb-088-068-071-136.pools.arcor-ip.net [88.68.71.136])
	by smtp.strato.de (cohen mo50) (RZmta 27.3 DYNA|AUTH)
	with ESMTPA id z064bco06KE521 ; Sat, 7 Jan 2012 01:04:51 +0100 (MET)
From: Bruno Haible <bruno@clisp.org>
To: bug-diffutils@gnu.org
Bcc: bruno@haible.de
Date: Sat, 07 Jan 2012 01:04:59 +0100
Message-ID: <4355365.Un2U1Fnndd@linuix>
User-Agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart9917112.WVR4nPmiLW"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta)
X-Received-From: 81.169.146.160
X-Mailman-Approved-At: Sat, 07 Jan 2012 13:28:34 -0500
Subject: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 07 Jan 2012 00:05:05 -0000


--nextPart9917112.WVR4nPmiLW
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

Hi,

Recently I made a backup of a root partition (with "tar cf - .")
and then wanted to compare the current state of that partition with
the backup.

The most suitable tool for this purpose appears to be "diff -r".
But symbolic links are a problem:
  - Symbolic links to targets inside the same tree could be ignored.
  - Symbolic links to targets outside the tree, given as relative filenames
    (e.g. /usr/bin/foo -> ../../etc/alternatives/foo), must not be compared
    because the two trees to be compared are not brethren.
  - Symbolic links to targets outside the tree, given as absolute filenames
    (e.g. /usr/bin/foo -> /etc/alternatives/foo), should not be compared
    because it would be a waste of time.

So one needs an option --no-dereference.

Other people have had the same wish, see
<https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00010.html>
<https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00014.html>

Obviously the option should be called '--no-dereference'. The short option
is '-h' for 'cp', 'chown', 'chgrp', 'chcon', 'touch'. So that's the best
candidate for 'diff' as well.

Here's a patch that implements this new feature. Patch to be applied with
"git am -3 < 0001-New-option-h-no-dereference.patch". It includes a unit test.


2012-01-06  Bruno Haible  <bruno@clisp.org>

	New option -h/--no-dereference.
	* src/diff.h (no_dereference_symlinks): New variable.
	* src/diff.c: Include xreadlink.h.
	(longopts): Add --no-dereference option.
	(main): Accept -h/--no-dereference option.
	(option_help_msgid): Mention the -h/--no-dereference option.
	(compare_files): If no_dereference_symlinks is true, use lstat()
	instead of stat(). Compare symbolic links by comparing their values.
	* bootstrap.conf (gnulib_modules): Add lstat, stat, xreadlink.
	* doc/diffutils.texi (Comparing Directories, diff Options): Mention the
	-h/--no-dereference option.
	* tests/no-dereference: New file.
	* tests/Makefile.am (TESTS): Add it.

>From f6b9e9ec8373e470dab9af2d5c4d1f1cff4c209c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 7 Jan 2012 00:57:29 +0100
Subject: [PATCH] New option -h/--no-dereference.
 * src/diff.h (no_dereference_symlinks): New variable.
 * src/diff.c: Include xreadlink.h.
 (longopts): Add --no-dereference option.
 (main): Accept -h/--no-dereference option.
 (option_help_msgid): Mention the -h/--no-dereference option.
 (compare_files): If no_dereference_symlinks is true, use lstat()
 instead of stat(). Compare symbolic links by comparing their values.
 * bootstrap.conf (gnulib_modules): Add lstat, stat, xreadlink.
 * doc/diffutils.texi (Comparing Directories, diff Options): Mention the
 -h/--no-dereference option.
 * tests/no-dereference: New file.
 * tests/Makefile.am (TESTS): Add it.

---
 bootstrap.conf       |    3 +
 doc/diffutils.texi   |    9 +++
 src/diff.c           |   74 +++++++++++++++++++---
 src/diff.h           |    3 +
 tests/Makefile.am    |    1 +
 tests/no-dereference |  169 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 251 insertions(+), 8 deletions(-)
 create mode 100644 tests/no-dereference

diff --git a/bootstrap.conf b/bootstrap.conf
index 2399d08..51da0c0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -48,6 +48,7 @@ hard-locale
 inttostr
 inttypes
 largefile
+lstat
 maintainer-makefile
 manywarnings
 mbrtowc
@@ -60,6 +61,7 @@ regex
 sh-quote
 signal
 sigprocmask
+stat
 stat-macros
 stat-time
 stdint
@@ -77,6 +79,7 @@ version-etc-fsf
 wcwidth
 xalloc
 xfreopen
+xreadlink
 xstrtoumax
 '
 
diff --git a/doc/diffutils.texi b/doc/diffutils.texi
index 5aff3c3..dc94ae2 100644
--- a/doc/diffutils.texi
+++ b/doc/diffutils.texi
@@ -1846,6 +1846,11 @@ is specified while the @option{--ignore-file-name-case} option is in
 effect, case is ignored when excluding file names matching the
 specified patterns.
 
+To avoid that @command{diff} follows symbolic links, use the
+@option{--no-dereference} (@option{-h}).  When this option is in use,
+symbolic links will be treated like a special kind of files, rather than
+comparing the target of each symbolic link.
+
 @node Adjusting Output
 @chapter Making @command{diff} Output Prettier
 
@@ -3786,6 +3791,10 @@ Headings}.
 @item --from-file=@var{file}
 Compare @var{file} to each operand; @var{file} may be a directory.
 
+@item -h
+@itemx --no-dereference
+Act on symbolic links themselves instead of what they point to.
+
 @item --help
 Output a summary of usage and then exit.
 
diff --git a/src/diff.c b/src/diff.c
index 004654e..96cbe09 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -39,6 +39,7 @@
 #include <timespec.h>
 #include <version-etc.h>
 #include <xalloc.h>
+#include <xreadlink.h>
 #include <binary-io.h>
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -188,6 +189,7 @@ static struct option const longopts[] =
   {"new-file", 0, 0, 'N'},
   {"new-group-format", 1, 0, NEW_GROUP_FORMAT_OPTION},
   {"new-line-format", 1, 0, NEW_LINE_FORMAT_OPTION},
+  {"no-dereference", 0, 0, 'h'},
   {"no-ignore-file-name-case", 0, 0, NO_IGNORE_FILE_NAME_CASE_OPTION},
   {"normal", 0, 0, NORMAL_OPTION},
   {"old-group-format", 1, 0, OLD_GROUP_FORMAT_OPTION},
@@ -400,10 +402,7 @@ main (int argc, char **argv)
 	  break;
 
 	case 'h':
-	  /* Split the files into chunks for faster processing.
-	     Usually does not change the result.
-
-	     This currently has no effect.  */
+	  no_dereference_symlinks = true;
 	  break;
 
 	case 'H':
@@ -872,6 +871,7 @@ static char const * const option_help_msgid[] = {
   N_("-l, --paginate                pass output through `pr' to paginate it"),
   "",
   N_("-r, --recursive                 recursively compare any subdirectories found"),
+  N_("-h, --no-dereference            don't follow symbolic links"),
   N_("-N, --new-file                  treat absent files as empty"),
   N_("    --unidirectional-new-file   treat absent first files as empty"),
   N_("    --ignore-file-name-case     ignore case when comparing file names"),
@@ -1128,7 +1128,10 @@ compare_files (struct comparison const *parent,
 		  set_mtime_to_now (&cmp.file[f].stat);
 		}
 	    }
-	  else if (stat (cmp.file[f].name, &cmp.file[f].stat) != 0)
+	  else if ((no_dereference_symlinks
+		    ? lstat (cmp.file[f].name, &cmp.file[f].stat)
+		    : stat (cmp.file[f].name, &cmp.file[f].stat))
+		   != 0)
 	    cmp.file[f].desc = ERRNO_ENCODE (errno);
 	}
     }
@@ -1182,7 +1185,10 @@ compare_files (struct comparison const *parent,
       if (STREQ (fnm, "-"))
 	fatal ("cannot compare `-' to a directory");
 
-      if (stat (filename, &cmp.file[dir_arg].stat) != 0)
+      if ((no_dereference_symlinks
+	   ? lstat (filename, &cmp.file[dir_arg].stat)
+	   : stat (filename, &cmp.file[dir_arg].stat))
+	  != 0)
 	{
 	  perror_with_name (filename);
 	  status = EXIT_TROUBLE;
@@ -1229,8 +1235,10 @@ compare_files (struct comparison const *parent,
     }
   else if ((DIR_P (0) | DIR_P (1))
 	   || (parent
-	       && (! S_ISREG (cmp.file[0].stat.st_mode)
-		   || ! S_ISREG (cmp.file[1].stat.st_mode))))
+	       && !((S_ISREG (cmp.file[0].stat.st_mode)
+		     || S_ISLNK (cmp.file[0].stat.st_mode))
+		    && (S_ISREG (cmp.file[1].stat.st_mode)
+			|| S_ISLNK  (cmp.file[1].stat.st_mode)))))
     {
       if (cmp.file[0].desc == NONEXISTENT || cmp.file[1].desc == NONEXISTENT)
 	{
@@ -1271,6 +1279,56 @@ compare_files (struct comparison const *parent,
 	  status = EXIT_FAILURE;
 	}
     }
+  else if (S_ISLNK (cmp.file[0].stat.st_mode)
+	   || S_ISLNK (cmp.file[1].stat.st_mode))
+    {
+      /* We get here only if we use lstat(), not stat().  */
+      assert (no_dereference_symlinks);
+
+      if (S_ISLNK (cmp.file[0].stat.st_mode)
+	  && S_ISLNK (cmp.file[1].stat.st_mode))
+	{
+	  /* Compare the values of the symbolic links.  */
+	  char *link_value[2] = { NULL, NULL };
+
+	  for (f = 0; f < 2; f++)
+	    {
+	      link_value[f] = xreadlink (cmp.file[f].name);
+	      if (link_value[f] == NULL)
+		{
+		  perror_with_name (cmp.file[f].name);
+		  status = EXIT_TROUBLE;
+		  break;
+		}
+	    }
+	  if (status == EXIT_SUCCESS)
+	    {
+	      if (strcmp (link_value[0], link_value[1]) != 0)
+		{
+		  message ("Symbolic links %s and %s differ\n",
+			   cmp.file[0].name, cmp.file[1].name);
+		  /* This is a difference.  */
+		  status = EXIT_FAILURE;
+		}
+	    }
+	  for (f = 0; f < 2; f++)
+	    free (link_value[f]);
+	}
+      else
+	{
+	  /* We have two files that are not to be compared, because
+	     one of them is a symbolic link and the other one is not.  */
+
+	  message5 ("File %s is a %s while file %s is a %s\n",
+		    file_label[0] ? file_label[0] : cmp.file[0].name,
+		    file_type (&cmp.file[0].stat),
+		    file_label[1] ? file_label[1] : cmp.file[1].name,
+		    file_type (&cmp.file[1].stat));
+
+	  /* This is a difference.  */
+	  status = EXIT_FAILURE;
+	}
+    }
   else if (files_can_be_treated_as_binary
 	   && S_ISREG (cmp.file[0].stat.st_mode)
 	   && S_ISREG (cmp.file[1].stat.st_mode)
diff --git a/src/diff.h b/src/diff.h
index 795cc0c..e77343a 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -135,6 +135,9 @@ XTERN bool ignore_case;
 /* Ignore differences in case of letters in file names.  */
 XTERN bool ignore_file_name_case;
 
+/* Act on symbolic links themselves rather than on their target (-h).  */
+XTERN bool no_dereference_symlinks;
+
 /* File labels for `-c' output headers (--label).  */
 XTERN char *file_label[2];
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9952d67..2f6ad53 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@ TESTS = \
   help-version	\
   function-line-vs-leading-space \
   label-vs-func	\
+  no-dereference \
   no-newline-at-eof \
   stdin
 
diff --git a/tests/no-dereference b/tests/no-dereference
new file mode 100644
index 0000000..1426beb
--- /dev/null
+++ b/tests/no-dereference
@@ -0,0 +1,169 @@
+#!/bin/sh
+# Test the --no-dereference option.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+echo 'Simple contents' > regular1
+echo 'Sample contents' > regular2
+echo 'Sample contents' > regular3
+ln -s regular1 symlink1
+ln -s regular1 symlink1bis
+ln -s regular2 symlink2
+ln -s regular3 symlink3
+
+# Non-recursive comparisons.
+
+# Test case 3: Compare regular file with regular file.
+diff --no-dereference regular1 regular2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+diff --no-dereference regular1 symlink1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File regular1 is a regular file while file symlink1 is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+diff --no-dereference symlink1 regular1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File symlink1 is a symbolic link while file regular1 is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+diff --no-dereference symlink1 symlink1bis > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+diff --no-dereference symlink1 symlink2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink1 and symlink2 differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+diff --no-dereference symlink2 symlink3 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink2 and symlink3 differ
+EOF
+compare expected out || fail=1
+
+# Recursive comparisons.
+
+# Test case 1: Compare symbolic link with nonexistent file.
+mkdir subdir1a
+mkdir subdir1b
+ln -s nonexistent subdir1a/foo
+ln -s ../regular1 subdir1a/bar
+diff -r --no-dereference subdir1a subdir1b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir1a: bar
+Only in subdir1a: foo
+EOF
+compare expected out || fail=1
+
+# Test case 1: Compare nonexistent file with symbolic link.
+mkdir subdir2a
+mkdir subdir2b
+ln -s nonexistent subdir2b/foo
+ln -s ../regular1 subdir2b/bar
+diff -r --no-dereference subdir2a subdir2b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir2b: bar
+Only in subdir2b: foo
+EOF
+compare expected out || fail=1
+
+# Test case 3: Compare regular file with regular file.
+mkdir subdir3a
+mkdir subdir3b
+cp regular1 subdir3a/foo
+cp regular2 subdir3b/foo
+diff -r --no-dereference subdir3a subdir3b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+diff -r --no-dereference subdir3a/foo subdir3b/foo
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+mkdir subdir4a
+mkdir subdir4b
+cp regular1 subdir4a/foo
+ln -s ../regular1 subdir4b/foo
+diff -r --no-dereference subdir4a subdir4b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+mkdir subdir5a
+mkdir subdir5b
+ln -s ../regular1 subdir5a/foo
+cp regular1 subdir5b/foo
+diff -r --no-dereference subdir5a subdir5b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+mkdir subdir6a
+mkdir subdir6b
+ln -s ../regular1 subdir6a/foo
+ln -s ../regular1 subdir6b/foo
+diff -r --no-dereference subdir6a subdir6b > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+mkdir subdir7a
+mkdir subdir7b
+ln -s ../regular1 subdir7a/foo
+ln -s ../regular2 subdir7b/foo
+diff -r --no-dereference subdir7a subdir7b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir7a/foo and subdir7b/foo differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+mkdir subdir8a
+mkdir subdir8b
+ln -s ../regular2 subdir8a/foo
+ln -s ../regular3 subdir8b/foo
+diff -r --no-dereference subdir8a subdir8b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir8a/foo and subdir8b/foo differ
+EOF
+compare expected out || fail=1
+
+Exit $fail
-- 
1.6.3.2


--nextPart9917112.WVR4nPmiLW
Content-Disposition: attachment; filename="0001-New-option-h-no-dereference.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-New-option-h-no-dereference.patch"

>From f6b9e9ec8373e470dab9af2d5c4d1f1cff4c209c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 7 Jan 2012 00:57:29 +0100
Subject: [PATCH] New option -h/--no-dereference.
 * src/diff.h (no_dereference_symlinks): New variable.
 * src/diff.c: Include xreadlink.h.
 (longopts): Add --no-dereference option.
 (main): Accept -h/--no-dereference option.
 (option_help_msgid): Mention the -h/--no-dereference option.
 (compare_files): If no_dereference_symlinks is true, use lstat()
 instead of stat(). Compare symbolic links by comparing their values.
 * bootstrap.conf (gnulib_modules): Add lstat, stat, xreadlink.
 * doc/diffutils.texi (Comparing Directories, diff Options): Mention the
 -h/--no-dereference option.
 * tests/no-dereference: New file.
 * tests/Makefile.am (TESTS): Add it.

---
 bootstrap.conf       |    3 +
 doc/diffutils.texi   |    9 +++
 src/diff.c           |   74 +++++++++++++++++++---
 src/diff.h           |    3 +
 tests/Makefile.am    |    1 +
 tests/no-dereference |  169 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 251 insertions(+), 8 deletions(-)
 create mode 100644 tests/no-dereference

diff --git a/bootstrap.conf b/bootstrap.conf
index 2399d08..51da0c0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -48,6 +48,7 @@ hard-locale
 inttostr
 inttypes
 largefile
+lstat
 maintainer-makefile
 manywarnings
 mbrtowc
@@ -60,6 +61,7 @@ regex
 sh-quote
 signal
 sigprocmask
+stat
 stat-macros
 stat-time
 stdint
@@ -77,6 +79,7 @@ version-etc-fsf
 wcwidth
 xalloc
 xfreopen
+xreadlink
 xstrtoumax
 '
 
diff --git a/doc/diffutils.texi b/doc/diffutils.texi
index 5aff3c3..dc94ae2 100644
--- a/doc/diffutils.texi
+++ b/doc/diffutils.texi
@@ -1846,6 +1846,11 @@ is specified while the @option{--ignore-file-name-case} option is in
 effect, case is ignored when excluding file names matching the
 specified patterns.
 
+To avoid that @command{diff} follows symbolic links, use the
+@option{--no-dereference} (@option{-h}).  When this option is in use,
+symbolic links will be treated like a special kind of files, rather than
+comparing the target of each symbolic link.
+
 @node Adjusting Output
 @chapter Making @command{diff} Output Prettier
 
@@ -3786,6 +3791,10 @@ Headings}.
 @item --from-file=@var{file}
 Compare @var{file} to each operand; @var{file} may be a directory.
 
+@item -h
+@itemx --no-dereference
+Act on symbolic links themselves instead of what they point to.
+
 @item --help
 Output a summary of usage and then exit.
 
diff --git a/src/diff.c b/src/diff.c
index 004654e..96cbe09 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -39,6 +39,7 @@
 #include <timespec.h>
 #include <version-etc.h>
 #include <xalloc.h>
+#include <xreadlink.h>
 #include <binary-io.h>
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -188,6 +189,7 @@ static struct option const longopts[] =
   {"new-file", 0, 0, 'N'},
   {"new-group-format", 1, 0, NEW_GROUP_FORMAT_OPTION},
   {"new-line-format", 1, 0, NEW_LINE_FORMAT_OPTION},
+  {"no-dereference", 0, 0, 'h'},
   {"no-ignore-file-name-case", 0, 0, NO_IGNORE_FILE_NAME_CASE_OPTION},
   {"normal", 0, 0, NORMAL_OPTION},
   {"old-group-format", 1, 0, OLD_GROUP_FORMAT_OPTION},
@@ -400,10 +402,7 @@ main (int argc, char **argv)
 	  break;
 
 	case 'h':
-	  /* Split the files into chunks for faster processing.
-	     Usually does not change the result.
-
-	     This currently has no effect.  */
+	  no_dereference_symlinks = true;
 	  break;
 
 	case 'H':
@@ -872,6 +871,7 @@ static char const * const option_help_msgid[] = {
   N_("-l, --paginate                pass output through `pr' to paginate it"),
   "",
   N_("-r, --recursive                 recursively compare any subdirectories found"),
+  N_("-h, --no-dereference            don't follow symbolic links"),
   N_("-N, --new-file                  treat absent files as empty"),
   N_("    --unidirectional-new-file   treat absent first files as empty"),
   N_("    --ignore-file-name-case     ignore case when comparing file names"),
@@ -1128,7 +1128,10 @@ compare_files (struct comparison const *parent,
 		  set_mtime_to_now (&cmp.file[f].stat);
 		}
 	    }
-	  else if (stat (cmp.file[f].name, &cmp.file[f].stat) != 0)
+	  else if ((no_dereference_symlinks
+		    ? lstat (cmp.file[f].name, &cmp.file[f].stat)
+		    : stat (cmp.file[f].name, &cmp.file[f].stat))
+		   != 0)
 	    cmp.file[f].desc = ERRNO_ENCODE (errno);
 	}
     }
@@ -1182,7 +1185,10 @@ compare_files (struct comparison const *parent,
       if (STREQ (fnm, "-"))
 	fatal ("cannot compare `-' to a directory");
 
-      if (stat (filename, &cmp.file[dir_arg].stat) != 0)
+      if ((no_dereference_symlinks
+	   ? lstat (filename, &cmp.file[dir_arg].stat)
+	   : stat (filename, &cmp.file[dir_arg].stat))
+	  != 0)
 	{
 	  perror_with_name (filename);
 	  status = EXIT_TROUBLE;
@@ -1229,8 +1235,10 @@ compare_files (struct comparison const *parent,
     }
   else if ((DIR_P (0) | DIR_P (1))
 	   || (parent
-	       && (! S_ISREG (cmp.file[0].stat.st_mode)
-		   || ! S_ISREG (cmp.file[1].stat.st_mode))))
+	       && !((S_ISREG (cmp.file[0].stat.st_mode)
+		     || S_ISLNK (cmp.file[0].stat.st_mode))
+		    && (S_ISREG (cmp.file[1].stat.st_mode)
+			|| S_ISLNK  (cmp.file[1].stat.st_mode)))))
     {
       if (cmp.file[0].desc == NONEXISTENT || cmp.file[1].desc == NONEXISTENT)
 	{
@@ -1271,6 +1279,56 @@ compare_files (struct comparison const *parent,
 	  status = EXIT_FAILURE;
 	}
     }
+  else if (S_ISLNK (cmp.file[0].stat.st_mode)
+	   || S_ISLNK (cmp.file[1].stat.st_mode))
+    {
+      /* We get here only if we use lstat(), not stat().  */
+      assert (no_dereference_symlinks);
+
+      if (S_ISLNK (cmp.file[0].stat.st_mode)
+	  && S_ISLNK (cmp.file[1].stat.st_mode))
+	{
+	  /* Compare the values of the symbolic links.  */
+	  char *link_value[2] = { NULL, NULL };
+
+	  for (f = 0; f < 2; f++)
+	    {
+	      link_value[f] = xreadlink (cmp.file[f].name);
+	      if (link_value[f] == NULL)
+		{
+		  perror_with_name (cmp.file[f].name);
+		  status = EXIT_TROUBLE;
+		  break;
+		}
+	    }
+	  if (status == EXIT_SUCCESS)
+	    {
+	      if (strcmp (link_value[0], link_value[1]) != 0)
+		{
+		  message ("Symbolic links %s and %s differ\n",
+			   cmp.file[0].name, cmp.file[1].name);
+		  /* This is a difference.  */
+		  status = EXIT_FAILURE;
+		}
+	    }
+	  for (f = 0; f < 2; f++)
+	    free (link_value[f]);
+	}
+      else
+	{
+	  /* We have two files that are not to be compared, because
+	     one of them is a symbolic link and the other one is not.  */
+
+	  message5 ("File %s is a %s while file %s is a %s\n",
+		    file_label[0] ? file_label[0] : cmp.file[0].name,
+		    file_type (&cmp.file[0].stat),
+		    file_label[1] ? file_label[1] : cmp.file[1].name,
+		    file_type (&cmp.file[1].stat));
+
+	  /* This is a difference.  */
+	  status = EXIT_FAILURE;
+	}
+    }
   else if (files_can_be_treated_as_binary
 	   && S_ISREG (cmp.file[0].stat.st_mode)
 	   && S_ISREG (cmp.file[1].stat.st_mode)
diff --git a/src/diff.h b/src/diff.h
index 795cc0c..e77343a 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -135,6 +135,9 @@ XTERN bool ignore_case;
 /* Ignore differences in case of letters in file names.  */
 XTERN bool ignore_file_name_case;
 
+/* Act on symbolic links themselves rather than on their target (-h).  */
+XTERN bool no_dereference_symlinks;
+
 /* File labels for `-c' output headers (--label).  */
 XTERN char *file_label[2];
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9952d67..2f6ad53 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@ TESTS = \
   help-version	\
   function-line-vs-leading-space \
   label-vs-func	\
+  no-dereference \
   no-newline-at-eof \
   stdin
 
diff --git a/tests/no-dereference b/tests/no-dereference
new file mode 100644
index 0000000..1426beb
--- /dev/null
+++ b/tests/no-dereference
@@ -0,0 +1,169 @@
+#!/bin/sh
+# Test the --no-dereference option.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+echo 'Simple contents' > regular1
+echo 'Sample contents' > regular2
+echo 'Sample contents' > regular3
+ln -s regular1 symlink1
+ln -s regular1 symlink1bis
+ln -s regular2 symlink2
+ln -s regular3 symlink3
+
+# Non-recursive comparisons.
+
+# Test case 3: Compare regular file with regular file.
+diff --no-dereference regular1 regular2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+diff --no-dereference regular1 symlink1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File regular1 is a regular file while file symlink1 is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+diff --no-dereference symlink1 regular1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File symlink1 is a symbolic link while file regular1 is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+diff --no-dereference symlink1 symlink1bis > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+diff --no-dereference symlink1 symlink2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink1 and symlink2 differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+diff --no-dereference symlink2 symlink3 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink2 and symlink3 differ
+EOF
+compare expected out || fail=1
+
+# Recursive comparisons.
+
+# Test case 1: Compare symbolic link with nonexistent file.
+mkdir subdir1a
+mkdir subdir1b
+ln -s nonexistent subdir1a/foo
+ln -s ../regular1 subdir1a/bar
+diff -r --no-dereference subdir1a subdir1b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir1a: bar
+Only in subdir1a: foo
+EOF
+compare expected out || fail=1
+
+# Test case 1: Compare nonexistent file with symbolic link.
+mkdir subdir2a
+mkdir subdir2b
+ln -s nonexistent subdir2b/foo
+ln -s ../regular1 subdir2b/bar
+diff -r --no-dereference subdir2a subdir2b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir2b: bar
+Only in subdir2b: foo
+EOF
+compare expected out || fail=1
+
+# Test case 3: Compare regular file with regular file.
+mkdir subdir3a
+mkdir subdir3b
+cp regular1 subdir3a/foo
+cp regular2 subdir3b/foo
+diff -r --no-dereference subdir3a subdir3b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+diff -r --no-dereference subdir3a/foo subdir3b/foo
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+mkdir subdir4a
+mkdir subdir4b
+cp regular1 subdir4a/foo
+ln -s ../regular1 subdir4b/foo
+diff -r --no-dereference subdir4a subdir4b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+mkdir subdir5a
+mkdir subdir5b
+ln -s ../regular1 subdir5a/foo
+cp regular1 subdir5b/foo
+diff -r --no-dereference subdir5a subdir5b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+mkdir subdir6a
+mkdir subdir6b
+ln -s ../regular1 subdir6a/foo
+ln -s ../regular1 subdir6b/foo
+diff -r --no-dereference subdir6a subdir6b > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+mkdir subdir7a
+mkdir subdir7b
+ln -s ../regular1 subdir7a/foo
+ln -s ../regular2 subdir7b/foo
+diff -r --no-dereference subdir7a subdir7b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir7a/foo and subdir7b/foo differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+mkdir subdir8a
+mkdir subdir8b
+ln -s ../regular2 subdir8a/foo
+ln -s ../regular3 subdir8b/foo
+diff -r --no-dereference subdir8a subdir8b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir8a/foo and subdir8b/foo differ
+EOF
+compare expected out || fail=1
+
+Exit $fail
-- 
1.6.3.2


--nextPart9917112.WVR4nPmiLW--



From MAILER-DAEMON Sat Jan 07 15:51:52 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjdF2-0003CO-Fn
	for mharc-bug-diffutils@gnu.org; Sat, 07 Jan 2012 15:51:52 -0500
Received: from eggs.gnu.org ([140.186.70.92]:43166)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjdF0-0003CF-23
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 15:51:50 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjdEy-0006OD-Hs
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 15:51:49 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:45625)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjdEy-0006NM-AY
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 15:51:48 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 03C77A60002;
	Sat,  7 Jan 2012 12:51:40 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id k6UEufGVukAK; Sat,  7 Jan 2012 12:51:39 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 8F7F139E8007;
	Sat,  7 Jan 2012 12:51:39 -0800 (PST)
Message-ID: <4F08B061.7060005@cs.ucla.edu>
Date: Sat, 07 Jan 2012 12:51:45 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version: 1.0
To: Bruno Haible <bruno@clisp.org>
References: <4355365.Un2U1Fnndd@linuix>
In-Reply-To: <4355365.Un2U1Fnndd@linuix>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 07 Jan 2012 20:51:51 -0000

Thanks for the patch!  I would like to fold something like
this in.

Two thoughts.

First, many programs (e.g., cp) have three options:
-H -L -P.  These distinctions seem to be useful for diff.
This suggests that the new --no-dereference flag should
be -P, not -h.  -h has a subtly different meaning from
-P, in programs like chown.

Changing the patch to use -P instead of -h should be easy;
we can implement -H and -L later as need be.

Second, and more important, the output of --no-dereference
should be something that we can feed to an (augmented)
'patch' so that it can alter a copy of the old tree,
symlinks and all, so that it looks like the new tree,
symlinks and all.  This suggests that the output of
'diff' needs to contain the symlink contents, and needs
to distinguish symlinks from regular files, so that 'patch'
can reconstruct the symlinks.


From MAILER-DAEMON Sat Jan 07 20:16:59 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjhNb-00005z-RP
	for mharc-bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:16:59 -0500
Received: from eggs.gnu.org ([140.186.70.92]:41321)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjhNY-000056-RF
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:16:58 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjhNX-0004Ys-JR
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:16:56 -0500
Received: from mo-p00-ob.rzone.de ([81.169.146.161]:63884)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjhNW-0004Ye-Vb
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:16:55 -0500
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1325985413; l=1188;
	s=domk; d=haible.de;
	h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:
	In-Reply-To:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH;
	bh=2UiqCs5od/JfWa7S4SHz94A25us=;
	b=Lss4iGOAhEGYKALX6o6X7/5FsPHtHycpBcT8YU88My4vdHeJU7ZEDK2H9Ace4MPybFq
	6C3o0WosxMmnDqAVjvezUEa7M+egN8T7LAI3+Y5y2ylHWx1pKC3YNDVdquCjhvD0lKbiu
	fsP06EAi4Q7o7NI63ffShLUpLb+KmCmMZgY=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvc44/6LjQ==
X-RZG-CLASS-ID: mo00
Received: from linuix.haible.de
	(dslb-088-068-071-136.pools.arcor-ip.net [88.68.71.136])
	by smtp.strato.de (fruni mo40) (RZmta 27.3 DYNA|AUTH)
	with ESMTPA id L05a12o0812vWd ; Sun, 8 Jan 2012 02:16:41 +0100 (MET)
From: Bruno Haible <bruno@clisp.org>
To: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Bcc: bruno@haible.de
Date: Sun, 08 Jan 2012 02:16:52 +0100
Message-ID: <7308010.vTWG6uvlWJ@linuix>
User-Agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )
In-Reply-To: <1325977662.3712.39.camel@schurl.linbit>
References: <4355365.Un2U1Fnndd@linuix> <4F08B061.7060005@cs.ucla.edu>
	<1325977662.3712.39.camel@schurl.linbit>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta)
X-Received-From: 81.169.146.161
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 01:16:58 -0000

Andreas Gruenbacher wrote:
> I wonder if comparing symlinks (instead of what they point to) shouldn't
> become the default once diff supports it.  At the very least, diff
> should warn when following symlinks though.

I disagree. --dereference should stay the default, for two reasons:

  1) Unix philosophy: By default, symlinks are followed. This is a
     general principle. It starts with open() and fopen() and continues
     through most command-line utilities.

  2) What are the use-cases for "diff"?
       - Compare files coming from two different users.
       - Comparing the new state of a directory with a backup.
       - Compating the new state of a partition with a backup.

     In the first two cases, --dereference is desired. In the third case,
     --no-dereference is desired.

     The first two cases are the most frequent ones.

     In other words, while you personally may be working frequently at
     the partition level, many users who put a symbolic link want it to be
     followed automatically.

See also the discussion at
<https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00011.html>
<https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00013.html>

Bruno



From MAILER-DAEMON Sat Jan 07 20:47:48 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjhrQ-0004pk-8A
	for mharc-bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:47:48 -0500
Received: from eggs.gnu.org ([140.186.70.92]:50590)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjhrN-0004pe-3s
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:47:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjhrK-0008D2-Sr
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:47:45 -0500
Received: from mo-p00-ob.rzone.de ([81.169.146.162]:36620)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjhrK-0008Cw-0A
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:47:42 -0500
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1325987259; l=17124;
	s=domk; d=haible.de;
	h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:
	In-Reply-To:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH;
	bh=7W0XLGJdkIQ6c5iOIjMyg+KLsJI=;
	b=m2Ov+bT7teE0+IdU9md0cfbzKyc5S/ycEjiqkUXGguDGeeg7CPl/52dsrzfOR38c3fP
	CAUjpyJ2WRfEz1U77jgtdR8LOiIKmArt6Nntte+Sgp7NpzCyUO11807dTjYZgCng1dJ3j
	EuBA0KqrURSnSFwD1TD8lh1PMoYkilu/vR8=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvc44/6LjQ==
X-RZG-CLASS-ID: mo00
Received: from linuix.haible.de
	(dslb-088-068-071-136.pools.arcor-ip.net [88.68.71.136])
	by smtp.strato.de (fruni mo58) (RZmta 27.3 DYNA|AUTH)
	with ESMTPA id p06705o081JMmC ; Sun, 8 Jan 2012 02:47:22 +0100 (MET)
From: Bruno Haible <bruno@clisp.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Bcc: bruno@haible.de
Date: Sun, 08 Jan 2012 02:47:36 +0100
Message-ID: <1619951.hBQeHAjaYO@linuix>
User-Agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )
In-Reply-To: <4F08B061.7060005@cs.ucla.edu>
References: <4355365.Un2U1Fnndd@linuix> <4F08B061.7060005@cs.ucla.edu>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart5026101.3Pso1c0qc6"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta)
X-Received-From: 81.169.146.162
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 01:47:46 -0000


--nextPart5026101.3Pso1c0qc6
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"

Paul Eggert wrote:
> Thanks for the patch!  I would like to fold something like
> this in.
> 
> Two thoughts.
> 
> First, many programs (e.g., cp) have three options:
> -H -L -P.  These distinctions seem to be useful for diff.
> This suggests that the new --no-dereference flag should
> be -P, not -h.  -h has a subtly different meaning from
> -P, in programs like chown.
> 
> Changing the patch to use -P instead of -h should be easy

But -P currently is equivalent to --unidirectional-new-file.
If we reassign -P immediately, we can silently break some users' scripts.
IMO we need to first deprecate the option -P and leave it that way for
some time (perhaps 1 year) before it can be used for a different purpose.

Find attached the revised set of patches.

> Second, and more important, the output of --no-dereference
> should be something that we can feed to an (augmented)
> 'patch' so that it can alter a copy of the old tree,
> symlinks and all, so that it looks like the new tree,
> symlinks and all.  This suggests that the output of
> 'diff' needs to contain the symlink contents, and needs
> to distinguish symlinks from regular files, so that 'patch'
> can reconstruct the symlinks.

Ideally, yes. But this can come later, for two reasons:

1) There are already other cases where 'diff' emits such lines that
   'patch' does not understand:

$ mkdir a
$ ln -s /dev/tty a/foo
$ mkdir b
$ diff -r a b
Only in a: foo
$ ln -s /dev/zero b/foo
$ diff -r a b
File a/foo is a character special file while file b/foo is a character special file

2) 'patch' does not break through this additional lines. It simply ignores
them.

Bruno

--nextPart5026101.3Pso1c0qc6
Content-Disposition: attachment; filename="0001-Deprecate-old-option-P.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-Deprecate-old-option-P.patch"

>From 75736b4292dec634dd6c6f0d25f6f05468bce9d9 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 8 Jan 2012 02:29:24 +0100
Subject: [PATCH 1/2] Deprecate old option -P.

* src/diff.c (UNIDIRECTIONAL_NEW_FILE_OPTION): New enumeration item.
(longopts): Use it instead of '-P'.
(main): Give an error message if option -P is used.
---
 src/diff.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/diff.c b/src/diff.c
index 004654e..c546a75 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -128,6 +128,7 @@ enum
   SUPPRESS_COMMON_LINES_OPTION,
   TABSIZE_OPTION,
   TO_FILE_OPTION,
+  UNIDIRECTIONAL_NEW_FILE_OPTION,
 
   /* These options must be in sequence.  */
   UNCHANGED_LINE_FORMAT_OPTION,
@@ -210,7 +211,7 @@ static struct option const longopts[] =
   {"to-file", 1, 0, TO_FILE_OPTION},
   {"unchanged-group-format", 1, 0, UNCHANGED_GROUP_FORMAT_OPTION},
   {"unchanged-line-format", 1, 0, UNCHANGED_LINE_FORMAT_OPTION},
-  {"unidirectional-new-file", 0, 0, 'P'},
+  {"unidirectional-new-file", 0, 0, UNIDIRECTIONAL_NEW_FILE_OPTION},
   {"unified", 2, 0, 'U'},
   {"version", 0, 0, 'v'},
   {"width", 1, 0, 'W'},
@@ -452,7 +453,7 @@ main (int argc, char **argv)
 	  break;
 
 	case 'P':
-	  unidirectional_new_file = true;
+	  fatal ("option -P no longer supported, use --unidirectional-new-file for the old meaning");
 	  break;
 
 	case 'q':
@@ -605,6 +606,10 @@ main (int argc, char **argv)
 	  specify_value (&to_file, optarg, "--to-file");
 	  break;
 
+	case UNIDIRECTIONAL_NEW_FILE_OPTION:
+	  unidirectional_new_file = true;
+	  break;
+
 	case UNCHANGED_LINE_FORMAT_OPTION:
 	case OLD_LINE_FORMAT_OPTION:
 	case NEW_LINE_FORMAT_OPTION:
-- 
1.6.3.2


--nextPart5026101.3Pso1c0qc6
Content-Disposition: attachment; filename="0002-New-option-no-dereference.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0002-New-option-no-dereference.patch"

>From 1b1bf9d9663b33b4f4eb6040420cb99442a851ad Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 7 Jan 2012 00:57:29 +0100
Subject: [PATCH 2/2] New option --no-dereference.

* src/diff.h (no_dereference_symlinks): New variable.
* src/diff.c: Include xreadlink.h.
(longopts): Add --no-dereference option.
(main): Accept --no-dereference option.
(option_help_msgid): Mention the --no-dereference option.
(compare_files): If no_dereference_symlinks is true, use lstat()
instead of stat(). Compare symbolic links by comparing their values.
* bootstrap.conf (gnulib_modules): Add lstat, stat, xreadlink.
* doc/diffutils.texi (Comparing Directories, diff Options): Mention the
--no-dereference option.
* tests/no-dereference: New file.
* tests/Makefile.am (TESTS): Add it.
---
 bootstrap.conf       |    3 +
 doc/diffutils.texi   |    8 +++
 src/diff.c           |   74 +++++++++++++++++++++-
 src/diff.h           |    4 +
 tests/Makefile.am    |    1 +
 tests/no-dereference |  169 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 255 insertions(+), 4 deletions(-)
 create mode 100644 tests/no-dereference

diff --git a/bootstrap.conf b/bootstrap.conf
index 2399d08..51da0c0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -48,6 +48,7 @@ hard-locale
 inttostr
 inttypes
 largefile
+lstat
 maintainer-makefile
 manywarnings
 mbrtowc
@@ -60,6 +61,7 @@ regex
 sh-quote
 signal
 sigprocmask
+stat
 stat-macros
 stat-time
 stdint
@@ -77,6 +79,7 @@ version-etc-fsf
 wcwidth
 xalloc
 xfreopen
+xreadlink
 xstrtoumax
 '
 
diff --git a/doc/diffutils.texi b/doc/diffutils.texi
index 5aff3c3..783f084 100644
--- a/doc/diffutils.texi
+++ b/doc/diffutils.texi
@@ -1846,6 +1846,11 @@ is specified while the @option{--ignore-file-name-case} option is in
 effect, case is ignored when excluding file names matching the
 specified patterns.
 
+To avoid that @command{diff} follows symbolic links, use the
+@option{--no-dereference} (@option{-P}).  When this option is in use,
+symbolic links will be treated like a special kind of files, rather than
+comparing the target of each symbolic link.
+
 @node Adjusting Output
 @chapter Making @command{diff} Output Prettier
 
@@ -3848,6 +3853,9 @@ file in if-then-else format.  @xref{Line Group Formats}.
 Use @var{format} to output a line taken from just the second file in
 if-then-else format.  @xref{Line Formats}.
 
+@item --no-dereference
+Act on symbolic links themselves instead of what they point to.
+
 @item --old-group-format=@var{format}
 Use @var{format} to output a group of lines taken from just the first
 file in if-then-else format.  @xref{Line Group Formats}.
diff --git a/src/diff.c b/src/diff.c
index c546a75..67b3109 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -39,6 +39,7 @@
 #include <timespec.h>
 #include <version-etc.h>
 #include <xalloc.h>
+#include <xreadlink.h>
 #include <binary-io.h>
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -120,6 +121,7 @@ enum
   INHIBIT_HUNK_MERGE_OPTION,
   LEFT_COLUMN_OPTION,
   LINE_FORMAT_OPTION,
+  NO_DEREFERENCE_OPTION,
   NO_IGNORE_FILE_NAME_CASE_OPTION,
   NORMAL_OPTION,
   SDIFF_MERGE_ASSIST_OPTION,
@@ -189,6 +191,7 @@ static struct option const longopts[] =
   {"new-file", 0, 0, 'N'},
   {"new-group-format", 1, 0, NEW_GROUP_FORMAT_OPTION},
   {"new-line-format", 1, 0, NEW_LINE_FORMAT_OPTION},
+  {"no-dereference", 0, 0, NO_DEREFERENCE_OPTION},
   {"no-ignore-file-name-case", 0, 0, NO_IGNORE_FILE_NAME_CASE_OPTION},
   {"normal", 0, 0, NORMAL_OPTION},
   {"old-group-format", 1, 0, OLD_GROUP_FORMAT_OPTION},
@@ -565,6 +568,10 @@ main (int argc, char **argv)
 	    specify_value (&line_format[i], optarg, "--line-format");
 	  break;
 
+	case NO_DEREFERENCE_OPTION:
+	  no_dereference_symlinks = true;
+	  break;
+
 	case NO_IGNORE_FILE_NAME_CASE_OPTION:
 	  ignore_file_name_case = false;
 	  break;
@@ -877,6 +884,7 @@ static char const * const option_help_msgid[] = {
   N_("-l, --paginate                pass output through `pr' to paginate it"),
   "",
   N_("-r, --recursive                 recursively compare any subdirectories found"),
+  N_("    --no-dereference            don't follow symbolic links"),
   N_("-N, --new-file                  treat absent files as empty"),
   N_("    --unidirectional-new-file   treat absent first files as empty"),
   N_("    --ignore-file-name-case     ignore case when comparing file names"),
@@ -1133,7 +1141,10 @@ compare_files (struct comparison const *parent,
 		  set_mtime_to_now (&cmp.file[f].stat);
 		}
 	    }
-	  else if (stat (cmp.file[f].name, &cmp.file[f].stat) != 0)
+	  else if ((no_dereference_symlinks
+		    ? lstat (cmp.file[f].name, &cmp.file[f].stat)
+		    : stat (cmp.file[f].name, &cmp.file[f].stat))
+		   != 0)
 	    cmp.file[f].desc = ERRNO_ENCODE (errno);
 	}
     }
@@ -1187,7 +1198,10 @@ compare_files (struct comparison const *parent,
       if (STREQ (fnm, "-"))
 	fatal ("cannot compare `-' to a directory");
 
-      if (stat (filename, &cmp.file[dir_arg].stat) != 0)
+      if ((no_dereference_symlinks
+	   ? lstat (filename, &cmp.file[dir_arg].stat)
+	   : stat (filename, &cmp.file[dir_arg].stat))
+	  != 0)
 	{
 	  perror_with_name (filename);
 	  status = EXIT_TROUBLE;
@@ -1234,8 +1248,10 @@ compare_files (struct comparison const *parent,
     }
   else if ((DIR_P (0) | DIR_P (1))
 	   || (parent
-	       && (! S_ISREG (cmp.file[0].stat.st_mode)
-		   || ! S_ISREG (cmp.file[1].stat.st_mode))))
+	       && !((S_ISREG (cmp.file[0].stat.st_mode)
+		     || S_ISLNK (cmp.file[0].stat.st_mode))
+		    && (S_ISREG (cmp.file[1].stat.st_mode)
+			|| S_ISLNK  (cmp.file[1].stat.st_mode)))))
     {
       if (cmp.file[0].desc == NONEXISTENT || cmp.file[1].desc == NONEXISTENT)
 	{
@@ -1276,6 +1292,56 @@ compare_files (struct comparison const *parent,
 	  status = EXIT_FAILURE;
 	}
     }
+  else if (S_ISLNK (cmp.file[0].stat.st_mode)
+	   || S_ISLNK (cmp.file[1].stat.st_mode))
+    {
+      /* We get here only if we use lstat(), not stat().  */
+      assert (no_dereference_symlinks);
+
+      if (S_ISLNK (cmp.file[0].stat.st_mode)
+	  && S_ISLNK (cmp.file[1].stat.st_mode))
+	{
+	  /* Compare the values of the symbolic links.  */
+	  char *link_value[2] = { NULL, NULL };
+
+	  for (f = 0; f < 2; f++)
+	    {
+	      link_value[f] = xreadlink (cmp.file[f].name);
+	      if (link_value[f] == NULL)
+		{
+		  perror_with_name (cmp.file[f].name);
+		  status = EXIT_TROUBLE;
+		  break;
+		}
+	    }
+	  if (status == EXIT_SUCCESS)
+	    {
+	      if (strcmp (link_value[0], link_value[1]) != 0)
+		{
+		  message ("Symbolic links %s and %s differ\n",
+			   cmp.file[0].name, cmp.file[1].name);
+		  /* This is a difference.  */
+		  status = EXIT_FAILURE;
+		}
+	    }
+	  for (f = 0; f < 2; f++)
+	    free (link_value[f]);
+	}
+      else
+	{
+	  /* We have two files that are not to be compared, because
+	     one of them is a symbolic link and the other one is not.  */
+
+	  message5 ("File %s is a %s while file %s is a %s\n",
+		    file_label[0] ? file_label[0] : cmp.file[0].name,
+		    file_type (&cmp.file[0].stat),
+		    file_label[1] ? file_label[1] : cmp.file[1].name,
+		    file_type (&cmp.file[1].stat));
+
+	  /* This is a difference.  */
+	  status = EXIT_FAILURE;
+	}
+    }
   else if (files_can_be_treated_as_binary
 	   && S_ISREG (cmp.file[0].stat.st_mode)
 	   && S_ISREG (cmp.file[1].stat.st_mode)
diff --git a/src/diff.h b/src/diff.h
index 795cc0c..05029a3 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -135,6 +135,10 @@ XTERN bool ignore_case;
 /* Ignore differences in case of letters in file names.  */
 XTERN bool ignore_file_name_case;
 
+/* Act on symbolic links themselves rather than on their target
+   (--no-dereference).  */
+XTERN bool no_dereference_symlinks;
+
 /* File labels for `-c' output headers (--label).  */
 XTERN char *file_label[2];
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9952d67..2f6ad53 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@ TESTS = \
   help-version	\
   function-line-vs-leading-space \
   label-vs-func	\
+  no-dereference \
   no-newline-at-eof \
   stdin
 
diff --git a/tests/no-dereference b/tests/no-dereference
new file mode 100644
index 0000000..1426beb
--- /dev/null
+++ b/tests/no-dereference
@@ -0,0 +1,169 @@
+#!/bin/sh
+# Test the --no-dereference option.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+echo 'Simple contents' > regular1
+echo 'Sample contents' > regular2
+echo 'Sample contents' > regular3
+ln -s regular1 symlink1
+ln -s regular1 symlink1bis
+ln -s regular2 symlink2
+ln -s regular3 symlink3
+
+# Non-recursive comparisons.
+
+# Test case 3: Compare regular file with regular file.
+diff --no-dereference regular1 regular2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+diff --no-dereference regular1 symlink1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File regular1 is a regular file while file symlink1 is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+diff --no-dereference symlink1 regular1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File symlink1 is a symbolic link while file regular1 is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+diff --no-dereference symlink1 symlink1bis > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+diff --no-dereference symlink1 symlink2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink1 and symlink2 differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+diff --no-dereference symlink2 symlink3 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink2 and symlink3 differ
+EOF
+compare expected out || fail=1
+
+# Recursive comparisons.
+
+# Test case 1: Compare symbolic link with nonexistent file.
+mkdir subdir1a
+mkdir subdir1b
+ln -s nonexistent subdir1a/foo
+ln -s ../regular1 subdir1a/bar
+diff -r --no-dereference subdir1a subdir1b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir1a: bar
+Only in subdir1a: foo
+EOF
+compare expected out || fail=1
+
+# Test case 1: Compare nonexistent file with symbolic link.
+mkdir subdir2a
+mkdir subdir2b
+ln -s nonexistent subdir2b/foo
+ln -s ../regular1 subdir2b/bar
+diff -r --no-dereference subdir2a subdir2b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir2b: bar
+Only in subdir2b: foo
+EOF
+compare expected out || fail=1
+
+# Test case 3: Compare regular file with regular file.
+mkdir subdir3a
+mkdir subdir3b
+cp regular1 subdir3a/foo
+cp regular2 subdir3b/foo
+diff -r --no-dereference subdir3a subdir3b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+diff -r --no-dereference subdir3a/foo subdir3b/foo
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+mkdir subdir4a
+mkdir subdir4b
+cp regular1 subdir4a/foo
+ln -s ../regular1 subdir4b/foo
+diff -r --no-dereference subdir4a subdir4b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+mkdir subdir5a
+mkdir subdir5b
+ln -s ../regular1 subdir5a/foo
+cp regular1 subdir5b/foo
+diff -r --no-dereference subdir5a subdir5b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+mkdir subdir6a
+mkdir subdir6b
+ln -s ../regular1 subdir6a/foo
+ln -s ../regular1 subdir6b/foo
+diff -r --no-dereference subdir6a subdir6b > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+mkdir subdir7a
+mkdir subdir7b
+ln -s ../regular1 subdir7a/foo
+ln -s ../regular2 subdir7b/foo
+diff -r --no-dereference subdir7a subdir7b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir7a/foo and subdir7b/foo differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+mkdir subdir8a
+mkdir subdir8b
+ln -s ../regular2 subdir8a/foo
+ln -s ../regular3 subdir8b/foo
+diff -r --no-dereference subdir8a subdir8b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir8a/foo and subdir8b/foo differ
+EOF
+compare expected out || fail=1
+
+Exit $fail
-- 
1.6.3.2


--nextPart5026101.3Pso1c0qc6--



From MAILER-DAEMON Sat Jan 07 21:22:29 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjiOz-0001NS-7P
	for mharc-bug-diffutils@gnu.org; Sat, 07 Jan 2012 21:22:29 -0500
Received: from eggs.gnu.org ([140.186.70.92]:47316)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjiOw-0001NK-Rj
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 21:22:27 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjiOv-0003fO-OP
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 21:22:26 -0500
Received: from mo-p00-ob.rzone.de ([81.169.146.162]:9734)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjiOv-0003f0-12
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 21:22:25 -0500
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1325989343; l=780;
	s=domk; d=haible.de;
	h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:
	In-Reply-To:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH;
	bh=qGeuC5iRS6P+XG+blhXjkMcxtMA=;
	b=wqdFk0MBg9ISniI77t7QrybXPdhEufrA7Sw47C62WI3qWIPRIJeY+bi2uFQlUpExIA7
	D2x8uHG4zQOghgpKVKb0pK86vZIbTLY3zbS0eiR5CNJvPevrr0GGc7gx/c0LEE8wuUFlW
	m1U7vrGnrKbfyKDTOCnIJSgNSGz/e95mfo0=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvc44/6LjQ==
X-RZG-CLASS-ID: mo00
Received: from linuix.haible.de
	(dslb-088-068-071-136.pools.arcor-ip.net [88.68.71.136])
	by smtp.strato.de (klopstock mo54) (RZmta 27.3 DYNA|AUTH)
	with ESMTPA id N00af6o080BAVC ; Sun, 8 Jan 2012 03:22:22 +0100 (MET)
From: Bruno Haible <bruno@clisp.org>
To: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Bcc: bruno@haible.de
Date: Sun, 08 Jan 2012 03:22:22 +0100
Message-ID: <15985033.iKpkQDS519@linuix>
User-Agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )
In-Reply-To: <1325987978.3712.65.camel@schurl.linbit>
References: <4355365.Un2U1Fnndd@linuix> <7308010.vTWG6uvlWJ@linuix>
	<1325987978.3712.65.camel@schurl.linbit>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta)
X-Received-From: 81.169.146.162
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 02:22:27 -0000

Andreas Gruenbacher wrote:
> In the two directories case, I really don't see when following symlinks
> would be desirable.  Here, diff is comparable to a tool like tar, for
> example -- in the tar case, I want to archive what's really there; in
> the diff case, I want to compare what's really there.

Take an example. I often move subdirectories and big files from one disk
to another one, for disk space reasons, and leave in a symlink that points
to the new location. When I now prepare a backup, I'll use "tar chf -".
And to compare the backup with the original contents, I use "diff -r".

I claim that this use-case is more frequent than the one which does not
follow symlinks. Proof: GNU diff users were happy with the existing behaviour
for 20 years.

Bruno



From MAILER-DAEMON Sun Jan 08 01:41:51 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjmRz-00086w-Ta
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 01:41:51 -0500
Received: from eggs.gnu.org ([140.186.70.92]:43892)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1RjfMX-00083Q-Sg
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 18:07:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1RjfMW-0005S3-Jn
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 18:07:45 -0500
Received: from mail-ey0-f169.google.com ([209.85.215.169]:34280)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1RjfMW-0005Rw-Dm
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 18:07:44 -0500
Received: by eabm6 with SMTP id m6so1902393eab.0
	for <bug-diffutils@gnu.org>; Sat, 07 Jan 2012 15:07:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=subject:from:to:cc:date:in-reply-to:references:content-type
	:x-mailer:content-transfer-encoding:message-id:mime-version;
	bh=JtAYLMQSGHThq4yTBvVJfyWWFEfa8gvqx4G3LjEVGYg=;
	b=cCzeqmr01actSuyuhbNXzXFyyEo7oePH7wpaAsO0p6xsBOT1olX+gvV8f5s55ehSKN
	iRpSyn4ZvBY1n9gGJqtnsKcJ+WFaMFSQdXgV4PaBweakX5oh+9hBaAR5gfZrql22NnNW
	HFXpDgB+zC2I1ubD2iP2nk/tb+ZOfsT7QLcu8=
Received: by 10.213.15.74 with SMTP id j10mr2164997eba.128.1325977663082;
	Sat, 07 Jan 2012 15:07:43 -0800 (PST)
Received: from [192.168.91.169] (chello084114015216.14.vie.surfer.at.
	[84.114.15.216])
	by mx.google.com with ESMTPS id 76sm268488091eeh.0.2012.01.07.15.07.41
	(version=SSLv3 cipher=OTHER); Sat, 07 Jan 2012 15:07:42 -0800 (PST)
From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 08 Jan 2012 00:07:40 +0100
In-Reply-To: <4F08B061.7060005@cs.ucla.edu>
References: <4355365.Un2U1Fnndd@linuix> <4F08B061.7060005@cs.ucla.edu>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.0.3 (3.0.3-1.fc15) 
Content-Transfer-Encoding: 7bit
Message-ID: <1325977662.3712.39.camel@schurl.linbit>
Mime-Version: 1.0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 209.85.215.169
X-Mailman-Approved-At: Sun, 08 Jan 2012 01:41:49 -0500
Cc: bug-diffutils@gnu.org, Bruno Haible <bruno@clisp.org>
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 07 Jan 2012 23:07:46 -0000

On Sat, 2012-01-07 at 12:51 -0800, Paul Eggert wrote:
> Thanks for the patch!  I would like to fold something like
> this in.
> 
> Two thoughts.
> 
> First, many programs (e.g., cp) have three options:
> -H -L -P.  These distinctions seem to be useful for diff.
> This suggests that the new --no-dereference flag should
> be -P, not -h.  -h has a subtly different meaning from
> -P, in programs like chown.
> 
> Changing the patch to use -P instead of -h should be easy;
> we can implement -H and -L later as need be.

I wonder if comparing symlinks (instead of what they point to) shouldn't
become the default once diff supports it.  At the very least, diff
should warn when following symlinks though.

> Second, and more important, the output of --no-dereference
> should be something that we can feed to an (augmented)
> 'patch' so that it can alter a copy of the old tree,
> symlinks and all, so that it looks like the new tree,
> symlinks and all.  This suggests that the output of
> 'diff' needs to contain the symlink contents, and needs
> to distinguish symlinks from regular files, so that 'patch'
> can reconstruct the symlinks.

Binary files, file permissions, copied/renamed files, creation/deletion
of empty files also are not supported by diff currently.  Alpha versions
of patch already mostly support git's extended diff format [*] which
addresses these shortcomings, so this would be a good place to start.

[*] https://github.com/gitster/git/blob/master/Documentation/
	diff-generate-patch.txt

Thanks,
Andreas



From MAILER-DAEMON Sun Jan 08 01:41:52 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjmRz-00087Q-WF
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 01:41:52 -0500
Received: from eggs.gnu.org ([140.186.70.92]:37783)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1Rji2x-0007Ib-V6
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:59:45 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1Rji2w-0001Lo-PQ
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:59:43 -0500
Received: from mail-ee0-f41.google.com ([74.125.83.41]:46473)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1Rji2w-0001Lk-Jb
	for bug-diffutils@gnu.org; Sat, 07 Jan 2012 20:59:42 -0500
Received: by eekc41 with SMTP id c41so1857590eek.0
	for <bug-diffutils@gnu.org>; Sat, 07 Jan 2012 17:59:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=subject:from:to:cc:date:in-reply-to:references:content-type
	:x-mailer:content-transfer-encoding:message-id:mime-version;
	bh=sD+MvrsIASgpG/0Tl/wTwl+QjFihjv7/w/0qGUymZZU=;
	b=FiWuugFmOlEg5/f9k9ehFzHne+dEo4+myCzOq4tPkR4B0Yy00IhvIbiZqvKzYZKXpq
	V5345XdFUedMEMDxxwOGDvBTgV0jbwwtn5ufeFkDQQlGVR2P5RKSYiRwQUwv+yl37sMZ
	Ybx6VCfxidK8ai5Z81UYpCdRy0JSdzl3WFSl4=
Received: by 10.213.110.12 with SMTP id l12mr635617ebp.73.1325987979893;
	Sat, 07 Jan 2012 17:59:39 -0800 (PST)
Received: from [192.168.91.169] (chello084114015216.14.vie.surfer.at.
	[84.114.15.216])
	by mx.google.com with ESMTPS id 76sm270096765eeh.0.2012.01.07.17.59.38
	(version=SSLv3 cipher=OTHER); Sat, 07 Jan 2012 17:59:38 -0800 (PST)
From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
To: Bruno Haible <bruno@clisp.org>
Date: Sun, 08 Jan 2012 02:59:37 +0100
In-Reply-To: <7308010.vTWG6uvlWJ@linuix>
References: <4355365.Un2U1Fnndd@linuix> <4F08B061.7060005@cs.ucla.edu>
	<1325977662.3712.39.camel@schurl.linbit> <7308010.vTWG6uvlWJ@linuix>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.0.3 (3.0.3-1.fc15) 
Content-Transfer-Encoding: 7bit
Message-ID: <1325987978.3712.65.camel@schurl.linbit>
Mime-Version: 1.0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 74.125.83.41
X-Mailman-Approved-At: Sun, 08 Jan 2012 01:41:49 -0500
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 01:59:45 -0000

On Sun, 2012-01-08 at 02:16 +0100, Bruno Haible wrote:
> Andreas Gruenbacher wrote:
> > I wonder if comparing symlinks (instead of what they point to) shouldn't
> > become the default once diff supports it.  At the very least, diff
> > should warn when following symlinks though.
> 
> I disagree. --dereference should stay the default, for two reasons:
> 
>   1) Unix philosophy: By default, symlinks are followed. This is a
>      general principle. It starts with open() and fopen() and continues
>      through most command-line utilities.
> 
>   2) What are the use-cases for "diff"?
>        - Compare files coming from two different users.
>        - Comparing the new state of a directory with a backup.
>        - Compating the new state of a partition with a backup.
> 
>      In the first two cases, --dereference is desired. In the third case,
>      --no-dereference is desired.
> 
>      The first two cases are the most frequent ones.
> 
>      In other words, while you personally may be working frequently at
>      the partition level, many users who put a symbolic link want it to be
>      followed automatically.
> 
> See also the discussion at
> <https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00011.html>
> <https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00013.html>

I don't find these three use cases very instructive -- I either compare
two files or two directory trees.  In the two files case, I agree with
what Paul Eggert says in the thread you refer to:

> But the default behavior of "diff FILE1 FILE2" should remain
> unchanged: it should follow symlinks, as many programs depend on this
> behavior. Also, POSIX requires it.

In the two directories case, I really don't see when following symlinks
would be desirable.  Here, diff is comparable to a tool like tar, for
example -- in the tar case, I want to archive what's really there; in
the diff case, I want to compare what's really there.

Could you try to explain in more detail?

In the behavior I have in mind, diff would default to following symlink
command-line arguments but not to follow symlinks encountered while
traversing a directory tree; this is what the -H mode is meant to do.

Thanks,
Andreas



From MAILER-DAEMON Sun Jan 08 06:57:51 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjrNn-0005YH-9m
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 06:57:51 -0500
Received: from eggs.gnu.org ([140.186.70.92]:37767)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1RjrNk-0005S1-HF
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 06:57:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1RjrNj-0002Qb-C6
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 06:57:48 -0500
Received: from mail-ey0-f169.google.com ([209.85.215.169]:49333)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1RjrNj-0002QQ-7Z
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 06:57:47 -0500
Received: by eabm6 with SMTP id m6so2006143eab.0
	for <bug-diffutils@gnu.org>; Sun, 08 Jan 2012 03:57:46 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=subject:from:to:cc:date:in-reply-to:references:content-type
	:x-mailer:content-transfer-encoding:message-id:mime-version;
	bh=TNBa4UPuoU6qGt0HSAMmZiP8Kq786wcCOZ+V+aMa8rw=;
	b=m+Lpc5EGAKXahoDzAxV5x3lv6ThNIliHUqMEzpqeUKkf+4/XSXg8U6SkL9KsGbFS04
	GyP5PixVimZVVzgR00PAe5O2Gjv+zxLZJRsOoI0ZaOstlZdzPuu+MP4PmZ+DEBwIwSm+
	VjUYfw6QM3CHYBhOlPdcL6rAwvM/cHv4S95jQ=
Received: by 10.213.6.205 with SMTP id a13mr814685eba.131.1326023866460;
	Sun, 08 Jan 2012 03:57:46 -0800 (PST)
Received: from [192.168.91.169] (chello084114015216.14.vie.surfer.at.
	[84.114.15.216])
	by mx.google.com with ESMTPS id s16sm275747236eef.2.2012.01.08.03.57.43
	(version=SSLv3 cipher=OTHER); Sun, 08 Jan 2012 03:57:44 -0800 (PST)
From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
To: Bruno Haible <bruno@clisp.org>
Date: Sun, 08 Jan 2012 12:57:42 +0100
In-Reply-To: <15985033.iKpkQDS519@linuix>
References: <4355365.Un2U1Fnndd@linuix> <7308010.vTWG6uvlWJ@linuix>
	<1325987978.3712.65.camel@schurl.linbit> <15985033.iKpkQDS519@linuix>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.0.3 (3.0.3-1.fc15) 
Content-Transfer-Encoding: 7bit
Message-ID: <1326023864.2534.16.camel@schurl.linbit>
Mime-Version: 1.0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 209.85.215.169
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 11:57:49 -0000

On Sun, 2012-01-08 at 03:22 +0100, Bruno Haible wrote:
> Andreas Gruenbacher wrote:
> > In the two directories case, I really don't see when following symlinks
> > would be desirable.  Here, diff is comparable to a tool like tar, for
> > example -- in the tar case, I want to archive what's really there; in
> > the diff case, I want to compare what's really there.
> 
> Take an example. I often move subdirectories and big files from one disk
> to another one, for disk space reasons, and leave in a symlink that points
> to the new location. When I now prepare a backup, I'll use "tar chf -".
> And to compare the backup with the original contents, I use "diff -r".
> 
> I claim that this use-case is more frequent than the one which does not
> follow symlinks.

You lose symlinks anywhere in the entire backup.  This may be fine in
your particular case, but it sure isn't what most users will expect.

> Proof: GNU diff users were happy with the existing behaviour
> for 20 years.

GNU diff currently is unsuitable to comparing arbitrary directory trees
because the diff format cannot represent arbitrary differences.  Most
users probably leave it at that once they figure out.  This discussion
is about ways to rectify the situation though.

Thanks,
Andreas



From MAILER-DAEMON Sun Jan 08 10:47:56 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjuyR-0000v3-W0
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:47:55 -0500
Received: from eggs.gnu.org ([140.186.70.92]:50906)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjuyM-0000tr-DL
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:47:53 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjuyL-0004f5-Gz
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:47:50 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:51404)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjuyL-0004eq-Bo
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:47:49 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 11EFB39E800D;
	Sun,  8 Jan 2012 07:47:48 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id BF1pPNigkJGQ; Sun,  8 Jan 2012 07:47:47 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A236639E800B;
	Sun,  8 Jan 2012 07:47:47 -0800 (PST)
Message-ID: <4F09BAAF.9070409@cs.ucla.edu>
Date: Sun, 08 Jan 2012 07:47:59 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version: 1.0
To: Bruno Haible <bruno@clisp.org>
References: <4355365.Un2U1Fnndd@linuix> <4F08B061.7060005@cs.ucla.edu>
	<1619951.hBQeHAjaYO@linuix>
In-Reply-To: <1619951.hBQeHAjaYO@linuix>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 15:47:53 -0000

On 01/07/12 17:47, Bruno Haible wrote:
> But -P currently is equivalent to --unidirectional-new-file.

Yeouch.  I forgot about that.  You're right, we'd need to take the
next step in deprecating -P.  (The first step was taken in 2002, when
it was removed from the documentation, precisely for this reason --
can you tell that this has been on the TODO list for some time?...)

We also would need to deprecate -H and -L.  -H has no effect anyway,
and probably --speed-large-files should be removed from the documentation
too (though still a no-op for backward compatibility).

Given the large set of changes, and the likely use of -P and -L in scripts,
I expect that the first deprecation step should just warn on stderr and continue,
rather than having a fatal error.

As far as the long option names go, the GNU utilities aren't
consistent here, but perhaps we should use this for diffutils:

   -P == --no-dereference (as in cp, du)
   -H == --dereference-command-line (as in ls)
   -L == --dereference (as in cp, du, ls, stat)

omitting the short options for now, as the old meanings are being deprecated.

> 'patch' does not break through this additional lines. It simply ignores them.

True, hence the proposed patch can be an intermediate one on
the way to building a better one.  But I suppose that we should
document that the output format is likely to change, so that
people are less likely to depend on it.


From MAILER-DAEMON Sun Jan 08 10:59:46 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Rjv9u-00049O-Qu
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:59:46 -0500
Received: from eggs.gnu.org ([140.186.70.92]:56022)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Rjv9s-00048A-Ty
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:59:45 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Rjv9r-00073L-Po
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:59:44 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:33130)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Rjv9r-00072j-9y
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 10:59:43 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 00B9839E800B;
	Sun,  8 Jan 2012 07:59:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id WO7tjlbgAes4; Sun,  8 Jan 2012 07:59:40 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 8BECB39E8007;
	Sun,  8 Jan 2012 07:59:40 -0800 (PST)
Message-ID: <4F09BD78.9060003@cs.ucla.edu>
Date: Sun, 08 Jan 2012 07:59:52 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version: 1.0
To: Bruno Haible <bruno@clisp.org>
References: <4355365.Un2U1Fnndd@linuix> <7308010.vTWG6uvlWJ@linuix>
	<1325987978.3712.65.camel@schurl.linbit>
	<15985033.iKpkQDS519@linuix>
In-Reply-To: <15985033.iKpkQDS519@linuix>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Cc: bug-diffutils@gnu.org, Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 15:59:45 -0000

On 01/07/12 18:22, Bruno Haible wrote:
> I claim that this use-case is more frequent than the one which does not
> follow symlinks. Proof: GNU diff users were happy with the existing behaviour
> for 20 years.

I'm not sure that this is much of a proof.  We've had many complaints
over the years.  I know I've not been happy with the existing behavior,
in many practical cases.

No matter what the default is, I imagine that occasionally one will
do a diff -r, be unhappy because the default wasn't the way one wanted it,
and then rerun with diff -rL or diff -rP (or whatever) to fix it.
So the issues are more: which behavior is more likely to be desired in
practice?  And, if they're roughly equally desired, or if we don't know which
is more desired, then which behavior is more likely to cause problems
in practice?  I'm not sure how to answer the first question, but for the
second question it seems that following symlinks is more likely to cause
problems than not following them, because of the problem of loops.

On the other hand, there's the issue of compatibility -- POSIX requires that
symlinks be followed all the time, and GNU diff has behaved
that way for many years.  Changing this is not something we'd want to
do lightly.


From MAILER-DAEMON Sun Jan 08 13:48:18 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Rjxn0-0000Ns-5l
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 13:48:18 -0500
Received: from eggs.gnu.org ([140.186.70.92]:51494)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1Rjxmx-0000Nc-C6
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 13:48:17 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1Rjxmu-0003us-JU
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 13:48:15 -0500
Received: from mo-p00-ob.rzone.de ([81.169.146.161]:46374)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1Rjxmt-0003ul-Lw
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 13:48:12 -0500
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1326048488; l=21732;
	s=domk; d=haible.de;
	h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:
	In-Reply-To:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH;
	bh=urO7S23oEXiDCoSnfoG81punCfw=;
	b=MU25kwy0k67MJyBJOLyzKLtF29dbn/4Q3BvUriI9oMwlxED9lHK7peyBf3FyWuVTtFJ
	U2uBvWZNLLT+JnToIZAF7jfVOBw50vHaAytvdp2bEAL+LPtrTEAWzJf9jT74/U6jF6r84
	0sO5ZNB98EPhw7sUo8t6yQym/XzYqkvcNZM=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvc44/6LjQ==
X-RZG-CLASS-ID: mo00
Received: from linuix.haible.de
	(dslb-088-068-071-136.pools.arcor-ip.net [88.68.71.136])
	by smtp.strato.de (klopstock mo52) (RZmta 27.3 DYNA|AUTH)
	with ESMTPA id B00a0ao08HqmG8 ; Sun, 8 Jan 2012 19:47:48 +0100 (MET)
From: Bruno Haible <bruno@clisp.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Bcc: bruno@haible.de
Date: Sun, 08 Jan 2012 19:48:02 +0100
Message-ID: <82887288.LpmnfA6aVQ@linuix>
User-Agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )
In-Reply-To: <4F09BAAF.9070409@cs.ucla.edu>
References: <4355365.Un2U1Fnndd@linuix> <1619951.hBQeHAjaYO@linuix>
	<4F09BAAF.9070409@cs.ucla.edu>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="nextPart6176925.6OAIBi7YFa"
Content-Transfer-Encoding: 7Bit
X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta)
X-Received-From: 81.169.146.161
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 18:48:17 -0000


--nextPart6176925.6OAIBi7YFa
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="iso-8859-1"

Hi Paul,

> > 'patch' does not break through this additional lines. It simply ign=
ores them.
>=20
> True, hence the proposed patch can be an intermediate one on
> the way to building a better one.

OK. Can I thus commit the patch that introduces --no-dereference?

> But I suppose that we should
> document that the output format is likely to change, so that
> people are less likely to depend on it.

It depends whether you want to work on that before the next diffutils
release.

> > But -P currently is equivalent to --unidirectional-new-file.
>=20
> Yeouch.  I forgot about that.  You're right, we'd need to take the
> next step in deprecating -P.  (The first step was taken in 2002, when=

> it was removed from the documentation, precisely for this reason --
> can you tell that this has been on the TODO list for some time?...)
>
> We also would need to deprecate -H and -L.  -H has no effect anyway

Rather, -H and -L are also undocumented, like -P.

> Given the large set of changes, and the likely use of -P and -L in sc=
ripts,
> I expect that the first deprecation step should just warn on stderr a=
nd continue,
> rather than having a fatal error.

I don't think that would be good. A warning is too easily overlooked.
When a user has overlooked the warning, the change in semantics will hi=
t
him just a like a silent change.

And I don't think many people use these options -P, -H, -L: They are
undocumented.

> and probably --speed-large-files should be removed from the documenta=
tion
> too (though still a no-op for backward compatibility).

Really?? --speed-large-files is essential for users who need to reduce
the running time from O(N=B2) to O(N). When you diff files of 100 MB or=
 so,
it becomes important.

> As far as the long option names go, the GNU utilities aren't
> consistent here, but perhaps we should use this for diffutils:
>=20
>    -P =3D=3D --no-dereference (as in cp, du)
>    -H =3D=3D --dereference-command-line (as in ls)
>    -L =3D=3D --dereference (as in cp, du, ls, stat)
>=20
> omitting the short options for now, as the old meanings are being dep=
recated.

I agree. Can I commit the --no-dereference patch and leave the rest to =
you?

Find attached the updated proposals.

Bruno

--nextPart6176925.6OAIBi7YFa
Content-Disposition: attachment; filename="0001-New-option-no-dereference.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-New-option-no-dereference.patch"

>From 5c1cfb7ad0793d91455a5783431657cba3bfffd5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sat, 7 Jan 2012 00:57:29 +0100
Subject: [PATCH 1/4] New option --no-dereference.

* src/diff.h (no_dereference_symlinks): New variable.
* src/diff.c: Include xreadlink.h.
(longopts): Add --no-dereference option.
(main): Accept --no-dereference option.
(option_help_msgid): Mention the --no-dereference option.
(compare_files): If no_dereference_symlinks is true, use lstat()
instead of stat(). Compare symbolic links by comparing their values.
* bootstrap.conf (gnulib_modules): Add lstat, stat, xreadlink.
* doc/diffutils.texi (Comparing Directories, diff Options): Mention the
--no-dereference option.
* tests/no-dereference: New file.
* tests/Makefile.am (TESTS): Add it.
---
 bootstrap.conf       |    3 +
 doc/diffutils.texi   |   10 +++
 src/diff.c           |   74 +++++++++++++++++++++-
 src/diff.h           |    4 +
 tests/Makefile.am    |    1 +
 tests/no-dereference |  169 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 257 insertions(+), 4 deletions(-)
 create mode 100644 tests/no-dereference

diff --git a/bootstrap.conf b/bootstrap.conf
index 2399d08..51da0c0 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -48,6 +48,7 @@ hard-locale
 inttostr
 inttypes
 largefile
+lstat
 maintainer-makefile
 manywarnings
 mbrtowc
@@ -60,6 +61,7 @@ regex
 sh-quote
 signal
 sigprocmask
+stat
 stat-macros
 stat-time
 stdint
@@ -77,6 +79,7 @@ version-etc-fsf
 wcwidth
 xalloc
 xfreopen
+xreadlink
 xstrtoumax
 '
 
diff --git a/doc/diffutils.texi b/doc/diffutils.texi
index 5aff3c3..58b140c 100644
--- a/doc/diffutils.texi
+++ b/doc/diffutils.texi
@@ -1846,6 +1846,13 @@ is specified while the @option{--ignore-file-name-case} option is in
 effect, case is ignored when excluding file names matching the
 specified patterns.
 
+To avoid that @command{diff} follows symbolic links, use the
+@c later: @option{--no-dereference} (@option{-P}).
+@option{--no-dereference}.
+When this option is in use,
+symbolic links will be treated like a special kind of files, rather than
+comparing the target of each symbolic link.
+
 @node Adjusting Output
 @chapter Making @command{diff} Output Prettier
 
@@ -3848,6 +3855,9 @@ file in if-then-else format.  @xref{Line Group Formats}.
 Use @var{format} to output a line taken from just the second file in
 if-then-else format.  @xref{Line Formats}.
 
+@item --no-dereference
+Act on symbolic links themselves instead of what they point to.
+
 @item --old-group-format=@var{format}
 Use @var{format} to output a group of lines taken from just the first
 file in if-then-else format.  @xref{Line Group Formats}.
diff --git a/src/diff.c b/src/diff.c
index 004654e..112c8c5 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -39,6 +39,7 @@
 #include <timespec.h>
 #include <version-etc.h>
 #include <xalloc.h>
+#include <xreadlink.h>
 #include <binary-io.h>
 
 /* The official name of this program (e.g., no `g' prefix).  */
@@ -120,6 +121,7 @@ enum
   INHIBIT_HUNK_MERGE_OPTION,
   LEFT_COLUMN_OPTION,
   LINE_FORMAT_OPTION,
+  NO_DEREFERENCE_OPTION,
   NO_IGNORE_FILE_NAME_CASE_OPTION,
   NORMAL_OPTION,
   SDIFF_MERGE_ASSIST_OPTION,
@@ -188,6 +190,7 @@ static struct option const longopts[] =
   {"new-file", 0, 0, 'N'},
   {"new-group-format", 1, 0, NEW_GROUP_FORMAT_OPTION},
   {"new-line-format", 1, 0, NEW_LINE_FORMAT_OPTION},
+  {"no-dereference", 0, 0, NO_DEREFERENCE_OPTION},
   {"no-ignore-file-name-case", 0, 0, NO_IGNORE_FILE_NAME_CASE_OPTION},
   {"normal", 0, 0, NORMAL_OPTION},
   {"old-group-format", 1, 0, OLD_GROUP_FORMAT_OPTION},
@@ -564,6 +567,10 @@ main (int argc, char **argv)
 	    specify_value (&line_format[i], optarg, "--line-format");
 	  break;
 
+	case NO_DEREFERENCE_OPTION:
+	  no_dereference_symlinks = true;
+	  break;
+
 	case NO_IGNORE_FILE_NAME_CASE_OPTION:
 	  ignore_file_name_case = false;
 	  break;
@@ -872,6 +879,7 @@ static char const * const option_help_msgid[] = {
   N_("-l, --paginate                pass output through `pr' to paginate it"),
   "",
   N_("-r, --recursive                 recursively compare any subdirectories found"),
+  N_("    --no-dereference            don't follow symbolic links"),
   N_("-N, --new-file                  treat absent files as empty"),
   N_("    --unidirectional-new-file   treat absent first files as empty"),
   N_("    --ignore-file-name-case     ignore case when comparing file names"),
@@ -1128,7 +1136,10 @@ compare_files (struct comparison const *parent,
 		  set_mtime_to_now (&cmp.file[f].stat);
 		}
 	    }
-	  else if (stat (cmp.file[f].name, &cmp.file[f].stat) != 0)
+	  else if ((no_dereference_symlinks
+		    ? lstat (cmp.file[f].name, &cmp.file[f].stat)
+		    : stat (cmp.file[f].name, &cmp.file[f].stat))
+		   != 0)
 	    cmp.file[f].desc = ERRNO_ENCODE (errno);
 	}
     }
@@ -1182,7 +1193,10 @@ compare_files (struct comparison const *parent,
       if (STREQ (fnm, "-"))
 	fatal ("cannot compare `-' to a directory");
 
-      if (stat (filename, &cmp.file[dir_arg].stat) != 0)
+      if ((no_dereference_symlinks
+	   ? lstat (filename, &cmp.file[dir_arg].stat)
+	   : stat (filename, &cmp.file[dir_arg].stat))
+	  != 0)
 	{
 	  perror_with_name (filename);
 	  status = EXIT_TROUBLE;
@@ -1229,8 +1243,10 @@ compare_files (struct comparison const *parent,
     }
   else if ((DIR_P (0) | DIR_P (1))
 	   || (parent
-	       && (! S_ISREG (cmp.file[0].stat.st_mode)
-		   || ! S_ISREG (cmp.file[1].stat.st_mode))))
+	       && !((S_ISREG (cmp.file[0].stat.st_mode)
+		     || S_ISLNK (cmp.file[0].stat.st_mode))
+		    && (S_ISREG (cmp.file[1].stat.st_mode)
+			|| S_ISLNK  (cmp.file[1].stat.st_mode)))))
     {
       if (cmp.file[0].desc == NONEXISTENT || cmp.file[1].desc == NONEXISTENT)
 	{
@@ -1271,6 +1287,56 @@ compare_files (struct comparison const *parent,
 	  status = EXIT_FAILURE;
 	}
     }
+  else if (S_ISLNK (cmp.file[0].stat.st_mode)
+	   || S_ISLNK (cmp.file[1].stat.st_mode))
+    {
+      /* We get here only if we use lstat(), not stat().  */
+      assert (no_dereference_symlinks);
+
+      if (S_ISLNK (cmp.file[0].stat.st_mode)
+	  && S_ISLNK (cmp.file[1].stat.st_mode))
+	{
+	  /* Compare the values of the symbolic links.  */
+	  char *link_value[2] = { NULL, NULL };
+
+	  for (f = 0; f < 2; f++)
+	    {
+	      link_value[f] = xreadlink (cmp.file[f].name);
+	      if (link_value[f] == NULL)
+		{
+		  perror_with_name (cmp.file[f].name);
+		  status = EXIT_TROUBLE;
+		  break;
+		}
+	    }
+	  if (status == EXIT_SUCCESS)
+	    {
+	      if (strcmp (link_value[0], link_value[1]) != 0)
+		{
+		  message ("Symbolic links %s and %s differ\n",
+			   cmp.file[0].name, cmp.file[1].name);
+		  /* This is a difference.  */
+		  status = EXIT_FAILURE;
+		}
+	    }
+	  for (f = 0; f < 2; f++)
+	    free (link_value[f]);
+	}
+      else
+	{
+	  /* We have two files that are not to be compared, because
+	     one of them is a symbolic link and the other one is not.  */
+
+	  message5 ("File %s is a %s while file %s is a %s\n",
+		    file_label[0] ? file_label[0] : cmp.file[0].name,
+		    file_type (&cmp.file[0].stat),
+		    file_label[1] ? file_label[1] : cmp.file[1].name,
+		    file_type (&cmp.file[1].stat));
+
+	  /* This is a difference.  */
+	  status = EXIT_FAILURE;
+	}
+    }
   else if (files_can_be_treated_as_binary
 	   && S_ISREG (cmp.file[0].stat.st_mode)
 	   && S_ISREG (cmp.file[1].stat.st_mode)
diff --git a/src/diff.h b/src/diff.h
index 795cc0c..05029a3 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -135,6 +135,10 @@ XTERN bool ignore_case;
 /* Ignore differences in case of letters in file names.  */
 XTERN bool ignore_file_name_case;
 
+/* Act on symbolic links themselves rather than on their target
+   (--no-dereference).  */
+XTERN bool no_dereference_symlinks;
+
 /* File labels for `-c' output headers (--label).  */
 XTERN char *file_label[2];
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9952d67..2f6ad53 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@ TESTS = \
   help-version	\
   function-line-vs-leading-space \
   label-vs-func	\
+  no-dereference \
   no-newline-at-eof \
   stdin
 
diff --git a/tests/no-dereference b/tests/no-dereference
new file mode 100644
index 0000000..1426beb
--- /dev/null
+++ b/tests/no-dereference
@@ -0,0 +1,169 @@
+#!/bin/sh
+# Test the --no-dereference option.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+echo 'Simple contents' > regular1
+echo 'Sample contents' > regular2
+echo 'Sample contents' > regular3
+ln -s regular1 symlink1
+ln -s regular1 symlink1bis
+ln -s regular2 symlink2
+ln -s regular3 symlink3
+
+# Non-recursive comparisons.
+
+# Test case 3: Compare regular file with regular file.
+diff --no-dereference regular1 regular2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+diff --no-dereference regular1 symlink1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File regular1 is a regular file while file symlink1 is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+diff --no-dereference symlink1 regular1 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File symlink1 is a symbolic link while file regular1 is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+diff --no-dereference symlink1 symlink1bis > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+diff --no-dereference symlink1 symlink2 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink1 and symlink2 differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+diff --no-dereference symlink2 symlink3 > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links symlink2 and symlink3 differ
+EOF
+compare expected out || fail=1
+
+# Recursive comparisons.
+
+# Test case 1: Compare symbolic link with nonexistent file.
+mkdir subdir1a
+mkdir subdir1b
+ln -s nonexistent subdir1a/foo
+ln -s ../regular1 subdir1a/bar
+diff -r --no-dereference subdir1a subdir1b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir1a: bar
+Only in subdir1a: foo
+EOF
+compare expected out || fail=1
+
+# Test case 1: Compare nonexistent file with symbolic link.
+mkdir subdir2a
+mkdir subdir2b
+ln -s nonexistent subdir2b/foo
+ln -s ../regular1 subdir2b/bar
+diff -r --no-dereference subdir2a subdir2b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Only in subdir2b: bar
+Only in subdir2b: foo
+EOF
+compare expected out || fail=1
+
+# Test case 3: Compare regular file with regular file.
+mkdir subdir3a
+mkdir subdir3b
+cp regular1 subdir3a/foo
+cp regular2 subdir3b/foo
+diff -r --no-dereference subdir3a subdir3b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+diff -r --no-dereference subdir3a/foo subdir3b/foo
+1c1
+< Simple contents
+---
+> Sample contents
+EOF
+compare expected out || fail=1
+
+# Test case 4: Compare regular file with symbolic link.
+mkdir subdir4a
+mkdir subdir4b
+cp regular1 subdir4a/foo
+ln -s ../regular1 subdir4b/foo
+diff -r --no-dereference subdir4a subdir4b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
+EOF
+compare expected out || fail=1
+
+# Test case 5: Compare symbolic link with regular file.
+mkdir subdir5a
+mkdir subdir5b
+ln -s ../regular1 subdir5a/foo
+cp regular1 subdir5b/foo
+diff -r --no-dereference subdir5a subdir5b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
+EOF
+compare expected out || fail=1
+
+# Test case 6: Compare symbolic links with same value.
+mkdir subdir6a
+mkdir subdir6b
+ln -s ../regular1 subdir6a/foo
+ln -s ../regular1 subdir6b/foo
+diff -r --no-dereference subdir6a subdir6b > out
+test $? = 0 || fail=1
+compare /dev/null out || fail=1
+
+# Test case 7: Compare symbolic links with different value and different target
+# contents.
+mkdir subdir7a
+mkdir subdir7b
+ln -s ../regular1 subdir7a/foo
+ln -s ../regular2 subdir7b/foo
+diff -r --no-dereference subdir7a subdir7b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir7a/foo and subdir7b/foo differ
+EOF
+compare expected out || fail=1
+
+# Test case 8: Compare symbolic links with different value and same target
+# contents.
+mkdir subdir8a
+mkdir subdir8b
+ln -s ../regular2 subdir8a/foo
+ln -s ../regular3 subdir8b/foo
+diff -r --no-dereference subdir8a subdir8b > out
+test $? = 1 || fail=1
+cat <<EOF > expected || framework_failure_
+Symbolic links subdir8a/foo and subdir8b/foo differ
+EOF
+compare expected out || fail=1
+
+Exit $fail
-- 
1.6.3.2


--nextPart6176925.6OAIBi7YFa
Content-Disposition: attachment; filename="0002-Deprecate-old-option-P.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0002-Deprecate-old-option-P.patch"

>From 0c75d97f72af7f1764657632a303b043ee6cf790 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 8 Jan 2012 02:29:24 +0100
Subject: [PATCH 2/4] Deprecate old option -P.

* src/diff.c (UNIDIRECTIONAL_NEW_FILE_OPTION): New enumeration item.
(longopts): Use it instead of '-P'.
(main): Give an error message if option -P is used.
---
 src/diff.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/diff.c b/src/diff.c
index 112c8c5..67b3109 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -130,6 +130,7 @@ enum
   SUPPRESS_COMMON_LINES_OPTION,
   TABSIZE_OPTION,
   TO_FILE_OPTION,
+  UNIDIRECTIONAL_NEW_FILE_OPTION,
 
   /* These options must be in sequence.  */
   UNCHANGED_LINE_FORMAT_OPTION,
@@ -213,7 +214,7 @@ static struct option const longopts[] =
   {"to-file", 1, 0, TO_FILE_OPTION},
   {"unchanged-group-format", 1, 0, UNCHANGED_GROUP_FORMAT_OPTION},
   {"unchanged-line-format", 1, 0, UNCHANGED_LINE_FORMAT_OPTION},
-  {"unidirectional-new-file", 0, 0, 'P'},
+  {"unidirectional-new-file", 0, 0, UNIDIRECTIONAL_NEW_FILE_OPTION},
   {"unified", 2, 0, 'U'},
   {"version", 0, 0, 'v'},
   {"width", 1, 0, 'W'},
@@ -455,7 +456,7 @@ main (int argc, char **argv)
 	  break;
 
 	case 'P':
-	  unidirectional_new_file = true;
+	  fatal ("option -P no longer supported, use --unidirectional-new-file for the old meaning");
 	  break;
 
 	case 'q':
@@ -612,6 +613,10 @@ main (int argc, char **argv)
 	  specify_value (&to_file, optarg, "--to-file");
 	  break;
 
+	case UNIDIRECTIONAL_NEW_FILE_OPTION:
+	  unidirectional_new_file = true;
+	  break;
+
 	case UNCHANGED_LINE_FORMAT_OPTION:
 	case OLD_LINE_FORMAT_OPTION:
 	case NEW_LINE_FORMAT_OPTION:
-- 
1.6.3.2


--nextPart6176925.6OAIBi7YFa
Content-Disposition: attachment; filename="0003-Deprecate-old-option-H.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0003-Deprecate-old-option-H.patch"

>From 71c89a405eb88d13f5edf9511bd082f9f4c01325 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 8 Jan 2012 19:39:41 +0100
Subject: [PATCH 3/4] Deprecate old option -H.

* src/diff.c (SPEED_LARGE_FILES_OPTION): New enumeration item.
(longopts): Use it instead of '-H'.
(main): Give an error message if option -H is used.
Suggested by Paul Eggert.
---
 src/diff.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/diff.c b/src/diff.c
index 67b3109..2d364e9 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -125,6 +125,7 @@ enum
   NO_IGNORE_FILE_NAME_CASE_OPTION,
   NORMAL_OPTION,
   SDIFF_MERGE_ASSIST_OPTION,
+  SPEED_LARGE_FILES_OPTION,
   STRIP_TRAILING_CR_OPTION,
   SUPPRESS_BLANK_EMPTY_OPTION,
   SUPPRESS_COMMON_LINES_OPTION,
@@ -204,7 +205,7 @@ static struct option const longopts[] =
   {"show-c-function", 0, 0, 'p'},
   {"show-function-line", 1, 0, 'F'},
   {"side-by-side", 0, 0, 'y'},
-  {"speed-large-files", 0, 0, 'H'},
+  {"speed-large-files", 0, 0, SPEED_LARGE_FILES_OPTION},
   {"starting-file", 1, 0, 'S'},
   {"strip-trailing-cr", 0, 0, STRIP_TRAILING_CR_OPTION},
   {"suppress-blank-empty", 0, 0, SUPPRESS_BLANK_EMPTY_OPTION},
@@ -411,7 +412,7 @@ main (int argc, char **argv)
 	  break;
 
 	case 'H':
-	  speed_large_files = true;
+	  fatal ("option -H no longer supported, use --speed-large-files for the old meaning");
 	  break;
 
 	case 'i':
@@ -585,6 +586,10 @@ main (int argc, char **argv)
 	  sdiff_merge_assist = true;
 	  break;
 
+	case SPEED_LARGE_FILES_OPTION:
+	  speed_large_files = true;
+	  break;
+
 	case STRIP_TRAILING_CR_OPTION:
 	  strip_trailing_cr = true;
 	  break;
-- 
1.6.3.2


--nextPart6176925.6OAIBi7YFa
Content-Disposition: attachment; filename="0004-Deprecate-old-option-L.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0004-Deprecate-old-option-L.patch"

>From e379f978114fed8ba653a9c63a5acd968a46825e Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 8 Jan 2012 19:42:40 +0100
Subject: [PATCH 4/4] Deprecate old option -L.

* src/diff.c (LABEL_OPTION): New enumeration item.
(longopts): Use it instead of '-L'.
(main): Give an error message if option -L is used.
Suggested by Paul Eggert.
---
 src/diff.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/diff.c b/src/diff.c
index 2d364e9..4f372ac 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -119,6 +119,7 @@ enum
   HORIZON_LINES_OPTION,
   IGNORE_FILE_NAME_CASE_OPTION,
   INHIBIT_HUNK_MERGE_OPTION,
+  LABEL_OPTION,
   LEFT_COLUMN_OPTION,
   LINE_FORMAT_OPTION,
   NO_DEREFERENCE_OPTION,
@@ -185,7 +186,7 @@ static struct option const longopts[] =
   {"ignore-trailing-space", 0, 0, 'Z'},
   {"inhibit-hunk-merge", 0, 0, INHIBIT_HUNK_MERGE_OPTION},
   {"initial-tab", 0, 0, 'T'},
-  {"label", 1, 0, 'L'},
+  {"label", 1, 0, LABEL_OPTION},
   {"left-column", 0, 0, LEFT_COLUMN_OPTION},
   {"line-format", 1, 0, LINE_FORMAT_OPTION},
   {"minimal", 0, 0, 'd'},
@@ -435,12 +436,7 @@ main (int argc, char **argv)
 	  break;
 
 	case 'L':
-	  if (!file_label[0])
-	    file_label[0] = optarg;
-	  else if (!file_label[1])
-	    file_label[1] = optarg;
-	  else
-	    fatal ("too many file label options");
+	  fatal ("option -L no longer supported, use --label for the old meaning");
 	  break;
 
 	case 'n':
@@ -559,6 +555,15 @@ main (int argc, char **argv)
              compatibility.  */
 	  break;
 
+	case LABEL_OPTION:
+	  if (!file_label[0])
+	    file_label[0] = optarg;
+	  else if (!file_label[1])
+	    file_label[1] = optarg;
+	  else
+	    fatal ("too many file label options");
+	  break;
+
 	case LEFT_COLUMN_OPTION:
 	  left_column = true;
 	  break;
-- 
1.6.3.2


--nextPart6176925.6OAIBi7YFa--



From MAILER-DAEMON Sun Jan 08 14:46:25 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjyhF-0003p0-Og
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 14:46:25 -0500
Received: from eggs.gnu.org ([140.186.70.92]:45652)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjyhD-0003on-5i
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 14:46:24 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjyhB-00048C-Ru
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 14:46:23 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:48394)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RjyhB-00047v-M7
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 14:46:21 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 44013A60008;
	Sun,  8 Jan 2012 11:46:20 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id GW4HTfC3MjAR; Sun,  8 Jan 2012 11:46:19 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id E4645A60002;
	Sun,  8 Jan 2012 11:46:19 -0800 (PST)
Message-ID: <4F09F299.5070604@cs.ucla.edu>
Date: Sun, 08 Jan 2012 11:46:33 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version: 1.0
To: Bruno Haible <bruno@clisp.org>
References: <4355365.Un2U1Fnndd@linuix> <1619951.hBQeHAjaYO@linuix>
	<4F09BAAF.9070409@cs.ucla.edu> <82887288.LpmnfA6aVQ@linuix>
In-Reply-To: <82887288.LpmnfA6aVQ@linuix>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 19:46:24 -0000

On 01/08/12 10:48, Bruno Haible wrote:

> OK. Can I thus commit the patch that introduces --no-dereference?

Yes, please go ahead.  I'd like to wait for further input
before going ahead with the backwards-incompatible changes to -P,
-H, -L.

> And I don't think many people use these options -P, -H, -L: They are
> undocumented.

The latest version of RCS (5.8) uses diff -L.  I'll file a bug report.
But that's not a good sign.

> --speed-large-files is essential for users who need to reduce
> the running time from O(N=C2=B2) to O(N).

The running time is O(ND) where D is the number of differences.
One can come up with examples exhibiting O(N**2) behavior, but
they're rare enough in practice that it doesn't seem to be a problem.
As far as I know, --speed-large-files has never been implemented in
GNU diff (as -h was in the original Unix diff); it has always been
a no-op.


From MAILER-DAEMON Sun Jan 08 15:52:50 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RjzjW-00054H-44
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 15:52:50 -0500
Received: from eggs.gnu.org ([140.186.70.92]:54444)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjzjS-00053G-R9
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 15:52:47 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjzjR-0004M0-E8
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 15:52:46 -0500
Received: from mo-p00-ob.rzone.de ([81.169.146.161]:47085)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1RjzjQ-0004Lq-6l
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 15:52:45 -0500
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1326055962; l=1186;
	s=domk; d=haible.de;
	h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:
	In-Reply-To:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH;
	bh=ElCOV8vBOaQb+YXjyZqfFZm2OxA=;
	b=cu5xdurjBoFnVAJh+G6Ishjz4Ac3L4LJ4SxKUT1HU3eooocFUoRTN4AreQyvNrNSruv
	UUCas1Vdx7N5CIyGkjCv50mSEIF+CzoE0DTOHOrosHaXuxGADPqdVN25SAnjrohROadPk
	2m69AEmYdOWMLtWJXbnnnbzUJ8YVjqCFA+M=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvc44/6LjQ==
X-RZG-CLASS-ID: mo00
Received: from linuix.haible.de
	(dslb-088-068-071-136.pools.arcor-ip.net [88.68.71.136])
	by smtp.strato.de (fruni mo10) (RZmta 27.3 DYNA|AUTH)
	with ESMTPA id 9043a2o08H6Erj ; Sun, 8 Jan 2012 21:52:19 +0100 (MET)
From: Bruno Haible <bruno@clisp.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Bcc: bruno@haible.de
Date: Sun, 08 Jan 2012 21:52:30 +0100
Message-ID: <3283470.QmA28soKDJ@linuix>
User-Agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )
In-Reply-To: <4F09F299.5070604@cs.ucla.edu>
References: <4355365.Un2U1Fnndd@linuix> <82887288.LpmnfA6aVQ@linuix>
	<4F09F299.5070604@cs.ucla.edu>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="iso-8859-1"
X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta)
X-Received-From: 81.169.146.161
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] --speed-large-files
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 20:52:47 -0000

Paul Eggert wrote:
> > --speed-large-files is essential for users who need to reduce
> > the running time from O(N=B2) to O(N).
>=20
> The running time is O(ND) where D is the number of differences.
> One can come up with examples exhibiting O(N**2) behavior, but
> they're rare enough in practice that it doesn't seem to be a problem.=


I encountered such cases a couple of years ago. IIRC, the files were
two mbox files that had diverged through different modifications on
different machines.

> As far as I know, --speed-large-files has never been implemented in
> GNU diff (as -h was in the original Unix diff); it has always been
> a no-op.

When you pass --speed-large-files, src/diff.c sets speed_large_files
to true. Then, src/analyze.c sets ctxt.heuristic to true. Then,
gnulib/lib/diffseq.h function diag() applies your heuristic.

It cannot be a no-op, as it has an effect on the run-time: In a contriv=
ed
example (two mbox files, each ca. 18 MB large),
  $ time diff -u mbox1 mbox2 > /dev/null
displays a run time of 3.81 seconds, whereas
  $ time diff -u --speed-large-files mbox1 mbox2 > /dev/null
displays a run time of 3.98 seconds.

Bruno



From MAILER-DAEMON Sun Jan 08 18:29:26 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Rk2B4-0002xH-9M
	for mharc-bug-diffutils@gnu.org; Sun, 08 Jan 2012 18:29:26 -0500
Received: from eggs.gnu.org ([140.186.70.92]:51461)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Rk2B3-0002xB-4W
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 18:29:25 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Rk2B2-0008Mk-7q
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 18:29:25 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:52984)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Rk2B1-0008Mg-Vw
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 18:29:24 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 7ADD739E800D;
	Sun,  8 Jan 2012 15:29:23 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id wMFbCS8n94t4; Sun,  8 Jan 2012 15:29:23 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 1F0EB39E800A;
	Sun,  8 Jan 2012 15:29:23 -0800 (PST)
Message-ID: <4F0A26E1.1010407@cs.ucla.edu>
Date: Sun, 08 Jan 2012 15:29:37 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version: 1.0
To: Bruno Haible <bruno@clisp.org>
References: <4355365.Un2U1Fnndd@linuix> <82887288.LpmnfA6aVQ@linuix>
	<4F09F299.5070604@cs.ucla.edu> <3283470.QmA28soKDJ@linuix>
In-Reply-To: <3283470.QmA28soKDJ@linuix>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Cc: bug-diffutils@gnu.org
Subject: Re: [bug-diffutils] --speed-large-files
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 08 Jan 2012 23:29:25 -0000

On 01/08/12 12:52, Bruno Haible wrote:
> gnulib/lib/diffseq.h function diag() applies your heuristic.

I forgot about that.  OK, then we should
keep that option.  It's not nearly as effective as it
should be, but that can await future improvements.

Sorry about the noise -- as you can tell, this is really
a trip down memory lane for me.


From MAILER-DAEMON Mon Jan 09 01:12:30 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Rk8T7-0003SI-Vj
	for mharc-bug-diffutils@gnu.org; Mon, 09 Jan 2012 01:12:29 -0500
Received: from eggs.gnu.org ([140.186.70.92]:45813)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Eric@Deplagne.name>) id 1Rk34g-00059N-78
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 19:26:55 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Eric@Deplagne.name>) id 1Rk34f-000757-9E
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 19:26:54 -0500
Received: from alcorak1.eric.deplagne.name ([213.246.39.115]:50510
	helo=exim4.alcorak1.eric.deplagne.name)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Eric@Deplagne.name>) id 1Rk34f-00074x-4z
	for bug-diffutils@gnu.org; Sun, 08 Jan 2012 19:26:53 -0500
Received: from [192.168.0.4] (helo=mail.eric.deplagne.name)
	by exim4.alcorak1.eric.deplagne.name with esmtp (Exim 4.69)
	(envelope-from <Eric@Deplagne.name>) id 1Rk34b-0008I0-UN
	for bug-diffutils@gnu.org; Mon, 09 Jan 2012 01:26:49 +0100
Received: from deplagne by mail.eric.deplagne.name with local (Exim 4.69)
	(envelope-from <Eric@Deplagne.name>) id 1Rk34b-0008Hx-SB
	for bug-diffutils@gnu.org; Mon, 09 Jan 2012 01:26:49 +0100
Date: Mon, 9 Jan 2012 01:26:49 +0100
From: Eric Deplagne <Eric@Deplagne.name>
To: bug-diffutils@gnu.org
Message-ID: <20120109002649.GK11058@mail.eric.deplagne.name>
References: <4355365.Un2U1Fnndd@linuix> <7308010.vTWG6uvlWJ@linuix>
	<1325987978.3712.65.camel@schurl.linbit>
	<15985033.iKpkQDS519@linuix>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="pN9MePJoZbRKbUk1"
Content-Disposition: inline
In-Reply-To: <15985033.iKpkQDS519@linuix>
User-Agent: Mutt/1.5.18 (2008-05-17)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 213.246.39.115
X-Mailman-Approved-At: Mon, 09 Jan 2012 01:12:28 -0500
Subject: Re: [bug-diffutils] diff: support for --no-dereference option
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 09 Jan 2012 00:26:55 -0000


--pN9MePJoZbRKbUk1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, 08 Jan 2012 03:22:22 +0100, Bruno Haible wrote:
> Andreas Gruenbacher wrote:
> > In the two directories case, I really don't see when following symlinks
> > would be desirable.  Here, diff is comparable to a tool like tar, for
> > example -- in the tar case, I want to archive what's really there; in
> > the diff case, I want to compare what's really there.
>=20
> Take an example. I often move subdirectories and big files from one disk
> to another one, for disk space reasons, and leave in a symlink that points
> to the new location. When I now prepare a backup, I'll use "tar chf -".
> And to compare the backup with the original contents, I use "diff -r".
>=20
> I claim that this use-case is more frequent than the one which does not
> follow symlinks. Proof: GNU diff users were happy with the existing behav=
iour
> for 20 years.

  I've been unhappy with the existing behaviour for symlinks and special fi=
les
  (devices and probably others, too) for more than 10 years...

  Never thought the "diff people" would bother, though, because it's in cas=
es
  I diff directory trees (from tar backups, usually) instead of code...

> Bruno

--=20
  Eric Deplagne

--pN9MePJoZbRKbUk1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFPCjRJej7DisjVpq4RAls1AJ94xUsBcQiOZ5TZiKGXUsQNJ3Nd/ACfZc89
w75Y74g8FxZSzSA9KUQZpNk=
=A4Gl
-----END PGP SIGNATURE-----

--pN9MePJoZbRKbUk1--


From MAILER-DAEMON Thu Jan 12 08:06:00 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RlKLw-0005Hp-Jw
	for mharc-bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:06:00 -0500
Received: from eggs.gnu.org ([140.186.70.92]:44030)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RlKLo-00056E-GS
	for bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:05:58 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RlKLj-00053j-9e
	for bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:05:52 -0500
Received: from mx.meyering.net ([88.168.87.75]:55192)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RlKLj-00053c-3p
	for bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:05:47 -0500
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id 3E184600D0
	for <bug-diffutils@gnu.org>; Thu, 12 Jan 2012 14:05:46 +0100 (CET)
From: Jim Meyering <jim@meyering.net>
To: bug-diffutils@gnu.org
Date: Thu, 12 Jan 2012 14:05:46 +0100
Message-ID: <8762ghxe8l.fsf@rho.meyering.net>
Lines: 27
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 88.168.87.75
Subject: [bug-diffutils] [PATCH] maint: avoid new syntax-check failure
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jan 2012 13:05:58 -0000

FYI,

>From 6e51ccfb4eccfdb6672e69c982723f633fb0f099 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 12 Jan 2012 14:04:17 +0100
Subject: [PATCH] maint: avoid new syntax-check failure

* src/diff.c (compare_files): Use STREQ, not strcmp.
---
 src/diff.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/diff.c b/src/diff.c
index 112c8c5..0911131 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1311,7 +1311,7 @@ compare_files (struct comparison const *parent,
 	    }
 	  if (status == EXIT_SUCCESS)
 	    {
-	      if (strcmp (link_value[0], link_value[1]) != 0)
+	      if ( ! STREQ (link_value[0], link_value[1]))
 		{
 		  message ("Symbolic links %s and %s differ\n",
 			   cmp.file[0].name, cmp.file[1].name);
--
1.7.9.rc0.25.gc7817


From MAILER-DAEMON Thu Jan 12 08:06:15 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RlKMB-0005JU-MP
	for mharc-bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:06:15 -0500
Received: from eggs.gnu.org ([140.186.70.92]:44078)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RlKM2-0005IB-TF
	for bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:06:13 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RlKLv-00055U-Oe
	for bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:06:06 -0500
Received: from mx.meyering.net ([88.168.87.75]:55194)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1RlKLv-00055H-7L
	for bug-diffutils@gnu.org; Thu, 12 Jan 2012 08:05:59 -0500
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id 9CD5B600D0
	for <bug-diffutils@gnu.org>; Thu, 12 Jan 2012 14:05:58 +0100 (CET)
From: Jim Meyering <jim@meyering.net>
To: bug-diffutils@gnu.org
Date: Thu, 12 Jan 2012 14:05:58 +0100
Message-ID: <8739blxe89.fsf@rho.meyering.net>
Lines: 562
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 88.168.87.75
Subject: [bug-diffutils] [PATCH] build: accommodate newer bootstrap from
	gnulib
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jan 2012 13:06:13 -0000

I've updated to latest bootstrap from gnulib:

>From 301a23cdbba22ad208e4014d277eb8eb600d2d0e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 12 Jan 2012 13:57:05 +0100
Subject: [PATCH] build: accommodate newer bootstrap from gnulib

* bootstrap.conf (gnulib_tool_option_extras): Add both --symlink
and --makefile-name=gnulib.mk.  Also remove now-obsolete $bt/ prefix.
* bootstrap: Update from gnulib.
* tests/init.sh: Update from gnulib.
* lib/Makefile.am: Initialize numerous variables, so that
generated code in gnulib.mk may use += to append to them.
---
 bootstrap       |  238 +++++++++++++++++-------------------------------------
 bootstrap.conf  |    8 +-
 lib/Makefile.am |   11 +++
 tests/init.sh   |  117 +++++++++++++++++++++++++--
 4 files changed, 198 insertions(+), 176 deletions(-)

diff --git a/bootstrap b/bootstrap
index 8c8a9cc..66da981 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2011-08-11.17; # UTC
+scriptversion=2012-01-06.07; # UTC

 # Bootstrap this package from checked-out sources.

@@ -38,10 +38,6 @@ export LC_ALL

 local_gl_dir=gl

-# Temporary directory names.
-bt='._bootmp'
-bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
-bt2=${bt}2
 me=$0

 usage() {
@@ -88,6 +84,9 @@ gnulib_modules=
 # Any gnulib files needed that are not in modules.
 gnulib_files=

+: ${AUTOPOINT=autopoint}
+: ${AUTORECONF=autoreconf}
+
 # A function to be called to edit gnulib.mk right after it's created.
 # Override it via your own definition in bootstrap.conf.
 gnulib_mk_hook() { :; }
@@ -105,6 +104,11 @@ po_download_command_format=\
 "rsync --delete --exclude '*.s1' -Lrtvz \
  'translationproject.org::tp/latest/%s/' '%s'"

+# Fallback for downloading .po files (if rsync fails).
+po_download_command_format2=\
+"wget --mirror -nd -q -np -A.po -P '%s' \
+ http://translationproject.org/latest/%s/"
+
 extract_package_name='
   /^AC_INIT(/{
      /.*,.*,.*, */{
@@ -312,8 +316,8 @@ insert_vc_ignore() {
   pattern="$2"
   case $vc_ignore_file in
   *.gitignore)
-    # A .gitignore entry that does not start with `/' applies
-    # recursively to subdirectories, so prepend `/' to every
+    # A .gitignore entry that does not start with '/' applies
+    # recursively to subdirectories, so prepend '/' to every
     # .gitignore entry.
     pattern=`echo "$pattern" | sed s,^,/,`;;
   esac
@@ -473,6 +477,32 @@ if test $use_libtool = 1; then
   find_tool LIBTOOLIZE glibtoolize libtoolize
 fi

+# gnulib-tool requires at least automake and autoconf.
+# If either is not listed, add it (with minimum version) as a prerequisite.
+case $buildreq in
+  *automake*) ;;
+  *) buildreq="automake 1.9
+$buildreq" ;;
+esac
+case $buildreq in
+  *autoconf*) ;;
+  *) buildreq="autoconf 2.59
+$buildreq" ;;
+esac
+
+# When we can deduce that gnulib-tool will require patch,
+# and when patch is not already listed as a prerequisite, add it, too.
+if test ! -d "$local_gl_dir" \
+    || find "$local_gl_dir" -name '*.diff' -exec false {} +; then
+  :
+else
+  case $buildreq in
+    *patch*) ;;
+    *) buildreq="patch -
+$buildreq" ;;
+  esac
+fi
+
 if ! printf "$buildreq" | check_versions; then
   echo >&2
   if test -f README-prereq; then
@@ -583,6 +613,9 @@ download_po_files() {
   domain=$2
   echo "$me: getting translations into $subdir for $domain..."
   cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
+  eval "$cmd" && return
+  # Fallback to HTTP.
+  cmd=`printf "$po_download_command_format2" "$subdir" "$domain"`
   eval "$cmd"
 }

@@ -703,56 +736,32 @@ symlink_to_dir()
   }
 }

-cp_mark_as_generated()
-{
-  cp_src=$1
-  cp_dst=$2
+# NOTE: we have to be careful to run both autopoint and libtoolize
+# before gnulib-tool, since gnulib-tool is likely to provide newer
+# versions of files "installed" by these two programs.
+# Then, *after* gnulib-tool (see below), we have to be careful to
+# run autoreconf in such a way that it does not run either of these
+# two just-pre-run programs.

-  if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
-    symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
-  elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
-    symlink_to_dir $local_gl_dir "$cp_dst"
-  else
-    case $cp_dst in
-      *.[ch])             c1='/* '; c2=' */';;
-      *.texi)             c1='@c '; c2=     ;;
-      *.m4|*/Make*|Make*) c1='# ' ; c2=     ;;
-      *)                  c1=     ; c2=     ;;
-    esac
+# Import from gettext.
+with_gettext=yes
+grep '^[	 ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
+    with_gettext=no

-    # If the destination directory doesn't exist, create it.
-    # This is required at least for "lib/uniwidth/cjk.h".
-    dst_dir=`dirname "$cp_dst"`
-    test -d "$dst_dir" || mkdir -p "$dst_dir"
-
-    if test -z "$c1"; then
-      cmp -s "$cp_src" "$cp_dst" || {
-        # Copy the file first to get proper permissions if it
-        # doesn't already exist.  Then overwrite the copy.
-        echo "$me: cp -f $cp_src $cp_dst" &&
-        rm -f "$cp_dst" &&
-        cp "$cp_src" "$cp_dst-t" &&
-        sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
-        mv -f "$cp_dst-t" "$cp_dst"
-      }
-    else
-      # Copy the file first to get proper permissions if it
-      # doesn't already exist.  Then overwrite the copy.
-      cp "$cp_src" "$cp_dst-t" &&
-      (
-        echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
-        echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
-        sed "s!$bt_regex/!!g" "$cp_src"
-      ) > $cp_dst-t &&
-      if cmp -s "$cp_dst-t" "$cp_dst"; then
-        rm -f "$cp_dst-t"
-      else
-        echo "$me: cp $cp_src $cp_dst # with edits" &&
-        mv -f "$cp_dst-t" "$cp_dst"
-      fi
-    fi
-  fi
-}
+if test $with_gettext = yes; then
+  # Released autopoint has the tendency to install macros that have been
+  # obsoleted in current gnulib, so run this before gnulib-tool.
+  echo "$0: $AUTOPOINT --force"
+  $AUTOPOINT --force || exit
+fi
+
+# Autoreconf runs aclocal before libtoolize, which causes spurious
+# warnings if the initial aclocal is confused by the libtoolized
+# (or worse out-of-date) macro directory.
+if grep '^[    ]*LT_INIT' configure.ac >/dev/null; then
+  echo "running: $LIBTOOLIZE --copy --install"
+  $LIBTOOLIZE --copy --install
+fi

 version_controlled_file() {
   dir=$1
@@ -771,83 +780,17 @@ version_controlled_file() {
   test $found = yes
 }

-slurp() {
-  for dir in . `(cd $1 && find * -type d -print)`; do
-    copied=
-    sep=
-    for file in `ls -a $1/$dir`; do
-      case $file in
-      .|..) continue;;
-      # FIXME: should all file names starting with "." be ignored?
-      .*) continue;;
-      esac
-      test -d $1/$dir/$file && continue
-      for excluded_file in $excluded_files; do
-        test "$dir/$file" = "$excluded_file" && continue 2
-      done
-      if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
-        copied=$copied${sep}$gnulib_mk; sep=$nl
-        remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
-        sed "$remove_intl" $1/$dir/$file |
-        cmp - $dir/$gnulib_mk > /dev/null || {
-          echo "$me: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
-          rm -f $dir/$gnulib_mk &&
-          sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
-          gnulib_mk_hook $dir/$gnulib_mk
-        }
-      elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
-           version_controlled_file $dir $file; then
-        echo "$me: $dir/$file overrides $1/$dir/$file"
-      else
-        copied=$copied$sep$file; sep=$nl
-        cp_mark_as_generated $1/$dir/$file $dir/$file
-      fi || exit
-    done
-
-    for dot_ig in x $vc_ignore; do
-      test $dot_ig = x && continue
-      ig=$dir/$dot_ig
-      if test -n "$copied"; then
-        insert_vc_ignore $ig "$copied"
-        # If an ignored file name ends with .in.h, then also add
-        # the name with just ".h".  Many gnulib headers are generated,
-        # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
-        # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
-        f=`echo "$copied" |
-          sed '
-            s/\.in\.h$/.h/
-            s/\.sin$/.sed/
-            s/\.y$/.c/
-            s/\.gperf$/.h/
-          '
-        `
-        insert_vc_ignore $ig "$f"
-
-        # For files like sys_stat.in.h and sys_time.in.h, record as
-        # ignorable the directory we might eventually create: sys/.
-        f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
-        insert_vc_ignore $ig "$f"
-      fi
-    done
-  done
-}
-
-
-# Create boot temporary directories to import from gnulib and gettext.
-rm -fr $bt $bt2 &&
-mkdir $bt $bt2 || exit
-
 # Import from gnulib.

 gnulib_tool_options="\
  --import\
  --no-changelog\
- --aux-dir $bt/$build_aux\
- --doc-base $bt/$doc_base\
+ --aux-dir $build_aux\
+ --doc-base $doc_base\
  --lib $gnulib_name\
- --m4-base $bt/$m4_base/\
- --source-base $bt/$source_base/\
- --tests-base $bt/$tests_base\
+ --m4-base $m4_base/\
+ --source-base $source_base/\
+ --tests-base $tests_base\
  --local-dir $local_gl_dir\
  $gnulib_tool_option_extras\
 "
@@ -859,26 +802,11 @@ if test $use_libtool = 1; then
 fi
 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
 $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
-slurp $bt || exit

 for file in $gnulib_files; do
   symlink_to_dir "$GNULIB_SRCDIR" $file || exit
 done

-
-# Import from gettext.
-with_gettext=yes
-grep '^[	 ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
-    with_gettext=no
-
-if test $with_gettext = yes; then
-  echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
-  cp configure.ac $bt2 &&
-  (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
-  slurp $bt2 $bt || exit
-fi
-rm -fr $bt $bt2 || exit
-
 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
 # gnulib-populated directories.  Such .m4 files would cause aclocal to fail.
 # The following requires GNU find 4.2.3 or newer.  Considering the usual
@@ -891,28 +819,12 @@ find "$m4_base" "$source_base" \
   -depth \( -name '*.m4' -o -name '*.[ch]' \) \
   -type l -xtype l -delete > /dev/null 2>&1

-# Reconfigure, getting other files.
-
-# Skip autoheader if it's not needed.
-grep -E '^[	 ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
-  AUTOHEADER=true
-
-for command in \
-  libtool \
-  "${ACLOCAL-aclocal} --force -I '$m4_base' $ACLOCAL_FLAGS" \
-  "${AUTOCONF-autoconf} --force" \
-  "${AUTOHEADER-autoheader} --force" \
-  "${AUTOMAKE-automake} --add-missing --copy --force-missing"
-do
-  if test "$command" = libtool; then
-    test $use_libtool = 0 \
-      && continue
-    command="${LIBTOOLIZE-libtoolize} -c -f"
-  fi
-  echo "$0: $command ..."
-  eval "$command" || exit
-done
-
+# Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
+echo "running: AUTOPOINT=true LIBTOOLIZE=true " \
+    "$AUTORECONF --verbose --install --no-recursive -I $m4_base $ACLOCAL_FLAGS"
+AUTOPOINT=true LIBTOOLIZE=true \
+    $AUTORECONF --verbose --install --no-recursive -I $m4_base $ACLOCAL_FLAGS \
+  || exit 1

 # Get some extra files from gnulib, overriding existing files.
 for file in $gnulib_extra_files; do
diff --git a/bootstrap.conf b/bootstrap.conf
index 51da0c0..9b67b74 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -119,9 +119,11 @@ if test $gettext_external = 1; then
 '
 fi

-gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests
+gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests
   --avoid=localename
   --avoid=lock
+  --symlink
+  --makefile-name=gnulib.mk
 "

 # Build prerequisites
@@ -144,9 +146,5 @@ touch ChangeLog || exit 1

 bootstrap_epilogue()
 {
-  # Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
-  m=gnulib-tests/gnulib.mk
-  sed 's,\.\./\.\.,..,g' $m > $m-t
-  mv -f $m-t $m
   perl -pi -e "s/\@PACKAGE\@/$package/g" README-release
 }
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 66e5cb2..c120366 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -15,6 +15,17 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

+AM_CFLAGS =
+BUILT_SOURCES =
+CLEANFILES =
+EXTRA_DIST =
+MOSTLYCLEANDIRS =
+MOSTLYCLEANFILES =
+MAINTAINERCLEANFILES =
+SUFFIXES =
+noinst_LIBRARIES =
+noinst_HEADERS =
+
 include gnulib.mk

 noinst_HEADERS += cmpbuf.h prepargs.h
diff --git a/tests/init.sh b/tests/init.sh
index ca1b022..5985552 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -61,7 +61,7 @@ ME_=`expr "./$0" : '.*/\(.*\)$'`

 # We use a trap below for cleanup.  This requires us to go through
 # hoops to get the right exit status transported through the handler.
-# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# So use 'Exit STATUS' instead of 'exit STATUS' inside of the tests.
 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
 # sh inside this function.
 Exit () { set +e; (exit $1); exit $1; }
@@ -74,7 +74,20 @@ Exit () { set +e; (exit $1); exit $1; }
 # the reason for skip/failure to console, rather than to the .log files.
 : ${stderr_fileno_=2}

-warn_ () { echo "$@" 1>&$stderr_fileno_; }
+# Note that correct expansion of "$*" depends on IFS starting with ' '.
+# Always write the full diagnostic to stderr.
+# When stderr_fileno_ is not 2, also emit the first line of the
+# diagnostic to that file descriptor.
+warn_ ()
+{
+  # If IFS does not start with ' ', set it and emit the warning in a subshell.
+  case $IFS in
+    ' '*) printf '%s\n' "$*" >&2
+          test $stderr_fileno_ = 2 \
+            || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;;
+    *) (IFS=' '; warn_ "$@");;
+  esac
+}
 fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; }
 skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; }
 fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; }
@@ -159,7 +172,7 @@ else
     if test "$re_shell_" = __current__; then
       # 'eval'ing this code makes Solaris 10's /bin/sh exit with
       # $? set to 2.  It does not evaluate any of the code after the
-      # "unexpected" first `('.  Thus, we must run it in a subshell.
+      # "unexpected" first '('.  Thus, we must run it in a subshell.
       ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1
     else
       "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null
@@ -208,14 +221,102 @@ export MALLOC_PERTURB_
 # a partition, or to undo any other global state changes.
 cleanup_ () { :; }

-if ( diff -u "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
-  compare () { diff -u "$@"; }
+# Emit a header similar to that from diff -u;  Print the simulated "diff"
+# command so that the order of arguments is clear.  Don't bother with @@ lines.
+emit_diff_u_header_ ()
+{
+  printf '%s\n' "diff -u $*" \
+    "--- $1	1970-01-01" \
+    "+++ $2	1970-01-01"
+}
+
+# Arrange not to let diff or cmp operate on /dev/null,
+# since on some systems (at least OSF/1 5.1), that doesn't work.
+# When there are not two arguments, or no argument is /dev/null, return 2.
+# When one argument is /dev/null and the other is not empty,
+# cat the nonempty file to stderr and return 1.
+# Otherwise, return 0.
+compare_dev_null_ ()
+{
+  test $# = 2 || return 2
+
+  if test "x$1" = x/dev/null; then
+    test -s "$2" || return 0
+    emit_diff_u_header_ "$@"; sed 's/^/+/' "$2"
+    return 1
+  fi
+
+  if test "x$2" = x/dev/null; then
+    test -s "$1" || return 0
+    emit_diff_u_header_ "$@"; sed 's/^/-/' "$1"
+    return 1
+  fi
+
+  return 2
+}
+
+if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null`; then
+  if test -z "$diff_out_"; then
+    compare_ () { diff -u "$@"; }
+  else
+    compare_ ()
+    {
+      if diff -u "$@" > diff.out; then
+        # No differences were found, but Solaris 'diff' produces output
+        # "No differences encountered". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
+elif diff_out_=`exec 2>/dev/null; diff -c "$0" "$0" < /dev/null`; then
+  if test -z "$diff_out_"; then
+    compare_ () { diff -c "$@"; }
+  else
+    compare_ ()
+    {
+      if diff -c "$@" > diff.out; then
+        # No differences were found, but AIX and HP-UX 'diff' produce output
+        # "No differences encountered" or "There are no differences between the
+        # files.". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
-  compare () { cmp -s "$@"; }
+  compare_ () { cmp -s "$@"; }
 else
-  compare () { cmp "$@"; }
+  compare_ () { cmp "$@"; }
 fi

+# Usage: compare EXPECTED ACTUAL
+#
+# Given compare_dev_null_'s preprocessing, defer to compare_ if 2 or more.
+# Otherwise, propagate $? to caller: any diffs have already been printed.
+compare ()
+{
+  # This looks like it can be factored to use a simple "case $?"
+  # after unchecked compare_dev_null_ invocation, but that would
+  # fail in a "set -e" environment.
+  if compare_dev_null_ "$@"; then
+    return 0
+  else
+    case $? in
+      1) return 1;;
+      *) compare_ "$@";;
+    esac
+  fi
+}
+
 # An arbitrary prefix to help distinguish test directories.
 testdir_prefix_ () { printf gt; }

@@ -426,7 +527,7 @@ mktempd_ ()
   esac

   # First, try to use mktemp.
-  d=`unset TMPDIR; mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
+  d=`unset TMPDIR; { mktemp -d -t -p "$destdir_" "$template_"; } 2>/dev/null` \
     || fail=1

   # The resulting name must be in the specified directory.
--
1.7.9.rc0.25.gc7817


From MAILER-DAEMON Sat Jan 21 21:51:31 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RonWl-0003zs-RO
	for mharc-bug-diffutils@gnu.org; Sat, 21 Jan 2012 21:51:31 -0500
Received: from eggs.gnu.org ([140.186.70.92]:46763)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1RonWj-0003yz-P8
	for bug-diffutils@gnu.org; Sat, 21 Jan 2012 21:51:30 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1RonWi-0005zT-GM
	for bug-diffutils@gnu.org; Sat, 21 Jan 2012 21:51:29 -0500
Received: from caiajhbdcagg.dreamhost.com ([208.97.132.66]:53027
	helo=homiemail-a2.g.dreamhost.com)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jidanni@jidanni.org>) id 1RonWi-0005zH-2S
	for bug-diffutils@gnu.org; Sat, 21 Jan 2012 21:51:28 -0500
Received: from homiemail-a2.g.dreamhost.com (localhost [127.0.0.1])
	by homiemail-a2.g.dreamhost.com (Postfix) with ESMTP id E2074280062
	for <bug-diffutils@gnu.org>; Sat, 21 Jan 2012 18:51:26 -0800 (PST)
DomainKey-Signature: a=rsa-sha1; c=nofws; d=jidanni.org; h=from:to:subject
	:date:message-id:mime-version:content-type; q=dns; s=jidanni.org
	; b=gvYXRrM2wlyJu0sCCPDmuFjXDzINGzyQPJYk45Tzq6BTIaM+QFXYAJfABLse
	nuL2+yU6deO7v4XWI2ikMr6R8Iqz9wFKrMVPc+X7tsVDsW2MP9HfaOpjKpTFXVvZ
	SxZ4r1tbeq+uGFj5qRqF9ZVwrK6n2uyOUBEdl4P+THzCdLs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to
	:subject:date:message-id:mime-version:content-type; s=
	jidanni.org; bh=j6ajjmG/ju1fgHnhxUTsFTU2yMs=; b=Ye5N8CAMtolxaNKm
	TUWjX985JNaOGFhaewarB9lQSAQnWC8NbBc3rLRjtJ4cTG9vuHuhBE9Qfi94c7i/
	a8R+6HWma3+2yZoGeXhsazHTTTZQcVjQhxEF7E9LCdJOrufUamtkopFzEi54G7JJ
	74U/62Hh26CJOD+h9UipbkmZn6s=
Received: from jidanni.org (218-174-211-25.dynamic.hinet.net [218.174.211.25])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	(Authenticated sender: jidanni@jidanni.org)
	by homiemail-a2.g.dreamhost.com (Postfix) with ESMTPSA id 59C05280061
	for <bug-diffutils@gnu.org>; Sat, 21 Jan 2012 18:51:26 -0800 (PST)
From: jidanni@jidanni.org
To: bug-diffutils@gnu.org
Date: Sun, 22 Jan 2012 10:39:59 +0800
Message-ID: <87wr8kpiio.fsf@jidanni.org>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.97.132.66
Subject: [bug-diffutils] man diff Exit status deserves own section
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 22 Jan 2012 02:51:30 -0000

In man diff

       FILES  are  `FILE1  FILE2'  or `DIR1 DIR2' or `DIR FILE...' or `FILE...
       DIR'.  If --from-file or --to-file is given, there are no  restrictions
       on  FILE(s).   If a FILE is `-', read standard input.  Exit status is 0
       if inputs are the same, 1 if different, 2 if trouble.

Exit status deserves its own section, just like man cat... which,
wait... doesn't even mention exit status. OK... at least all man pages
should mention it or all just say it in Info.


From MAILER-DAEMON Thu Jan 26 02:59:50 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RqKFK-0000FP-Nn
	for mharc-bug-diffutils@gnu.org; Thu, 26 Jan 2012 02:59:50 -0500
Received: from eggs.gnu.org ([140.186.70.92]:45927)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RqKFI-0000FG-1c
	for bug-diffutils@gnu.org; Thu, 26 Jan 2012 02:59:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RqKFC-0005Mj-Fr
	for bug-diffutils@gnu.org; Thu, 26 Jan 2012 02:59:48 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:36418)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RqKFC-0005MZ-9Q
	for bug-diffutils@gnu.org; Thu, 26 Jan 2012 02:59:42 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 32294A60030
	for <bug-diffutils@gnu.org>; Wed, 25 Jan 2012 23:59:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Rb1AJeBp1cIc for <bug-diffutils@gnu.org>;
	Wed, 25 Jan 2012 23:59:40 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id E560DA60006
	for <bug-diffutils@gnu.org>; Wed, 25 Jan 2012 23:59:40 -0800 (PST)
Message-ID: <4F2107EF.1000903@cs.ucla.edu>
Date: Wed, 25 Jan 2012 23:59:43 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:9.0) Gecko/20111229 Thunderbird/9.0
MIME-Version: 1.0
To: bug-diffutils@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Subject: [bug-diffutils] [PATCH 1/2] build: update gnulib submodule to latest
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 26 Jan 2012 07:59:49 -0000

---
 gnulib |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gnulib b/gnulib
index 443bc5f..55b0a0b 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 443bc5ffcf7429e557f4a371b0661abe98ddbc13
+Subproject commit 55b0a0b1dd267ef48971e4bb84768244ff58b340
-- 
1.7.6.5


From MAILER-DAEMON Thu Jan 26 03:01:33 2012
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1RqKGz-0000Tx-B0
	for mharc-bug-diffutils@gnu.org; Thu, 26 Jan 2012 03:01:33 -0500
Received: from eggs.gnu.org ([140.186.70.92]:46185)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RqKGt-0000RK-Ho
	for bug-diffutils@gnu.org; Thu, 26 Jan 2012 03:01:31 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RqKGk-0005ZL-7B
	for bug-diffutils@gnu.org; Thu, 26 Jan 2012 03:01:27 -0500
Received: from smtp.cs.ucla.edu ([131.179.128.62]:36466)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1RqKGj-0005Z8-2S
	for bug-diffutils@gnu.org; Thu, 26 Jan 2012 03:01:18 -0500
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.cs.ucla.edu (Postfix) with ESMTP id 6EF3BA60030
	for <bug-diffutils@gnu.org>; Thu, 26 Jan 2012 00:01:16 -0800 (PST)
X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu
Received: from smtp.cs.ucla.edu ([127.0.0.1])
	by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id XbfqflpBP2Vo for <bug-diffutils@gnu.org>;
	Thu, 26 Jan 2012 00:01:13 -0800 (PST)
Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net
	[71.189.109.235])
	by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 2B5A0A60006
	for <bug-diffutils@gnu.org>; Thu, 26 Jan 2012 00:01:13 -0800 (PST)
Message-ID: <4F21084B.3060509@cs.ucla.edu>
Date: Thu, 26 Jan 2012 00:01:15 -0800
From: Paul Eggert <eggert@cs.ucla.edu>
Organization: UCLA Computer Science Department
User-Agent: Mozilla/5.0 (X11; Linux i686;
	rv:9.0) Gecko/20111229 Thunderbird/9.0
MIME-Version: 1.0
To: bug-diffutils@gnu.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 131.179.128.62
Subject: [bug-diffutils] [PATCH 2/2] maint: quote 'like this' or "like this",
	not `like this'
X-BeenThere: bug-diffutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "All diffutils discussion." <bug-diffutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-diffutils>
List-Post: <mailto:bug-diffutils@gnu.org>
List-Help: <mailto:bug-diffutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-diffutils>,
	<mailto:bug-diffutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 26 Jan 2012 08:01:31 -0000

This is in response to a recent change in the GNU coding standards,
which now suggest quoting 'like this' or "like this", instead of
`like this' or ``like this''.
* HACKING, NEWS, README, README-hacking, TODO, doc/diagmeet.note:
* doc/diffutils.texi, ms/config.bat, ms/config.site:
* src/analyze.c, src/cmp.c, src/context.c, src/diff.c:
* src/diff.h, src/diff3.c, src/dir.c, src/ifdef.c, src/io.c:
* src/sdiff.c, src/side.c, src/system.h, src/util.c:
* tests/help-version:
Quote 'like this' or "like this" in commentary.
* cfg.mk (old_NEWS_hash): Adjust to reflect new NEWS quoting.
* man/help2man: Update to 1.40.4 version, with quoting fixed as above.
* po/en.po: Remove translation involving `, as it's no longer needed.
* src/cmp.c (try_help, specify_ignore_initial, usage, main):
* src/diff.c (main, try_help, option_help_msgid, specify_value)
(compare_files):
* src/diff3.c (main, try_help, option_help_msgid, usage)
(read_diff):
* src/dir.c (compare_names):
* src/sdiff.c (try_help, usage, check_child_status, main):
* src/util.c (finish_output):
* tests/help-version:
Quote 'like this' in output.
---
 HACKING            |    4 ++--
 NEWS               |   26 +++++++++++++-------------
 README             |   10 +++++-----
 README-hacking     |    2 +-
 TODO               |    2 +-
 cfg.mk             |    2 +-
 doc/diagmeet.note  |    2 +-
 doc/diffutils.texi |    2 +-
 man/help2man       |   33 +++++++++++++++++++--------------
 ms/config.bat      |    2 +-
 ms/config.site     |    2 +-
 po/en.po           |   14 +++-----------
 src/analyze.c      |    6 +++---
 src/cmp.c          |   20 ++++++++++----------
 src/context.c      |   10 +++++-----
 src/diff.c         |   40 ++++++++++++++++++++--------------------
 src/diff.h         |    8 ++++----
 src/diff3.c        |   26 +++++++++++++-------------
 src/dir.c          |    8 ++++----
 src/ifdef.c        |    2 +-
 src/io.c           |    4 ++--
 src/sdiff.c        |   22 +++++++++++-----------
 src/side.c         |    6 +++---
 src/system.h       |    6 +++---
 src/util.c         |   24 ++++++++++++------------
 tests/help-version |   12 ++++++------
 26 files changed, 146 insertions(+), 149 deletions(-)

diff --git a/HACKING b/HACKING
index 3a99833..522e0b5 100644
--- a/HACKING
+++ b/HACKING
@@ -587,5 +587,5 @@ Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
 any later version published by the Free Software Foundation; with no
 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
-Texts.  A copy of the license is included in the ``GNU Free
-Documentation License'' file as part of this distribution.
+Texts.  A copy of the license is included in the "GNU Free
+Documentation License" file as part of this distribution.
diff --git a/NEWS b/NEWS
index 8105f1d..808c603 100644
--- a/NEWS
+++ b/NEWS
@@ -58,7 +58,7 @@ GNU diffutils NEWS                                    -*- outline -*-
 
   New diff option --suppress-blank-empty.
 
-  Bring back support for `diff -NUM', where NUM is a number,
+  Bring back support for 'diff -NUM', where NUM is a number,
   even when conforming to POSIX 1003.1-2001.  This change reverts to
   the behavior of GNU diff 2.7 and earlier.  This is a change only
   when conforming to POSIX 1003.1-2001; there is no effect when
@@ -94,7 +94,7 @@ User-visible changes in version 2.8.6:
   that 'patch' creates to indicate nonexistent backups) are now
   treated as nonexistent when they are in the 'backup' file position.
 
-* If multiple SKIP values are given to cmp, e.g., `cmp -i 10 -i 20',
+* If multiple SKIP values are given to cmp, e.g., 'cmp -i 10 -i 20',
   cmp now uses the maximal value instead of the last one.
 
 * diff now omits the ".000000000" on hosts that do not support
@@ -134,7 +134,7 @@ User-visible changes in version 2.8:
 * cmp and diff now conform to POSIX 1003.1-2001 (IEEE Std 1003.1-2001)
   if the underlying system conforms to POSIX and if the _POSIX2_VERSION
   environment variable is set to 200112.  Conformance removes support
-  for `diff -NUM', where NUM is a number.  Use -C NUM or -U NUM instead.
+  for 'diff -NUM', where NUM is a number.  Use -C NUM or -U NUM instead.
 * cmp now supports trailing operands SKIP1 and SKIP2, like BSD cmp.
 * cmp -i or --ignore-initial now accepts SKIP1:SKIP2 option value.
 * New cmp option: -n or --bytes.
@@ -168,13 +168,13 @@ User-visible changes in version 2.8:
   category if possible, instead of using native byte comparison.
 * Recursive diffs now detect and report directory loops.
 * Diff printf specs can now use the "0" and "'" flags.
-* The new sdiff interactive command `ed' precedes each version with a header.
+* The new sdiff interactive command 'ed' precedes each version with a header.
 * On 64-bit hosts, files larger than 2 GB can be compared.
 * Some internationalization support has been added, but multibyte locales
   are still not completely supported yet.
 * Some diagnostics have been reworded slightly for consistency.
-  Also, `diff -D FOO' now outputs `/* ! FOO */' instead of `/* not FOO */'.
-* The `patch' part of the manual now describes `patch' version 2.5.4.
+  Also, 'diff -D FOO' now outputs '/* ! FOO */' instead of '/* not FOO */'.
+* The 'patch' part of the manual now describes 'patch' version 2.5.4.
 * Man pages are now distributed and installed.
 * There is support for DJGPP; see the 'ms' subdirectory and the files
   m4/dos.m4 and */setmode.*.
@@ -212,7 +212,7 @@ User-visible changes in version 2.4:
       A printf spec followed by one of the following letters
       causes the integer corresponding to that letter to be
       printed according to the printf specification.
-      E.g. `%5df' prints the number of the first line in the
+      E.g. '%5df' prints the number of the first line in the
       group in the old file using the "%5d" format.
 	e: line number just before the group in old file; equals f - 1
 	f: first line number in group in the old file
@@ -225,9 +225,9 @@ User-visible changes in version 2.4:
       constant or a single letter interpreted as above.  T and E are
       arbitrary format strings.  This format spec is equivalent to T if
       A's value equals B's; otherwise it is equivalent to E.  For
-      example, `%(N=0?no:%dN) line%(N=1?:s)' is equivalent to `no lines'
+      example, '%(N=0?no:%dN) line%(N=1?:s)' is equivalent to 'no lines'
       if N (the number of lines in the group in the new file) is 0,
-      to `1 line' if N is 1, and to `%dN lines' otherwise.
+      to '1 line' if N is 1, and to '%dN lines' otherwise.
   %c'C'
       where C is a single character, stands for the character C.  C may not
       be a backslash or an apostrophe.  E.g. %c':' stands for a colon.
@@ -237,7 +237,7 @@ User-visible changes in version 2.4:
 * New diff line format specifications:
   <PRINTF_SPEC>n
       The line number, printed with <PRINTF_SPEC>.
-      E.g. `%5dn' prints the line number with a "%5d" format.
+      E.g. '%5dn' prints the line number with a "%5d" format.
   %c'C'
   %c'\O'
       The character C, or with octal code O, as above.
@@ -249,14 +249,14 @@ User-visible changes in version 2.4:
 * cmp and diff now conform to POSIX 1003.2-1992 (ISO/IEC 9945-2:1993)
   if the underlying system conforms to POSIX:
   - Some messages' wordings are changed in minor ways.
-  - ``White space'' is now whatever C's `isspace' says it is.
-  - When comparing directories, if `diff' finds a file that is not a regular
+  - "White space" is now whatever C's 'isspace' says it is.
+  - When comparing directories, if 'diff' finds a file that is not a regular
     file or a directory, it reports the file's type instead of diffing it.
     (As usual, it follows symbolic links first.)
   - When signaled, sdiff exits with the signal's status, not with status 2.
 * Now portable to hosts where int, long, pointer, etc. are not all the same
   size.
-* `cmp - -' now works like `diff - -'.
+* 'cmp - -' now works like 'diff - -'.
 
 
 User-visible changes in version 2.3:
diff --git a/README b/README
index b249c56..ddab36e 100644
--- a/README
+++ b/README
@@ -9,8 +9,8 @@ Please see the file COPYING for copying conditions.
 Please see the file doc/version.texi for version information.
 
 Please see the file doc/diffutils.texi (or doc/diffutils.info) for
-documentation that can be printed with TeX, or read with the `info'
-program or with Emacs's `M-x info'.  Brief man pages are in man/*,
+documentation that can be printed with TeX, or read with the 'info'
+program or with Emacs's 'M-x info'.  Brief man pages are in man/*,
 but they are no substitute for the documentation.
 
 Please see the file ABOUT-NLS for notes about translations.
@@ -21,7 +21,7 @@ command "./configure --help" lists the supported --enable and --with
 options.
 
 If you have a problem with internationalization, you might be able to
-work around it as described in ABOUT-NLS by invoking `./configure
+work around it as described in ABOUT-NLS by invoking './configure
 --disable-nls'.  Many of the problems arise from dynamic linking
 issues on non-GNU platforms (e.g. with the iconv library).  Such
 problems tend to be shared by other GNU applications on these
@@ -60,5 +60,5 @@ Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
 any later version published by the Free Software Foundation; with no
 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
-Texts.  A copy of the license is included in the ``GNU Free
-Documentation License'' file as part of this distribution.
+Texts.  A copy of the license is included in the "GNU Free
+Documentation License" file as part of this distribution.
diff --git a/README-hacking b/README-hacking
index b5dc6f8..e276592 100644
--- a/README-hacking
+++ b/README-hacking
@@ -19,7 +19,7 @@ Valgrind <http://valgrind.org/> is also highly recommended, if
 Valgrind supports your architecture.
 
 While building from a just-cloned source tree may require installing a
-few prerequisites, later, a plain `git pull && make' should be sufficient.
+few prerequisites, later, a plain 'git pull && make' should be sufficient.
 
 * First GIT checkout
 
diff --git a/TODO b/TODO
index f8dc34a..5132de8 100644
--- a/TODO
+++ b/TODO
@@ -6,4 +6,4 @@ http://www.pkix.net/~chuck/sdiff2.diff
 Propagate stderr from subprocess so that diff3 does
 a better job of explaining _why_:
   > $ diff3 /bin/sh /bin/false /bin/mv
-  > diff3: subsidiary program `diff' failed (exit status 2)
+  > diff3: subsidiary program 'diff' failed (exit status 2)
diff --git a/cfg.mk b/cfg.mk
index f4d58db..72fddc0 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -29,7 +29,7 @@ bootstrap-tools = autoconf,automake,gnulib
 # Now that we have better tests, make this the default.
 export VERBOSE = yes
 
-old_NEWS_hash = becaac48768c0024859d5837010c801e
+old_NEWS_hash = 7d70c18e90495732e671b3c94da01651
 
 # Tell maint.mk's syntax-check rules that diff gets config.h directly or
 # via diff.h or system.h.
diff --git a/doc/diagmeet.note b/doc/diagmeet.note
index 9ffd175..2d30d21 100644
--- a/doc/diagmeet.note
+++ b/doc/diagmeet.note
@@ -1,5 +1,5 @@
 Here is a comparison matrix which shows a case in which
-it is possible for the forward and backward scan in `diag'
+it is possible for the forward and backward scan in 'diag'
 to meet along a nonzero length of diagonal simultaneous
 (so that bdiag[d] and fdiag[d] are not equal)
 even though there is no snake on that diagonal at the meeting point.
diff --git a/doc/diffutils.texi b/doc/diffutils.texi
index 58b140c..00403df 100644
--- a/doc/diffutils.texi
+++ b/doc/diffutils.texi
@@ -3190,7 +3190,7 @@ characters.
 @c locale.
 @c @item locale
 @c @c Use @t instead of @samp to avoid duplicate quoting in some output styles.
-@c Like @samp{clocale}, but quote @t{`like this'} instead of @t{"like
+@c Like @samp{clocale}, but quote @t{'like this'} instead of @t{"like
 @c this"} in the default C locale.  This looks nicer on many displays.
 @end table
 
diff --git a/man/help2man b/man/help2man
index f9983f7..8bc961c 100755
--- a/man/help2man
+++ b/man/help2man
@@ -1,7 +1,8 @@
 #!/usr/bin/perl -w
 
 # Generate a short man page from --help and --version output.
-# Copyright (C) 1997-2005, 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2010,
+# 2011 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
@@ -27,7 +28,7 @@ use Text::Tabs qw(expand);
 use POSIX qw(strftime setlocale LC_ALL);
 
 my $this_program = 'help2man';
-my $this_version = '1.39.2';
+my $this_version = '1.40.4';
 
 sub _ { $_[0] }
 sub configure_locale
@@ -55,7 +56,7 @@ Written by Brendan O'Dea <bod@debian.org>
 EOT
 
 my $help_info = enc_user sprintf _(<<'EOT'), $this_program, $this_program;
-`%s' generates a man page out of `--help' and `--version' output.
+'%s' generates a man page out of '--help' and '--version' output.
 
 Usage: %s [OPTION]... EXECUTABLE
 
@@ -64,16 +65,16 @@ Usage: %s [OPTION]... EXECUTABLE
  -m, --manual=TEXT       name of manual (User Commands, ...)
  -S, --source=TEXT       source of program (FSF, Debian, ...)
  -L, --locale=STRING     select locale (default "C")
- -i, --include=FILE      include material from `FILE'
- -I, --opt-include=FILE  include material from `FILE' if it exists
- -o, --output=FILE       send output to `FILE'
+ -i, --include=FILE      include material from 'FILE'
+ -I, --opt-include=FILE  include material from 'FILE' if it exists
+ -o, --output=FILE       send output to 'FILE'
  -p, --info-page=TEXT    name of Texinfo manual
  -N, --no-info           suppress pointer to Texinfo manual
- -l, --libtool           exclude the `lt-' from the program name
+ -l, --libtool           exclude the 'lt-' from the program name
      --help              print this help, then exit
      --version           print version number, then exit
 
-EXECUTABLE should accept `--help' and `--version' options and produce output on
+EXECUTABLE should accept '--help' and '--version' options and produce output on
 stdout although alternatives may be specified using:
 
  -h, --help-option=STRING     help option string
@@ -137,7 +138,7 @@ while (@opt_include)
     my ($inc, $required) = @{shift @opt_include};
 
     next unless -f $inc or $required;
-    kark N_("%s: can't open `%s' (%s)"), $this_program, $inc, $!
+    kark N_("%s: can't open '%s' (%s)"), $this_program, $inc, $!
 	unless open INC, $inc;
 
     my $key;
@@ -198,7 +199,7 @@ while (@opt_include)
 
     close INC;
 
-    kark N_("%s: no valid information found in `%s'"), $this_program, $inc
+    kark N_("%s: no valid information found in '%s'"), $this_program, $inc
 	unless $key;
 }
 
@@ -214,7 +215,11 @@ sub get_option_value;
 my $help_text   = get_option_value $ARGV[0], $help_option;
 $version_text ||= get_option_value $ARGV[0], $version_option;
 
-my $date = strftime "%B %Y", localtime;
+# Translators: the following message is a strftime(3) format string, which in
+# the English version expands to the month as a word and the full year.  It
+# is used on the footer of the generated manual pages.  If in doubt, you may
+# just use %x as the value (which should be the full locale-specific date).
+my $date = enc strftime _("%B %Y"), localtime;
 (my $program = $ARGV[0]) =~ s!.*/!!;
 my $package = $program;
 my $version;
@@ -261,7 +266,7 @@ else
 
 $program =~ s!.*/!!;
 
-# No info for `info' itself.
+# No info for 'info' itself.
 $opt_no_info = 1 if $program eq 'info';
 
 # Translators: "NAME", "SYNOPSIS" and other one or two word strings in all
@@ -637,9 +642,9 @@ sub get_option_value
 
     unless ($value)
     {
-	my $err = N_("%s: can't get `%s' info from %s%s");
+	my $err = N_("%s: can't get '%s' info from %s%s");
 	my $extra = $discard_stderr
-	    ? "\n" . N_("Try `--no-discard-stderr' if option outputs to stderr")
+	    ? "\n" . N_("Try '--no-discard-stderr' if option outputs to stderr")
 	    : '';
 
 	kark $err, $this_program, $opt, $prog, $extra;
diff --git a/ms/config.bat b/ms/config.bat
index 44ef13b..57d5f3f 100644
--- a/ms/config.bat
+++ b/ms/config.bat
@@ -134,7 +134,7 @@ if not errorlevel 1 mv -f %XSRC%/m4/Makefile.am.in %XSRC%/m4/Makefile.am-in
 

 Rem This is required because DOS/Windows are case-insensitive

 Rem to file names, and "make install" will do nothing if Make

-Rem finds a file called `install'.

+Rem finds a file called 'install'.

 if exist INSTALL ren INSTALL INSTALL.txt

 

 Rem Set HOME to a sane default so configure stops complaining.

diff --git a/ms/config.site b/ms/config.site
index 31f9aff..c863616 100644
--- a/ms/config.site
+++ b/ms/config.site
@@ -73,6 +73,6 @@ MAKEINFO=${MAKEINFO='makeinfo'}
 # Force the test for 'ln -s' to report 'cp -pf'.
 ac_cv_prog_LN_S='cp -pf'
 
-# We have `fork', but it always fails.  Don't trust Autoconf to be
+# We have 'fork', but it always fails.  Don't trust Autoconf to be
 # smart enough to detect that...
 ac_cv_func_fork=no
diff --git a/po/en.po b/po/en.po
index c95e389..ad59232 100644
--- a/po/en.po
+++ b/po/en.po
@@ -4,23 +4,15 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: GNU diffutils 2.8.3\n"
+"Project-Id-Version: GNU diffutils 3.2\n"
 "POT-Creation-Date: 2002-06-16 23:44-0700\n"
-"PO-Revision-Date: 2002-06-17 00:01-0700\n"
-"Last-Translator: Paul Eggert <eggert@twinsun.com>\n"
+"PO-Revision-Date: 2012-01-25 23:11-0700\n"
+"Last-Translator: Paul Eggert <eggert@cs.ucla.edu>\n"
 "Language-Team: English <en@translate.freefriends.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=ISO-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-# POSIX requires the word "illegal" in the POSIX locale, but the error
-# is not really against the law.  This is not the POSIX locale, so fix
-# the wording.
-#: lib/getopt.c:800
-#, c-format
-msgid "%s: illegal option -- %c\n"
-msgstr "%s: unrecognized option `-%c'\n"
-
 #. TRANSLATORS: Please translate "(C)" to the C-in-a-circle symbol
 #. (U+00A9, COPYRIGHT SIGN) if possible, as this has some minor
 #. technical advantages in international copyright law.  If the
diff --git a/src/analyze.c b/src/analyze.c
index 124ded5..0e61a82 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -38,7 +38,7 @@
 
    A line which is discarded will not be considered by the actual
    comparison algorithm; it will be as if that line were not in the file.
-   The file's `realindexes' table maps virtual line numbers
+   The file's 'realindexes' table maps virtual line numbers
    (which don't count the discarded lines) into real line numbers;
    this is how the actual comparison algorithm produces results
    that are comprehensible when the discarded lines are counted.
@@ -251,7 +251,7 @@ discard_confusing_lines (struct file_data filevec[])
    We do something when a run of changed lines include a
    line at one end and have an excluded, identical line at the other.
    We are free to choose which identical line is included.
-   `compareseq' usually chooses the one at the beginning,
+   'compareseq' usually chooses the one at the beginning,
    but usually it is cleaner to consider the following identical line
    to be the "change".  */
 
@@ -595,7 +595,7 @@ diff_2_files (struct comparison *cmp)
       shift_boundaries (cmp->file);
 
       /* Get the results of comparison in the form of a chain
-	 of `struct change's -- an edit script.  */
+	 of 'struct change's -- an edit script.  */
 
       if (output_style == OUTPUT_ED)
 	script = build_reverse_script (cmp->file);
diff --git a/src/cmp.c b/src/cmp.c
index 53ae791..1387ec1 100644
--- a/src/cmp.c
+++ b/src/cmp.c
@@ -36,7 +36,7 @@
 #include <binary-io.h>
 #include <xstrtol.h>
 
-/* The official name of this program (e.g., no `g' prefix).  */
+/* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "cmp"
 
 #define AUTHORS \
@@ -115,7 +115,7 @@ try_help (char const *reason_msgid, char const *operand)
   if (reason_msgid)
     error (0, 0, _(reason_msgid), operand);
   error (EXIT_TROUBLE, 0,
-	 _("Try `%s --help' for more information."), program_name);
+	 _("Try '%s --help' for more information."), program_name);
   abort ();
 }
 
@@ -134,7 +134,7 @@ specify_ignore_initial (int f, char **argptr, char delimiter)
   if (! (e == LONGINT_OK
 	 || (e == LONGINT_INVALID_SUFFIX_CHAR && **argptr == delimiter))
       || TYPE_MAXIMUM (off_t) < val)
-    try_help ("invalid --ignore-initial value `%s'", arg);
+    try_help ("invalid --ignore-initial value '%s'", arg);
   if (ignore_initial[f] < val)
     ignore_initial[f] = val;
 }
@@ -191,7 +191,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
 	  _("SKIP values may be followed by the following multiplicative suffixes:\n\
 kB 1000, K 1024, MB 1,000,000, M 1,048,576,\n\
 GB 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y."),
-	  _("If a FILE is `-' or missing, read standard input."),
+	  _("If a FILE is '-' or missing, read standard input."),
 	  _("Exit status is 0 if inputs are the same, 1 if different, 2 if trouble."));
   emit_bug_reporting_address ();
 }
@@ -237,7 +237,7 @@ main (int argc, char **argv)
 	{
 	  uintmax_t n;
 	  if (xstrtoumax (optarg, 0, 0, &n, valid_suffixes) != LONGINT_OK)
-	    try_help ("invalid --bytes value `%s'", optarg);
+	    try_help ("invalid --bytes value '%s'", optarg);
 	  if (n < bytes)
 	    bytes = n;
 	}
@@ -263,7 +263,7 @@ main (int argc, char **argv)
       }
 
   if (optind == argc)
-    try_help ("missing operand after `%s'", argv[argc - 1]);
+    try_help ("missing operand after '%s'", argv[argc - 1]);
 
   file[0] = argv[optind++];
   file[1] = optind < argc ? argv[optind++] : "-";
@@ -275,7 +275,7 @@ main (int argc, char **argv)
     }
 
   if (optind < argc)
-    try_help ("extra operand `%s'", argv[optind]);
+    try_help ("extra operand '%s'", argv[optind]);
 
   for (f = 0; f < 2; f++)
     {
@@ -370,8 +370,8 @@ main (int argc, char **argv)
   return exit_status;
 }
 
-/* Compare the two files already open on `file_desc[0]' and `file_desc[1]',
-   using `buffer[0]' and `buffer[1]'.
+/* Compare the two files already open on 'file_desc[0]' and 'file_desc[1]',
+   using 'buffer[0]' and 'buffer[1]'.
    Return EXIT_SUCCESS if identical, EXIT_FAILURE if different,
    >1 if error.  */
 
@@ -383,7 +383,7 @@ cmp (void)
   uintmax_t remaining = bytes;	/* Remaining number of bytes to compare.  */
   size_t read0, read1;		/* Number of bytes read from each file. */
   size_t first_diff;		/* Offset (0...) in buffers of 1st diff. */
-  size_t smaller;		/* The lesser of `read0' and `read1'. */
+  size_t smaller;		/* The lesser of 'read0' and 'read1'. */
   word *buffer0 = buffer[0];
   word *buffer1 = buffer[1];
   char *buf0 = (char *) buffer0;
diff --git a/src/context.c b/src/context.c
index bd1c981..b73d5c3 100644
--- a/src/context.c
+++ b/src/context.c
@@ -158,7 +158,7 @@ print_context_function (FILE *out, char const *function)
 
 /* Print a portion of an edit script in context format.
    HUNK is the beginning of the portion to be printed.
-   The end is marked by a `link' that has been nulled out.
+   The end is marked by a 'link' that has been nulled out.
 
    Prints out lines from both files, and precedes each
    line with the appropriate flag-character.  */
@@ -288,7 +288,7 @@ print_unidiff_number_range (struct file_data const *file, lin a, lin b)
 
 /* Print a portion of an edit script in unidiff format.
    HUNK is the beginning of the portion to be printed.
-   The end is marked by a `link' that has been nulled out.
+   The end is marked by a 'link' that has been nulled out.
 
    Prints out lines from both files, and precedes each
    line with the appropriate flag-character.  */
@@ -392,7 +392,7 @@ pr_unidiff_hunk (struct change *hunk)
 
 /* Scan a (forward-ordered) edit script for the first place that more than
    2*CONTEXT unchanged lines appear, and return a pointer
-   to the `struct change' for the last change before those lines.  */
+   to the 'struct change' for the last change before those lines.  */
 
 static struct change * _GL_ATTRIBUTE_PURE
 find_hunk (struct change *start)
@@ -430,7 +430,7 @@ find_hunk (struct change *start)
   return prev;
 }
 
-/* Set the `ignore' flag properly in each change in SCRIPT.
+/* Set the 'ignore' flag properly in each change in SCRIPT.
    It should be 1 if all the lines inserted or deleted in that change
    are ignorable lines.  */
 
@@ -458,7 +458,7 @@ mark_ignorable (struct change *script)
 }
 
 /* Find the last function-header line in LINBUF prior to line number LINENUM.
-   This is a line containing a match for the regexp in `function_regexp'.
+   This is a line containing a match for the regexp in 'function_regexp'.
    Return the address of the text, or NULL if no function-header is found.  */
 
 static char const *
diff --git a/src/diff.c b/src/diff.c
index 0911131..972d84d 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -42,7 +42,7 @@
 #include <xreadlink.h>
 #include <binary-io.h>
 
-/* The official name of this program (e.g., no `g' prefix).  */
+/* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "diff"
 
 #define AUTHORS \
@@ -59,9 +59,9 @@
 struct regexp_list
 {
   char *regexps;	/* chars representing disjunction of the regexps */
-  size_t len;		/* chars used in `regexps' */
-  size_t size;		/* size malloc'ed for `regexps'; 0 if not malloc'ed */
-  bool multiple_regexps;/* Does `regexps' represent a disjunction?  */
+  size_t len;		/* chars used in 'regexps' */
+  size_t size;		/* size malloc'ed for 'regexps'; 0 if not malloc'ed */
+  bool multiple_regexps;/* Does 'regexps' represent a disjunction?  */
   struct re_pattern_buffer *buf;
 };
 
@@ -94,13 +94,13 @@ enum { binary = true };
 
 /* When comparing directories, if a file appears only in one
    directory, treat it as present but empty in the other (-N).
-   Then `patch' would create the file with appropriate contents.  */
+   Then 'patch' would create the file with appropriate contents.  */
 static bool new_file;
 
 /* When comparing directories, if a file appears only in the second
    directory of the two, treat it as present but empty in the other
    (--unidirectional-new-file).
-   Then `patch' would create the file with appropriate contents.  */
+   Then 'patch' would create the file with appropriate contents.  */
 static bool unidirectional_new_file;
 
 /* Report files compared that are the same (-s).
@@ -340,7 +340,7 @@ main (int argc, char **argv)
 	      {
 		numval = strtoumax (optarg, &numend, 10);
 		if (*numend)
-		  try_help ("invalid context length `%s'", optarg);
+		  try_help ("invalid context length '%s'", optarg);
 		if (LIN_MAX < numval)
 		  numval = LIN_MAX;
 	      }
@@ -515,7 +515,7 @@ main (int argc, char **argv)
 	case 'W':
 	  numval = strtoumax (optarg, &numend, 10);
 	  if (! (0 < numval && numval <= SIZE_MAX) || *numend)
-	    try_help ("invalid width `%s'", optarg);
+	    try_help ("invalid width '%s'", optarg);
 	  if (width != numval)
 	    {
 	      if (width)
@@ -544,7 +544,7 @@ main (int argc, char **argv)
 	case HORIZON_LINES_OPTION:
 	  numval = strtoumax (optarg, &numend, 10);
 	  if (*numend)
-	    try_help ("invalid horizon length `%s'", optarg);
+	    try_help ("invalid horizon length '%s'", optarg);
 	  horizon_lines = MAX (horizon_lines, MIN (numval, LIN_MAX));
 	  break;
 
@@ -599,7 +599,7 @@ main (int argc, char **argv)
 	case TABSIZE_OPTION:
 	  numval = strtoumax (optarg, &numend, 10);
 	  if (! (0 < numval && numval <= SIZE_MAX) || *numend)
-	    try_help ("invalid tabsize `%s'", optarg);
+	    try_help ("invalid tabsize '%s'", optarg);
 	  if (tabsize != numval)
 	    {
 	      if (tabsize)
@@ -758,9 +758,9 @@ main (int argc, char **argv)
 	  if (argc - optind != 2)
 	    {
 	      if (argc - optind < 2)
-		try_help ("missing operand after `%s'", argv[argc - 1]);
+		try_help ("missing operand after '%s'", argv[argc - 1]);
 	      else
-		try_help ("extra operand `%s'", argv[optind + 2]);
+		try_help ("extra operand '%s'", argv[optind + 2]);
 	    }
 
 	  exit_status = compare_files (NULL, argv[optind], argv[optind + 1]);
@@ -840,7 +840,7 @@ try_help (char const *reason_msgid, char const *operand)
 {
   if (reason_msgid)
     error (0, 0, _(reason_msgid), operand);
-  error (EXIT_TROUBLE, 0, _("Try `%s --help' for more information."),
+  error (EXIT_TROUBLE, 0, _("Try '%s --help' for more information."),
 	 program_name);
   abort ();
 }
@@ -876,7 +876,7 @@ static char const * const option_help_msgid[] = {
   N_("-T, --initial-tab             make tabs line up by prepending a tab"),
   N_("    --tabsize=NUM             tab stops every NUM (default 8) print columns"),
   N_("    --suppress-blank-empty    suppress space or tab before empty output lines"),
-  N_("-l, --paginate                pass output through `pr' to paginate it"),
+  N_("-l, --paginate                pass output through 'pr' to paginate it"),
   "",
   N_("-r, --recursive                 recursively compare any subdirectories found"),
   N_("    --no-dereference            don't follow symbolic links"),
@@ -906,13 +906,13 @@ static char const * const option_help_msgid[] = {
   N_("    --binary                    read and write data in binary mode"),
 #endif
   "",
-  N_("-D, --ifdef=NAME                output merged file with `#ifdef NAME' diffs"),
+  N_("-D, --ifdef=NAME                output merged file with '#ifdef NAME' diffs"),
   N_("    --GTYPE-group-format=GFMT   format GTYPE input groups with GFMT"),
   N_("    --line-format=LFMT          format all input lines with LFMT"),
   N_("    --LTYPE-line-format=LFMT    format LTYPE input lines with LFMT"),
   N_("  These format options provide fine-grained control over the output\n"
      "    of diff, generalizing -D/--ifdef."),
-  N_("  LTYPE is `old', `new', or `unchanged'.  GTYPE is LTYPE or `changed'."),
+  N_("  LTYPE is 'old', 'new', or 'unchanged'.  GTYPE is LTYPE or 'changed'."),
   N_("  GFMT (only) may contain:\n\
     %<  lines from FILE1\n\
     %>  lines from FILE2\n\
@@ -942,9 +942,9 @@ static char const * const option_help_msgid[] = {
   N_("    --help               display this help and exit"),
   N_("-v, --version            output version information and exit"),
   "",
-  N_("FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'."),
+  N_("FILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE...' or 'FILE... DIR'."),
   N_("If --from-file or --to-file is given, there are no restrictions on FILE(s)."),
-  N_("If a FILE is `-', read standard input."),
+  N_("If a FILE is '-', read standard input."),
   N_("Exit status is 0 if inputs are the same, 1 if different, 2 if trouble."),
   0
 };
@@ -989,7 +989,7 @@ specify_value (char const **var, char const *value, char const *option)
 {
   if (*var && ! STREQ (*var, value))
     {
-      error (0, 0, _("conflicting %s option value `%s'"), option, value);
+      error (0, 0, _("conflicting %s option value '%s'"), option, value);
       try_help (NULL, NULL);
     }
   *var = value;
@@ -1191,7 +1191,7 @@ compare_files (struct comparison const *parent,
 	= find_dir_file_pathname (dir, last_component (fnm));
 
       if (STREQ (fnm, "-"))
-	fatal ("cannot compare `-' to a directory");
+	fatal ("cannot compare '-' to a directory");
 
       if ((no_dereference_symlinks
 	   ? lstat (filename, &cmp.file[dir_arg].stat)
diff --git a/src/diff.h b/src/diff.h
index 05029a3..4b6595c 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -61,7 +61,7 @@ enum output_style
   /* Output the differences in a unified context diff format (-u).  */
   OUTPUT_UNIFIED,
 
-  /* Output the differences as commands suitable for `ed' (-e).  */
+  /* Output the differences as commands suitable for 'ed' (-e).  */
   OUTPUT_ED,
 
   /* Output the diff as a forward ed script (-f).  */
@@ -139,7 +139,7 @@ XTERN bool ignore_file_name_case;
    (--no-dereference).  */
 XTERN bool no_dereference_symlinks;
 
-/* File labels for `-c' output headers (--label).  */
+/* File labels for '-c' output headers (--label).  */
 XTERN char *file_label[2];
 
 /* Regexp to identify function-header lines (-F).  */
@@ -215,8 +215,8 @@ XTERN bool minimal;
 /* The strftime format to use for time strings.  */
 XTERN char const *time_format;
 
-/* The result of comparison is an "edit script": a chain of `struct change'.
-   Each `struct change' represents one place where some lines are deleted
+/* The result of comparison is an "edit script": a chain of 'struct change'.
+   Each 'struct change' represents one place where some lines are deleted
    and some are inserted.
 
    LINE0 and LINE1 are the first affected lines in the two files (origin 0).
diff --git a/src/diff3.c b/src/diff3.c
index 7d8a9a5..3b01071 100644
--- a/src/diff3.c
+++ b/src/diff3.c
@@ -34,7 +34,7 @@
 #include <xalloc.h>
 #include <xfreopen.h>
 
-/* The official name of this program (e.g., no `g' prefix).  */
+/* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "diff3"
 
 #define AUTHORS \
@@ -158,7 +158,7 @@ static bool overlap_only;
 /* If nonzero, show information for DIFF_2ND diffs.  */
 static bool show_2nd;
 
-/* If nonzero, include `:wq' at the end of the script
+/* If nonzero, include ':wq' at the end of the script
    to write out the file being edited.   */
 static bool finalwrite;
 
@@ -315,9 +315,9 @@ main (int argc, char **argv)
   if (argc - optind != 3)
     {
       if (argc - optind < 3)
-	try_help ("missing operand after `%s'", argv[argc - 1]);
+	try_help ("missing operand after '%s'", argv[argc - 1]);
       else
-	try_help ("extra operand `%s'", argv[optind + 3]);
+	try_help ("extra operand '%s'", argv[optind + 3]);
     }
 
   file = &argv[optind];
@@ -350,7 +350,7 @@ main (int argc, char **argv)
 	 file instead.  */
       common = 3 - common;
       if (STREQ (file[0], "-") || STREQ (file[common], "-"))
-	fatal ("`-' specified for more than one input file");
+	fatal ("'-' specified for more than one input file");
     }
 
   mapping[0] = 0;
@@ -411,7 +411,7 @@ try_help (char const *reason_msgid, char const *operand)
   if (reason_msgid)
     error (0, 0, _(reason_msgid), operand);
   error (EXIT_TROUBLE, 0,
-	 _("Try `%s --help' for more information."), program_name);
+	 _("Try '%s --help' for more information."), program_name);
   abort ();
 }
 
@@ -433,7 +433,7 @@ static char const * const option_help_msgid[] = {
   N_("-3, --easy-only             like -e, but incorporate only nonoverlapping changes"),
   N_("-x, --overlap-only          like -e, but incorporate only overlapping changes"),
   N_("-X                          like -x, but bracket conflicts"),
-  N_("-i                          append `w' and `q' commands to ed scripts"),
+  N_("-i                          append 'w' and 'q' commands to ed scripts"),
   "",
   N_("-m, --merge                 output actual merged file, according to\n"
      "                                -A if no other options are given"),
@@ -478,7 +478,7 @@ Finally, the -m (--merge) option causes diff3 to do the merge internally\n\
 and output the actual merged file.  For unusual input, this is more\n\
 robust than using ed.\n"), stdout);
   printf ("\n%s\n%s\n",
-	  _("If a FILE is `-', read standard input."),
+	  _("If a FILE is '-', read standard input."),
 	  _("Exit status is 0 if successful, 1 if conflicts, 2 if trouble."));
   emit_bug_reporting_address ();
 }
@@ -1293,12 +1293,12 @@ read_diff (char const *filea,
   if (EXIT_TROUBLE <= status)
     error (EXIT_TROUBLE, werrno,
 	   _(status == 126
-	     ? "subsidiary program `%s' could not be invoked"
+	     ? "subsidiary program '%s' could not be invoked"
 	     : status == 127
-	     ? "subsidiary program `%s' not found"
+	     ? "subsidiary program '%s' not found"
 	     : status == INT_MAX
-	     ? "subsidiary program `%s' failed"
-	     : "subsidiary program `%s' failed (exit status %d)"),
+	     ? "subsidiary program '%s' failed"
+	     : "subsidiary program '%s' failed (exit status %d)"),
 	   diff_program, status);
 
   return diff_result + total;
@@ -1493,7 +1493,7 @@ undotlines (FILE *outputfile, bool leading_dot, long int start, lin num)
    around the problems involved with changing line numbers in an ed
    script.
 
-   As in `output_diff3', the variable MAPPING maps from file number
+   As in 'output_diff3', the variable MAPPING maps from file number
    according to the argument list to file number according to the diff
    passed.  All files listed below are in terms of the argument list.
    REV_MAPPING is the inverse of MAPPING.
diff --git a/src/dir.c b/src/dir.c
index 2fbaf4b..57134c7 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -85,7 +85,7 @@ dir_read (struct file_data const *dir, struct dirdata *dirdata)
       dirdata->data = data = xmalloc (data_alloc);
 
       /* Read the directory entries, and insert the subfiles
-	 into the `data' table.  */
+	 into the 'data' table.  */
 
       while ((errno = 0, (next = readdir (reading)) != 0))
 	{
@@ -126,7 +126,7 @@ dir_read (struct file_data const *dir, struct dirdata *dirdata)
 #endif
     }
 
-  /* Create the `names' table from the `data' table.  */
+  /* Create the 'names' table from the 'data' table.  */
   if (PTRDIFF_MAX / sizeof *names - 1 <= nnames)
     xalloc_die ();
   dirdata->names = names = xmalloc ((nnames + 1) * sizeof *names);
@@ -155,7 +155,7 @@ compare_names (char const *name1, char const *name2)
 	r = strcoll (name1, name2);
       if (errno)
 	{
-	  error (0, errno, _("cannot compare file names `%s' and `%s'"),
+	  error (0, errno, _("cannot compare file names '%s' and '%s'"),
 		 name1, name2);
 	  longjmp (failed_locale_specific_sorting, 1);
 	}
@@ -235,7 +235,7 @@ diff_dirs (struct comparison const *cmp,
 	qsort (names[i], dirdata[i].nnames, sizeof *dirdata[i].names,
 	       compare_names_for_qsort);
 
-      /* If `-S name' was given, and this is the topmost level of comparison,
+      /* If '-S name' was given, and this is the topmost level of comparison,
 	 ignore all file names less than the specified starting name.  */
 
       if (starting_file && ! cmp->parent)
diff --git a/src/ifdef.c b/src/ifdef.c
index 7251085..94f170b 100644
--- a/src/ifdef.c
+++ b/src/ifdef.c
@@ -132,7 +132,7 @@ format_group (register FILE *out, char const *format, char endchar,
 	    break;
 
 	  case '(':
-	    /* Print if-then-else format e.g. `%(n=1?thenpart:elsepart)'.  */
+	    /* Print if-then-else format e.g. '%(n=1?thenpart:elsepart)'.  */
 	    {
 	      int i;
 	      uintmax_t value[2];
diff --git a/src/io.c b/src/io.c
index 722cdf0..5a631a5 100644
--- a/src/io.c
+++ b/src/io.c
@@ -57,10 +57,10 @@ static size_t nbuckets;
    The number of an equivalence class is its index in this array.  */
 static struct equivclass *equivs;
 
-/* Index of first free element in the array `equivs'.  */
+/* Index of first free element in the array 'equivs'.  */
 static lin equivs_index;
 
-/* Number of elements allocated in the array `equivs'.  */
+/* Number of elements allocated in the array 'equivs'.  */
 static lin equivs_alloc;
 
 /* Read a block of data into a file buffer, checking for EOF and error.  */
diff --git a/src/sdiff.c b/src/sdiff.c
index a77b36b..e1bb117 100644
--- a/src/sdiff.c
+++ b/src/sdiff.c
@@ -35,7 +35,7 @@
 #include <version-etc.h>
 #include <xalloc.h>
 
-/* The official name of this program (e.g., no `g' prefix).  */
+/* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "sdiff"
 
 #define AUTHORS \
@@ -91,7 +91,7 @@ static int const sigs[] = {
 };
 
 #if HAVE_SIGACTION
-  /* Prefer `sigaction' if available, since `signal' can lose signals.  */
+  /* Prefer 'sigaction' if available, since 'signal' can lose signals.  */
   static struct sigaction initial_action[NUM_SIGS];
 # define initial_handler(i) (initial_action[i].sa_handler)
   static void signal_handler (int, void (*) (int));
@@ -152,7 +152,7 @@ try_help (char const *reason_msgid, char const *operand)
 {
   if (reason_msgid)
     error (0, 0, _(reason_msgid), operand);
-  error (EXIT_TROUBLE, 0, _("Try `%s --help' for more information."),
+  error (EXIT_TROUBLE, 0, _("Try '%s --help' for more information."),
 	 program_name);
   abort ();
 }
@@ -213,7 +213,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
     else
       putchar ('\n');
   printf ("\n%s\n%s\n",
-	  _("If a FILE is `-', read standard input."),
+	  _("If a FILE is '-', read standard input."),
 	  _("Exit status is 0 if inputs are the same, 1 if different, 2 if trouble."));
   emit_bug_reporting_address ();
 }
@@ -269,12 +269,12 @@ check_child_status (int werrno, int wstatus, int max_ok_status,
     {
       error (0, werrno,
 	     _(status == 126
-	       ? "subsidiary program `%s' could not be invoked"
+	       ? "subsidiary program '%s' could not be invoked"
 	       : status == 127
-	       ? "subsidiary program `%s' not found"
+	       ? "subsidiary program '%s' not found"
 	       : status == INT_MAX
-	       ? "subsidiary program `%s' failed"
-	       : "subsidiary program `%s' failed (exit status %d)"),
+	       ? "subsidiary program '%s' failed"
+	       : "subsidiary program '%s' failed (exit status %d)"),
 	     subsidiary_program, status);
       exiterr ();
     }
@@ -559,9 +559,9 @@ main (int argc, char *argv[])
   if (argc - optind != 2)
     {
       if (argc - optind < 2)
-	try_help ("missing operand after `%s'", argv[argc - 1]);
+	try_help ("missing operand after '%s'", argv[argc - 1]);
       else
-	try_help ("extra operand `%s'", argv[optind + 2]);
+	try_help ("extra operand '%s'", argv[optind + 2]);
     }
 
   if (! output)
@@ -706,7 +706,7 @@ main (int argc, char *argv[])
 	exit (WEXITSTATUS (wstatus));
       }
     }
-  return EXIT_SUCCESS;			/* Fool `-Wall'.  */
+  return EXIT_SUCCESS;			/* Fool '-Wall'.  */
 }
 
 static void
diff --git a/src/side.c b/src/side.c
index 19958b4..076b898 100644
--- a/src/side.c
+++ b/src/side.c
@@ -292,7 +292,7 @@ print_sdiff_hunk (struct change *hunk)
       fprintf (outfile, "c%ld,%ld\n", len0, len1);
     }
 
-  /* Print ``xxx  |  xxx '' lines */
+  /* Print "xxx  |  xxx " lines.  */
   if (changes == CHANGED)
     {
       for (i = first0, j = first1;  i <= last0 && j <= last1;  i++, j++)
@@ -302,7 +302,7 @@ print_sdiff_hunk (struct change *hunk)
       next1 = first1 = j;
     }
 
-  /* Print ``     >  xxx '' lines */
+  /* Print "     >  xxx " lines.  */
   if (changes & NEW)
     {
       for (j = first1; j <= last1; ++j)
@@ -310,7 +310,7 @@ print_sdiff_hunk (struct change *hunk)
       next1 = j;
     }
 
-  /* Print ``xxx  <     '' lines */
+  /* Print "xxx  <     " lines.  */
   if (changes & OLD)
     {
       for (i = first0; i <= last0; ++i)
diff --git a/src/system.h b/src/system.h
index 9919d68..2767b57 100644
--- a/src/system.h
+++ b/src/system.h
@@ -20,14 +20,14 @@
 
 #include <config.h>
 
-/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+/* Use this to suppress gcc's "...may be used before initialized" warnings. */
 #ifdef lint
 # define IF_LINT(Code) Code
 #else
 # define IF_LINT(Code) /* empty */
 #endif
 
-/* Define `__attribute__' and `volatile' first
+/* Define '__attribute__' and 'volatile' first
    so that they're used consistently in all system includes.  */
 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
 # define __attribute__(x)
@@ -99,7 +99,7 @@ int strcasecmp (char const *, char const *);
    - It's typically faster.
    POSIX 1003.1-2001 says that only '0' through '9' are digits.
    Prefer ISDIGIT to isdigit unless it's important to use the locale's
-   definition of `digit' even when the host does not conform to POSIX.  */
+   definition of 'digit' even when the host does not conform to POSIX.  */
 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
 
 #include <errno.h>
diff --git a/src/util.c b/src/util.c
index 16638a3..2b0bbbf 100644
--- a/src/util.c
+++ b/src/util.c
@@ -27,7 +27,7 @@
 char const pr_program[] = PR_PROGRAM;
 
 /* Queue up one-line messages to be printed at the end,
-   when -l is specified.  Each message is recorded with a `struct msg'.  */
+   when -l is specified.  Each message is recorded with a 'struct msg'.  */
 
 struct msg
 {
@@ -121,7 +121,7 @@ message5 (char const *format_msgid, char const *arg1, char const *arg2,
     }
 }
 
-/* Output all the messages that were saved up by calls to `message'.  */
+/* Output all the messages that were saved up by calls to 'message'.  */
 
 void
 print_message_queue (void)
@@ -146,8 +146,8 @@ print_message_queue (void)
    to set up OUTFILE, the stdio stream for the output to go to.
 
    Usually, OUTFILE is just stdout.  But when -l was specified
-   we fork off a `pr' and make OUTFILE a pipe to it.
-   `pr' then outputs to our stdout.  */
+   we fork off a 'pr' and make OUTFILE a pipe to it.
+   'pr' then outputs to our stdout.  */
 
 static char const *current_name0;
 static char const *current_name1;
@@ -190,7 +190,7 @@ begin_output (void)
       if (fflush (stdout) != 0)
 	pfatal_with_name (_("write failed"));
 
-      /* Make OUTFILE a pipe to a subsidiary `pr'.  */
+      /* Make OUTFILE a pipe to a subsidiary 'pr'.  */
       {
 #if HAVE_WORKING_FORK
 	int pipes[2];
@@ -241,7 +241,7 @@ begin_output (void)
   else
     {
 
-      /* If -l was not specified, output the diff straight to `stdout'.  */
+      /* If -l was not specified, output the diff straight to 'stdout'.  */
 
       outfile = stdout;
 
@@ -270,7 +270,7 @@ begin_output (void)
 }
 
 /* Call after the end of output of diffs for one file.
-   Close OUTFILE and get rid of the `pr' subfork.  */
+   Close OUTFILE and get rid of the 'pr' subfork.  */
 
 void
 finish_output (void)
@@ -298,12 +298,12 @@ finish_output (void)
       if (status)
 	error (EXIT_TROUBLE, werrno,
 	       _(status == 126
-		 ? "subsidiary program `%s' could not be invoked"
+		 ? "subsidiary program '%s' could not be invoked"
 		 : status == 127
-		 ? "subsidiary program `%s' not found"
+		 ? "subsidiary program '%s' not found"
 		 : status == INT_MAX
-		 ? "subsidiary program `%s' failed"
-		 : "subsidiary program `%s' failed (exit status %d)"),
+		 ? "subsidiary program '%s' failed"
+		 : "subsidiary program '%s' failed (exit status %d)"),
 	       pr_program, status);
     }
 
@@ -677,7 +677,7 @@ print_number_range (char sepchar, struct file_data *file, lin a, lin b)
 
 /* Look at a hunk of edit script and report the range of lines in each file
    that it applies to.  HUNK is the start of the hunk, which is a chain
-   of `struct change'.  The first and last line numbers of file 0 are stored in
+   of 'struct change'.  The first and last line numbers of file 0 are stored in
    *FIRST0 and *LAST0, and likewise for file 1 in *FIRST1 and *LAST1.
    Note that these are internal line numbers that count from 0.
 
diff --git a/tests/help-version b/tests/help-version
index 8eb313a..bc9edce 100755
--- a/tests/help-version
+++ b/tests/help-version
@@ -74,7 +74,7 @@ test "x$v" = "x$VERSION" \
 for lang in C fr da; do
   for i in $built_programs; do
 
-    # Skip `test'; it doesn't accept --help or --version.
+    # Skip 'test'; it doesn't accept --help or --version.
     test $i = test && continue;
 
     # false fails even when invoked with --help or --version.
@@ -84,7 +84,7 @@ for lang in C fr da; do
       continue
     fi
 
-    # The just-built install executable is always named `ginstall'.
+    # The just-built install executable is always named 'ginstall'.
     test $i = install && i=ginstall
 
     # Make sure they exit successfully, under normal conditions.
@@ -95,7 +95,7 @@ for lang in C fr da; do
     grep "$PACKAGE_BUGREPORT" h-$i > /dev/null || fail=1
     rm -f h-$i
 
-    # Make sure they fail upon `disk full' error.
+    # Make sure they fail upon 'disk full' error.
     if test -w /dev/full && test -c /dev/full; then
       env $i --help    >/dev/full 2>/dev/null && fail=1
       env $i --version >/dev/full 2>/dev/null && fail=1
@@ -107,7 +107,7 @@ for lang in C fr da; do
         : # ok
       else
         fail=1
-        echo "*** $i: bad exit status \`$status' (expected $expected)," 1>&2
+        echo "*** $i: bad exit status '$status' (expected $expected)," 1>&2
         echo "  with --help or --version output redirected to /dev/full" 1>&2
       fi
     fi
@@ -139,7 +139,7 @@ chown_setup () { args=--version; }
 mkfifo_setup () { args=--version; }
 mknod_setup () { args=--version; }
 # Punt on uptime, since it fails (e.g., failing to get boot time)
-# on some systems, and we shouldn't let that stop `make check'.
+# on some systems, and we shouldn't let that stop 'make check'.
 uptime_setup () { args=--version; }
 
 # Create a file in the current directory, not in $TMPDIR.
@@ -187,7 +187,7 @@ basename_setup () { args=$tmp_in; }
 dirname_setup () { args=$tmp_in; }
 expr_setup () { args=foo; }
 
-# Punt, in case GNU `id' hasn't been installed yet.
+# Punt, in case GNU 'id' hasn't been installed yet.
 groups_setup () { args=--version; }
 
 pathchk_setup () { args=$tmp_in; }
-- 
1.7.6.5


