Simplify and document.
authorBruno Haible <bruno@clisp.org>
Thu, 28 Sep 2006 20:52:13 +0000 (20:52 +0000)
committerBruno Haible <bruno@clisp.org>
Thu, 28 Sep 2006 20:52:13 +0000 (20:52 +0000)
lib/ChangeLog
lib/strndup.h
m4/ChangeLog
m4/strndup.m4

index 5619b15a8194bde3448075f4233c67acaed988c6..0738759c028405b243d58f60b869d33c3aadc612 100644 (file)
@@ -1,3 +1,8 @@
+2006-09-28  Bruno Haible  <bruno@clisp.org>
+
+       * strndup.h: Simplify the redefinition of strndup.
+       (_GL_CONCAT, _GL_XCONCAT, __STRNDUP_ID): Remove macros.
+
 2006-09-28  Bruno Haible  <bruno@clisp.org>
 
        * gl_avltreehash_list.c: Include <stdint.h> instead of size_max.h.
index b8fb3cb317af3e15bd4528305e3ba3b8762ebb2f..b983dd2281c5e56e130b01fe5d21f03a56713a83 100644 (file)
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#include <string.h>
+/* Get size_t.  */
 #include <stddef.h>
+/* If HAVE_STRNDUP, get the strndup declaration.
+   If !HAVE_STRNDUP, include <string.h> now so that it doesn't cause
+   trouble if included later.  */
+#include <string.h>
 
-#ifdef __STRNDUP_PREFIX
-# define _GL_CONCAT(x, y) x ## y
-# define _GL_XCONCAT(x, y) _GL_CONCAT (x, y)
-# define __STRNDUP_ID(y) _GL_XCONCAT (__STRNDUP_PREFIX, y)
+#if !HAVE_STRNDUP
 # undef strndup
-# define strndup __STRNDUP_ID (strndup)
-# if !HAVE_DECL_STRNDUP
+# define strndup rpl_strndup
+# if !HAVE_DECL_STRNDUP  /* Don't risk conflicting declarations.  */
 /* Return a newly allocated copy of at most N bytes of STRING.  */
 extern char *strndup (const char *string, size_t n);
 # endif
index baf5ee94baea7b40e661da4ff25b272e6bff75a7..2999054b1105d7e030c7f5fdd332f0ccc307db7a 100644 (file)
@@ -1,3 +1,7 @@
+2006-09-28  Bruno Haible  <bruno@clisp.org>
+
+       * strndup.m4 (gl_FUNC_STRNDUP): Don't define __STRNDUP_PREFIX.
+
 2006-09-28  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * intmax.m4 (gt_TYPE_INTMAX_T): Avoid unused variables warning.
index 65a50e82148091f0e30521e69536c0d3cb18d5d2..dd5780b6350859e6c151fa86f61525e65670ca33 100644 (file)
@@ -1,4 +1,4 @@
-# strndup.m4 serial 10
+# strndup.m4 serial 11
 dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -39,8 +39,6 @@ AC_DEFUN([gl_FUNC_STRNDUP],
     AC_DEFINE([HAVE_STRNDUP], 1,
       [Define if you have the strndup() function and it works.])
   else
-    AC_DEFINE([__STRNDUP_PREFIX], [[rpl_]],
-      [Define to rpl_ if the strndup replacement function should be used.])
     AC_LIBOBJ([strndup])
     gl_PREREQ_STRNDUP
   fi