aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2017-05-08 19:46:00 +0000
committerVincent Richard <[email protected]>2017-05-08 19:46:00 +0000
commit8d3ea37b554d1a9f3d98d72eac1d8e539c223454 (patch)
treeda3872f6eabc52fdd8ae7206110b8b63c195e151
parentFixed #171: cross-compiling detection. (diff)
downloadvmime-8d3ea37b554d1a9f3d98d72eac1d8e539c223454.tar.gz
vmime-8d3ea37b554d1a9f3d98d72eac1d8e539c223454.zip
Issue #138: more reliable detection of strerror_r() variant.
-rw-r--r--src/vmime/platforms/posix/posixSocket.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/vmime/platforms/posix/posixSocket.cpp b/src/vmime/platforms/posix/posixSocket.cpp
index ea0b345b..012e8842 100644
--- a/src/vmime/platforms/posix/posixSocket.cpp
+++ b/src/vmime/platforms/posix/posixSocket.cpp
@@ -59,6 +59,32 @@
#endif
+// Workaround for detection of strerror_r variants
+#if VMIME_HAVE_STRERROR_R
+
+namespace
+{
+
+char* vmime_strerror_r_result(int /* res */, char* buf)
+{
+ // XSI-compliant prototype:
+ // int strerror_r(int errnum, char *buf, size_t buflen);
+ return buf;
+}
+
+char* vmime_strerror_r_result(char* res, char* /* buf */)
+{
+ // GNU-specific prototype:
+ // char *strerror_r(int errnum, char *buf, size_t buflen);
+ return res;
+}
+
+}
+
+#endif // VMIME_HAVE_STRERROR_R
+
+
+
namespace vmime {
namespace platforms {
namespace posix {
@@ -872,20 +898,7 @@ void posixSocket::throwSocketError(const int err)
#if VMIME_HAVE_STRERROR_R
char errbuf[512];
-
- #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
-
- // XSI-compliant strerror_r()
- strerror_r(err, errbuf, sizeof(errbuf));
- throw exceptions::socket_exception(errbuf);
-
- #else
-
- // GNU-specific strerror_r()
- const std::string strmsg(strerror_r(err, errbuf, sizeof(errbuf)));
- throw exceptions::socket_exception(strmsg);
-
- #endif
+ throw exceptions::socket_exception(vmime_strerror_r_result(strerror_r(err, errbuf, sizeof(errbuf)), errbuf));
#else // !VMIME_HAVE_STRERROR_R