]> Savannah Git Hosting - gnulib.git/commitdiff
strerror_r-posix: Avoid a link error on MSVC.
authorBruno Haible <bruno@clisp.org>
Thu, 22 Sep 2011 22:13:29 +0000 (00:13 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 22 Sep 2011 22:13:29 +0000 (00:13 +0200)
* m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Check for snprintf.
* lib/strerror_r.c (snprintf): Define to _snprintf if it doesn't exist.

ChangeLog
lib/strerror_r.c
m4/strerror_r.m4

index 3af8904e0f551dc3de7c2c207f98e39b428e6902..9c713cd8e0edbf53c499aec262cf8b7fcc31540d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-22  Bruno Haible  <bruno@clisp.org>
+
+       strerror_r-posix: Avoid a link error on MSVC.
+       * m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Check for snprintf.
+       * lib/strerror_r.c (snprintf): Define to _snprintf if it doesn't exist.
+
 2011-09-22  Bruno Haible  <bruno@clisp.org>
 
        select: Avoid link errors on MSVC.
index 2b3f1f267e2a671019b5e2709aa9d5c42aa47991..7fd90b70835ed1c3a1d935cc88cda4521d2b2077 100644 (file)
@@ -86,6 +86,12 @@ gl_lock_define_initialized(static, strerror_lock)
 
 #endif
 
+/* On MSVC, there is no snprintf() function, just a _snprintf().
+   It is of lower quality, but sufficient for the simple use here.  */
+#if !HAVE_SNPRINTF
+# define snprintf _snprintf
+#endif
+
 /* Copy as much of MSG into BUF as possible, without corrupting errno.
    Return 0 if MSG fit in BUFLEN, otherwise return ERANGE.  */
 static int
index 0c5cc696805ad5f5487a1fa60f1671d9c35deda9..1d4a653d2c75fecfc77ada0324790fbf657052f2 100644 (file)
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 13
+# strerror_r.m4 serial 14
 dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -43,6 +43,7 @@ AC_DEFUN([gl_PREREQ_STRERROR_R], [
   dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r.
   AC_CHECK_FUNCS_ONCE([__xpg_strerror_r])
   AC_CHECK_FUNCS_ONCE([catgets])
+  AC_CHECK_FUNCS_ONCE([snprintf])
 ])
 
 # Detect if strerror_r works, but without affecting whether a replacement