From 7d55c47ce0f411471680f28b367e11b9b1937702 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 14 Oct 2007 21:15:25 +0100 Subject: import gnulib xgetcwd module; replace getcwd_allocated with xgetcwd --- gnulib/lib/Makefile.am | 29 ++- gnulib/lib/Makefile.in | 40 ++-- gnulib/lib/dirfd.c | 29 +++ gnulib/lib/dirfd.h | 29 +++ gnulib/lib/getcwd.c | 428 ++++++++++++++++++++++++++++++++++++++++++ gnulib/lib/xgetcwd.c | 41 ++++ gnulib/lib/xgetcwd.h | 18 ++ gnulib/m4/d-ino.m4 | 41 ++++ gnulib/m4/dirfd.m4 | 74 ++++++++ gnulib/m4/getcwd-abort-bug.m4 | 106 +++++++++++ gnulib/m4/getcwd-path-max.m4 | 190 +++++++++++++++++++ gnulib/m4/getcwd.m4 | 64 +++++++ gnulib/m4/gnulib-cache.m4 | 4 +- gnulib/m4/gnulib-comp.m4 | 16 ++ gnulib/m4/xgetcwd.m4 | 12 ++ 15 files changed, 1103 insertions(+), 18 deletions(-) create mode 100644 gnulib/lib/dirfd.c create mode 100644 gnulib/lib/dirfd.h create mode 100644 gnulib/lib/getcwd.c create mode 100644 gnulib/lib/xgetcwd.c create mode 100644 gnulib/lib/xgetcwd.h create mode 100644 gnulib/m4/d-ino.m4 create mode 100644 gnulib/m4/dirfd.m4 create mode 100644 gnulib/m4/getcwd-abort-bug.m4 create mode 100644 gnulib/m4/getcwd-path-max.m4 create mode 100644 gnulib/m4/getcwd.m4 create mode 100644 gnulib/m4/xgetcwd.m4 (limited to 'gnulib') diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am index fbf81ae2..c4e504c7 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 --aux-dir=tools --no-libtool --macro-prefix=gl error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xstrndup +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=tools --no-libtool --macro-prefix=gl error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xgetcwd xstrndup AUTOMAKE_OPTIONS = 1.5 gnits @@ -71,6 +71,15 @@ EXTRA_DIST += alloca_.h ## end gnulib module alloca-opt +## begin gnulib module dirfd + + +EXTRA_DIST += dirfd.c dirfd.h + +EXTRA_libgnu_a_SOURCES += dirfd.c + +## end gnulib module dirfd + ## begin gnulib module error @@ -108,6 +117,15 @@ EXTRA_libgnu_a_SOURCES += fnmatch.c fnmatch_loop.c ## end gnulib module fnmatch +## begin gnulib module getcwd + + +EXTRA_DIST += getcwd.c + +EXTRA_libgnu_a_SOURCES += getcwd.c + +## end gnulib module getcwd + ## begin gnulib module getlogin_r @@ -594,6 +612,15 @@ libgnu_a_SOURCES += xalloc-die.c ## end gnulib module xalloc-die +## begin gnulib module xgetcwd + + +EXTRA_DIST += xgetcwd.c xgetcwd.h + +EXTRA_libgnu_a_SOURCES += xgetcwd.c + +## end gnulib module xgetcwd + ## begin gnulib module xstrndup libgnu_a_SOURCES += xstrndup.h xstrndup.c diff --git a/gnulib/lib/Makefile.in b/gnulib/lib/Makefile.in index 01b16e57..06653b7f 100644 --- a/gnulib/lib/Makefile.in +++ b/gnulib/lib/Makefile.in @@ -23,7 +23,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 --aux-dir=tools --no-libtool --macro-prefix=gl error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xstrndup +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=tools --no-libtool --macro-prefix=gl error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xgetcwd xstrndup @@ -50,12 +50,17 @@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in alloca.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/alloca.m4 \ + $(top_srcdir)/gnulib/m4/d-ino.m4 \ $(top_srcdir)/gnulib/m4/d-type.m4 \ + $(top_srcdir)/gnulib/m4/dirfd.m4 \ $(top_srcdir)/gnulib/m4/eealloc.m4 \ $(top_srcdir)/gnulib/m4/error.m4 \ $(top_srcdir)/gnulib/m4/exitfail.m4 \ $(top_srcdir)/gnulib/m4/extensions.m4 \ $(top_srcdir)/gnulib/m4/fnmatch.m4 \ + $(top_srcdir)/gnulib/m4/getcwd-abort-bug.m4 \ + $(top_srcdir)/gnulib/m4/getcwd-path-max.m4 \ + $(top_srcdir)/gnulib/m4/getcwd.m4 \ $(top_srcdir)/gnulib/m4/getlogin_r.m4 \ $(top_srcdir)/gnulib/m4/getopt.m4 \ $(top_srcdir)/gnulib/m4/gettimeofday.m4 \ @@ -87,6 +92,7 @@ am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/alloca.m4 \ $(top_srcdir)/gnulib/m4/wchar.m4 \ $(top_srcdir)/gnulib/m4/wctype.m4 \ $(top_srcdir)/gnulib/m4/xalloc.m4 \ + $(top_srcdir)/gnulib/m4/xgetcwd.m4 \ $(top_srcdir)/gnulib/m4/xstrndup.m4 \ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \ @@ -463,15 +469,16 @@ AUTOMAKE_OPTIONS = 1.5 gnits noinst_HEADERS = noinst_LIBRARIES = libgnu.a noinst_LTLIBRARIES = -EXTRA_DIST = alloca.c alloca_.h error.c error.h exitfail.c exitfail.h \ - fnmatch.c fnmatch_.h fnmatch_loop.c getlogin_r.c getopt.c \ - getopt1.c getopt_.h getopt_int.h gettimeofday.c glob-libc.h \ - glob.c glob_.h $(top_srcdir)/tools/link-warning.h malloc.c \ - malloca.h malloca.valgrind memcmp.c mempcpy.c mkdtemp.c \ - mkstemp.c setenv.c setenv.h unsetenv.c stdbool_.h stdint_.h \ - stdlib_.h strcspn.c strdup.c string_.h strndup.c strnlen.c \ - sys_stat_.h sys_time_.h tempname.c tempname.h unistd_.h \ - wchar_.h wctype_.h xalloc.h xmalloc.c +EXTRA_DIST = alloca.c alloca_.h dirfd.c dirfd.h error.c error.h \ + exitfail.c exitfail.h fnmatch.c fnmatch_.h fnmatch_loop.c \ + getcwd.c getlogin_r.c getopt.c getopt1.c getopt_.h \ + getopt_int.h gettimeofday.c glob-libc.h glob.c glob_.h \ + $(top_srcdir)/tools/link-warning.h malloc.c malloca.h \ + malloca.valgrind memcmp.c mempcpy.c mkdtemp.c mkstemp.c \ + setenv.c setenv.h unsetenv.c stdbool_.h stdint_.h stdlib_.h \ + strcspn.c strdup.c string_.h strndup.c strnlen.c sys_stat_.h \ + sys_time_.h tempname.c tempname.h unistd_.h wchar_.h wctype_.h \ + xalloc.h xmalloc.c xgetcwd.c xgetcwd.h BUILT_SOURCES = $(ALLOCA_H) $(FNMATCH_H) $(GETOPT_H) $(GLOB_H) \ $(STDBOOL_H) $(STDINT_H) stdlib.h string.h $(SYS_STAT_H) \ $(SYS_TIME_H) unistd.h $(WCHAR_H) $(WCTYPE_H) @@ -490,11 +497,11 @@ libgnu_a_SOURCES = gettext.h malloca.c xalloc-die.c xstrndup.h \ xstrndup.c libgnu_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@ libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@ -EXTRA_libgnu_a_SOURCES = alloca.c error.c exitfail.c fnmatch.c \ - fnmatch_loop.c getlogin_r.c getopt.c getopt1.c gettimeofday.c \ - glob.c malloc.c memcmp.c mempcpy.c mkdtemp.c mkstemp.c \ - setenv.c unsetenv.c strcspn.c strdup.c strndup.c strnlen.c \ - tempname.c xmalloc.c +EXTRA_libgnu_a_SOURCES = alloca.c dirfd.c error.c exitfail.c fnmatch.c \ + fnmatch_loop.c getcwd.c getlogin_r.c getopt.c getopt1.c \ + gettimeofday.c glob.c malloc.c memcmp.c mempcpy.c mkdtemp.c \ + mkstemp.c setenv.c unsetenv.c strcspn.c strdup.c strndup.c \ + strnlen.c tempname.c xmalloc.c xgetcwd.c # Use this preprocessor expression to decide whether #include_next works. # Do not rely on a 'configure'-time test for this, since the expression @@ -560,10 +567,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch_loop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getcwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getlogin_r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ @@ -583,6 +592,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tempname.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xalloc-die.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetcwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrndup.Po@am__quote@ diff --git a/gnulib/lib/dirfd.c b/gnulib/lib/dirfd.c new file mode 100644 index 00000000..06cb3c46 --- /dev/null +++ b/gnulib/lib/dirfd.c @@ -0,0 +1,29 @@ +/* dirfd.c -- return the file descriptor associated with an open DIR* + + Copyright (C) 2001, 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#include + +#include "dirfd.h" + +int +dirfd (DIR const *dir_p) +{ + return DIR_TO_FD (dir_p); +} diff --git a/gnulib/lib/dirfd.h b/gnulib/lib/dirfd.h new file mode 100644 index 00000000..05b77774 --- /dev/null +++ b/gnulib/lib/dirfd.h @@ -0,0 +1,29 @@ +/* Declare dirfd, if necessary. + Copyright (C) 2001, 2002, 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Written by Jim Meyering. */ + +#include + +#include + +#ifndef HAVE_DECL_DIRFD +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_DIRFD && !defined dirfd +int dirfd (DIR const *); +#endif diff --git a/gnulib/lib/getcwd.c b/gnulib/lib/getcwd.c new file mode 100644 index 00000000..23b35de6 --- /dev/null +++ b/gnulib/lib/getcwd.c @@ -0,0 +1,428 @@ +/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004,2005,2006,2007 Free Software + Foundation, Inc. + This file is part of the GNU C Library. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#if !_LIBC +# include +# include +# include "dirfd.h" +#endif + +#include +#include +#include +#include +#include + +#include /* For AT_FDCWD on Solaris 9. */ + +#ifndef __set_errno +# define __set_errno(val) (errno = (val)) +#endif + +#include +#ifndef _D_EXACT_NAMLEN +# define _D_EXACT_NAMLEN(d) strlen ((d)->d_name) +#endif +#ifndef _D_ALLOC_NAMLEN +# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1) +#endif + +#include +#include +#include + +#if _LIBC +# ifndef mempcpy +# define mempcpy __mempcpy +# endif +#endif + +#include + +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + +#ifdef ENAMETOOLONG +# define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG) +#else +# define is_ENAMETOOLONG(x) 0 +#endif + +#ifndef MAX +# define MAX(a, b) ((a) < (b) ? (b) : (a)) +#endif +#ifndef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif +#endif + +#if D_INO_IN_DIRENT +# define MATCHING_INO(dp, ino) ((dp)->d_ino == (ino)) +#else +# define MATCHING_INO(dp, ino) true +#endif + +#if !_LIBC +# define __getcwd getcwd +# define __lstat lstat +# define __closedir closedir +# define __opendir opendir +# define __readdir readdir +#endif + +/* The results of opendir() in this file are not used with dirfd and fchdir, + therefore save some unnecessary recursion in fchdir.c. */ +#undef opendir +#undef closedir + +/* Get the name of the current working directory, and put it in SIZE + bytes of BUF. Returns NULL if the directory couldn't be determined or + SIZE was too small. If successful, returns BUF. In GNU, if BUF is + NULL, an array is allocated with `malloc'; the array is SIZE bytes long, + unless SIZE == 0, in which case it is as big as necessary. */ + +char * +__getcwd (char *buf, size_t size) +{ + /* Lengths of big file name components and entire file names, and a + deep level of file name nesting. These numbers are not upper + bounds; they are merely large values suitable for initial + allocations, designed to be large enough for most real-world + uses. */ + enum + { + BIG_FILE_NAME_COMPONENT_LENGTH = 255, + BIG_FILE_NAME_LENGTH = MIN (4095, PATH_MAX - 1), + DEEP_NESTING = 100 + }; + +#ifdef AT_FDCWD + int fd = AT_FDCWD; + bool fd_needs_closing = false; +#else + char dots[DEEP_NESTING * sizeof ".." + BIG_FILE_NAME_COMPONENT_LENGTH + 1]; + char *dotlist = dots; + size_t dotsize = sizeof dots; + size_t dotlen = 0; +#endif + DIR *dirstream = NULL; + dev_t rootdev, thisdev; + ino_t rootino, thisino; + char *dir; + register char *dirp; + struct stat st; + size_t allocated = size; + size_t used; + +#if HAVE_PARTLY_WORKING_GETCWD + /* The system getcwd works, except it sometimes fails when it + shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT. If + AT_FDCWD is not defined, the algorithm below is O(N**2) and this + is much slower than the system getcwd (at least on GNU/Linux). + So trust the system getcwd's results unless they look + suspicious. + + Use the system getcwd even if we have openat support, since the + system getcwd works even when a parent is unreadable, while the + openat-based approach does not. */ + +# undef getcwd + dir = getcwd (buf, size); + if (dir || (errno != ERANGE && !is_ENAMETOOLONG (errno) && errno != ENOENT)) + return dir; +#endif + + if (size == 0) + { + if (buf != NULL) + { + __set_errno (EINVAL); + return NULL; + } + + allocated = BIG_FILE_NAME_LENGTH + 1; + } + + if (buf == NULL) + { + dir = malloc (allocated); + if (dir == NULL) + return NULL; + } + else + dir = buf; + + dirp = dir + allocated; + *--dirp = '\0'; + + if (__lstat (".", &st) < 0) + goto lose; + thisdev = st.st_dev; + thisino = st.st_ino; + + if (__lstat ("/", &st) < 0) + goto lose; + rootdev = st.st_dev; + rootino = st.st_ino; + + while (!(thisdev == rootdev && thisino == rootino)) + { + struct dirent *d; + dev_t dotdev; + ino_t dotino; + bool mount_point; + int parent_status; + size_t dirroom; + size_t namlen; + bool use_d_ino = true; + + /* Look at the parent directory. */ +#ifdef AT_FDCWD + fd = openat (fd, "..", O_RDONLY); + if (fd < 0) + goto lose; + fd_needs_closing = true; + parent_status = fstat (fd, &st); +#else + dotlist[dotlen++] = '.'; + dotlist[dotlen++] = '.'; + dotlist[dotlen] = '\0'; + parent_status = __lstat (dotlist, &st); +#endif + if (parent_status != 0) + goto lose; + + if (dirstream && __closedir (dirstream) != 0) + { + dirstream = NULL; + goto lose; + } + + /* Figure out if this directory is a mount point. */ + dotdev = st.st_dev; + dotino = st.st_ino; + mount_point = dotdev != thisdev; + + /* Search for the last directory. */ +#ifdef AT_FDCWD + dirstream = fdopendir (fd); + if (dirstream == NULL) + goto lose; + /* Reset fd. It may have been closed by fdopendir. */ + fd = dirfd (dirstream); + fd_needs_closing = false; +#else + dirstream = __opendir (dotlist); + if (dirstream == NULL) + goto lose; + dotlist[dotlen++] = '/'; +#endif + for (;;) + { + /* Clear errno to distinguish EOF from error if readdir returns + NULL. */ + __set_errno (0); + d = __readdir (dirstream); + + /* When we've iterated through all directory entries without finding + one with a matching d_ino, rewind the stream and consider each + name again, but this time, using lstat. This is necessary in a + chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where + .., ../.., ../../.., etc. all had the same device number, yet the + d_ino values for entries in / did not match those obtained + via lstat. */ + if (d == NULL && errno == 0 && use_d_ino) + { + use_d_ino = false; + rewinddir (dirstream); + d = __readdir (dirstream); + } + + if (d == NULL) + { + if (errno == 0) + /* EOF on dirstream, which can mean e.g., that the current + directory has been removed. */ + __set_errno (ENOENT); + goto lose; + } + if (d->d_name[0] == '.' && + (d->d_name[1] == '\0' || + (d->d_name[1] == '.' && d->d_name[2] == '\0'))) + continue; + + if (use_d_ino) + { + bool match = (MATCHING_INO (d, thisino) || mount_point); + if (! match) + continue; + } + + { + int entry_status; +#ifdef AT_FDCWD + entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW); +#else + /* Compute size needed for this file name, or for the file + name ".." in the same directory, whichever is larger. + Room for ".." might be needed the next time through + the outer loop. */ + size_t name_alloc = _D_ALLOC_NAMLEN (d); + size_t filesize = dotlen + MAX (sizeof "..", name_alloc); + + if (filesize < dotlen) + goto memory_exhausted; + + if (dotsize < filesize) + { + /* My, what a deep directory tree you have, Grandma. */ + size_t newsize = MAX (filesize, dotsize * 2); + size_t i; + if (newsize < dotsize) + goto memory_exhausted; + if (dotlist != dots) + free (dotlist); + dotlist = malloc (newsize); + if (dotlist == NULL) + goto lose; + dotsize = newsize; + + i = 0; + do + { + dotlist[i++] = '.'; + dotlist[i++] = '.'; + dotlist[i++] = '/'; + } + while (i < dotlen); + } + + memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d)); + entry_status = __lstat (dotlist, &st); +#endif + /* We don't fail here if we cannot stat() a directory entry. + This can happen when (network) file systems fail. If this + entry is in fact the one we are looking for we will find + out soon as we reach the end of the directory without + having found anything. */ + if (entry_status == 0 && S_ISDIR (st.st_mode) + && st.st_dev == thisdev && st.st_ino == thisino) + break; + } + } + + dirroom = dirp - dir; + namlen = _D_EXACT_NAMLEN (d); + + if (dirroom <= namlen) + { + if (size != 0) + { + __set_errno (ERANGE); + goto lose; + } + else + { + char *tmp; + size_t oldsize = allocated; + + allocated += MAX (allocated, namlen); + if (allocated < oldsize + || ! (tmp = realloc (dir, allocated))) + goto memory_exhausted; + + /* Move current contents up to the end of the buffer. + This is guaranteed to be non-overlapping. */ + dirp = memcpy (tmp + allocated - (oldsize - dirroom), + tmp + dirroom, + oldsize - dirroom); + dir = tmp; + } + } + dirp -= namlen; + memcpy (dirp, d->d_name, namlen); + *--dirp = '/'; + + thisdev = dotdev; + thisino = dotino; + } + + if (dirstream && __closedir (dirstream) != 0) + { + dirstream = NULL; + goto lose; + } + + if (dirp == &dir[allocated - 1]) + *--dirp = '/'; + +#ifndef AT_FDCWD + if (dotlist != dots) + free (dotlist); +#endif + + used = dir + allocated - dirp; + memmove (dir, dirp, used); + + if (size == 0) + /* Ensure that the buffer is only as large as necessary. */ + buf = realloc (dir, used); + + if (buf == NULL) + /* Either buf was NULL all along, or `realloc' failed but + we still have the original string. */ + buf = dir; + + return buf; + + memory_exhausted: + __set_errno (ENOMEM); + lose: + { + int save = errno; + if (dirstream) + __closedir (dirstream); +#ifdef AT_FDCWD + if (fd_needs_closing) + close (fd); +#else + if (dotlist != dots) + free (dotlist); +#endif + if (buf == NULL) + free (dir); + __set_errno (save); + } + return NULL; +} + +#ifdef weak_alias +weak_alias (__getcwd, getcwd) +#endif diff --git a/gnulib/lib/xgetcwd.c b/gnulib/lib/xgetcwd.c new file mode 100644 index 00000000..26ea5da5 --- /dev/null +++ b/gnulib/lib/xgetcwd.c @@ -0,0 +1,41 @@ +/* xgetcwd.c -- return current directory with unlimited length + + Copyright (C) 2001, 2003, 2004, 2006, 2007 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. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#include + +#include "xgetcwd.h" + +#include +#include + +#include "xalloc.h" + +/* Return the current directory, newly allocated. + Upon an out-of-memory error, call xalloc_die. + Upon any other type of error, return NULL. */ + +char * +xgetcwd (void) +{ + char *cwd = getcwd (NULL, 0); + if (! cwd && errno == ENOMEM) + xalloc_die (); + return cwd; +} diff --git a/gnulib/lib/xgetcwd.h b/gnulib/lib/xgetcwd.h new file mode 100644 index 00000000..70afe35e --- /dev/null +++ b/gnulib/lib/xgetcwd.h @@ -0,0 +1,18 @@ +/* prototype for xgetcwd + Copyright (C) 1995, 2001, 2003 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. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +extern char *xgetcwd (void); diff --git a/gnulib/m4/d-ino.m4 b/gnulib/m4/d-ino.m4 new file mode 100644 index 00000000..6e6dab3d --- /dev/null +++ b/gnulib/m4/d-ino.m4 @@ -0,0 +1,41 @@ +#serial 10 + +dnl From Jim Meyering. +dnl +dnl Check whether struct dirent has a member named d_ino. +dnl + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2006, 2007 Free Software +# Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO], + [AC_CACHE_CHECK([for d_ino member in directory struct], + gl_cv_struct_dirent_d_ino, + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + ]], + [[DIR *dp = opendir ("."); + struct dirent *e; + struct stat st; + if (! dp) + return 1; + e = readdir (dp); + return ! (e + && stat (e->d_name, &st) == 0 + && e->d_ino == st.st_ino);]])], + [gl_cv_struct_dirent_d_ino=yes], + [gl_cv_struct_dirent_d_ino=no], + [gl_cv_struct_dirent_d_ino=no])]) + if test $gl_cv_struct_dirent_d_ino = yes; then + AC_DEFINE(D_INO_IN_DIRENT, 1, + [Define if struct dirent has a member d_ino that actually works.]) + fi + ] +) diff --git a/gnulib/m4/dirfd.m4 b/gnulib/m4/dirfd.m4 new file mode 100644 index 00000000..125966b1 --- /dev/null +++ b/gnulib/m4/dirfd.m4 @@ -0,0 +1,74 @@ +#serial 14 -*- Autoconf -*- + +dnl Find out how to get the file descriptor associated with an open DIR*. + +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering + +AC_DEFUN([gl_FUNC_DIRFD], +[ + dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. + AC_REQUIRE([AC_PROG_CPP]) + AC_REQUIRE([AC_PROG_EGREP]) + AC_CHECK_FUNCS(dirfd) + AC_CHECK_DECLS([dirfd], , , + [#include + #include ]) + + AC_CACHE_CHECK([whether dirfd is a macro], + gl_cv_func_dirfd_macro, + [AC_EGREP_CPP([dirent_header_defines_dirfd], [ +#include +#include +#ifdef dirfd + dirent_header_defines_dirfd +#endif], + gl_cv_func_dirfd_macro=yes, + gl_cv_func_dirfd_macro=no)]) + + # Use the replacement only if we have no function, macro, + # or declaration with that name. + if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$gl_cv_func_dirfd_macro \ + = no,no,no; then + AC_REPLACE_FUNCS([dirfd]) + AC_CACHE_CHECK( + [how to get the file descriptor associated with an open DIR*], + gl_cv_sys_dir_fd_member_name, + [ + dirfd_save_CFLAGS=$CFLAGS + for ac_expr in d_fd dd_fd; do + + CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" + AC_TRY_COMPILE( + [#include + #include ], + [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;], + dir_fd_found=yes + ) + CFLAGS=$dirfd_save_CFLAGS + test "$dir_fd_found" = yes && break + done + test "$dir_fd_found" = yes || ac_expr=no_such_member + + gl_cv_sys_dir_fd_member_name=$ac_expr + ] + ) + if test $gl_cv_sys_dir_fd_member_name != no_such_member; then + AC_DEFINE_UNQUOTED(DIR_FD_MEMBER_NAME, + $gl_cv_sys_dir_fd_member_name, + [the name of the file descriptor member of DIR]) + fi + AH_VERBATIM(DIR_TO_FD, + [#ifdef DIR_FD_MEMBER_NAME +# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME) +#else +# define DIR_TO_FD(Dir_p) -1 +#endif +]) + fi +]) diff --git a/gnulib/m4/getcwd-abort-bug.m4 b/gnulib/m4/getcwd-abort-bug.m4 new file mode 100644 index 00000000..a431a7cc --- /dev/null +++ b/gnulib/m4/getcwd-abort-bug.m4 @@ -0,0 +1,106 @@ +#serial 1 +# Determine whether getcwd aborts when the length of the working directory +# name is unusually large. Any length between 4k and 16k trigger the bug +# when using glibc-2.4.90-9 or older. + +# Copyright (C) 2006 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# From Jim Meyering + +# gl_FUNC_GETCWD_ABORT_BUG([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG], +[ + AC_CHECK_DECLS_ONCE(getcwd) + AC_CHECK_FUNCS(getpagesize) + AC_CACHE_CHECK([whether getcwd aborts when 4k < cwd_length < 16k], + gl_cv_func_getcwd_abort_bug, + [# Remove any remnants of a previous test. + rm -rf confdir-14B--- + # Arrange for deletion of the temporary directory this test creates. + ac_clean_files="$ac_clean_files confdir-14B---" + AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[ +#include +#include +#include +#include +#include + +/* Don't get link errors because mkdir is redefined to rpl_mkdir. */ +#undef mkdir + +#ifndef S_IRWXU +# define S_IRWXU 0700 +#endif + +/* FIXME: skip the run-test altogether on systems without getpagesize. */ +#if ! HAVE_GETPAGESIZE +# define getpagesize() 0 +#endif + +/* This size is chosen to be larger than PATH_MAX (4k), yet smaller than + the 16kB pagesize on ia64 linux. Those conditions make the code below + trigger a bug in glibc's getcwd implementation before 2.4.90-10. */ +#define TARGET_LEN (5 * 1024) + +int +main () +{ + char const *dir_name = "confdir-14B---"; + char *cwd; + size_t initial_cwd_len; + int fail = 0; + size_t desired_depth; + size_t d; + + /* The bug is triggered when PATH_MAX < getpagesize (), so skip + this relative expensive and invasive test if that's not true. */ + if (getpagesize () <= PATH_MAX) + return 0; + + cwd = getcwd (NULL, 0); + if (cwd == NULL) + return 0; + + initial_cwd_len = strlen (cwd); + free (cwd); + desired_depth = ((TARGET_LEN - 1 - initial_cwd_len) + / (1 + strlen (dir_name))); + for (d = 0; d < desired_depth; d++) + { + if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0) + { + fail = 3; /* Unable to construct deep hierarchy. */ + break; + } + } + + /* If libc has the bug in question, this invocation of getcwd + results in a failed assertion. */ + cwd = getcwd (NULL, 0); + if (cwd == NULL) + fail = 4; /* getcwd failed. This is ok, and expected. */ + free (cwd); + + /* Call rmdir first, in case the above chdir failed. */ + rmdir (dir_name); + while (0 < d--) + { + if (chdir ("..") < 0) + break; + rmdir (dir_name); + } + + return 0; +} + ]])], + [gl_cv_func_getcwd_abort_bug=no], + [gl_cv_func_getcwd_abort_bug=yes], + [gl_cv_func_getcwd_abort_bug=yes]) + ]) + AS_IF([test $gl_cv_func_getcwd_abort_bug = yes], [$1], [$2]) +]) diff --git a/gnulib/m4/getcwd-path-max.m4 b/gnulib/m4/getcwd-path-max.m4 new file mode 100644 index 00000000..5e6d58bd --- /dev/null +++ b/gnulib/m4/getcwd-path-max.m4 @@ -0,0 +1,190 @@ +#serial 13 +# Check for several getcwd bugs with long file names. +# If so, arrange to compile the wrapper function. + +# This is necessary for at least GNU libc on linux-2.4.19 and 2.4.20. +# I've heard that this is due to a Linux kernel bug, and that it has +# been fixed between 2.4.21-pre3 and 2.4.21-pre4. */ + +# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# From Jim Meyering + +AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX], +[ + AC_CHECK_DECLS_ONCE(getcwd) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CACHE_CHECK([whether getcwd handles long file names properly], + gl_cv_func_getcwd_path_max, + [# Arrange for deletion of the temporary directory this test creates. + ac_clean_files="$ac_clean_files confdir3" + AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef AT_FDCWD +# define AT_FDCWD 0 +#endif +#ifdef ENAMETOOLONG +# define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG) +#else +# define is_ENAMETOOLONG(x) 0 +#endif + +/* Don't get link errors because mkdir is redefined to rpl_mkdir. */ +#undef mkdir + +#ifndef S_IRWXU +# define S_IRWXU 0700 +#endif + +/* The length of this name must be 8. */ +#define DIR_NAME "confdir3" +#define DIR_NAME_LEN 8 +#define DIR_NAME_SIZE (DIR_NAME_LEN + 1) + +/* The length of "../". */ +#define DOTDOTSLASH_LEN 3 + +/* Leftover bytes in the buffer, to work around library or OS bugs. */ +#define BUF_SLOP 20 + +int +main () +{ +#ifndef PATH_MAX + /* The Hurd doesn't define this, so getcwd can't exhibit the bug -- + at least not on a local file system. And if we were to start worrying + about remote file systems, we'd have to enable the wrapper function + all of the time, just to be safe. That's not worth the cost. */ + exit (0); +#elif ((INT_MAX / (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) \ + - DIR_NAME_SIZE - BUF_SLOP) \ + <= PATH_MAX) + /* FIXME: Assuming there's a system for which this is true, + this should be done in a compile test. */ + exit (0); +#else + char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) + + DIR_NAME_SIZE + BUF_SLOP]; + char *cwd = getcwd (buf, PATH_MAX); + size_t initial_cwd_len; + size_t cwd_len; + int fail = 0; + size_t n_chdirs = 0; + + if (cwd == NULL) + exit (1); + + cwd_len = initial_cwd_len = strlen (cwd); + + while (1) + { + size_t dotdot_max = PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN); + char *c = NULL; + + cwd_len += DIR_NAME_SIZE; + /* If mkdir or chdir fails, it could be that this system cannot create + any file with an absolute name longer than PATH_MAX, such as cygwin. + If so, leave fail as 0, because the current working directory can't + be too long for getcwd if it can't even be created. For other + errors, be pessimistic and consider that as a failure, too. */ + if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0) + { + if (! (errno == ERANGE || is_ENAMETOOLONG (errno))) + fail = 2; + break; + } + + if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DIR_NAME_SIZE) + { + c = getcwd (buf, PATH_MAX); + if (!c && errno == ENOENT) + { + fail = 1; + break; + } + if (c || ! (errno == ERANGE || is_ENAMETOOLONG (errno))) + { + fail = 2; + break; + } + } + + if (dotdot_max <= cwd_len - initial_cwd_len) + { + if (dotdot_max + DIR_NAME_SIZE < cwd_len - initial_cwd_len) + break; + c = getcwd (buf, cwd_len + 1); + if (!c) + { + if (! (errno == ERANGE || errno == ENOENT + || is_ENAMETOOLONG (errno))) + { + fail = 2; + break; + } + if (AT_FDCWD || errno == ERANGE || errno == ENOENT) + { + fail = 1; + break; + } + } + } + + if (c && strlen (c) != cwd_len) + { + fail = 2; + break; + } + ++n_chdirs; + } + + /* Leaving behind such a deep directory is not polite. + So clean up here, right away, even though the driving + shell script would also clean up. */ + { + size_t i; + + /* Try rmdir first, in case the chdir failed. */ + rmdir (DIR_NAME); + for (i = 0; i <= n_chdirs; i++) + { + if (chdir ("..") < 0) + break; + if (rmdir (DIR_NAME) != 0) + break; + } + } + + exit (fail); +#endif +} + ]])], + [gl_cv_func_getcwd_path_max=yes], + [case $? in + 1) gl_cv_func_getcwd_path_max='no, but it is partly working';; + *) gl_cv_func_getcwd_path_max=no;; + esac], + [gl_cv_func_getcwd_path_max=no]) + ]) + case $gl_cv_func_getcwd_path_max in + no,*) + AC_DEFINE([HAVE_PARTLY_WORKING_GETCWD], 1, + [Define to 1 if getcwd works, except it sometimes fails when it shouldn't, + setting errno to ERANGE, ENAMETOOLONG, or ENOENT. If __GETCWD_PREFIX + is not defined, it doesn't matter whether HAVE_PARTLY_WORKING_GETCWD + is defined.]);; + esac +]) diff --git a/gnulib/m4/getcwd.m4 b/gnulib/m4/getcwd.m4 new file mode 100644 index 00000000..6ebe2fce --- /dev/null +++ b/gnulib/m4/getcwd.m4 @@ -0,0 +1,64 @@ +# getcwd.m4 - check for working getcwd that is compatible with glibc + +# Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. + +AC_DEFUN([gl_FUNC_GETCWD_NULL], + [ + AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result], + [gl_cv_func_getcwd_null], + [AC_TRY_RUN( + [ +# include +# include +# ifndef getcwd + char *getcwd (); +# endif + int + main () + { + if (chdir ("/") != 0) + exit (1); + else + { + char *f = getcwd (NULL, 0); + exit (! (f && f[0] == '/' && !f[1])); + } + }], + [gl_cv_func_getcwd_null=yes], + [gl_cv_func_getcwd_null=no], + [gl_cv_func_getcwd_null=no])]) +]) + +AC_DEFUN([gl_FUNC_GETCWD], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_GETCWD_NULL]) + + gl_abort_bug=no + case $gl_cv_func_getcwd_null in + yes) + gl_FUNC_GETCWD_PATH_MAX + gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]);; + esac + + case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in + yes,yes,no) ;; + *) + REPLACE_GETCWD=1 + AC_LIBOBJ([getcwd]) + gl_PREREQ_GETCWD;; + esac +]) + +# Prerequisites of lib/getcwd.c. +AC_DEFUN([gl_PREREQ_GETCWD], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO]) + : +]) diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4 index 56bd7e55..e5050b12 100644 --- a/gnulib/m4/gnulib-cache.m4 +++ b/gnulib/m4/gnulib-cache.m4 @@ -15,11 +15,11 @@ # 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 --aux-dir=tools --no-libtool --macro-prefix=gl error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xstrndup +# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=tools --no-libtool --macro-prefix=gl error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xgetcwd xstrndup # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) -gl_MODULES([error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xstrndup]) +gl_MODULES([error fnmatch-gnu getopt glob memcmp mkdtemp mkstemp setenv strcspn xalloc xgetcwd xstrndup]) gl_AVOID([]) gl_SOURCE_BASE([gnulib/lib]) gl_M4_BASE([gnulib/m4]) diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4 index 8dadf1f9..ee57d6ab 100644 --- a/gnulib/m4/gnulib-comp.m4 +++ b/gnulib/m4/gnulib-comp.m4 @@ -41,11 +41,15 @@ AC_DEFUN([gl_INIT], gl_ltlibdeps= gl_source_base='gnulib/lib' gl_FUNC_ALLOCA + gl_CHECK_TYPE_STRUCT_DIRENT_D_INO gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE + gl_FUNC_DIRFD gl_ERROR gl_EXITFAIL # No macro. You should also use one of fnmatch-posix or fnmatch-gnu. gl_FUNC_FNMATCH_GNU + gl_FUNC_GETCWD + gl_UNISTD_MODULE_INDICATOR([getcwd]) gl_GETLOGIN_R gl_UNISTD_MODULE_INDICATOR([getlogin_r]) gl_GETOPT @@ -86,6 +90,7 @@ AC_DEFUN([gl_INIT], gl_WCHAR_H gl_WCTYPE_H gl_XALLOC + gl_XGETCWD gl_XSTRNDUP LIBGNU_LIBDEPS="$gl_libdeps" AC_SUBST([LIBGNU_LIBDEPS]) @@ -131,6 +136,8 @@ AC_DEFUN([gl_FILE_LIST], [ build-aux/link-warning.h lib/alloca.c lib/alloca_.h + lib/dirfd.c + lib/dirfd.h lib/error.c lib/error.h lib/exitfail.c @@ -138,6 +145,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/fnmatch.c lib/fnmatch_.h lib/fnmatch_loop.c + lib/getcwd.c lib/getlogin_r.c lib/getopt.c lib/getopt1.c @@ -176,17 +184,24 @@ AC_DEFUN([gl_FILE_LIST], [ lib/wctype_.h lib/xalloc-die.c lib/xalloc.h + lib/xgetcwd.c + lib/xgetcwd.h lib/xmalloc.c lib/xstrndup.c lib/xstrndup.h m4/absolute-header.m4 m4/alloca.m4 + m4/d-ino.m4 m4/d-type.m4 + m4/dirfd.m4 m4/eealloc.m4 m4/error.m4 m4/exitfail.m4 m4/extensions.m4 m4/fnmatch.m4 + m4/getcwd-abort-bug.m4 + m4/getcwd-path-max.m4 + m4/getcwd.m4 m4/getlogin_r.m4 m4/getopt.m4 m4/gettimeofday.m4 @@ -221,5 +236,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/wctype.m4 m4/wint_t.m4 m4/xalloc.m4 + m4/xgetcwd.m4 m4/xstrndup.m4 ]) diff --git a/gnulib/m4/xgetcwd.m4 b/gnulib/m4/xgetcwd.m4 new file mode 100644 index 00000000..d8609d12 --- /dev/null +++ b/gnulib/m4/xgetcwd.m4 @@ -0,0 +1,12 @@ +#serial 6 +dnl Copyright (C) 2002, 2003, 2004, 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, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_XGETCWD], +[ + AC_LIBOBJ([xgetcwd]) + + AC_REQUIRE([gl_FUNC_GETCWD]) +]) -- cgit v1.2.3