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

ruby-changes:35744

From: nobu <ko1@a...>
Date: Tue, 7 Oct 2014 11:17:18 +0900 (JST)
Subject: [ruby-changes:35744] nobu:r47826 (trunk): etc.c: try confstr on Mac OS X

nobu	2014-10-07 11:17:10 +0900 (Tue, 07 Oct 2014)

  New Revision: 47826

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

  Log:
    etc.c: try confstr on Mac OS X
    
    * ext/etc/etc.c (etc_systmpdir): try user temporary directory by
      confstr() on Mac OS X.
      c.f. http://www.opensource.apple.com/source/ruby/ruby-104/patches/ext_etc_etc.c.diff

  Modified files:
    trunk/ChangeLog
    trunk/ext/etc/etc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47825)
+++ ChangeLog	(revision 47826)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct  7 11:17:08 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/etc/etc.c (etc_systmpdir): try user temporary directory by
+	  confstr() on Mac OS X.
+	  c.f. http://www.opensource.apple.com/source/ruby/ruby-104/patches/ext_etc_etc.c.diff
+
 Tue Oct  7 10:48:17 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (struct stat.st_size): prefer off_t over int, long,
Index: ext/etc/etc.c
===================================================================
--- ext/etc/etc.c	(revision 47825)
+++ ext/etc/etc.c	(revision 47826)
@@ -640,7 +640,22 @@ etc_systmpdir(void) https://github.com/ruby/ruby/blob/trunk/ext/etc/etc.c#L640
     if (!len) return Qnil;
     tmpdir = rb_w32_conv_from_wchar(path, rb_filesystem_encoding());
 #else
-    tmpdir = rb_filesystem_str_new_cstr("/tmp");
+    const char default_tmp[] = "/tmp";
+    const char *tmpstr = default_tmp;
+    size_t tmplen = 0;
+# if defined _CS_DARWIN_USER_TEMP_DIR
+    #ifndef MAXPATHLEN
+    #define MAXPATHLEN 1024
+    #endif
+    char path[MAXPATHLEN];
+    size_t len;
+    len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path));
+    if (len > 0) {
+	tmpstr = path;
+	tmplen = len - 1;
+    }
+# endif
+    tmpdir = rb_filesystem_str_new(tmpstr, tmplen);
 #endif
     FL_UNSET(tmpdir, FL_TAINT);
     return tmpdir;

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

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