Skip to content

Instantly share code, notes, and snippets.

@shirosaki
Created December 4, 2012 01:30
Show Gist options
  • Save shirosaki/4199712 to your computer and use it in GitHub Desktop.
Save shirosaki/4199712 to your computer and use it in GitHub Desktop.
Build 1.9.3-p327 with falcon patch on Windows
# clone latest rubyinstaller from github
$ git clone https://github.com/oneclick/rubyinstaller.git
$ cd rubyinstaller

# download patches into resources\patches\ruby193 directory
$ mkdir resources\patches\ruby193
$ cd resources\patches\ruby193
$ curl -o 1-falcon.patch https://raw.github.com/gist/4136373/falcon.diff
$ curl -O https://raw.github.com/gist/4199712/2-fix-file-expand_path-globing.patch
$ cd ..\..\..

# Build ruby
$ rake ruby19

# Install
$ xcopy /E/H/Y sandbox\ruby19_mingw C:\Ruby193p327opt\
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index f3c36aa..d80c430 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -601,6 +601,13 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal("#{DRIVE}/dir", File.expand_path("#{DRIVE}/./dir"))
end
+ def test_expand_path_does_not_expand_wildcards
+ assert_equal("#{DRIVE}/*", File.expand_path("./*", "#{DRIVE}/"))
+ assert_equal("#{Dir.pwd}/*", File.expand_path("./*", Dir.pwd))
+ assert_equal("#{DRIVE}/?", File.expand_path("./?", "#{DRIVE}/"))
+ assert_equal("#{Dir.pwd}/?", File.expand_path("./?", Dir.pwd))
+ end if DRIVE
+
def test_expand_path_does_not_modify_the_string_argument
str = "./a/b/../c"
assert_equal("#{Dir.pwd}/a/c", File.expand_path(str, Dir.pwd))
diff --git a/win32/file.c b/win32/file.c
index e3b50b4..dfe1224 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -276,6 +276,11 @@ replace_to_long_name(wchar_t **wfullpath, size_t size, int heap)
return size;
}
+ /* skip long name conversion if path contains wildcard characters */
+ if (wcspbrk(pos, L"*?")) {
+ return size;
+ }
+
pos = *wfullpath + size - 1;
while (!IS_DIR_SEPARATOR_P(*pos) && pos != *wfullpath) {
if (!extension_len && *pos == L'.') {

vanilla

C:\devruby\measurements>rci bench core_require_empty
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]
Rehearsal ------------------------------------------------------
core_require_empty   0.469000   1.110000   1.579000 (  1.656250)
--------------------------------------------- total: 1.579000sec

                         user     system      total        real
core_require_empty   0.718000   0.875000   1.593000 (  1.640625)

patched

C:\devruby\measurements>rci bench core_require_empty
ruby 1.9.3p327 (2012-11-10 revision 37606) [i386-mingw32]
Rehearsal ------------------------------------------------------
core_require_empty   0.453000   0.906000   1.359000 (  1.359375)
--------------------------------------------- total: 1.359000sec

                         user     system      total        real
core_require_empty   0.438000   0.907000   1.345000 (  1.375000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment