diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-08-28 20:47:43 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-08-28 20:48:10 -0700 |
commit | a70468036d9b780bc7ec921f7feb6e1275778169 (patch) | |
tree | 302c8b4f4a30203c9549dbd7579006a729c1830f /ext/clogger_ext/ruby_1_9_compat.h | |
download | clogger-a70468036d9b780bc7ec921f7feb6e1275778169.tar.gz |
Diffstat (limited to 'ext/clogger_ext/ruby_1_9_compat.h')
-rw-r--r-- | ext/clogger_ext/ruby_1_9_compat.h | 23 |
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 |