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

ruby-changes:37456

From: nobu <ko1@a...>
Date: Sat, 7 Feb 2015 19:25:40 +0900 (JST)
Subject: [ruby-changes:37456] nobu:r49537 (trunk): dir.c: long path name on Windows

nobu	2015-02-07 19:25:27 +0900 (Sat, 07 Feb 2015)

  New Revision: 49537

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

  Log:
    dir.c: long path name on Windows
    
    * dir.c (has_magic): always get long path name on Windows even if
      no tilde is there.  [ruby-core:68011] [Bug #10819]
    * dir.c (replace_real_basename): FindFirstFile ignore redirection
      character, check if exists before call it.  cf. [Bug #8597]

  Modified files:
    trunk/ChangeLog
    trunk/dir.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49536)
+++ ChangeLog	(revision 49537)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Feb  7 19:25:25 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (has_magic): always get long path name on Windows even if
+	  no tilde is there.  [ruby-core:68011] [Bug #10819]
+
+	* dir.c (replace_real_basename): FindFirstFile ignore redirection
+	  character, check if exists before call it.  cf. [Bug #8597]
+
 Sat Feb  7 13:30:11 2015  Masaki Suketa <masaki.suketa@n...>
 
 	* test/win32ole/test_win32ole_record.rb
Index: dir.c
===================================================================
--- dir.c	(revision 49536)
+++ dir.c	(revision 49537)
@@ -71,6 +71,9 @@ char *strchr(char*,char); https://github.com/ruby/ruby/blob/trunk/dir.c#L71
 #define rmdir(p) rb_w32_urmdir(p)
 #undef opendir
 #define opendir(p) rb_w32_uopendir(p)
+#define IS_WIN32 1
+#else
+#define IS_WIN32 0
 #endif
 
 #ifdef HAVE_SYS_ATTR_H
@@ -1210,28 +1213,17 @@ has_magic(const char *p, const char *pen https://github.com/ruby/ruby/blob/trunk/dir.c#L1213
 	    break;
 
 #ifdef _WIN32
+	  case '.':
+	    break;
+
 	  case '~':
-	    /* possibly legacy 8.3 short name */
-	    if (p < pend && (c = *p, ISDIGIT(c))) {
-		while (++p < pend && (c = *p, ISDIGIT(c)));
-		if (p == pend || c == '.') hasalpha = 1;
-	    }
-	    continue;
+	    hasalpha = 1;
+	    break;
 #endif
-
 	  default:
-	    if (ISALPHA(c)) {
+	    if (IS_WIN32 || ISALPHA(c)) {
 		hasalpha = 1;
 	    }
-#ifdef _WIN32
-	    else if (!rb_isascii(c)) {
-		unsigned int code = rb_enc_mbc_to_codepoint(p, pend, enc);
-		if (ONIGENC_IS_CODE_ALPHA(enc, code)) {
-		    /* Full width alphabets */
-		    hasalpha = 1;
-		}
-	    }
-#endif
 	    break;
 	}
 
@@ -1469,8 +1461,9 @@ replace_real_basename(char *path, long b https://github.com/ruby/ruby/blob/trunk/dir.c#L1461
     char *plainname = path;
     volatile VALUE tmp = 0;
     WIN32_FIND_DATAW fd;
+    WIN32_FILE_ATTRIBUTE_DATA fa;
     WCHAR *wplain;
-    HANDLE h;
+    HANDLE h = INVALID_HANDLE_VALUE;
     long wlen;
     if (enc &&
 	enc != rb_usascii_encoding() &&
@@ -1483,7 +1476,8 @@ replace_real_basename(char *path, long b https://github.com/ruby/ruby/blob/trunk/dir.c#L1476
     wplain = rb_w32_mbstr_to_wstr(CP_UTF8, plainname, -1, &wlen);
     if (tmp) rb_str_resize(tmp, 0);
     if (!wplain) return path;
-    h = FindFirstFileW(wplain, &fd);
+    if (GetFileAttributesExW(wplain, GetFileExInfoStandard, &fa))
+	h = FindFirstFileW(wplain, &fd);
     free(wplain);
     if (h == INVALID_HANDLE_VALUE) return path;
     FindClose(h);

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

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