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

ruby-changes:39836

From: nobu <ko1@a...>
Date: Tue, 22 Sep 2015 21:00:08 +0900 (JST)
Subject: [ruby-changes:39836] nobu:r51917 (trunk): win32.c: fallback to WCHAR-version in MSVCRT

nobu	2015-09-22 20:59:47 +0900 (Tue, 22 Sep 2015)

  New Revision: 51917

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

  Log:
    win32.c: fallback to WCHAR-version in MSVCRT
    
    * win32/win32.c (rb_w32_open): should not fallback to ANSI-version
      in MSVCRT, fallback to WCHAR-version in rb_w32_wopen instead.

  Modified files:
    trunk/win32/win32.c
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 51916)
+++ win32/win32.c	(revision 51917)
@@ -5975,19 +5975,7 @@ check_if_wdir(const WCHAR *wfile) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5975
     return TRUE;
 }
 
-/* License: Ruby's */
-static int
-check_if_dir(const char *file)
-{
-    WCHAR *wfile;
-    int ret;
-
-    if (!(wfile = filecp_to_wstr(file, NULL)))
-	return FALSE;
-    ret = check_if_wdir(wfile);
-    free(wfile);
-    return ret;
-}
+static int w32_wopen(const WCHAR *file, int oflag, int perm);
 
 /* License: Ruby's */
 int
@@ -6002,16 +5990,9 @@ rb_w32_open(const char *file, int oflag, https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5990
     pmode = va_arg(arg, int);
     va_end(arg);
 
-    if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
-	oflag &= ~O_SHARE_DELETE;
-	ret = _open(file, oflag, pmode);
-	if (ret == -1 && errno == EACCES) check_if_dir(file);
-	return ret;
-    }
-
     if (!(wfile = filecp_to_wstr(file, NULL)))
 	return -1;
-    ret = rb_w32_wopen(wfile, oflag, pmode);
+    ret = w32_wopen(wfile, oflag, pmode);
     free(wfile);
     return ret;
 }
@@ -6020,6 +6001,21 @@ rb_w32_open(const char *file, int oflag, https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6001
 int
 rb_w32_wopen(const WCHAR *file, int oflag, ...)
 {
+    int pmode = 0;
+
+    if (oflag & O_CREAT) {
+	va_list arg;
+	va_start(arg, oflag);
+	pmode = va_arg(arg, int);
+	va_end(arg);
+    }
+
+    return w32_wopen(file, oflag, pmode);
+}
+
+static int
+w32_wopen(const WCHAR *file, int oflag, int pmode)
+{
     char flags = 0;
     int fd;
     DWORD access;
@@ -6032,11 +6028,6 @@ rb_w32_wopen(const WCHAR *file, int ofla https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6028
     share_delete = oflag & O_SHARE_DELETE ? FILE_SHARE_DELETE : 0;
     oflag &= ~O_SHARE_DELETE;
     if ((oflag & O_TEXT) || !(oflag & O_BINARY)) {
-	va_list arg;
-	int pmode;
-	va_start(arg, oflag);
-	pmode = va_arg(arg, int);
-	va_end(arg);
 	fd = _wopen(file, oflag, pmode);
 	if (fd == -1) {
 	    switch (errno) {
@@ -6105,11 +6096,6 @@ rb_w32_wopen(const WCHAR *file, int ofla https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6096
 	return -1;
     }
     if (oflag & O_CREAT) {
-	va_list arg;
-	int pmode;
-	va_start(arg, oflag);
-	pmode = va_arg(arg, int);
-	va_end(arg);
 	/* TODO: we need to check umask here, but it's not exported... */
 	if (!(pmode & S_IWRITE))
 	    attr = FILE_ATTRIBUTE_READONLY;

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

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