From 423fbad83583fffa7779d64dbf50af26c4af3850 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 13 May 2015 20:07:19 +0200 Subject: [PATCH] Fix perror(3) compliance. --- libc/stdio/perror.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libc/stdio/perror.cpp b/libc/stdio/perror.cpp index d024241a..bc350ae0 100644 --- a/libc/stdio/perror.cpp +++ b/libc/stdio/perror.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2015. This file is part of the Sortix C Library. @@ -22,11 +22,12 @@ *******************************************************************************/ -#include -#include #include extern "C" void perror(const char* s) { - error(0, errno, "%s", s); + if ( s && s[0] ) + fprintf(stderr, "%s: %m\n", s); + else + fprintf(stderr, "%m\n"); }