From 610209ecb4bfe8127a2557e29c08719ffc007c0d Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 4 May 2022 13:28:00 +0300 Subject: [PATCH] Drop now redundant bundled copies of stpcpy() and stpncpy() stpcpy() and stpncpy() got added to POSIX-1.2008 (surprisingly if you ask me), and as that's the version we require now since commit 96ec957e281220f8e137a2d5eb23b83a6377d556, we don't need to carry this dusty stuff (only touched once since -98...) --- configure.ac | 4 +- misc/Makefile.am | 3 -- misc/stpcpy.c | 51 ------------------------ misc/stpncpy.c | 101 ----------------------------------------------- system.h | 8 ---- 5 files changed, 1 insertion(+), 166 deletions(-) delete mode 100644 misc/stpcpy.c delete mode 100644 misc/stpncpy.c diff --git a/configure.ac b/configure.ac index 3a0182d025..76d2f0c3d2 100644 --- a/configure.ac +++ b/configure.ac @@ -602,15 +602,13 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([extern const char *__progname;], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])) -AC_REPLACE_FUNCS(stpcpy stpncpy) - AC_CHECK_FUNCS([secure_getenv __secure_getenv]) AC_CHECK_FUNCS( [mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown \ utimes getline localtime_r statvfs getaddrinfo \ openat mkdirat fstatat linkat symlinkat mkfifoat mknodat unlinkat \ - renameat utimensat fchmodat fchownat ], + renameat utimensat fchmodat fchownat stpcpy stpncpy ], [], [AC_MSG_ERROR([function required by rpm])]) dnl check if python is requested diff --git a/misc/Makefile.am b/misc/Makefile.am index 3a26d41750..b2adbd829b 100644 --- a/misc/Makefile.am +++ b/misc/Makefile.am @@ -3,9 +3,6 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/include AM_CPPFLAGS += -I$(top_srcdir)/misc -EXTRA_DIST = \ - stpcpy.c stpncpy.c - noinst_LTLIBRARIES = libmisc.la libmisc_la_SOURCES = fts.c rpmfts.h diff --git a/misc/stpcpy.c b/misc/stpcpy.c deleted file mode 100644 index 167d22db84..0000000000 --- a/misc/stpcpy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 1992, 1995, 1997 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 General Public License as published by the - Free Software Foundation; either version 2, or (at your option) 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include - -#undef __stpcpy -#undef stpcpy - -#ifndef weak_alias -# define __stpcpy stpcpy -#endif - -/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ -char * -__stpcpy (dest, src) - 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/misc/stpncpy.c b/misc/stpncpy.c deleted file mode 100644 index cb218e3b58..0000000000 --- a/misc/stpncpy.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright (C) 1993, 1995, 1996, 1997 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 General Public License as published by the - Free Software Foundation; either version 2, or (at your option) 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -/* This is almost copied from strncpy.c, written by Torbjorn Granlund. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifdef _LIBC -# include -#else -# include -#endif - -#ifndef weak_alias -# define __stpncpy stpncpy -#endif - -/* Copy no more than N characters of SRC to DEST, returning the address of - the terminating '\0' in DEST, if any, or else DEST + N. */ -char * -__stpncpy (dest, src, n) - char *dest; - const char *src; - size_t n; -{ - char c; - char *s = dest; - - if (n >= 4) - { - size_t n4 = n >> 2; - - for (;;) - { - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - if (--n4 == 0) - goto last_chars; - } - n -= dest - s; - goto zero_fill; - } - - last_chars: - n &= 3; - if (n == 0) - return dest; - - for (;;) - { - c = *src++; - --n; - *dest++ = c; - if (c == '\0') - break; - if (n == 0) - return dest; - } - - zero_fill: - while (n-- > 0) - dest[n] = '\0'; - - return dest - 1; -} -#ifdef weak_alias -weak_alias (__stpncpy, stpncpy) -#endif diff --git a/system.h b/system.h index 461712a0a4..afdfdbf6ec 100644 --- a/system.h +++ b/system.h @@ -29,14 +29,6 @@ extern char ** environ; #endif #endif -#if !defined(HAVE_STPCPY) -char * stpcpy(char * dest, const char * src); -#endif - -#if !defined(HAVE_STPNCPY) -char * stpncpy(char * dest, const char * src, size_t n); -#endif - #if HAVE_SECURE_GETENV #define getenv(_s) secure_getenv(_s) #elif HAVE___SECURE_GETENV