about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2010-09-27 18:06:34 -0700
committerEric Wong <e@yhbt.net>2010-09-27 18:06:34 -0700
commit24f1d168eb0937f0586c45b266bcd208431f0107 (patch)
tree41663ec1fca76d628a9289a4a4cd2689b27f2eca
parente4d204c86e9420023ba3e4d8dbeb6b3fea8d6cf7 (diff)
downloadkgio-24f1d168eb0937f0586c45b266bcd208431f0107.tar.gz
This is tested on Ruby 1.8.6-p114, but may work
for 1.8.5, too.  Ugh, people ought to upgrade.
-rw-r--r--ext/kgio/extconf.rb1
-rw-r--r--ext/kgio/kgio_ext.c1
-rw-r--r--ext/kgio/missing/ancient_ruby.h19
3 files changed, 21 insertions, 0 deletions
diff --git a/ext/kgio/extconf.rb b/ext/kgio/extconf.rb
index 09d710b..dcc1418 100644
--- a/ext/kgio/extconf.rb
+++ b/ext/kgio/extconf.rb
@@ -15,6 +15,7 @@ else
 end
 have_func('rb_io_ascii8bit_binmode')
 have_func('rb_thread_blocking_region')
+have_func('rb_str_set_len')
 
 dir_config('kgio')
 create_makefile('kgio_ext')
diff --git a/ext/kgio/kgio_ext.c b/ext/kgio/kgio_ext.c
index ac6f448..3b20064 100644
--- a/ext/kgio/kgio_ext.c
+++ b/ext/kgio/kgio_ext.c
@@ -15,6 +15,7 @@
 #include <assert.h>
 
 #include "missing/accept4.h"
+#include "missing/ancient_ruby.h"
 #include "nonblock.h"
 #include "my_fileno.h"
 #include "sock_for_fd.h"
diff --git a/ext/kgio/missing/ancient_ruby.h b/ext/kgio/missing/ancient_ruby.h
new file mode 100644
index 0000000..014e4b8
--- /dev/null
+++ b/ext/kgio/missing/ancient_ruby.h
@@ -0,0 +1,19 @@
+#ifndef MISSING_ANCIENT_RUBY_H
+#define MISSING_ANCIENT_RUBY_H
+
+#ifndef HAVE_RB_STR_SET_LEN
+static void rb_str_set_len(VALUE str, long len)
+{
+        RSTRING(str)->len = len;
+        RSTRING(str)->ptr[len] = '\0';
+}
+#endif /* ! HAVE_RB_STR_SET_LEN */
+
+#ifndef RSTRING_PTR
+#  define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#endif /* !defined(RSTRING_PTR) */
+#ifndef RSTRING_LEN
+#  define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif /* !defined(RSTRING_LEN) */
+
+#endif /* MISSING_ANCIENT_RUBY_H */