summaryrefslogtreecommitdiff
path: root/sysdeps/mach/_strerror.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-05-09 07:03:38 +0000
committerRoland McGrath <roland@gnu.org>1995-05-09 07:03:38 +0000
commit273d56ce89f26233cb7a703c542d2732adbea87d (patch)
treee489d7e9e6cd644a5d0d85d4b39a8c75692e3633 /sysdeps/mach/_strerror.c
parent421f82e5cc8f81ab003247d771bcecbad799be85 (diff)
downloadglibc-273d56ce89f26233cb7a703c542d2732adbea87d.tar.gz
(__data_start): Define this symbol as the first thing in .data.
Diffstat (limited to 'sysdeps/mach/_strerror.c')
-rw-r--r--sysdeps/mach/_strerror.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sysdeps/mach/_strerror.c b/sysdeps/mach/_strerror.c
index 398c77fbdf..eeebb9e360 100644
--- a/sysdeps/mach/_strerror.c
+++ b/sysdeps/mach/_strerror.c
@@ -16,15 +16,15 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stdio.h>
#include <string.h>
#include <mach/error.h>
#include <errorlib.h>
+#include "../stdio/_itoa.h"
/* Return a string describing the errno code in ERRNUM. */
char *
-DEFUN(_strerror_internal, (errnum, buf), int errnum AND char buf[1024])
+_strerror_internal (int errnum, char buf[1024])
{
int system;
int sub;
@@ -40,8 +40,12 @@ DEFUN(_strerror_internal, (errnum, buf), int errnum AND char buf[1024])
if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
{
- sprintf (buf, "Unknown error system %d", system);
- return buf;
+ static const char unk[] = "Error in unknown error system: ";
+ char *p = buf + sizeof buf;
+ *p-- = '\0';
+ p = _itoa (errnum, p, 16, 1);
+ p -= sizeof unk - 1;
+ return memcpy (p, unk, sizeof unk - 1);
}
es = &__mach_error_systems[system];
@@ -51,9 +55,14 @@ DEFUN(_strerror_internal, (errnum, buf), int errnum AND char buf[1024])
if (code >= es->subsystem[sub].max_code)
{
- sprintf (buf, "Unknown error %d in system %d subsystem %d",
- code, system, sub);
- return buf;
+ static const char unk[] = "Unknown error ";
+ char *p = buf + sizeof buf;
+ size_t len = strlen (es->subsystem[sub].subsys_name);
+ *p-- = '\0';
+ p = _itoa (errnum, p, 16, 1);
+ *p-- = ' ';
+ p = memcpy (p - len, es->subsystem[sub].subsys_name, len);
+ return memcpy (p - sizeof unk - 1, unk, sizeof unk - 1);
}
return (char *) es->subsystem[sub].codes[code];