diff options
author | Jim Meyering <jim@meyering.net> | 2006-09-28 11:16:05 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-09-28 11:16:05 +0000 |
commit | cdd246abc713a8fd65892452d135ce36ca0aae62 (patch) | |
tree | e2d0ac75e4f75f100ba54f2a073615fe485af5f9 /lib/strndup.c | |
parent | ba6b2865caee98a973cfbb959ed8ebd82f4d74d2 (diff) | |
download | gnulib-cdd246abc713a8fd65892452d135ce36ca0aae62.tar.gz |
[lib/ChangeLog]
This function could end up with a definition for a function
named __strndup, rather than rpl_strndup on a system with
incomplete weak_alias support.
* strndup.c (strndup): Rename from __strndup.
Remove #defines that used to map __strndup to strndup.
Don't use K&R prototypes.
Remove LIBC-related code, since this file is not sync'd with glibc.
* strndup.h: Revamp, accordingly.
[m4/ChangeLog]
* strndup.m4: Modernize.
Diffstat (limited to 'lib/strndup.c')
-rw-r--r-- | lib/strndup.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/lib/strndup.c b/lib/strndup.c index 55cb560361..290f494f4e 100644 --- a/lib/strndup.c +++ b/lib/strndup.c @@ -1,8 +1,7 @@ -/* Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006 Free - Software Foundation, Inc. +/* A replacement function, for systems that lack strndup. - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. + Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006 Free + Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -18,36 +17,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if !_LIBC -# include <config.h> -# include "strndup.h" -#endif +#include <config.h> +#include "strndup.h" #include <stdlib.h> #include <string.h> -#if !_LIBC -# include "strnlen.h" -# ifndef __strnlen -# define __strnlen strnlen -# endif -#endif - -#undef __strndup -#if _LIBC -# undef strndup -#endif - -#ifndef weak_alias -# define __strndup strndup -#endif +#include "strnlen.h" char * -__strndup (s, n) - const char *s; - size_t n; +strndup (char const *s, size_t n) { - size_t len = __strnlen (s, n); + size_t len = strnlen (s, n); char *new = malloc (len + 1); if (new == NULL) @@ -56,9 +37,3 @@ __strndup (s, n) new[len] = '\0'; return memcpy (new, s, len); } -#ifdef libc_hidden_def -libc_hidden_def (__strndup) -#endif -#ifdef weak_alias -weak_alias (__strndup, strndup) -#endif |