projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix evaluation of "Before C" condition of FINAL_SIGMA.
[gnulib.git]
/
lib
/
getcwd.c
diff --git
a/lib/getcwd.c
b/lib/getcwd.c
index
98df8bf
..
b9e57d3
100644
(file)
--- a/
lib/getcwd.c
+++ b/
lib/getcwd.c
@@
-1,5
+1,4
@@
-/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2004,2005,2006,2007 Free Software
- Foundation, Inc.
+/* Copyright (C) 1991-1999, 2004-2008 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
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@
-18,7
+17,6
@@
#if !_LIBC
# include <config.h>
# include <unistd.h>
#if !_LIBC
# include <config.h>
# include <unistd.h>
-# include "dirfd.h"
#endif
#include <errno.h>
#endif
#include <errno.h>
@@
-29,9
+27,12
@@
#include <fcntl.h> /* For AT_FDCWD on Solaris 9. */
#include <fcntl.h> /* For AT_FDCWD on Solaris 9. */
-/* On a system without the openat function, undefine AT_FDCWD. */
-#if ! HAVE_OPENAT
-# undef AT_FDCWD
+/* If this host provides the openat function, then enable
+ code below to make getcwd more efficient and robust. */
+#ifdef HAVE_OPENAT
+# define HAVE_OPENAT_SUPPORT 1
+#else
+# define HAVE_OPENAT_SUPPORT 0
#endif
#ifndef __set_errno
#endif
#ifndef __set_errno
@@
-127,7
+128,7
@@
__getcwd (char *buf, size_t size)
DEEP_NESTING = 100
};
DEEP_NESTING = 100
};
-#if
def AT_FDCWD
+#if
HAVE_OPENAT_SUPPORT
int fd = AT_FDCWD;
bool fd_needs_closing = false;
#else
int fd = AT_FDCWD;
bool fd_needs_closing = false;
#else
@@
-208,7
+209,7
@@
__getcwd (char *buf, size_t size)
bool use_d_ino = true;
/* Look at the parent directory. */
bool use_d_ino = true;
/* Look at the parent directory. */
-#if
def AT_FDCWD
+#if
HAVE_OPENAT_SUPPORT
fd = openat (fd, "..", O_RDONLY);
if (fd < 0)
goto lose;
fd = openat (fd, "..", O_RDONLY);
if (fd < 0)
goto lose;
@@
-235,7
+236,7
@@
__getcwd (char *buf, size_t size)
mount_point = dotdev != thisdev;
/* Search for the last directory. */
mount_point = dotdev != thisdev;
/* Search for the last directory. */
-#if
def AT_FDCWD
+#if
HAVE_OPENAT_SUPPORT
dirstream = fdopendir (fd);
if (dirstream == NULL)
goto lose;
dirstream = fdopendir (fd);
if (dirstream == NULL)
goto lose;
@@
-291,7
+292,7
@@
__getcwd (char *buf, size_t size)
{
int entry_status;
{
int entry_status;
-#if
def AT_FDCWD
+#if
HAVE_OPENAT_SUPPORT
entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW);
#else
/* Compute size needed for this file name, or for the file
entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW);
#else
/* Compute size needed for this file name, or for the file
@@
-387,7
+388,7
@@
__getcwd (char *buf, size_t size)
if (dirp == &dir[allocated - 1])
*--dirp = '/';
if (dirp == &dir[allocated - 1])
*--dirp = '/';
-#if
ndef AT_FDCWD
+#if
! HAVE_OPENAT_SUPPORT
if (dotlist != dots)
free (dotlist);
#endif
if (dotlist != dots)
free (dotlist);
#endif
@@
-413,7
+414,7
@@
__getcwd (char *buf, size_t size)
int save = errno;
if (dirstream)
__closedir (dirstream);
int save = errno;
if (dirstream)
__closedir (dirstream);
-#if
def AT_FDCWD
+#if
HAVE_OPENAT_SUPPORT
if (fd_needs_closing)
close (fd);
#else
if (fd_needs_closing)
close (fd);
#else