changeset 7385:265d7425a7a3

Simplify and document.
author Bruno Haible <bruno@clisp.org>
date Thu, 28 Sep 2006 20:52:13 +0000
parents a89982bfa73d
children 0b46424de74d
files lib/ChangeLog lib/strndup.h m4/ChangeLog m4/strndup.m4
diffstat 4 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
--- a/lib/strndup.h
+++ b/lib/strndup.h
@@ -15,16 +15,17 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
+/* 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>
-#include <stddef.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
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -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.
--- a/m4/strndup.m4
+++ b/m4/strndup.m4
@@ -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_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