Subject: Re: misc/23162 (was: Some post-install problems)
To: #List NetBSD current users <current-users@NetBSD.ORG>
From: Christian Biere <christianbiere@gmx.de>
List: current-users
Date: 01/23/2004 09:15:05
--k4f25fnPtRuIRUb3
Content-Type: multipart/mixed; boundary="E13BgyNx05feLLmH"
Content-Disposition: inline


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

Tom Ivar Helbekkmo wrote:
> > 2. For every file which is different and a merge is attempted, I get
> >
> > 	sdiff: subsidiary program `ed' failed
> >
> >    at the end of the merge.
=20
> I've been trying to understand the sdiff source code in order to
> figure out why it does this, but to no avail.  I'm usually very good
> at debugging, but this one has me stumped...

I've found and fixed the bug. sdiff uses diff which returns EXIT_FAILURE
if the files are different. However, sdiff bombs with this wrong
error message when diff returns EXIT_FAILURE. Anyway, *after* fixing
the bug I googled for it and found that Paul Eggert fixed the bug
about a year ago. Still there's no fixed version available...

I've attached my version of the bugfix.

--=20
Christian

--E13BgyNx05feLLmH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sdiff.c.udif"
Content-Transfer-Encoding: quoted-printable

Index: sdiff.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/src/gnu/dist/diffutils/src/sdiff.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sdiff.c
--- sdiff.c	2003/01/26 00:43:17	1.1.1.1
+++ sdiff.c	2004/01/23 07:55:04
@@ -263,26 +261,50 @@
 }
=20
 static void
+sub_program_failure (const char *program, int errnum, int status)
+{
+  char const *failure_msgid =3D N_("subsidiary program `%s' failed");
+
+  if (! errnum && WIFEXITED (status))
+    switch (WEXITSTATUS (status))
+    {
+    case 126:
+      failure_msgid =3D N_("subsidiary program `%s' not executable");
+      break;
+    case 127:
+      failure_msgid =3D N_("subsidiary program `%s' not found");
+      break;
+    }
+
+  error (0, errnum, _(failure_msgid), program);
+  exiterr ();
+}
+
+static void
 ck_editor_status (int errnum, int status)
 {
   if (errnum | status)
     {
-      char const *failure_msgid =3D N_("subsidiary program `%s' failed");
-      if (! errnum && WIFEXITED (status))
-	switch (WEXITSTATUS (status))
-	  {
-	  case 126:
-	    failure_msgid =3D N_("subsidiary program `%s' not executable");
-	    break;
-	  case 127:
-	    failure_msgid =3D N_("subsidiary program `%s' not found");
-	    break;
-	  }
-      error (0, errnum, _(failure_msgid), editor_program);
-      exiterr ();
+       sub_program_failure(editor_program, errnum, status);
     }
 }
=20
+static void
+ck_diff_status (int errnum, int status)
+{
+/* Copy & paste from diff.c:
+
+   Value is EXIT_SUCCESS if files are the same, EXIT_FAILURE if
+   different, EXIT_TROUBLE if there is a problem opening them.  */
+
+  if (errnum || !WIFEXITED(status) || (WEXITSTATUS(status) !=3D EXIT_SUCCE=
SS &&
+      WEXITSTATUS(status) !=3D EXIT_FAILURE))
+    {
+       sub_program_failure(DEFAULT_DIFF_PROGRAM, errnum, status);
+    }
+}
+
+
 static FILE *
 ck_fopen (char const *fname, char const *type)
 {
@@ -726,7 +748,7 @@
 	if (! interact_ok)
 	  exiterr ();
=20
-	ck_editor_status (werrno, wstatus);
+	ck_diff_status (werrno, wstatus);
 	untrapsig (0);
 	checksigs ();
 	exit (WEXITSTATUS (wstatus));

--E13BgyNx05feLLmH--

--k4f25fnPtRuIRUb3
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFAENgI0KQix3oyIMcRAgcRAJ9uMWb5Nmm+GKpyqRZFTl0CmJQo+ACfTVyZ
lWesB+RJ37LcKa3ENO8IpBA=
=It/P
-----END PGP SIGNATURE-----

--k4f25fnPtRuIRUb3--