summaryrefslogtreecommitdiff
path: root/glob/glob.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1995-12-12 02:42:43 +0000
committerRoland McGrath <roland@redhat.com>1995-12-12 02:42:43 +0000
commitffea662953c33653f1da482a1fb3fe715b3487df (patch)
tree1a4132ee6b13de9d26d58d69f78f838467217a0a /glob/glob.c
parentdb5cc03f759d859bb352087589ade7db84d4bbc1 (diff)
downloadgunmake-ffea662953c33653f1da482a1fb3fe715b3487df.tar.gz
Updated from libc
Diffstat (limited to 'glob/glob.c')
-rw-r--r--glob/glob.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/glob/glob.c b/glob/glob.c
index 6bd5628..ce17fe1 100644
--- a/glob/glob.c
+++ b/glob/glob.c
@@ -184,10 +184,7 @@ extern char *alloca ();
#endif
#ifndef __GNU_LIBRARY__
-#define __lstat lstat
-#ifndef HAVE_LSTAT
-#define lstat stat
-#endif
+#define __stat stat
#ifdef STAT_MACROS_BROKEN
#undef S_ISDIR
#endif
@@ -346,16 +343,6 @@ glob (pattern, flags, errfunc, pglob)
oldcount = pglob->gl_pathc;
- pglob->gl_flags = flags;
- if (!(flags & GLOB_ALTDIRFUNC))
- {
- pglob->gl_closedir = (void (*) __P ((void *))) &closedir;
- pglob->gl_readdir = (struct dirent *(*) __P ((void *))) &readdir;
- pglob->gl_opendir = (__ptr_t (*) __P ((const char *))) &opendir;
- pglob->gl_lstat = &lstat;
- pglob->gl_stat = &stat;
- }
-
if ((flags & GLOB_TILDE) && dirname[0] == '~')
{
if (dirname[1] == '\0')
@@ -508,7 +495,8 @@ glob (pattern, flags, errfunc, pglob)
int i;
struct stat st;
for (i = oldcount; i < pglob->gl_pathc; ++i)
- if (__lstat (pglob->gl_pathv[i], &st) == 0 &&
+ if (((flags & GLOB_ALTDIRFUNC) ?
+ *pglob->gl_stat : __stat) (pglob->gl_pathv[i], &st) == 0 &&
S_ISDIR (st.st_mode))
{
size_t len = strlen (pglob->gl_pathv[i]) + 2;
@@ -675,7 +663,9 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
{
flags |= GLOB_MAGCHAR;
- stream = (*pglob->gl_opendir) (directory);
+ stream = ((flags & GLOB_ALTDIRFUNC) ?
+ (*pglob->gl_opendir) (directory) :
+ opendir (directory));
if (stream == NULL)
{
if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
@@ -687,7 +677,9 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
{
const char *name;
size_t len;
- struct dirent *d = (*pglob->gl_readdir) (stream);
+ struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ?
+ (*pglob->gl_readdir) (stream) :
+ readdir (stream));
if (d == NULL)
break;
if (! REAL_DIR_ENTRY (d))
@@ -759,7 +751,10 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
if (stream != NULL)
{
int save = errno;
- (*pglob->gl_closedir) (stream);
+ if (flags & GLOB_ALTDIRFUNC)
+ (*pglob->gl_closedir) (stream);
+ else
+ closedir (stream);
errno = save;
}
return nfound == 0 ? GLOB_NOMATCH : 0;
@@ -767,7 +762,10 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
memory_error:
{
int save = errno;
- (*pglob->gl_closedir) (stream);
+ if (flags & GLOB_ALTDIRFUNC)
+ (*pglob->gl_closedir) (stream);
+ else
+ closedir (stream);
errno = save;
}
while (names != NULL)
@@ -779,4 +777,5 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
return GLOB_NOSPACE;
}
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* Not ELIDE_CODE. */
+