From: Richard W.M. Jones Date: Mon, 5 Dec 2011 10:36:13 +0000 (+0000) Subject: ruby: Use RSTRING_PTR, RSTRING_LEN for compat with Ruby 1.9 (RHBZ#760000). X-Git-Tag: 1.15.10~2 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=2972987d0257d9c3d26b53f961e802d121b436cd;p=libguestfs.git ruby: Use RSTRING_PTR, RSTRING_LEN for compat with Ruby 1.9 (RHBZ#760000). --- diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index a43b21f..82d0018 100644 --- a/generator/generator_ruby.ml +++ b/generator/generator_ruby.ml @@ -50,6 +50,15 @@ let rec generate_ruby_c () = #define RARRAY_LEN(r) (RARRAY((r))->len) #endif +/* For Ruby < 1.8 */ +#ifndef RSTRING_LEN +#define RSTRING_LEN(r) (RSTRING((r))->len) +#endif + +#ifndef RSTRING_PTR +#define RSTRING_PTR(r) (RSTRING((r))->ptr) +#endif + static VALUE m_guestfs; /* guestfs module */ static VALUE c_guestfs; /* guestfs_h handle */ static VALUE e_Error; /* used for all errors */ @@ -417,11 +426,11 @@ ruby_user_cancel (VALUE gv) pr " const char *%s = StringValueCStr (%sv);\n" n n; | BufferIn n -> pr " Check_Type (%sv, T_STRING);\n" n; - pr " const char *%s = RSTRING (%sv)->ptr;\n" n n; + pr " const char *%s = RSTRING_PTR (%sv);\n" n n; pr " if (!%s)\n" n; pr " rb_raise (rb_eTypeError, \"expected string for parameter %%s of %%s\",\n"; pr " \"%s\", \"%s\");\n" n name; - pr " size_t %s_size = RSTRING (%sv)->len;\n" n n + pr " size_t %s_size = RSTRING_LEN (%sv);\n" n n | OptString n -> pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n n | StringList n | DeviceList n ->