1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
From ee464be3d02c424970a29e39002ec7a8decc2721 Mon Sep 17 00:00:00 2001
From: Adam Palmblad <adam.palmblad@teampages.com>
Date: Tue, 6 Jan 2015 19:28:14 -0800
Subject: [PATCH] multimap would not compile in ruby 2.2
Per https://github.com/ruby/ruby/commit/8250aa2df0d6b4dcfa11dbad5307d28c2d5dd85f, RHASH is no longer provided by ruby.h. Looks like multimap just needed an RHASH_IFNONE check anyways, so I've replaced it with that macro, which is available, and defined it to what it was prior to ruby 2.2 if it is not available.
Note that RHASH_IFNONE is deprecated, so this is just kicking the can
down the road a bit.
---
ext/nested_multimap_ext.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ext/nested_multimap_ext.c b/ext/nested_multimap_ext.c
index 9f42615..30910a6 100644
--- a/ext/nested_multimap_ext.c
+++ b/ext/nested_multimap_ext.c
@@ -1,4 +1,7 @@
#include "ruby.h"
+#ifndef RHASH_IFNONE
+#define HASH_IFNONE (RHASH(h)->ifnone)
+#endif
VALUE cNestedMultimap;
@@ -10,7 +13,7 @@ static VALUE rb_nested_multimap_aref(int argc, VALUE *argv, VALUE self)
for (i = 0, r = self; rb_obj_is_kind_of(r, cNestedMultimap) == Qtrue; i++) {
h = rb_funcall(r, rb_intern("_internal_hash"), 0);
Check_Type(h, T_HASH);
- r = (i < argc) ? rb_hash_aref(h, argv[i]) : RHASH(h)->ifnone;
+ r = (i < argc) ? rb_hash_aref(h, argv[i]) : RHASH_IFNONE(h);
}
return r;
|