From 42422ba06e84ac8bdecfec210ee8bd20d9c26ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Mon, 28 Feb 2005 07:29:18 +0000 Subject: [PATCH] added ifdef for non glibc (Solaris) --- mrw/errno.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mrw/errno.cpp b/mrw/errno.cpp index be7e6ac..944eecf 100644 --- a/mrw/errno.cpp +++ b/mrw/errno.cpp @@ -8,6 +8,9 @@ @license LGPL, see file COPYING $Log$ + Revision 1.3 2005/02/28 07:29:18 marc + added ifdef for non glibc (Solaris) + Revision 1.2 2005/02/18 15:53:07 marc I'm so stupid, there's strerror for mapping errno to a string... @@ -23,15 +26,28 @@ #include #include #include +#ifndef __GLIBC__ +#include +#endif mrw::Errno::Errno() throw(): _errno(errno) {} mrw::Errno::operator std::string() const throw(std::bad_exception) { +#ifdef __GLIBC__ char error[1024]; - return strerror_r(_errno, error, 1024) ? error : std::string("errno=")+_errno; + return !strerror_r(_errno, error, 1024) ? + error : std::string("errno=")+_errno; +#else + return mrw::ifelse(strerror(_errno), (std::string("errno=")+_errno).c_str()); +#endif } std::string mrw::Errno::string() const throw(std::bad_exception) { +#ifdef __GLIBC__ char error[1024]; - return strerror_r(_errno, error, 1024) ? error : std::string("errno=")+_errno; + return !strerror_r(_errno, error, 1024) ? + error : std::string("errno=")+_errno; +#else + return mrw::ifelse(strerror(_errno), (std::string("errno=")+_errno).c_str()); +#endif }