From fd98286b24a10c2b53f4f4172f68ea8ce46ce1a7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 4 Jan 2016 23:48:59 +0100 Subject: macro that allows errno == 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- doc/man/libhaiku_perror.3 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/man/libhaiku_perror.3 b/doc/man/libhaiku_perror.3 index 7c0476d..1514470 100644 --- a/doc/man/libhaiku_perror.3 +++ b/doc/man/libhaiku_perror.3 @@ -33,7 +33,18 @@ Unlike .B libhaiku_perror shall not print anything if .B errno -is zero. +is zero. If you rather it did, you can use the macro +.PP +.nf +#define libhaiku_perror(s) \\ + do { \\ + const char *s__ = (s); \\ + if (errno && s__) \\ + perror(s__); \\ + errno = errno ? errno : -1; \\ + libhaiku_perror(s__); \\ + } while (0) +.fi .SH "SEE ALSO" .BR libhaiku (7), .BR perror (3) -- cgit v1.2.3-70-g09d2