From: KUBO Takehiro Date: 2008-01-02T23:36:00+09:00 Subject: Re: Using "sort!" in a C extension (1.9 problem) Hi, On Jan 2, 2008 10:13 PM, Andre Nathan wrote: > Is this patch going to be applied? Should I send a report to ruby-core? No. I found a correct way. 1. add the following line to 'extconf.rb' before create_makefile. have_type('rb_block_call_func', 'ruby.h') 2. fix sort_by_length as follows. static VALUE sort_by_length(VALUE i, VALUE dummy #ifdef HAVE_TYPE_RB_BLOCK_CALL_FUNC , int argc, VALUE *argv #endif ) { #ifdef HAVE_TYPE_RB_BLOCK_CALL_FUNC /* ruby 1.9 uses argc and argv. */ VALUE a0 = argv[0]; VALUE a1 = argv[1]; #else /* ruby 1.8 uses i. */ VALUE a0 = RARRAY_PTR(i)[0]; VALUE a1 = RARRAY_PTR(i)[1]; #endif Check_Type(a0, T_ARRAY); Check_Type(a1, T_ARRAY); return LONG2FIX(RARRAY_LEN(a0) - RARRAY_LEN(a1)); }