summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--misc/Makefile.am6
-rw-r--r--misc/basename.c13
-rw-r--r--misc/getcwd.c52
-rw-r--r--misc/getwd.c29
-rw-r--r--misc/realpath.c133
-rw-r--r--rpmio/stubs.c16
-rw-r--r--system.h3
8 files changed, 2 insertions, 252 deletions
diff --git a/configure.ac b/configure.ac
index bda94c0cf..58fe0c751 100644
--- a/configure.ac
+++ b/configure.ac
@@ -555,8 +555,6 @@ AC_CHECK_FUNCS(mtrace)
AC_CHECK_FUNCS(strndup)
AC_CHECK_FUNCS(putenv)
-AC_REPLACE_FUNCS(basename getcwd getwd)
-AC_REPLACE_FUNCS(realpath)
AC_REPLACE_FUNCS(stpcpy stpncpy)
AC_CHECK_FUNCS(__secure_getenv)
diff --git a/misc/Makefile.am b/misc/Makefile.am
index 52ab1e47d..16558258d 100644
--- a/misc/Makefile.am
+++ b/misc/Makefile.am
@@ -4,11 +4,9 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_builddir)/include/rpm
AM_CPPFLAGS += -I$(top_srcdir)/misc
EXTRA_DIST = \
- basename.c \
fakefork.c fnmatch.c fnmatch.h \
- getcwd.c getmntent.c \
- getwd.c glob.c glob.h \
- realpath.c stpcpy.c stpncpy.c
+ getmntent.c glob.c glob.h \
+ stpcpy.c stpncpy.c
noinst_LTLIBRARIES = libmisc.la
diff --git a/misc/basename.c b/misc/basename.c
deleted file mode 100644
index a948859f9..000000000
--- a/misc/basename.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-char *
-basename(const char *file)
-{
- char *fn = strrchr(file, '/');
- return fn ? fn+1 : (char *)file;
-}
diff --git a/misc/getcwd.c b/misc/getcwd.c
deleted file mode 100644
index 60c1dd84e..000000000
--- a/misc/getcwd.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Emulate getcwd using getwd.
- This function is in the public domain. */
-
-/*
-NAME
- getcwd -- get absolute pathname for current working directory
-
-SYNOPSIS
- char *getcwd (char pathname[len], len)
-
-DESCRIPTION
- Copy the absolute pathname for the current working directory into
- the supplied buffer and return a pointer to the buffer. If the
- current directory's path doesn't fit in LEN characters, the result
- is NULL and errno is set.
-
-BUGS
- Emulated via the getwd() call, which is reasonable for most
- systems that do not have getcwd().
-
-*/
-
-#ifndef NO_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#include <errno.h>
-
-extern char *getwd ();
-extern int errno;
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif
-
-char *
-getcwd (buf, len)
- char *buf;
- int len;
-{
- char ourbuf[MAXPATHLEN];
- char *result;
-
- result = getwd (ourbuf);
- if (result) {
- if (strlen (ourbuf) >= len) {
- errno = ERANGE;
- return 0;
- }
- strcpy (buf, ourbuf);
- }
- return buf;
-}
diff --git a/misc/getwd.c b/misc/getwd.c
deleted file mode 100644
index a7a64b82d..000000000
--- a/misc/getwd.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* getwd.c -- get current working directory pathname
- Copyright (C) 1992 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 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. */
-
-/* Some systems which include both getwd() and getcwd() have an implementation
- of getwd() which is much faster than getcwd(). As a result, we use the
- system's getwd() if it is available */
-
-#include "system.h"
-
-/* Get the current working directory into PATHNAME */
-
-char *
-getwd (pathname)
- char *pathname;
-{
- char *getcwd();
-
- return (getcwd(pathname, PATH_MAX));
-}
diff --git a/misc/realpath.c b/misc/realpath.c
deleted file mode 100644
index c0908d3a1..000000000
--- a/misc/realpath.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * realpath.c -- canonicalize pathname by removing symlinks
- * Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library 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 Library Public License for more details.
- */
-
-#include "system.h"
-
-#ifndef STDC_HEADERS
-extern int errno;
-#endif
-
-#define MAX_READLINKS 32
-
-#ifdef __STDC__
-char *realpath(const char *path, char resolved_path [])
-#else
-char *realpath(path, resolved_path)
-const char *path;
-char resolved_path [];
-#endif
-{
- char copy_path[PATH_MAX];
- char link_path[PATH_MAX];
- char *new_path = resolved_path;
- char *max_path;
- int readlinks = 0;
- int n;
-
- /* Make a copy of the source path since we may need to modify it. */
- strcpy(copy_path, path);
- path = copy_path;
- max_path = copy_path + PATH_MAX - 2;
- /* If it's a relative pathname use getwd for starters. */
- if (*path != '/') {
-#ifdef HAVE_GETCWD
- getcwd(new_path, PATH_MAX - 1);
-#else
- getwd(new_path);
-#endif
- new_path += strlen(new_path);
- if (new_path[-1] != '/')
- *new_path++ = '/';
- }
- else {
- *new_path++ = '/';
- path++;
- }
- /* Expand each slash-separated pathname component. */
- while (*path != '\0') {
- /* Ignore stray "/". */
- if (*path == '/') {
- path++;
- continue;
- }
- if (*path == '.') {
- /* Ignore ".". */
- if (path[1] == '\0' || path[1] == '/') {
- path++;
- continue;
- }
- if (path[1] == '.') {
- if (path[2] == '\0' || path[2] == '/') {
- path += 2;
- /* Ignore ".." at root. */
- if (new_path == resolved_path + 1)
- continue;
- /* Handle ".." by backing up. */
- while ((--new_path)[-1] != '/');
- continue;
- }
- }
- }
- /* Safely copy the next pathname component. */
- while (*path != '\0' && *path != '/') {
- if (path > max_path) {
- errno = ENAMETOOLONG;
- return NULL;
- }
- *new_path++ = *path++;
- }
-#ifdef S_IFLNK
- /* Protect against infinite loops. */
- if (readlinks++ > MAX_READLINKS) {
- errno = ELOOP;
- return NULL;
- }
- /* See if latest pathname component is a symlink. */
- *new_path = '\0';
- n = readlink(resolved_path, link_path, PATH_MAX - 1);
- if (n < 0) {
- /* EINVAL means the file exists but isn't a symlink. */
- if (errno != EINVAL)
- return NULL;
- }
- else {
- /* Note: readlink doesn't add the null byte. */
- link_path[n] = '\0';
- if (*link_path == '/')
- /* Start over for an absolute symlink. */
- new_path = resolved_path;
- else
- /* Otherwise back up over this component. */
- while (*(--new_path) != '/');
- /* Safe sex check. */
- if (strlen(path) + n >= PATH_MAX) {
- errno = ENAMETOOLONG;
- return NULL;
- }
- /* Insert symlink contents into path. */
- strcat(link_path, path);
- strcpy(copy_path, link_path);
- path = copy_path;
- }
-#endif /* S_IFLNK */
- *new_path++ = '/';
- }
- /* Delete trailing slash but don't whomp a lone slash. */
- if (new_path != resolved_path + 1 && new_path[-1] == '/')
- new_path--;
- /* Make sure it's null terminated. */
- *new_path = '\0';
- return resolved_path;
-}
diff --git a/rpmio/stubs.c b/rpmio/stubs.c
index 4b988c546..9c3f7b454 100644
--- a/rpmio/stubs.c
+++ b/rpmio/stubs.c
@@ -6,26 +6,10 @@
#include "system.h"
-#if !defined(HAVE_BASENAME)
-#include "misc/basename.c"
-#endif
-
-#if !defined(HAVE_GETCWD)
-#include "misc/getcwd.c"
-#endif
-
-#if !defined(HAVE_GETWD)
-#include "misc/getwd.c"
-#endif
-
#if defined(USE_GETMNTENT)
#include "misc/getmntent.c"
#endif
-#if !defined(HAVE_REALPATH)
-#include "misc/realpath.c"
-#endif
-
#if !defined(HAVE_STPCPY)
#include "misc/stpcpy.c"
#endif
diff --git a/system.h b/system.h
index 142d8a454..0269d2741 100644
--- a/system.h
+++ b/system.h
@@ -76,9 +76,6 @@ extern int errno;
#undef getopt
#else /* not STDC_HEADERS */
char *getenv (const char *name);
-#if ! HAVE_REALPATH
-char *realpath(const char *path, char resolved_path []);
-#endif
#endif /* STDC_HEADERS */
/* XXX solaris2.5.1 has not */