From a70468036d9b780bc7ec921f7feb6e1275778169 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 28 Aug 2009 20:47:43 -0700 Subject: initial import --- ext/clogger_ext/ruby_1_9_compat.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ext/clogger_ext/ruby_1_9_compat.h (limited to 'ext/clogger_ext/ruby_1_9_compat.h') 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 -- cgit v1.2.3-24-ge0c7