summaryrefslogtreecommitdiff
path: root/src/glob/glob.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-23 15:22:33 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-23 15:22:33 -0500
commit1221e834f49adb91eb0b7443a57274f2611459c2 (patch)
tree7afb7ed5a203ddefd5559005af7ec61d801b972e /src/glob/glob.c
parentf546f27d1fdb8d2663b2fbb130f53ee32cac90b0 (diff)
compile in current environment
Diffstat (limited to 'src/glob/glob.c')
-rw-r--r--src/glob/glob.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/glob/glob.c b/src/glob/glob.c
index 15e30731..e8e6b8a6 100644
--- a/src/glob/glob.c
+++ b/src/glob/glob.c
@@ -1,3 +1,4 @@
+#include "sys/types.h"
#include <glob.h>
#include "stdlib.h"
#include "string.h"
@@ -5,14 +6,18 @@
#include "fnmatch.h"
#include "errno.h"
#include "unistd.h"
-#include "__nonstd.h"
+#include "nonstd/assert.h"
int glob(const char * restrict pattern, int flags, int (*errfunc) (const char * epath, int eerrno), glob_t * restrict pglob)
{
- __ASSERT_NONNULL(pattern);
- __ASSERT_NONNULL(pglob);
+ ASSERT_NONNULL(pattern);
+ ASSERT_NONNULL(pglob);
+
+ int slashes = 0;
+ size_t i;
int fnmatch_flags = FNM_PATHNAME | FNM_PERIOD;
+
if (flags & GLOB_NOESCAPE) {
fnmatch_flags |= FNM_NOESCAPE;
}
@@ -32,9 +37,8 @@ int glob(const char * restrict pattern, int flags, int (*errfunc) (const char *
}
char *path = strdup(pattern);
- int slashes = 0;
- for (size_t i = 0; path[i]; i++) {
+ for (i = 0; path[i]; i++) {
if (path[i] == '/') {
slashes++;
path[i] = '\0';