Use strerror_r() rather than trying to hack our own. This avoids
dealing with the nonstandardized types of sys_nerr and sys_errlst[] and works for both -current and recent (>=4.5) values of -stable. The previous implementation knew too much about sys_nerr for its own good.
This commit is contained in:
parent
8cefe4530f
commit
e915e951f5
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=68531
@ -1,19 +1,41 @@
|
||||
--- src/print.c.orig Thu Apr 4 07:25:04 1996
|
||||
+++ src/print.c Sun Dec 12 16:29:07 1999
|
||||
@@ -6,6 +6,7 @@
|
||||
--- ../../work.orig/elk-3.0/src/print.c Thu Apr 4 08:25:04 1996
|
||||
+++ src/print.c Mon Oct 21 15:48:05 2002
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
+#include <string.h>
|
||||
#include <varargs.h>
|
||||
+#include <sys/param.h>
|
||||
|
||||
#ifdef FLUSH_TIOCFLUSH
|
||||
# include <sys/ioctl.h>
|
||||
@@ -556,7 +557,7 @@
|
||||
@@ -555,10 +556,6 @@
|
||||
char *p;
|
||||
register c;
|
||||
char buf[256];
|
||||
extern sys_nerr;
|
||||
- extern sys_nerr;
|
||||
-#ifndef __bsdi__
|
||||
+#if !(defined(BSD) && (BSD >= 199306))
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
- extern char *sys_errlist[];
|
||||
-#endif
|
||||
GC_Node;
|
||||
Alloca_Begin;
|
||||
|
||||
@@ -573,13 +570,13 @@
|
||||
} else if (c == '%') {
|
||||
Print_Char (port, '\n');
|
||||
} else if (c == 'e' || c == 'E') {
|
||||
- if (Saved_Errno > 0 && Saved_Errno < sys_nerr) {
|
||||
- s = sys_errlist[Saved_Errno];
|
||||
- sprintf (buf, "%c%s", isupper (*s) ? tolower (*s) :
|
||||
- *s, s+1);
|
||||
- } else {
|
||||
- sprintf (buf, "error %d", Saved_Errno);
|
||||
+ if (strerror_r(Saved_Errno, buf, sizeof(buf)) != 0) {
|
||||
+ snprintf(buf, sizeof(buf) - 1, "unknown error: %d",
|
||||
+ Saved_Errno);
|
||||
+ buf[sizeof(buf) - 1] = '\0';
|
||||
}
|
||||
+ if (isupper(buf[0]))
|
||||
+ buf[0] = tolower(buf[0]);
|
||||
Print_Object (Make_String (buf, strlen (buf)), port,
|
||||
c == 'E', 0, 0);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user