ruby-changes:52624
From: shirosaki <ko1@a...>
Date: Wed, 26 Sep 2018 00:31:07 +0900 (JST)
Subject: [ruby-changes:52624] shirosaki:r64836 (trunk): dir.c: fix glob with recursive and brace
shirosaki 2018-09-26 00:31:02 +0900 (Wed, 26 Sep 2018) New Revision: 64836 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64836 Log: dir.c: fix glob with recursive and brace Fixed bug that glob with recursive and braces (**/{a,b}) pattern fails. [Feature #13167] Modified files: trunk/dir.c Index: dir.c =================================================================== --- dir.c (revision 64835) +++ dir.c (revision 64836) @@ -1683,21 +1683,6 @@ glob_make_pattern(const char *p, const c https://github.com/ruby/ruby/blob/trunk/dir.c#L1683 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_patte https://github.com/ruby/ruby/blob/trunk/dir.c#L2045 { 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_patte https://github.com/ruby/ruby/blob/trunk/dir.c#L2055 break; default: str = p->str; + if (!str) continue; } if (!path) { path_len = strlen(str); @@ -2137,7 +2123,9 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L2123 #endif break; case BRACE: - brace = 1; + if (!recursive) { + brace = 1; + } break; case MAGICAL: magical = 2; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/