[PATCH] P11-GLUE: Implement strerror_r compatible with WinXP (common/compat.c)
Pavel A.
pavel.aronsky at daynix.com
Mon Jun 16 05:38:29 PDT 2014
From: Pavel A <pavel.aronsky at daynix.com>
Signed-off-by: Pavel A <pavel.aronsky at daynix.com>
---
common/compat.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/common/compat.c b/common/compat.c
index f5b88ec..8ad35b7 100644
--- a/common/compat.c
+++ b/common/compat.c
@@ -840,7 +840,14 @@ strerror_r (int errnum,
size_t buflen)
{
#ifdef OS_WIN32
- return strerror_s (buf, buflen, errnum);
+ /* strerror_s in MSVCRT.DLL is like strerror_r
+ * but exists only since Win2003. Using strerror
+ * to keep compatibility with WinXP.
+ */
+ char const *p = strerror(errnum);
+ strncpy(buf, p ? p : "", buflen - 1);
+ buf[buflen - 1] = 0;
+ return 0;
#else
#error no strerror_r implementation
#endif
--
1.9.3
More information about the p11-glue
mailing list