(ETAGSOBJ): Remove reference to obsolete alloca.obj.
[bpt/emacs.git] / lib-src / env.c
index 853cb5b..2ae81a6 100644 (file)
@@ -1,5 +1,5 @@
 /* env - manipulate environment and execute a program in that environment
-   Copyright (C) 1986 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1994 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
@@ -59,7 +59,7 @@
      { USER=rms EDITOR=emacs PATH=.:/gnubin:/hacks }
 
      * "env DISPLAY=gnu:0 nemacs"
-        calls "nemacs" in the envionment
+        calls "nemacs" in the environment
        { USER=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 }
 
      * "env - USER=foo /hacks/hack bar baz"
@@ -96,6 +96,9 @@ void setenv ();
 void fatal ();
 char *myindex ();
 
+extern char *strerror ();
+
+
 main (argc, argv, envp)
      register int argc;
      register char **argv;
@@ -194,17 +197,14 @@ main (argc, argv, envp)
     }
   else
     {
-      extern int errno, sys_nerr;
-      extern char *sys_errlist[];
+      extern int errno;
+      extern char *strerror ();
 
       environ = nenv;
       (void) execvp (*argv, argv);
 
-      fprintf (stderr, "%s: cannot execute `%s'", progname, *argv);
-      if (errno < sys_nerr)
-       fprintf (stderr, ": %s\n", sys_errlist[errno]);
-      else
-       putc ('\n', stderr);
+      fprintf (stderr, "%s: cannot execute `%s': %s\n",
+              progname, *argv, strerror (errno));
       exit (errno != 0 ? errno : 1);
     }
 }
@@ -336,3 +336,18 @@ myindex (str, c)
     }
   return 0;
 }
+\f
+#ifndef HAVE_STRERROR
+char *
+strerror (errnum)
+     int errnum;
+{
+  extern char *sys_errlist[];
+  extern int sys_nerr;
+
+  if (errnum >= 0 && errnum < sys_nerr)
+    return sys_errlist[errnum];
+  return (char *) "Unknown error";
+}
+
+#endif /* ! HAVE_STRERROR */