bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[diffutils 2.8.X] real PATCH: sdiff "subsidiary program `ed' failed"


From: Matthias Andree
Subject: [diffutils 2.8.X] real PATCH: sdiff "subsidiary program `ed' failed"
Date: Mon, 24 Feb 2003 13:34:25 +0100
User-agent: Mutt/1.4i

Paul,

I looked through the archives and the sdiff code about the "subsidiary
program `?' failed" issue. I think I found the actual problem.

Please look around line 727 of sdiff.c, near the call to
ck_editor_status. The problem is that the exit status (obtained with
pclose or waidpid) is diff's, not $EDITOR's, and the call to
ck_editor_status is therefore bogus, it should have to be
ck_diff_status (which doesn't exist).

Evidently, when closing the diffout or waiting for diffpid code,
the condition (WIFEXITED(s) && WEXITSTATUS(s) == 1) means SUCCESS
because diff will exit 0 when no differences were found, 1 when
differences were found, and 2 (of WIFSIGNALED(s)) in case of trouble.

I have patches (and GnuPG-signed SHA1 sums) against 2.8.1 and 2.8.4 for
download at http://mandree.home.pages.de/diffutils/

That patch you suggest in
http://mail.gnu.org/archive/html/bug-gnu-utils/2003-01/msg00122.html
doesn't look right to me, it doesn't fix blaming the fault for an
alleged diff failure on the RIGHT program, ed. The patches are herewith
put in the public domain.

My diffutils 2.8.4 patch is also included here for convenience,
worksforme[tm] on SuSE Linux 8.1:

diff -ur --exclude '*.[1o]' diffutils-2.8.4/src/sdiff.c 
diffutils-2.8.4-ma/src/sdiff.c
--- diffutils-2.8.4/src/sdiff.c.bak     2002-06-17 07:55:42.000000000 +0200
+++ diffutils-2.8.4/src/sdiff.c 2003-02-24 13:08:24.000000000 +0100
@@ -265,7 +265,7 @@
 static void
 ck_editor_status (int errnum, int status)
 {
-  if (errnum | status)
+  if (errnum || status)
     {
       error (0, errnum,
             _(! errnum && WIFEXITED (status) && WEXITSTATUS (status) == 127
@@ -276,6 +276,20 @@
     }
 }
 
+static void
+ck_diff_status (int errnum, int status)
+{
+  if (errnum || WIFSIGNALED(status) || (WIFEXITED(status) && 
WEXITSTATUS(status) > 1))
+    {
+      error (0, errnum,
+            _(! errnum && WIFEXITED (status) && WEXITSTATUS (status) == 127
+              ? "subsidiary program `%s' not found"
+              : "subsidiary program `%s' failed"),
+            diffargv[0]);
+      exiterr ();
+    }
+}
+
 static FILE *
 ck_fopen (char const *fname, char const *type)
 {
@@ -718,7 +732,7 @@
        if (! interact_ok)
          exiterr ();
 
-       ck_editor_status (werrno, wstatus);
+       ck_diff_status (werrno, wstatus);
        untrapsig (0);
        checksigs ();
        exit (WEXITSTATUS (wstatus));

-- 
Matthias Andree




reply via email to

[Prev in Thread] Current Thread [Next in Thread]