summaryrefslogtreecommitdiff
path: root/src/glob
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
parentf546f27d1fdb8d2663b2fbb130f53ee32cac90b0 (diff)
compile in current environment
Diffstat (limited to 'src/glob')
-rw-r--r--src/glob/glob.c14
-rw-r--r--src/glob/globfree.c5
2 files changed, 13 insertions, 6 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';
diff --git a/src/glob/globfree.c b/src/glob/globfree.c
index f04708c4..228dcea8 100644
--- a/src/glob/globfree.c
+++ b/src/glob/globfree.c
@@ -1,13 +1,16 @@
+#include "sys/types.h"
#include <glob.h>
#include "stdlib.h"
void globfree(glob_t * pglob)
{
+ size_t i;
+
if (pglob == NULL) {
return;
}
- for (size_t i = 0; i < pglob->gl_pathc; i++) {
+ for (i = 0; i < pglob->gl_pathc; i++) {
if (pglob->gl_pathv[i] != NULL) {
free(pglob->gl_pathv[i]);
}