From 32514265eae23c9196b09477c63ab26850ecbe6a Mon Sep 17 00:00:00 2001 From: tjg Date: Wed, 13 Oct 1999 15:37:34 +0000 Subject: Portability: use POSIX strerror() where it's available; fake it with sys_errlist[] where not. --- utils.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index ded0c03..00be28b 100644 --- a/utils.c +++ b/utils.c @@ -19,14 +19,15 @@ extern void pr_error(char *s, int offset) { /* our perror */ extern void uerror(char *s) { - extern int sys_nerr; - extern char *sys_errlist[]; - if (errno > sys_nerr) - return; - if (s != NULL) - fprint(2, "%s: %s\n", s, sys_errlist[errno]); + char *err; + + err = strerror(errno); + if (!err) err = "unknown error"; + + if (s) + fprint(2, "%s: %s\n", s, err); else - fprint(2, "%s\n", sys_errlist[errno]); + fprint(2, "%s\n", err); } /* Die horribly. This should never get called. Please let me know if it does. */ -- cgit v1.2.3