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

ruby-changes:9795

From: nobu <ko1@a...>
Date: Mon, 5 Jan 2009 12:52:32 +0900 (JST)
Subject: [ruby-changes:9795] Ruby:r21336 (trunk, ruby_1_8): * win32/win32.c (init_env): use user profile folder than personal

nobu	2009-01-05 12:52:11 +0900 (Mon, 05 Jan 2009)

  New Revision: 21336

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

  Log:
    * win32/win32.c (init_env): use user profile folder than personal
      folder.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/version.h
    branches/ruby_1_8/win32/win32.c
    trunk/ChangeLog
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21335)
+++ ChangeLog	(revision 21336)
@@ -1,3 +1,8 @@
+Mon Jan  5 12:52:08 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (init_env): use user profile folder than personal
+	  folder.
+
 Mon Jan  5 08:41:13 2009  Yukihiro Matsumoto  <matz@r...>
 
 	* file.c (rb_file_s_stat): need type check for non string values.
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 21335)
+++ win32/win32.c	(revision 21336)
@@ -360,13 +360,31 @@
     return p;
 }
 
+#ifndef CSIDL_PROFILE
+#define CSIDL_PROFILE 40
+#endif
+
+static BOOL
+get_special_folder(int n, char *env)
+{
+    LPITEMIDLIST pidl;
+    LPMALLOC alloc;
+    BOOL f = FALSE;
+    if (SHGetSpecialFolderLocation(NULL, n, &pidl) == 0) {
+	f = SHGetPathFromIDList(pidl, env);
+	SHGetMalloc(&alloc);
+	alloc->lpVtbl->Free(alloc, pidl);
+	alloc->lpVtbl->Release(alloc);
+    }
+    return f;
+}
+
 static void
 init_env(void)
 {
     char env[_MAX_PATH];
     DWORD len;
     BOOL f;
-    LPITEMIDLIST pidl;
 
     if (!GetEnvironmentVariable("HOME", env, sizeof(env))) {
 	f = FALSE;
@@ -380,13 +398,12 @@
 	else if (GetEnvironmentVariable("USERPROFILE", env, sizeof(env))) {
 	    f = TRUE;
 	}
-	else if (SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl) == 0) {
-	    LPMALLOC alloc;
-	    f = SHGetPathFromIDList(pidl, env);
-	    SHGetMalloc(&alloc);
-	    alloc->lpVtbl->Free(alloc, pidl);
-	    alloc->lpVtbl->Release(alloc);
+	else if (get_special_folder(CSIDL_PROFILE, env)) {
+	    f = TRUE;
 	}
+	else if (get_special_folder(CSIDL_PERSONAL, env)) {
+	    f = TRUE;
+	}
 	if (f) {
 	    char *p = translate_char(env, '\\', '/');
 	    if (p - env == 2 && env[1] == ':') {
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 21335)
+++ ruby_1_8/ChangeLog	(revision 21336)
@@ -1,3 +1,8 @@
+Mon Jan  5 12:52:08 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (init_env): use user profile folder than personal
+	  folder.
+
 Sun Jan  4 11:58:43 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* numeric.c (ruby_float_step): extracted from num_step().
Index: ruby_1_8/version.h
===================================================================
--- ruby_1_8/version.h	(revision 21335)
+++ ruby_1_8/version.h	(revision 21336)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2009-01-04"
+#define RUBY_RELEASE_DATE "2009-01-05"
 #define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20090104
+#define RUBY_RELEASE_CODE 20090105
 #define RUBY_PATCHLEVEL 5000
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 7
 #define RUBY_RELEASE_YEAR 2009
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 4
+#define RUBY_RELEASE_DAY 5
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8/win32/win32.c
===================================================================
--- ruby_1_8/win32/win32.c	(revision 21335)
+++ ruby_1_8/win32/win32.c	(revision 21336)
@@ -389,13 +389,31 @@
     DeleteCriticalSection(&select_mutex);
 }
 
+#ifndef CSIDL_PROFILE
+#define CSIDL_PROFILE 40
+#endif
+
+static BOOL
+get_special_folder(int n, char *env)
+{
+    LPITEMIDLIST pidl;
+    LPMALLOC alloc;
+    BOOL f = FALSE;
+    if (SHGetSpecialFolderLocation(NULL, n, &pidl) == 0) {
+	f = SHGetPathFromIDList(pidl, env);
+	SHGetMalloc(&alloc);
+	alloc->lpVtbl->Free(alloc, pidl);
+	alloc->lpVtbl->Release(alloc);
+    }
+    return f;
+}
+
 static void
 init_env(void)
 {
     char env[_MAX_PATH];
     DWORD len;
     BOOL f;
-    LPITEMIDLIST pidl;
 
     if (!GetEnvironmentVariable("HOME", env, sizeof(env))) {
 	f = FALSE;
@@ -409,13 +427,12 @@
 	else if (GetEnvironmentVariable("USERPROFILE", env, sizeof(env))) {
 	    f = TRUE;
 	}
-	else if (SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl) == 0) {
-	    LPMALLOC alloc;
-	    f = SHGetPathFromIDList(pidl, env);
-	    SHGetMalloc(&alloc);
-	    alloc->lpVtbl->Free(alloc, pidl);
-	    alloc->lpVtbl->Release(alloc);
+	else if (get_special_folder(CSIDL_PROFILE, env)) {
+	    f = TRUE;
 	}
+	else if (get_special_folder(CSIDL_PERSONAL, env)) {
+	    f = TRUE;
+	}
 	if (f) {
 	    char *p = env;
 	    while (*p) {

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

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