Skip to content

Ruby 1.8.X Breaking Change: rb_hash_dup #35

@Nejuf

Description

@Nejuf
@@ -144,21 +174,13 @@ rb_ldap_entry_get_attributes (VALUE self)
 VALUE
 rb_ldap_entry_to_hash (VALUE self)
 {
-  VALUE attrs = rb_ldap_entry_get_attributes (self);
-  VALUE hash = rb_hash_new ();
-  VALUE attr, vals;
-  int i;
-
-  Check_Type (attrs, T_ARRAY);
-  rb_hash_aset (hash, rb_tainted_str_new2 ("dn"),
-               rb_ary_new3 (1, rb_ldap_entry_get_dn (self)));
-  for (i = 0; i < RARRAY_LEN (attrs); i++)
-    {
-      attr = rb_ary_entry (attrs, i);
-      vals = rb_ldap_entry_get_values (self, attr);
-      rb_hash_aset (hash, attr, vals);
-    }
+  RB_LDAPENTRY_DATA *edata;
+  VALUE hash, dn_ary;

+  GET_LDAPENTRY_DATA (self, edata);
+  hash = rb_hash_dup(edata->attr);
+  dn_ary = rb_ary_new3(1, edata->dn);
+  rb_hash_aset(hash, rb_tainted_str_new2("dn"), dn_ary);
   return hash;

v0.9.17 #32 introduced a breaking change for Ruby 1.8.X. The rb_hash_dup method was not added until Ruby 1.9. Below is the resulting error.

symbol lookup error: /opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.17/lib/ldap.so: undefined symbol: rb_hash_dup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions