Ruby 1.9.3p327(2012-11-10revision37606)
|
00001 #include "ruby.h" 00002 00003 static VALUE 00004 bug_str_cstr_term(VALUE str) 00005 { 00006 long len; 00007 char *s; 00008 rb_str_modify(str); 00009 len = RSTRING_LEN(str); 00010 RSTRING_PTR(str)[len] = 'x'; 00011 s = StringValueCStr(str); 00012 rb_gc(); 00013 return INT2NUM(s[len]); 00014 } 00015 00016 void 00017 Init_cstr(VALUE klass) 00018 { 00019 rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0); 00020 } 00021