+Fri Dec 8 13:04:51 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
+
+ * posix/glob.c: Implement new options GLOB_ALTDIRFUNC, GLOB_BRACE,
+ GLOB_TILDE, GLOB_NOMAGIC.
+ (glob): Use stat instead of lstat to determine directoriness.
+ * posix/glob.h (GLOB_ALTDIRFUNC, GLOB_BRACE, GLOB_NOMAGIC, GLOB_TILDE):
+ New flag bits.
+ (__GLOB_FLAGS): Include them.
+ (glob_t): New members gl_closedir, gl_readdir, gl_opendir, gl_lstat,
+ gl_stat.
+
Mon Sep 11 14:00:14 1995 Roland McGrath <roland@whiz-bang.gnu.ai.mit.edu>
* posix/glob.c (glob): Comment fix.
#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
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')
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;
{
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)) ||
{
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))
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;
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)
return GLOB_NOSPACE;
}
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* Not ELIDE_CODE. */
+