summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-07 02:17:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-07 02:17:10 +0000
commitf18065f469e302711f9d98813ee72549dfa21ce8 (patch)
tree577327cf423511dab66de3c2604e524702811328
parent9b6a8da0ebc6b39d19b671c8f5e3cb4f8cb7a3f9 (diff)
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/etc/etc.c17
2 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ff2478f..8a0d18d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Oct 7 11:17:08 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* configure.in (struct stat.st_size): prefer off_t over int, long,
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 0a70c27..6560dd9 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -640,7 +640,22 @@ etc_systmpdir(void)
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;