about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-31 09:10:09 +0000
committerEric Wong <normalperson@yhbt.net>2011-01-31 09:10:09 +0000
commitea0455e966a95f7a4be0c8f4b9c0481f0392ff39 (patch)
tree0147f7ada42bf61767aa739b344cf98143ea2234
parent480219900f3d47c7b9ddf830a1e19b4aa39e83e2 (diff)
downloadmahoro-ea0455e966a95f7a4be0c8f4b9c0481f0392ff39.tar.gz
update for Ruby 1.9 compatibility
RSTRING(str)->len no longer works in Ruby 1.9 due to internal
data representation changes for performance.
-rw-r--r--mahoro.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mahoro.c b/mahoro.c
index 6476bc6..2ee9953 100644
--- a/mahoro.c
+++ b/mahoro.c
@@ -5,6 +5,10 @@
 #include <ruby.h>
 #include <magic.h>
 
+#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));
         }