aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-09 14:10:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-09 14:10:32 +0000
commit3ed259abbc4317322a6354ab1a2fd7a92a845551 (patch)
tree4008442489fff3797f600b15cc687e3c329a61bc
parent8c8796333afcfc6a889cb7af614b4bf6b5d16057 (diff)
downloadruby-3ed259abbc4317322a6354ab1a2fd7a92a845551.tar.gz
* win32/win32.c (isUNCRoot, winnt_stat): support long UNC.
[ruby-core:30623][Feature #3399] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_file.rb10
-rw-r--r--win32/win32.c11
3 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index daf4dac952..b76ee58d85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Apr 9 23:10:26 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * win32/win32.c (isUNCRoot, winnt_stat): support long UNC.
+ [ruby-core:30623][Feature #3399]
+
Mon Apr 9 15:16:01 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (string_content, parser_yylex): count brace nesting to
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index cc266a4c4a..52dcffdcd0 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -204,4 +204,14 @@ class TestFile < Test::Unit::TestCase
assert_equal(File.chmod(0666, file), 1, bug5671)
end
end
+
+ if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM
+ def test_long_unc
+ feature3399 = '[ruby-core:30623]'
+ path = File.expand_path(__FILE__)
+ assert_nothing_raised(Errno::ENOENT, feature3399) do
+ File.stat("//?/#{path}")
+ end
+ end
+ end
end
diff --git a/win32/win32.c b/win32/win32.c
index 82ed1104c3..e7dfa9d39b 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4407,8 +4407,11 @@ static int
isUNCRoot(const WCHAR *path)
{
if (path[0] == L'\\' && path[1] == L'\\') {
- const WCHAR *p;
- for (p = path + 2; *p; p++) {
+ const WCHAR *p = path + 2;
+ if (p[0] == L'?' && p[1] == L'\\') {
+ p += 2;
+ }
+ for (; *p; p++) {
if (*p == L'\\')
break;
}
@@ -4577,11 +4580,13 @@ winnt_stat(const WCHAR *path, struct stati64 *st)
{
HANDLE h;
WIN32_FIND_DATAW wfd;
+ const WCHAR *p = path;
memset(st, 0, sizeof(*st));
st->st_nlink = 1;
- if (wcspbrk(path, L"?*")) {
+ if (wcsncmp(p, L"\\\\?\\", 4) == 0) p += 4;
+ if (wcspbrk(p, L"?*")) {
errno = ENOENT;
return -1;
}