(my_strerror): Return "cannot access" if errno is 0.

(perror_with_name, pfatal_with_name, perror_exec): Don't assume that
the returned value from my_strerror contains no '%'s.
(sys_nerr): Declare only if HAVE_STRERROR is not defined.

From-SVN: r10714
This commit is contained in:
Richard Kenner 1995-12-13 19:12:10 -05:00
parent 493810116d
commit c6b51be9d2

View File

@ -175,8 +175,8 @@ extern char *getenv ();
extern int errno; extern int errno;
#endif #endif
extern int sys_nerr;
#ifndef HAVE_STRERROR #ifndef HAVE_STRERROR
extern int sys_nerr;
#if defined(bsd4_4) #if defined(bsd4_4)
extern const char *const sys_errlist[]; extern const char *const sys_errlist[];
#else #else
@ -1023,7 +1023,7 @@ my_strerror(e)
static char buffer[30]; static char buffer[30];
if (!e) if (!e)
return ""; return "cannot access";
if (e > 0 && e < sys_nerr) if (e > 0 && e < sys_nerr)
return sys_errlist[e]; return sys_errlist[e];
@ -4722,40 +4722,22 @@ static void
pfatal_with_name (name) pfatal_with_name (name)
char *name; char *name;
{ {
char *s; fatal ("%s: %s", name, my_strerror (errno));
if (errno < sys_nerr)
s = concat ("%s: ", my_strerror( errno ));
else
s = "cannot open `%s'";
fatal (s, name);
} }
static void static void
perror_with_name (name) perror_with_name (name)
char *name; char *name;
{ {
char *s; error ("%s: %s", name, my_strerror (errno));
if (errno < sys_nerr)
s = concat ("%s: ", my_strerror( errno ));
else
s = "cannot open `%s'";
error (s, name);
} }
static void static void
perror_exec (name) perror_exec (name)
char *name; char *name;
{ {
char *s; error ("installation problem, cannot exec `%s': %s",
name, my_strerror (errno));
if (errno < sys_nerr)
s = concat ("installation problem, cannot exec `%s': ",
my_strerror (errno));
else
s = "installation problem, cannot exec `%s'";
error (s, name);
} }
/* More 'friendly' abort that prints the line and file. /* More 'friendly' abort that prints the line and file.