From 1a2a4084d94b750646874e5f383b34fcc606dcc9 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 31 Oct 2015 23:39:37 +0000 Subject: [PATCH] tcltklib.c: basename * ext/tk/tcltklib.c (setup_rubytkkit): use ruby_enc_find_basename if available, instead of File.basename. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/extconf.rb | 4 +++- ext/tk/tcltklib.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb index 12bccd58f7fe18..a6e87eb5b30d10 100644 --- a/ext/tk/extconf.rb +++ b/ext/tk/extconf.rb @@ -1795,7 +1795,9 @@ def pthread_check() %w"ruby_native_thread_p rb_errinfo rb_safe_level rb_hash_lookup rb_proc_new rb_obj_untrust rb_obj_taint rb_set_safe_level_force - rb_sourcefile rb_thread_alive_p rb_thread_check_trap_pending".each do |func| + rb_sourcefile rb_thread_alive_p rb_thread_check_trap_pending + ruby_enc_find_basename +".each do |func| have_func(func, "ruby.h") print(".") # progress end diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index 01479301d8d81c..2906cb7281de6c 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -1263,11 +1263,17 @@ setup_rubytkkit(void) #ifdef __WIN32__ /* rbtk_win32_SetHINSTANCE("tcltklib.so"); */ { +# ifdef HAVE_RUBY_ENC_FIND_BASENAME + const char *base = ruby_enc_find_basename(rb_sourcefile(), NULL, NULL, + rb_filesystem_encoding()); + rbtk_win32_SetHINSTANCE(base); +# else VALUE basename; basename = rb_funcall(rb_cFile, rb_intern("basename"), 1, rb_str_new2(rb_sourcefile())); rbtk_win32_SetHINSTANCE(RSTRING_PTR(basename)); RB_GC_GUARD(basename); +# endif } #endif set_rubytk_kitpath(rb_sourcefile());