[前][次][番号順一覧][スレッド一覧]

ruby-changes:55146

From: naruse <ko1@a...>
Date: Thu, 28 Mar 2019 12:28:42 +0900 (JST)
Subject: [ruby-changes:55146] naruse:r67353 (ruby_2_6): merge revision(s) 67332: [Backport #15649]

naruse	2019-03-28 12:28:38 +0900 (Thu, 28 Mar 2019)

  New Revision: 67353

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67353

  Log:
    merge revision(s) 67332: [Backport #15649]
    
    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]

  Modified directories:
    branches/ruby_2_6/
  Modified files:
    branches/ruby_2_6/dir.c
    branches/ruby_2_6/test/ruby/test_dir.rb
    branches/ruby_2_6/version.h
Index: ruby_2_6/version.h
===================================================================
--- ruby_2_6/version.h	(revision 67352)
+++ ruby_2_6/version.h	(revision 67353)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_6/version.h#L1
 #define RUBY_VERSION "2.6.3"
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 50
+#define RUBY_PATCHLEVEL 51
 
 #define RUBY_RELEASE_YEAR 2019
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_6/dir.c
===================================================================
--- ruby_2_6/dir.c	(revision 67352)
+++ ruby_2_6/dir.c	(revision 67353)
@@ -2432,6 +2432,24 @@ push_caller(const char *path, VALUE val, https://github.com/ruby/ruby/blob/trunk/ruby_2_6/dir.c#L2432
     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,
@@ -2444,6 +2462,17 @@ ruby_glob0(const char *path, int fd, con https://github.com/ruby/ruby/blob/trunk/ruby_2_6/dir.c#L2462
     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);
Index: ruby_2_6/test/ruby/test_dir.rb
===================================================================
--- ruby_2_6/test/ruby/test_dir.rb	(revision 67352)
+++ ruby_2_6/test/ruby/test_dir.rb	(revision 67353)
@@ -205,6 +205,14 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_6/test/ruby/test_dir.rb#L205
     end
   end
 
+  def test_glob_starts_with_brace
+    Dir.chdir(@root) do
+      bug15649 = '[ruby-core:91728] [Bug #15649]'
+      assert_equal(["#{@root}/a", "#{@root}/b"],
+                   Dir.glob("{#{@root}/a,#{@root}/b}"), bug15649)
+    end
+  end
+
   if Process.const_defined?(:RLIMIT_NOFILE)
     def test_glob_too_may_open_files
       assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}", chdir: @root)
Index: ruby_2_6
===================================================================
--- ruby_2_6	(revision 67352)
+++ ruby_2_6	(revision 67353)

Property changes on: ruby_2_6
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r67332

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]