summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;