diff options
author | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-21 13:32:03 +0000 |
---|---|---|
committer | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-21 13:32:03 +0000 |
commit | 0f63d961169989a7f6dcf7c0487fe29da178a4d2 (patch) | |
tree | 9addd6552097d7b56b93354ba1e5ef9f0a3a2564 /dir.c | |
parent | 638c96858274deb90b2b923477d6b9525e1ed065 (diff) |
dir.c: fix Dir.glob starts with brace
* dir.c (ruby_glob0): expand braces if a glob pattern starts with
brace.
[ruby-core:91728] [Bug #15649]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -2433,6 +2433,24 @@ push_caller(const char *path, VALUE val, void *enc) return status; } +static int ruby_glob0(const char *path, int fd, const char *base, int flags, + const ruby_glob_funcs_t *funcs, VALUE arg, rb_encoding *enc); + +struct push_glob0_args { + int fd; + const char *base; + int flags; + const ruby_glob_funcs_t *funcs; + VALUE arg; +}; + +static int +push_glob0_caller(const char *path, VALUE val, void *enc) +{ + struct push_glob0_args *arg = (struct push_glob0_args *)val; + return ruby_glob0(path, arg->fd, arg->base, arg->flags, arg->funcs, arg->arg, enc); +} + static int ruby_glob0(const char *path, int fd, const char *base, int flags, const ruby_glob_funcs_t *funcs, VALUE arg, @@ -2445,6 +2463,17 @@ ruby_glob0(const char *path, int fd, const char *base, int flags, int status, dirsep = FALSE; start = root = path; + + if (*root == '{') { + struct push_glob0_args args; + args.fd = fd; + args.base = base; + args.flags = flags; + args.funcs = funcs; + args.arg = arg; + return ruby_brace_expand(path, flags, push_glob0_caller, (VALUE)&args, enc, Qfalse); + } + flags |= FNM_SYSCASE; #if defined DOSISH root = rb_enc_path_skip_prefix(root, root + strlen(root), enc); |