diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-09 01:20:20 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-09 01:20:20 +0000 |
commit | 58f2e6bc942bb161f73adad6410769a6ef581f8e (patch) | |
tree | 08e7127d98a6593b8e3b22b259b4f1ffe4dac67d /dir.c | |
parent | 0528838b377ff3e5161d47df753c3203b028bf57 (diff) |
dir.c: fix directory glob
* dir.c (glob_helper): fix directory glob which resulted in lacking
the first byte. adjust the length of basename to be appended as
well as removing the heading path, not the length of the joined
path. [ruby-dev:50588] [Bug #14899]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2068,10 +2068,11 @@ glob_helper( if (status) return status; } if (match_dir && pathtype == path_directory) { - const char *subpath = path + baselen + (baselen && path[baselen] == '/'); - char *tmp = join_path(subpath, namelen, dirsep, "", 0); + int seplen = (baselen && path[baselen] == '/'); + const char *subpath = path + baselen + seplen; + char *tmp = join_path(subpath, namelen - seplen, dirsep, "", 0); if (!tmp) return -1; - status = glob_call_func(funcs->match, tmp + (baselen ? dirsep : 0), arg, enc); + status = glob_call_func(funcs->match, tmp, arg, enc); GLOB_FREE(tmp); if (status) return status; } |