diff options
| author | Jakob Kaivo <jkk@ung.org> | 2020-08-15 15:47:51 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2020-08-15 15:47:51 -0400 |
| commit | 1309dd2cc1d464ab24283119eda2aa487338b9be (patch) | |
| tree | cb39c447b4ed7e26488748884a9774d91c20e00f | |
| parent | 91d875c5e85ca2d17f4a2c217cd4f83efe9af6dc (diff) | |
put fnmatch() parameters in the right order
| -rw-r--r-- | src/glob/glob.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/glob/glob.c b/src/glob/glob.c index ef94d919..eafc1c82 100644 --- a/src/glob/glob.c +++ b/src/glob/glob.c @@ -58,7 +58,7 @@ int glob(const char * restrict pattern, int flags, int (*errfunc) (const char * do { const char *p = path + strlen(path) + 1; struct dirent *de; - DIR *d = opendir(path); + DIR *d = opendir(slashes ? path : "."); if (d == NULL) { if (errfunc != NULL) { if (errfunc(path, errno) != 0) { @@ -72,7 +72,7 @@ int glob(const char * restrict pattern, int flags, int (*errfunc) (const char * } while ((de = readdir(d)) != NULL) { - if (fnmatch(de->d_name, p, fnmatch_flags) == 0) { + if (fnmatch(p, de->d_name, fnmatch_flags) == 0) { pglob->gl_pathc++; char **tmp = realloc(pglob->gl_pathv, sizeof(char*) * pglob->gl_pathc); if (tmp == NULL) { |
