summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/misc/glob/glob.c72
-rw-r--r--libc/misc/glob/glob64.c2
2 files changed, 40 insertions, 34 deletions
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c
index 0773c10b3..14e2a6e22 100644
--- a/libc/misc/glob/glob.c
+++ b/libc/misc/glob/glob.c
@@ -25,10 +25,10 @@ Cambridge, MA 02139, USA. */
#include <dirent.h>
#include <malloc.h>
#include <fnmatch.h>
+#define _GNU_SOURCE
#include <glob.h>
extern __ptr_t (*__glob_opendir_hook) __P ((const char *directory));
-extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
extern void (*__glob_closedir_hook) __P ((__ptr_t stream));
extern const char *(*__glob_readdir_hook) __P ((__ptr_t stream));
@@ -41,6 +41,43 @@ static int prefix_array __P ((const char *prefix, char **array, size_t n,
int add_slash));
static int collated_compare __P ((const __ptr_t, const __ptr_t));
+#ifdef __GLOB64
+extern int glob_pattern_p(const char *pattern, int quote);
+#else
+/* Return nonzero if PATTERN contains any metacharacters.
+ Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
+int glob_pattern_p(const char *pattern, int quote)
+{
+ const char *p;
+ int open = 0;
+
+ for (p = pattern; *p != '\0'; ++p)
+ switch (*p)
+ {
+ case '?':
+ case '*':
+ return 1;
+
+ case '\\':
+ if (quote)
+ ++p;
+ break;
+
+ case '[':
+ open = 1;
+ break;
+
+ case ']':
+ if (open)
+ return 1;
+ break;
+ }
+
+ return 0;
+}
+#endif
+
+
/* Do glob searching for PATTERN, placing results in PGLOB.
The bits defined above may be set in FLAGS.
If a directory cannot be opened or read and ERRFUNC is not nil,
@@ -332,39 +369,6 @@ prefix_array (dirname, array, n, add_slash)
}
-/* Return nonzero if PATTERN contains any metacharacters.
- Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
-int glob_pattern_p(const char *pattern, int quote)
-{
- register const char *p;
- int open = 0;
-
- for (p = pattern; *p != '\0'; ++p)
- switch (*p)
- {
- case '?':
- case '*':
- return 1;
-
- case '\\':
- if (quote)
- ++p;
- break;
-
- case '[':
- open = 1;
- break;
-
- case ']':
- if (open)
- return 1;
- break;
- }
-
- return 0;
-}
-
-
/* Like `glob', but PATTERN is a final pathname component,
and matches are searched for in DIRECTORY.
The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
diff --git a/libc/misc/glob/glob64.c b/libc/misc/glob/glob64.c
index c053de4f0..5829fec14 100644
--- a/libc/misc/glob/glob64.c
+++ b/libc/misc/glob/glob64.c
@@ -30,6 +30,8 @@
#define stat stat64
#define lstat lstat64
+#define __GLOB64 1
+
#include "glob.c"
#endif