[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] strndup patch to assume C89 or better
From: |
Paul Eggert |
Subject: |
Re: [Bug-gnulib] strndup patch to assume C89 or better |
Date: |
11 Sep 2003 01:47:13 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
I installed the following slightly-more-ambitious patch. It also
elides <stdio.h>, <sys/types.h>, and the (char *) cast, all of which
shouldn't be needed on C89 hosts.
2003-09-11 Paul Eggert <address@hidden>
* strndup.c: Don't include <stdio.h>, <sys/types.h>.
Include <stdlib.h>, <string.h> unconditionally.
Remove now-unnecessary cast to char *.
* strndup.m4 (gl_PREREQ_STRNDUP): Remove STDC_HEADERS check.
Index: lib/strndup.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strndup.c,v
retrieving revision 1.9
diff -p -u -r1.9 strndup.c
--- lib/strndup.c 4 Jul 2000 17:37:43 -0000 1.9
+++ lib/strndup.c 11 Sep 2003 08:40:18 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
Library.
Bugs can be reported to address@hidden
@@ -21,15 +21,8 @@
# include "config.h"
#endif
-#include <stdio.h>
-#include <sys/types.h>
-
-#if defined _LIBC || defined STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-char *malloc ();
-#endif
+#include <stdlib.h>
+#include <string.h>
#ifndef HAVE_DECL_STRNLEN
"this configure-time declaration test was not run"
@@ -55,7 +48,7 @@ __strndup (const char *s, size_t n)
return NULL;
new[len] = '\0';
- return (char *) memcpy (new, s, len);
+ return memcpy (new, s, len);
}
#ifdef weak_alias
weak_alias (__strndup, strndup)
Index: m4/strndup.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strndup.m4,v
retrieving revision 1.1
diff -p -u -r1.1 strndup.m4
--- m4/strndup.m4 31 Dec 2002 13:42:07 -0000 1.1
+++ m4/strndup.m4 11 Sep 2003 08:40:18 -0000
@@ -1,5 +1,5 @@
-# strndup.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# strndup.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
@@ -19,7 +19,6 @@ AC_DEFUN([gl_FUNC_STRNDUP],
# Prerequisites of lib/strndup.c.
AC_DEFUN([gl_PREREQ_STRNDUP], [
- AC_REQUIRE([AC_HEADER_STDC])
AC_CHECK_DECLS(strnlen)
])