projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replaced with <unistd.h>.
[gnulib.git]
/
lib
/
glob.c
diff --git
a/lib/glob.c
b/lib/glob.c
index
c1613f4
..
ccd0e7a
100644
(file)
--- a/
lib/glob.c
+++ b/
lib/glob.c
@@
-1,4
+1,4
@@
-/* Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2002,2003,2004,2005,2006
,2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@
-16,7
+16,7
@@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#if
def HAVE_CONFIG_H
+#if
ndef _LIBC
# include <config.h>
#endif
# include <config.h>
#endif
@@
-47,20
+47,12
@@
# define __set_errno(val) errno = (val)
#endif
# define __set_errno(val) errno = (val)
#endif
-#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# include <ndir.h>
-#endif
+#include <dirent.h>
/* In GNU systems, <dirent.h> defines this macro for us. */
/* In GNU systems, <dirent.h> defines this macro for us. */
-#ifdef _D_NAMLEN
-# undef NAMLEN
-# define NAMLEN(d) _D_NAMLEN(d)
+#ifndef _D_EXACT_NAMLEN
+# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
#endif
/* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
#endif
/* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
@@
-86,13
+78,6
@@
/* If the system has the `struct dirent64' type we use it internally. */
#if defined _LIBC && !defined COMPILE_GLOB64
/* If the system has the `struct dirent64' type we use it internally. */
#if defined _LIBC && !defined COMPILE_GLOB64
-# if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
-# define CONVERT_D_NAMLEN(d64, d32)
-# else
-# define CONVERT_D_NAMLEN(d64, d32) \
- (d64)->d_namlen = (d32)->d_namlen;
-# endif
-
# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
# define CONVERT_D_INO(d64, d32)
# else
# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
# define CONVERT_D_INO(d64, d32)
# else
@@
-108,8
+93,7
@@
# endif
# define CONVERT_DIRENT_DIRENT64(d64, d32) \
# endif
# define CONVERT_DIRENT_DIRENT64(d64, d32) \
- memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32) + 1); \
- CONVERT_D_NAMLEN (d64, d32) \
+ memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1); \
CONVERT_D_INO (d64, d32) \
CONVERT_D_TYPE (d64, d32)
#endif
CONVERT_D_INO (d64, d32) \
CONVERT_D_TYPE (d64, d32)
#endif
@@
-149,9
+133,6
@@
# define struct_stat64 struct stat64
#else /* !_LIBC */
# include "getlogin_r.h"
# define struct_stat64 struct stat64
#else /* !_LIBC */
# include "getlogin_r.h"
-# include "mempcpy.h"
-# include "stat-macros.h"
-# include "strdup.h"
# define __stat64(fname, buf) stat (fname, buf)
# define struct_stat64 struct stat
# define __stat(fname, buf) stat (fname, buf)
# define __stat64(fname, buf) stat (fname, buf)
# define struct_stat64 struct stat
# define __stat(fname, buf) stat (fname, buf)
@@
-179,6
+160,11
@@
static const char *next_brace_sub (const char *begin, int flags) __THROW;
#endif /* !defined _LIBC || !defined GLOB_ONLY_P */
#endif /* !defined _LIBC || !defined GLOB_ONLY_P */
+/* The results of opendir() in this file are not used with dirfd and fchdir,
+ therefore save some unnecessary work in fchdir.c. */
+#undef opendir
+#undef closedir
+
static int glob_in_dir (const char *pattern, const char *directory,
int flags, int (*errfunc) (const char *, int),
glob_t *pglob);
static int glob_in_dir (const char *pattern, const char *directory,
int flags, int (*errfunc) (const char *, int),
glob_t *pglob);
@@
-1192,7
+1178,7
@@
glob_in_dir (const char *pattern, const char *directory, int flags,
struct globlink *new =
__alloca (sizeof (struct globlink));
char *p;
struct globlink *new =
__alloca (sizeof (struct globlink));
char *p;
- len = NAMLEN (d);
+ len =
_D_EXACT_
NAMLEN (d);
new->name =
malloc (len + 1 + ((flags & GLOB_MARK) && isdir));
if (new->name == NULL)
new->name =
malloc (len + 1 + ((flags & GLOB_MARK) && isdir));
if (new->name == NULL)