From 72d7d28ef8f7292d1c75d6e24b7a353cc7d47a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 25 Jan 2005 21:20:35 +0000 Subject: [PATCH] I accidently broke glibc's perror() - now it's working. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11040 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/glibc/stdio-common/perror.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kernel/libroot/posix/glibc/stdio-common/perror.c b/src/kernel/libroot/posix/glibc/stdio-common/perror.c index dad528660f..c6abc603e9 100644 --- a/src/kernel/libroot/posix/glibc/stdio-common/perror.c +++ b/src/kernel/libroot/posix/glibc/stdio-common/perror.c @@ -23,10 +23,10 @@ #include -/** Print a line on stderr consisting of the text in S, a colon, +/** Print a line on stderr consisting of the text in \a s, a colon, * a space, a message describing the meaning of the contents of * `errno' and a newline. - * If S is NULL or "", the colon and space are omitted. + * If \a s is NULL or "", the colon and space are omitted. */ void @@ -35,11 +35,17 @@ perror(const char *s) const char *colon; char buffer[1024]; + // ToDo: we should not change the orientation of the stream + // (wide char support is currently disabled, so this doesn't matter yet) + if (s == NULL || *s == '\0') s = colon = ""; else colon = ": "; - fprintf(stderr, "%s%s%s\n", s, colon, strerror_r(errno, buffer, sizeof(buffer))); + if (strerror_r(errno, buffer, sizeof(buffer)) != 0) + sprintf("Unknown error %ld", errno); + + fprintf(stderr, "%s%s%s\n", s, colon, buffer); }