From 4e8f63fdaa44e8d2b29a056caae105bcf15a0846 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 27 Jan 2009 10:30:30 +0000 Subject: [PATCH] use gnulib's stpcpy module * bootstrap (modules): Add stpcpy, and pull in gnulib bits: * gnulib/lib/stpcpy.c: New file. * gnulib/m4/stpcpy.m4: New file. * gnulib/lib/Makefile.am: Update. * gnulib/m4/gnulib-cache.m4: Update. * gnulib/m4/gnulib-comp.m4: Update. --- ChangeLog | 10 ++++++++ bootstrap | 1 + gnulib/lib/Makefile.am | 11 ++++++++- gnulib/lib/stpcpy.c | 48 +++++++++++++++++++++++++++++++++++++++ gnulib/m4/gnulib-cache.m4 | 3 ++- gnulib/m4/gnulib-comp.m4 | 4 ++++ gnulib/m4/stpcpy.m4 | 26 +++++++++++++++++++++ 7 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 gnulib/lib/stpcpy.c create mode 100644 gnulib/m4/stpcpy.m4 diff --git a/ChangeLog b/ChangeLog index 15facf3848..68e27dd625 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Jan 27 10:38:09 +0100 2009 Jim Meyering + + use gnulib's stpcpy module + * bootstrap (modules): Add stpcpy, and pull in gnulib bits: + * gnulib/lib/stpcpy.c: New file. + * gnulib/m4/stpcpy.m4: New file. + * gnulib/lib/Makefile.am: Update. + * gnulib/m4/gnulib-cache.m4: Update. + * gnulib/m4/gnulib-comp.m4: Update. + Tue Jan 27 10:38:09 +0100 2009 Jim Meyering update from gnulib diff --git a/bootstrap b/bootstrap index b4eed3ec39..baf52e7dfd 100755 --- a/bootstrap +++ b/bootstrap @@ -85,6 +85,7 @@ random_r send setsockopt socket +stpcpy strndup strerror strsep diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am index 1e23d09858..62ded7b300 100644 --- a/gnulib/lib/Makefile.am +++ b/gnulib/lib/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl --no-vc-files c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton ioctl mkstemp mktempd perror physmem poll posix-shell random_r recv send setsockopt socket strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl --no-vc-files c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton ioctl mkstemp mktempd perror physmem poll posix-shell random_r recv send setsockopt socket stpcpy strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify AUTOMAKE_OPTIONS = 1.5 gnits @@ -733,6 +733,15 @@ EXTRA_DIST += stdlib.in.h ## end gnulib module stdlib +## begin gnulib module stpcpy + + +EXTRA_DIST += stpcpy.c + +EXTRA_libgnu_la_SOURCES += stpcpy.c + +## end gnulib module stpcpy + ## begin gnulib module strdup-posix diff --git a/gnulib/lib/stpcpy.c b/gnulib/lib/stpcpy.c new file mode 100644 index 0000000000..71b5091ed1 --- /dev/null +++ b/gnulib/lib/stpcpy.c @@ -0,0 +1,48 @@ +/* stpcpy.c -- copy a string and return pointer to end of new string + Copyright (C) 1992, 1995, 1997-1998, 2006 Free Software Foundation, Inc. + + 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. + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2.1 of the License, or any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +#include + +#undef __stpcpy +#ifdef _LIBC +# undef stpcpy +#endif + +#ifndef weak_alias +# define __stpcpy stpcpy +#endif + +/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ +char * +__stpcpy (char *dest, const char *src) +{ + register char *d = dest; + register const char *s = src; + + do + *d++ = *s; + while (*s++ != '\0'); + + return d - 1; +} +#ifdef weak_alias +weak_alias (__stpcpy, stpcpy) +#endif diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4 index 74b2139610..43106262eb 100644 --- a/gnulib/m4/gnulib-cache.m4 +++ b/gnulib/m4/gnulib-cache.m4 @@ -15,7 +15,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl --no-vc-files c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton ioctl mkstemp mktempd perror physmem poll posix-shell random_r recv send setsockopt socket strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify +# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl --no-vc-files c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton ioctl mkstemp mktempd perror physmem poll posix-shell random_r recv send setsockopt socket stpcpy strerror strndup strsep sys_stat time_r useless-if-before-free vasprintf vc-list-files verify # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) @@ -40,6 +40,7 @@ gl_MODULES([ send setsockopt socket + stpcpy strerror strndup strsep diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4 index 80281c3c07..9589b93531 100644 --- a/gnulib/m4/gnulib-comp.m4 +++ b/gnulib/m4/gnulib-comp.m4 @@ -138,6 +138,8 @@ AC_SUBST([LTALLOCA]) gl_STDINT_H gl_STDIO_H gl_STDLIB_H + gl_FUNC_STPCPY + gl_STRING_MODULE_INDICATOR([stpcpy]) gl_FUNC_STRDUP_POSIX gl_STRING_MODULE_INDICATOR([strdup]) gl_FUNC_STRERROR @@ -385,6 +387,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stdio-write.c lib/stdio.in.h lib/stdlib.in.h + lib/stpcpy.c lib/strdup.c lib/strerror.c lib/string.in.h @@ -477,6 +480,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdint_h.m4 m4/stdio_h.m4 m4/stdlib_h.m4 + m4/stpcpy.m4 m4/strdup.m4 m4/strerror.m4 m4/string_h.m4 diff --git a/gnulib/m4/stpcpy.m4 b/gnulib/m4/stpcpy.m4 new file mode 100644 index 0000000000..96de86795a --- /dev/null +++ b/gnulib/m4/stpcpy.m4 @@ -0,0 +1,26 @@ +# stpcpy.m4 serial 7 +dnl Copyright (C) 2002, 2007, 2009 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STPCPY], +[ + dnl Persuade glibc to declare stpcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REPLACE_FUNCS([stpcpy]) + if test $ac_cv_func_stpcpy = no; then + HAVE_STPCPY=0 + gl_PREREQ_STPCPY + fi +]) + +# Prerequisites of lib/stpcpy.c. +AC_DEFUN([gl_PREREQ_STPCPY], [ + : +])