Tk.rb: incompatible change between 1.8.1 and 1.8.2

Hi all,

The "can't dup Fixnum" error what I have mentioned in my previous post
is caused by a change in tk.rb.

The tk.rb in 1.8.1 has the following portion from line 657:

module TkCore
  include TkComm
  extend TkComm

  unless self.const_defined? :INTERP
    if self.const_defined? :IP_NAME
      name = IP_NAME.to_s
    else
      name = nil
#### ^^^^^^^^^^ #####################
    end
    if self.const_defined? :IP_OPTS
      if IP_OPTS.kind_of?(Hash)
        opts = hash_kv(IP_OPTS).join(' ')
      else
        opts = IP_OPTS.to_s
      end
    else
      opts = ''
    end

    INTERP = TclTkIp.new(name, opts)
[...]

The 1.8.2 version has this (from line 940):

module TkCore
  include TkComm
  extend TkComm

  unless self.const_defined? :INTERP
    if self.const_defined? :IP_NAME
      name = IP_NAME.to_s
    else
      #name = nil
      name = $0
#### ^^^^^^^^^^ #####################
    end
    if self.const_defined? :IP_OPTS
      if IP_OPTS.kind_of?(Hash)
        opts = hash_kv(IP_OPTS).join(' ')
      else
        opts = IP_OPTS.to_s
      end
    else
      opts = ''
    end

    INTERP = TclTkIp.new(name, opts)

(The version numbers are from the debian packages.)

This change causes the fixnum problem in class TclTkExtIp's constructor.

I have a 1.8.0 source where TclTkIp's initialize fn (in tcltklib.c) do
not get params, so I do not know why is it for.

What to do?

Thanks,
Ferenc

Hi,

···

From: Ferenc Engard <ferenc@engard.hu>
Subject: tk.rb: incompatible change between 1.8.1 and 1.8.2
Date: Sat, 28 Aug 2004 22:28:23 +0900
Message-ID: <41308872.6D98ACD9@engard.hu>

The "can't dup Fixnum" error what I have mentioned in my previous post
is caused by a change in tk.rb.

   (snip)

This change causes the fixnum problem in class TclTkExtIp's constructor.

Sorry. This changes default Tk.appname from 'tk' to
current command/script name.
I didn't observe 'tcltk-ext' library on 1.8.2.
As you point, it cannot work with 1.8.2.
Please adopt the following patch.

diff -u ../tcltk-ext051/tcltkextlib.rb ./tcltkextlib.rb
--- ../tcltk-ext051/tcltkextlib.rb 2000-09-28 15:25:56.000000000 +0900
+++ ./tcltkextlib.rb 2004-08-29 02:18:01.000000000 +0900
@@ -278,7 +278,24 @@
   def initialize(*libs)
     @libs =
     @namespace =
- @ip = TclTkIp.new_orig
+
+ if TclTkIp.method(:new_orig).arity != 0
+ # libs ==> [ip_name, [ip_opts,]] libs
+ if libs.empty? || libs[0].kind_of?(Array)
+ ip_name = nil
+ ip_opts = ''
+ else
+ ip_name = libs.shift
+ if libs.empty? || libs[0].kind_of?(Array)
+ ip_opts = ''
+ else
+ ip_opts = libs.shift
+ end
+ end
+ @ip = TclTkIp.new_orig(ip_name, ip_opts)
+ else
+ @ip = TclTkIp.new_orig
+ end
     setup_libs(*libs)
   end
end

--
                                  Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

> The "can't dup Fixnum" error what I have mentioned in my previous post
> is caused by a change in tk.rb.
   (snip)
> This change causes the fixnum problem in class TclTkExtIp's constructor.

Sorry. This changes default Tk.appname from 'tk' to
current command/script name.
I didn't observe 'tcltk-ext' library on 1.8.2.
As you point, it cannot work with 1.8.2.
Please adopt the following patch.

diff -u ../tcltk-ext051/tcltkextlib.rb ./tcltkextlib.rb

[...]

I patched it, and it works now. Thank you!

Ferenc