summaryrefslogtreecommitdiff
path: root/glob.c
diff options
context:
space:
mode:
authorToby Goodwin <tgoodwin@cygnus.co.uk>1997-07-07 00:00:01 +0100
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:22:09 +0100
commit671e1e2d1599aa8c5f1010b3fe75c151c56a7403 (patch)
tree906ba5d55d6993f59d7bb1def63d494bafd38728 /glob.c
parenta076248389c82276e079756bee26c011b03f70f2 (diff)
beta: rc-1.5b2
Diffstat (limited to 'glob.c')
-rw-r--r--glob.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/glob.c b/glob.c
index bdd3b6c..043f767 100644
--- a/glob.c
+++ b/glob.c
@@ -3,16 +3,28 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "rc.h"
-#ifdef NODIRENT
-#include <sys/dir.h>
-#define dirent direct /* need to get the struct declaraction right */
+
+/* Lifted from autoconf documentation.*/
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
-#include <dirent.h>
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
#endif
static List *dmatch(char *, char *, char *);
static List *doglob(char *, char *);
-static List *lglob(List *, char *, char *, SIZE_T);
+static List *lglob(List *, char *, char *, size_t);
static List *sort(List *);
/*
@@ -90,10 +102,6 @@ static List *dmatch(char *d, char *p, char *m) {
static DIR *dirp;
static struct dirent *dp;
static struct stat s;
- /* prototypes for XXXdir functions. comment out if necessary */
- extern DIR *opendir(const char *);
- extern struct dirent *readdir(DIR *);
- /*extern int closedir(DIR *);*/
int i;
/*
@@ -151,11 +159,11 @@ static List *dmatch(char *d, char *p, char *m) {
matched name. e.g., for matching ////tmp/////foo*
*/
-static List *lglob(List *s, char *p, char *m, SIZE_T slashcount) {
+static List *lglob(List *s, char *p, char *m, size_t slashcount) {
List *q, *r, *top, foo;
static struct {
List l;
- SIZE_T size;
+ size_t size;
} slash;
if (slashcount+1 > slash.size) {
slash.size = 2*(slashcount+1);
@@ -191,9 +199,9 @@ static List *lglob(List *s, char *p, char *m, SIZE_T slashcount) {
static List *doglob(char *w, char *m) {
static char *dir = NULL, *pattern = NULL, *metadir = NULL, *metapattern = NULL;
- static SIZE_T dsize = 0;
+ static size_t dsize = 0;
char *d, *p, *md, *mp;
- SIZE_T psize;
+ size_t psize;
char *s = w;
List firstdir;
List *matched;
@@ -238,7 +246,7 @@ static List *doglob(char *w, char *m) {
matched = dmatch(".", dir, metadir);
}
do {
- SIZE_T slashcount;
+ size_t slashcount;
sigchk();
for (slashcount = 0; *s == '/'; s++, m++)
slashcount++; /* skip slashes */
@@ -258,7 +266,7 @@ end: if (matched == NULL) {
}
static List *sort(List *s) {
- SIZE_T nel = listnel(s);
+ size_t nel = listnel(s);
if (nel > 1) {
char **a;
List *t;