[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coreutils 6.2
From: |
Jim Meyering |
Subject: |
Re: coreutils 6.2 |
Date: |
Wed, 27 Sep 2006 08:59:51 +0200 |
"Gabor Z. Papp" <address@hidden> wrote:
...
> gcc -std=gnu99 -g -O2 -Wl,--as-needed -o cp cp.o copy.o cp-hash.o
> ../lib/libcoreutils.a ../lib/libcoreutils.a
> ../lib/libcoreutils.a(xstrndup.o): In function `xstrndup':
> /home/gzp/src/coreutils-6.2/lib/xstrndup.c:37: undefined reference to
> `rpl_strndup'
> collect2: ld returned 1 exit status
> make[2]: *** [cp] Error 1
> make[2]: Leaving directory `/home/gzp/src/coreutils-6.2/src'
> make[1]: *** [all] Error 2
> make[1]: Leaving directory `/home/gzp/src/coreutils-6.2/src'
> make: *** [all-recursive] Error 1
Thanks for reporting that.
The above makes me think your tools have incomplete "weak_alias" support,
so that lib/strndup.o ends up with a definition for a function
named __strndup, rather than rpl_strndup.
Gabor, would you please tell us what compiler and libc/OS you're using?
--------------
...
#ifndef weak_alias
# define __strndup strndup
#endif
char *
__strndup (s, n)
const char *s;
size_t n;
{
...
}
#ifdef weak_alias
weak_alias (__strndup, strndup)
#endif
-------------------
If one person (Paul?) signs off on this, I'll check it in
and use it for coreutils-6.3. I've tested it on systems
without strndup. Running one more test, now...
[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.
Index: lib/strndup.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/strndup.c,v
retrieving revision 1.16
diff -u -r1.16 strndup.c
--- lib/strndup.c 13 Sep 2006 22:38:14 -0000 1.16
+++ lib/strndup.c 27 Sep 2006 06:52:31 -0000
@@ -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 address@hidden
+ 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 @@
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
Index: lib/strndup.h
===================================================================
RCS file: /sources/gnulib/gnulib/lib/strndup.h,v
retrieving revision 1.2
diff -u -r1.2 strndup.h
--- lib/strndup.h 14 May 2005 06:03:58 -0000 1.2
+++ lib/strndup.h 27 Sep 2006 06:52:31 -0000
@@ -1,5 +1,5 @@
/* Duplicate a size-bounded string.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 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
@@ -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. */
-#if HAVE_STRNDUP
-
-/* Get strndup() declaration. */
#include <string.h>
-
-#else
-
#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)
+# undef strndup
+# define strndup __STRNDUP_ID (strndup)
+# if !HAVE_DECL_STRNDUP
/* Return a newly allocated copy of at most N bytes of STRING. */
extern char *strndup (const char *string, size_t n);
-
+# endif
#endif
Index: m4/strndup.m4
===================================================================
RCS file: /sources/gnulib/gnulib/m4/strndup.m4,v
retrieving revision 1.10
diff -u -r1.10 strndup.m4
--- m4/strndup.m4 22 Sep 2006 17:26:02 -0000 1.10
+++ m4/strndup.m4 27 Sep 2006 06:52:31 -0000
@@ -1,4 +1,4 @@
-# strndup.m4 serial 9
+# strndup.m4 serial 10
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,9 +39,9 @@
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])
- AC_DEFINE(strndup, rpl_strndup,
- [Define to rpl_strndup if the replacement function should be used,])
gl_PREREQ_STRNDUP
fi
])
- Re: coreutils 6.2,
Jim Meyering <=