summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorshirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 15:31:02 +0000
committershirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 15:31:02 +0000
commitf73d504c6d23059df79d1eea8380c88e3b3b7d1d (patch)
treed379a377ebc5b5b8ee9d1c601ea028be157b3b74 /dir.c
parentb14325443a1e868100c3a5fa4365223b61a77f08 (diff)
dir.c: fix glob with recursive and brace
Fixed bug that glob with recursive and braces (**/{a,b}) pattern fails. [Feature #13167] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/dir.c b/dir.c
index 6c6b40e..a6b68ba 100644
--- a/dir.c
+++ b/dir.c
@@ -1683,21 +1683,6 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc)
const enum glob_pattern_type non_magic = (USE_NAME_ON_FS || FNM_SYSCASE) ? PLAIN : ALPHA;
char *buf;
- if (magic == BRACE) {
- /* brace pattern is parsed after expansion */
- buf = GLOB_ALLOC_N(char, e-p+1);
- if (!buf) {
- GLOB_FREE(tmp);
- goto error;
- }
- memcpy(buf, p, e-p);
- buf[e-p] = '\0';
- tmp->type = BRACE;
- tmp->str = buf;
- *tail = tmp;
- tmp->next = 0;
- return list;
- }
if (!(FNM_SYSCASE || magic > non_magic) && !recursive && *m) {
const char *m2;
while (has_magic(m+1, m2 = find_dirsep(m+1, e, flags, enc), flags, enc) <= non_magic &&
@@ -2060,7 +2045,7 @@ join_path_from_pattern(struct glob_pattern **beg)
{
struct glob_pattern *p;
char *path = NULL;
- size_t path_len;
+ size_t path_len = 0;
for (p = *beg; p; p = p->next) {
const char *str;
@@ -2070,6 +2055,7 @@ join_path_from_pattern(struct glob_pattern **beg)
break;
default:
str = p->str;
+ if (!str) continue;
}
if (!path) {
path_len = strlen(str);
@@ -2137,7 +2123,9 @@ glob_helper(
#endif
break;
case BRACE:
- brace = 1;
+ if (!recursive) {
+ brace = 1;
+ }
break;
case MAGICAL:
magical = 2;