From b815b84a5942f591e8a79c731100712558fa41c6 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Sun, 7 Jul 2002 20:13:41 +0000 Subject: Attempt to clean up the strerror_r situation. --- libc/stdio/stdio.c | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'libc/stdio/stdio.c') diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c index a56eff777..1bce679f9 100644 --- a/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -3218,7 +3218,7 @@ void perror(register const char *s) { char buf[64]; fprintf(stderr, "%s%s%s\n", s, sep, - _stdio_strerror_r(errno, buf, sizeof(buf))); + _glibc_strerror_r(errno, buf, sizeof(buf))); } #endif #else @@ -3228,7 +3228,7 @@ void perror(register const char *s) __STDIO_THREADLOCK(stderr); _stdio_fdout(STDERR_FILENO, s, sep, - _stdio_strerror_r(errno, buf, sizeof(buf))); + _glibc_strerror_r(errno, buf, sizeof(buf))); __STDIO_THREADUNLOCK(stderr); } #endif @@ -3328,37 +3328,3 @@ char *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval, #endif /**********************************************************************/ -#ifdef L__stdio_strerror_r - -/* This is an internal routine, and assumes buf and buflen are set - * appropriately. - * - * WARNING!!! While it is similar to the glibc strerror_r function, - * it is not the same. It is expected that "unknown" error strings - * will fit in the buffer passed. Also, the return value may not - * be == buf, as unknown strings are "right-justified" in the buf - * due to the way _int10stostr works. */ - -static const char unknown[] = "Unknown error"; - -char *_stdio_strerror_r(int err, register char *buf, size_t buflen) -{ - int errsave; - - assert(buflen >= __UIM_BUFLEN_INT + sizeof(unknown)); - - errsave = errno; /* Backup the errno. */ - - if (strerror_r(err, buf, buflen)) { /* Failed! */ - __set_errno(errsave); /* Restore old errno. */ - - buf = _int10tostr(buf+buflen-1, err) - sizeof(unknown); - strcpy(buf, unknown); - buf[sizeof(unknown)-1] = ' '; /* Overwrite the nul. */ - } - - return buf; -} - -#endif -/**********************************************************************/ -- cgit v1.2.3