File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,10 @@ def configure_extension
109109
110110 abort_could_not_find ( libname ) unless find_library ( libname , "sqlite3_libversion_number" , "sqlite3.h" )
111111
112+ # Truffle Ruby doesn't support this yet:
113+ # https://github.com/oracle/truffleruby/issues/3408
114+ have_func ( "rb_enc_interned_str_cstr" )
115+
112116 # Functions defined in 1.9 but not 1.8
113117 have_func ( "rb_proc_arity" )
114118
Original file line number Diff line number Diff line change @@ -364,6 +364,22 @@ column_count(VALUE self)
364364 return INT2NUM (sqlite3_column_count (ctx -> st ));
365365}
366366
367+ #if HAVE_RB_ENC_INTERNED_STR_CSTR
368+ static VALUE
369+ interned_utf8_cstr (const char * str )
370+ {
371+ return rb_enc_interned_str_cstr (str , rb_utf8_encoding ());
372+ }
373+ #else
374+ static VALUE
375+ interned_utf8_cstr (const char * str )
376+ {
377+ VALUE rb_str = rb_utf8_str_new_cstr (str );
378+ rb_funcall (rb_str , rb_intern ("-@" ), 0 );
379+ return rb_str ;
380+ }
381+ #endif
382+
367383/* call-seq: stmt.column_name(index)
368384 *
369385 * Get the column name at +index+. 0 based.
@@ -382,7 +398,7 @@ column_name(VALUE self, VALUE index)
382398 VALUE ret = Qnil ;
383399
384400 if (name ) {
385- ret = rb_enc_interned_str_cstr (name , rb_utf8_encoding () );
401+ ret = interned_utf8_cstr (name );
386402 }
387403 return ret ;
388404}
You can’t perform that action at this time.
0 commit comments