diff --git a/src/regex/glob.c b/src/regex/glob.c index 5b6ff124..cc9e012f 100644 --- a/src/regex/glob.c +++ b/src/regex/glob.c @@ -162,13 +162,6 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i size_t offs = (flags & GLOB_DOOFFS) ? g->gl_offs : 0; int error = 0; - if (*p == '/') { - for (; *p == '/'; p++); - d = "/"; - } else { - d = ""; - } - if (!errfunc) errfunc = ignore_err; if (!(flags & GLOB_APPEND)) { @@ -179,6 +172,13 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i if (strnlen(p, PATH_MAX+1) > PATH_MAX) return GLOB_NOSPACE; + if (*p == '/') { + for (; *p == '/'; p++); + d = "/"; + } else { + d = ""; + } + if (*p) error = match_in_dir(d, p, flags, errfunc, &tail); if (error == GLOB_NOSPACE) { freelist(&head);