about summary refs log tree commit homepage
path: root/ext/clogger_ext/ruby_1_9_compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'ext/clogger_ext/ruby_1_9_compat.h')
-rw-r--r--ext/clogger_ext/ruby_1_9_compat.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/clogger_ext/ruby_1_9_compat.h b/ext/clogger_ext/ruby_1_9_compat.h
new file mode 100644
index 0000000..e0ba4ac
--- /dev/null
+++ b/ext/clogger_ext/ruby_1_9_compat.h
@@ -0,0 +1,23 @@
+/* Ruby 1.8.6+ macros (for compatibility with Ruby 1.9) */
+#ifndef RSTRING_PTR
+#  define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#endif
+#ifndef RSTRING_LEN
+#  define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+#ifndef RARRAY_PTR
+#  define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#endif
+#ifndef RARRAY_LEN
+#  define RARRAY_LEN(s) (RARRAY(s)->len)
+#endif
+
+#ifndef HAVE_RB_STR_SET_LEN
+/* this is taken from Ruby 1.8.7, 1.8.6 may not have it */
+static void rb_18_str_set_len(VALUE str, long len)
+{
+        RSTRING(str)->len = len;
+        RSTRING(str)->ptr[len] = '\0';
+}
+#define rb_str_set_len(str,len) rb_18_str_set_len(str,len)
+#endif