about summary refs log tree commit homepage
diff options
context:
space:
mode:
-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));
         }