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

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

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


From: Paul Eggert
Subject: Re: [diffutils 2.8.X] real PATCH: sdiff "subsidiary program `ed' failed"
Date: 24 Feb 2003 23:03:41 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.3

Matthias Andree <address@hidden> writes:

> 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

Good point.  How about the following patch instead?  It is a slight
variant of the other patch, which keeps track of the name of the
subsidiary program.

--- sdiff.c     2002/06/17 05:55:42     1.39
+++ sdiff.c     2003/02/25 06:58:06
@@ -263,15 +263,24 @@ perror_fatal (char const *msg)
 }
 
 static void
-ck_editor_status (int errnum, int status)
+check_child_status (int werrno, int wstatus, int max_ok_status,
+                   char const *subsidiary_program)
 {
-  if (errnum | status)
-    {
-      error (0, errnum,
-            _(! errnum && WIFEXITED (status) && WEXITSTATUS (status) == 127
+  int status = (! werrno && WIFEXITED (wstatus)
+               ? WEXITSTATUS (wstatus)
+               : INT_MAX);
+
+  if (max_ok_status < status)
+    {
+      error (0, werrno,
+            _(status == 126
+              ? "subsidiary program `%s' could not be invoked"
+              : status == 127
               ? "subsidiary program `%s' not found"
-              : "subsidiary program `%s' failed"),
-            editor_program);
+              : status == INT_MAX
+              ? "subsidiary program `%s' failed"
+              : "subsidiary program `%s' failed (exit status %d)"),
+            subsidiary_program, status);
       exiterr ();
     }
 }
@@ -658,7 +667,7 @@ main (int argc, char *argv[])
              }
 
            execvp (diffargv[0], (char **) diffargv);
-           _exit (127);
+           _exit (errno == ENOENT ? 127 : 126);
          }
 
 # if HAVE_WORKING_VFORK
@@ -718,7 +727,7 @@ main (int argc, char *argv[])
        if (! interact_ok)
          exiterr ();
 
-       ck_editor_status (werrno, wstatus);
+       check_child_status (werrno, wstatus, EXIT_FAILURE, diffargv[0]);
        untrapsig (0);
        checksigs ();
        exit (WEXITSTATUS (wstatus));
@@ -1064,7 +1073,7 @@ edit (struct line_filter *left, char con
                    argv[i] = 0;
 
                    execvp (editor_program, (char **) argv);
-                   _exit (127);
+                   _exit (errno == ENOENT ? 127 : 126);
                  }
 
                if (pid < 0)
@@ -1079,7 +1088,8 @@ edit (struct line_filter *left, char con
              }
 
              ignore_SIGINT = 0;
-             ck_editor_status (werrno, wstatus);
+             check_child_status (werrno, wstatus, EXIT_SUCCESS,
+                                 editor_program);
            }
 
            {




reply via email to

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