Unable to Patch C extension gems - What approach?
shawn.starr at rogers.com
shawn.starr at rogers.com
Wed Feb 8 03:10:16 UTC 2012
>>On Tuesday, February 07, 2012 09:15:49 PM Shawn Starr wrote:
In addition, I can't run any minitests with 1.9.3 and
rubygems-1.8.15-2.fc17.1.noarch?
$ ruby -r test/unit -e 'print 1'
/usr/share/rubygems/rubygems/custom_require.rb:36:in `require': cannot load
such file -- minitest/unit (LoadError)
from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /usr/share/ruby/test/unit.rb:3:in `<top (required)>'
from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
Thanks,
Shawn.
> Hello,
>
> What would be the best way to patch C code which fails to build for 1.9.x?
>
> I previous packaged rubygem-idn but this broke now with 1.9.3 (hence its
> failing in rawhide)
>
> What is recommendation? I can unpack but there's no gemspec file to rebuild
> the gem. I cant use install since it clobbers any changes made.
>
> Can someone give me an idea on the proper solution in this case?
>
> Spec:
>
> <snip>
>
> %prep
> %setup -q -c -T
>
> mkdir -p .%{gem_dir}
> export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
> gem unpack -V --target .%{gem_dir} \
> %{SOURCE0}
>
> pushd ./%{gem_dir}/%{gem_name}-%{version}
>
> # Patch for Ruby 1.9 changes
> %patch0
>
> popd
>
> Patch:
>
> diff -Nrup ext/idna.c ext.fixed/idna.c
> --- ext/idna.c 1969-12-31 19:00:00.000000000 -0500
> +++ ext.fixed/idna.c 2012-02-07 20:49:34.456092037 -0500
> @@ -85,7 +85,7 @@ static VALUE toASCII(int argc, VALUE arg
> flags = 0x0000;
> }
>
> - rc = idna_to_ascii_8z(RSTRING(str)->ptr, &buf, flags);
> + rc = idna_to_ascii_8z(RSTRING_PTR(str), &buf, flags);
>
> if (rc != IDNA_SUCCESS) {
> xfree(buf);
> @@ -125,7 +125,7 @@ static VALUE toUnicode(int argc, VALUE a
> flags = 0x0000;
> }
>
> - rc = idna_to_unicode_8z8z(RSTRING(str)->ptr, &buf, flags);
> + rc = idna_to_unicode_8z8z(RSTRING_PTR(str), &buf, flags);
>
> if (rc != IDNA_SUCCESS) {
> xfree(buf);
> diff -Nrup ext/punycode.c ext.fixed/punycode.c
> --- ext/punycode.c 1969-12-31 19:00:00.000000000 -0500
> +++ ext.fixed/punycode.c 2012-02-07 20:51:15.247831966 -0500
> @@ -66,7 +66,7 @@ static VALUE encode(VALUE self, VALUE st
> VALUE retv;
>
> str = rb_check_convert_type(str, T_STRING, "String", "to_s");
> - ustr = stringprep_utf8_to_ucs4(RSTRING(str)->ptr, RSTRING(str)->len,
> &len); + ustr = stringprep_utf8_to_ucs4(RSTRING_PTR(str),
> RSTRING_LEN(str), &len);
>
> while (1) {
> buf = realloc(buf, buflen);
> @@ -116,7 +116,7 @@ static VALUE decode(VALUE self, VALUE st
>
> str = rb_check_convert_type(str, T_STRING, "String", "to_s");
>
> - len = RSTRING(str)->len;
> + len = RSTRING_LEN(str);
> ustr = malloc(len * sizeof(punycode_uint));
>
> if (ustr == NULL) {
> @@ -124,7 +124,7 @@ static VALUE decode(VALUE self, VALUE st
> return Qnil;
> }
>
> - rc = punycode_decode(RSTRING(str)->len, RSTRING(str)->ptr,
> + rc = punycode_decode(RSTRING_LEN(str), RSTRING_PTR(str),
> &len, ustr, NULL);
>
> if (rc != PUNYCODE_SUCCESS) {
> diff -Nrup ext/stringprep.c ext.fixed/stringprep.c
> --- ext/stringprep.c 1969-12-31 19:00:00.000000000 -0500
> +++ ext.fixed/stringprep.c 2012-02-07 20:50:11.559628179 -0500
> @@ -64,7 +64,7 @@ static VALUE stringprep_internal(VALUE s
> VALUE retv;
>
> str = rb_check_convert_type(str, T_STRING, "String", "to_s");
> - rc = stringprep_profile(RSTRING(str)->ptr, &buf, profile, 0);
> + rc = stringprep_profile(RSTRING_PTR(str), &buf, profile, 0);
>
> if (rc != STRINGPREP_OK) {
> rb_raise(eStringprepError, "%s (%d)", stringprep_strerror(rc), rc);
> @@ -135,7 +135,7 @@ static VALUE resourceprep(VALUE self, VA
> static VALUE with_profile(VALUE self, VALUE str, VALUE profile)
> {
> profile = rb_check_convert_type(profile, T_STRING, "String", "to_s");
> - return stringprep_internal(str, RSTRING(profile)->ptr);
> + return stringprep_internal(str, RSTRING_PTR(profile));
> }
>
> /*
> @@ -153,7 +153,7 @@ static VALUE nfkc_normalize(VALUE self,
> VALUE retv;
>
> str = rb_check_convert_type(str, T_STRING, "String", "to_s");
> - buf = stringprep_utf8_nfkc_normalize(RSTRING(str)->ptr,
> RSTRING(str)->len); + buf =
> stringprep_utf8_nfkc_normalize(RSTRING_PTR(str), RSTRING_LEN(str));
>
> retv = rb_str_new2(buf);
> xfree(buf);
More information about the ruby-sig
mailing list