diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-06-22 09:46:39 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-06-22 11:29:57 +0100 |
commit | 8098d062b4cb70defd4aecba0ba8cd75cf893751 (patch) | |
tree | 912a2a2f6190f680b8bba09ba8841ac3551bcce8 /generator | |
parent | 823ba05ebd8f1a12574a3f154aaf7c8b4f2aeeac (diff) | |
download | libguestfs-8098d062b4cb70defd4aecba0ba8cd75cf893751.tar.gz libguestfs-8098d062b4cb70defd4aecba0ba8cd75cf893751.tar.xz libguestfs-8098d062b4cb70defd4aecba0ba8cd75cf893751.zip |
ruby: Add a replacement rb_hash_lookup function for Ruby 1.8.5.
This function was first added to Ruby in 1.8.7.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator_ruby.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index d438a892..742a0cc4 100644 --- a/generator/generator_ruby.ml +++ b/generator/generator_ruby.ml @@ -35,6 +35,8 @@ let rec generate_ruby_c () = generate_header CStyle LGPLv2plus; pr "\ +#include <config.h> + #include <stdio.h> #include <stdlib.h> #include <stdint.h> @@ -59,6 +61,20 @@ let rec generate_ruby_c () = #define RSTRING_PTR(r) (RSTRING((r))->ptr) #endif +/* For RHEL 5 (Ruby 1.8.5) */ +#ifndef HAVE_RB_HASH_LOOKUP +VALUE +rb_hash_lookup (VALUE hash, VALUE key) +{ + VALUE val; + + if (!st_lookup (RHASH(hash)->tbl, key, &val)) + return Qnil; + + return val; +} +#endif /* !HAVE_RB_HASH_LOOKUP */ + static VALUE m_guestfs; /* guestfs module */ static VALUE c_guestfs; /* guestfs_h handle */ static VALUE e_Error; /* used for all errors */ |