aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/tkutil
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-28 09:14:59 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-28 09:14:59 +0000
commit41d41fbdb9e2448404865310c295dd666ce60d00 (patch)
tree8a2a332a7cae900cfd066998598bf60e4493f5e7 /ext/tk/tkutil
parent501fdc09d8fa09adc1e326c87942276102cbd92b (diff)
downloadruby-41d41fbdb9e2448404865310c295dd666ce60d00.tar.gz
* ext/tk/stubs.c: When --enable-tcltk-stubs, the initialize
routine creates a Tcl/Tk interpreter and deletes it. However, init cost of Tk's MainWindow is not so small. And that makes it impossible to use libraries written with Tcl functions only on an environment without a graphical display. This changes support delaying initalization of Tk_Stubs until the script needs Tk. * ext/tk/stubs.h: New file. Define prototypes and return codes of functions on stubs.c. * ext/tk/tcltklib.c: Support delaying initalization of Tk_Stubs until the script needs Tk. * ext/tk/tcltklib.c: Show friendly error messages for errors on initialization. * ext/tk/tcltklib.c: Avoid SEGV on ip_finalize() when ruby is exiting and $DEBUG is true. (Not fix. If you know the reason of why, please fix it.) * ext/tk/tkutil/tkutil.c (ary2list, ary2list2): bug fix on handling of encoding. * ext/tk/lib/multi-tk.rb: MultiTkIp#eval_string and bg_eval_string don't work propery. * ext/tk/lib/tk.rb: Forget extending Tk::Encoding module to Tk. * ext/tk/lib/tk/variable.rb: TkVarAccess fails to initialize the object for an element of a Tcl's array variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tkutil')
-rw-r--r--ext/tk/tkutil/tkutil.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c
index 496649f8c5..f191eb1627 100644
--- a/ext/tk/tkutil/tkutil.c
+++ b/ext/tk/tkutil/tkutil.c
@@ -8,7 +8,7 @@
************************************************/
-#define TKUTIL_RELEASE_DATE "2005-07-22"
+#define TKUTIL_RELEASE_DATE "2005-07-28"
#include "ruby.h"
#include "rubysig.h"
@@ -246,16 +246,20 @@ ary2list(ary, enc_flag, self)
volatile VALUE sys_enc, dst_enc, str_enc;
sys_enc = rb_funcall(cTclTkLib, ID_encoding, 0, 0);
- if NIL_P(sys_enc) {
+ if (NIL_P(sys_enc)) {
sys_enc = rb_funcall(cTclTkLib, ID_encoding_system, 0, 0);
+ sys_enc = rb_funcall(sys_enc, ID_to_s, 0, 0);
}
if NIL_P(enc_flag) {
dst_enc = sys_enc;
req_chk_flag = 1;
- } else {
+ } else if (TYPE(enc_flag) == T_TRUE || TYPE(enc_flag) == T_FALSE) {
dst_enc = enc_flag;
req_chk_flag = 0;
+ } else {
+ dst_enc = rb_funcall(enc_flag, ID_to_s, 0, 0);
+ req_chk_flag = 0;
}
/* size = RARRAY(ary)->len; */
@@ -280,7 +284,7 @@ ary2list(ary, enc_flag, self)
if (req_chk_flag) {
str_enc = rb_ivar_get(str_val, ID_at_enc);
- if NIL_P(str_enc) {
+ if (!NIL_P(str_enc)) {
str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
} else {
str_enc = sys_enc;
@@ -327,7 +331,7 @@ ary2list(ary, enc_flag, self)
if (req_chk_flag) {
str_enc = rb_ivar_get(str_val, ID_at_enc);
- if NIL_P(str_enc) {
+ if (!NIL_P(str_enc)) {
str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
} else {
str_enc = sys_enc;
@@ -347,7 +351,7 @@ ary2list(ary, enc_flag, self)
if (req_chk_flag) {
str_enc = rb_ivar_get(str_val, ID_at_enc);
- if NIL_P(str_enc) {
+ if (!NIL_P(str_enc)) {
str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
} else {
str_enc = sys_enc;
@@ -398,14 +402,18 @@ ary2list2(ary, enc_flag, self)
sys_enc = rb_funcall(cTclTkLib, ID_encoding, 0, 0);
if NIL_P(sys_enc) {
sys_enc = rb_funcall(cTclTkLib, ID_encoding_system, 0, 0);
+ sys_enc = rb_funcall(sys_enc, ID_to_s, 0, 0);
}
if NIL_P(enc_flag) {
dst_enc = sys_enc;
req_chk_flag = 1;
- } else {
+ } else if (TYPE(enc_flag) == T_TRUE || TYPE(enc_flag) == T_FALSE) {
dst_enc = enc_flag;
req_chk_flag = 0;
+ } else {
+ dst_enc = rb_funcall(enc_flag, ID_to_s, 0, 0);
+ req_chk_flag = 0;
}
size = RARRAY(ary)->len;
@@ -438,7 +446,7 @@ ary2list2(ary, enc_flag, self)
if (req_chk_flag) {
str_enc = rb_ivar_get(str_val, ID_at_enc);
- if NIL_P(str_enc) {
+ if (!NIL_P(str_enc)) {
str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
} else {
str_enc = sys_enc;
@@ -884,7 +892,7 @@ tk_get_eval_enc_str(self, obj)
static VALUE
tk_conv_args(argc, argv, self)
int argc;
- VALUE *argv;
+ VALUE *argv; /* [0]:base_array, [1]:enc_mode, [2]..[n]:args */
VALUE self;
{
int idx, size;