summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authortjg <tjg>1999-10-13 15:37:34 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:16 +0100
commit32514265eae23c9196b09477c63ab26850ecbe6a (patch)
tree444e58a6c77df0aabfc8d950a698afe5bfbf1a55 /utils.c
parent55187d8e921d611b3fa9ff4a166125c44b7dd6d9 (diff)
Portability: use POSIX strerror() where it's available; fake it with
sys_errlist[] where not.
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c15
1 files changed, 8 insertions, 7 deletions
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. */