From ea0455e966a95f7a4be0c8f4b9c0481f0392ff39 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 31 Jan 2011 09:10:09 +0000 Subject: update for Ruby 1.9 compatibility RSTRING(str)->len no longer works in Ruby 1.9 due to internal data representation changes for performance. --- mahoro.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mahoro.c b/mahoro.c index 6476bc6..2ee9953 100644 --- a/mahoro.c +++ b/mahoro.c @@ -5,6 +5,10 @@ #include #include +#ifndef RSTRING_LEN +# define RSTRING_LEN(s)->len +#endif + struct MagicCookie { magic_t cookie; @@ -88,7 +92,7 @@ mahoro_buffer(self, input) magic_t cookie = ((struct MagicCookie *) DATA_PTR(self))->cookie; if(!(msg = magic_buffer(cookie, StringValuePtr(input), - RSTRING(StringValue(input))->len))) { + RSTRING_LEN(StringValue(input))))) { rb_raise(eMahoroError, "failed lookup: %s", magic_error(cookie)); } -- cgit v1.2.3-24-ge0c7