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

ruby-changes:17302

From: nobu <ko1@a...>
Date: Mon, 20 Sep 2010 23:23:28 +0900 (JST)
Subject: [ruby-changes:17302] Ruby:r29306 (trunk): * dir.c (bracket): get rid of scanning at the end of the pattern

nobu	2010-09-20 23:23:16 +0900 (Mon, 20 Sep 2010)

  New Revision: 29306

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29306

  Log:
    * dir.c (bracket): get rid of scanning at the end of the pattern
      string, not to raise an exception while globbing command line.
      [ruby-core:32478]

  Modified files:
    trunk/ChangeLog
    trunk/dir.c
    trunk/test/ruby/test_rubyoptions.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29305)
+++ ChangeLog	(revision 29306)
@@ -1,3 +1,9 @@
+Mon Sep 20 23:23:05 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (bracket): get rid of scanning at the end of the pattern
+	  string, not to raise an exception while globbing command line.
+	  [ruby-core:32478]
+
 Mon Sep 20 11:25:49 2010  Tanaka Akira  <akr@f...>
 
 	* ext/pathname/pathname.c (Init_pathname): Pathname#=~ undefinition
Index: dir.c
===================================================================
--- dir.c	(revision 29305)
+++ dir.c	(revision 29306)
@@ -108,6 +108,7 @@
     int r;
     int ok = 0, not = 0;
 
+    if (p >= pend) return NULL;
     if (*p == '!' || *p == '^') {
 	not = 1;
 	p++;
@@ -120,6 +121,7 @@
 	if (!*t1)
 	    return NULL;
 	p = t1 + (r = rb_enc_mbclen(t1, pend, enc));
+	if (p >= pend) return NULL;
 	if (p[0] == '-' && p[1] != ']') {
 	    const char *t2 = p + 1;
 	    int r2;
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 29305)
+++ test/ruby/test_rubyoptions.rb	(revision 29306)
@@ -461,4 +461,15 @@
     }
     assert_equal("\"zzz\\n\"\n", result, '[ruby-core:30910]')
   end
+
+  def test_unmatching_glob
+    bug3851 = '[ruby-core:32478]'
+    a = "a[foo"
+    Dir.mktmpdir do |dir|
+      open(File.join(dir, a), "w") {|f| f.puts("p 42")}
+      assert_in_out_err(["-C", dir, a], "", ["42"], [], bug3851)
+      File.unlink(File.join(dir, a))
+      assert_in_out_err(["-C", dir, a], "", [], /LoadError/, bug3851)
+    end
+  end
 end

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

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