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

ruby-changes:29703

From: nobu <ko1@a...>
Date: Wed, 3 Jul 2013 14:15:38 +0900 (JST)
Subject: [ruby-changes:29703] nobu:r41755 (trunk): dir.c: get rid of FindFirstFile bug

nobu	2013-07-03 14:15:28 +0900 (Wed, 03 Jul 2013)

  New Revision: 41755

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

  Log:
    dir.c: get rid of FindFirstFile bug
    
    * dir.c (do_stat): use rb_w32_ustati64() in win32.c to get rid of
      mysterious behavior of FindFirstFile() Windows API which treat "<"
      and ">" like as wildcard characters.  [ruby-core:55764] [Bug #8597]

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41754)
+++ ChangeLog	(revision 41755)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul  3 14:15:25 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (do_stat): use rb_w32_ustati64() in win32.c to get rid of
+	  mysterious behavior of FindFirstFile() Windows API which treat "<"
+	  and ">" like as wildcard characters.  [ruby-core:55764] [Bug #8597]
+
 Wed Jul  3 12:06:42 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (maxpow_in_bdigit): Renamed from calc_hbase and return
Index: dir.c
===================================================================
--- dir.c	(revision 41754)
+++ dir.c	(revision 41755)
@@ -1029,12 +1029,18 @@ sys_warning_1(VALUE mesg) https://github.com/ruby/ruby/blob/trunk/dir.c#L1029
  */
 #define to_be_ignored(e) ((e) == ENOENT || (e) == ENOTDIR)
 
+#ifdef _WIN32
+#define STAT(p, s)	rb_w32_ustati64((p), (s))
+#else
+#define STAT(p, s)	stat((p), (s))
+#endif
+
 /* System call with warning */
 static int
 do_stat(const char *path, struct stat *pst, int flags)
 
 {
-    int ret = stat(path, pst);
+    int ret = STAT(path, pst);
     if (ret < 0 && !to_be_ignored(errno))
 	sys_warning(path);
 
Index: test/ruby/test_dir.rb
===================================================================
--- test/ruby/test_dir.rb	(revision 41754)
+++ test/ruby/test_dir.rb	(revision 41755)
@@ -213,4 +213,8 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L213
     Dir.glob(File.join(@root, "**/"))
   end
 
+  def test_glob_metachar
+    bug8597 = '[ruby-core:55764] [Bug #8597]'
+    assert_empty(Dir.glob(File.join(@root, "<")), bug8597)
+  end
 end

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

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