Tcl/Tk 8.6.7 RELEASED

Tcl / Tk 8.6.7 RELEASED

Tcl/Tk 釋出了新的版本 8.6.7,下面是修正的項目:

Summary of Changes since Tcl/Tk 8.6.6:

This is a patch release, so it primarily includes bug fixes and corrections to erratic behavior.  Highlighted changes are noted below. The changes file at the root of the source tree contains a more complete list.  The Timelines of all changes are online.


    * [TIP 473] (TclOO 1.1.0) Let [oo::copy] specify target namespace
    * [TIP 464] Support multimedia keys on Windows
    * Revise Tcl_LinkVar to tolerate some prefixes

    * Allow empty command as [interp alias] target

    * Revise Tcl_UtfToUniChar() handling of invalid UTF-8

    * [clock] and [encoding] are now ensembles
    * Several [clock] subcommands are now compiled to bytecode

    * Fix crashes or hangs in...
      - [socket -async ::1 0] with no host
      - Threaded memory allocator in thread finalization
      - Tcl_ListObjReplace() error when passed NULL interp
      - [binary scan a$n] when $n overflows int
      - [lsort -unique [lrepeat [expr {1<<27 1="" br="">      - Drawing many dashed canvas objects
      - Using Tk after IME restart
      - Warp pointer operations
      - [[text .t] insert 0.0 \na; .t replace 2.0 3.0 b]
      - Resource exhaustion processing corrupt GIF

    * Fix memory leaks in...
      - namespace delete when unset trace revives namespace variable.
      - Deletion of the [history] command
      - http::geturl when keep-alive is denied
      - TclJoinPath on a custom Tcl_Filesystem
      - text BTree operations

    * Update Unicode data to 10.0

    * Merge updates from new libtommath release; purge unused files

    * Update bundled zlib to release 1.2.11

    * Remove legacy support macro panic() - conflicts with system libs

    * Revise Tk font support to avoid type mismatch with recent Xft
    * Repair cmd resolver caching, demonstrated by tests resolver-3.1*
    * Repair zlib stream buffer flushing; zlib-7.8 and PNG writing
    * Prevent Win thread termination during init and teardown
    * Make KeyRelease event handling get _L and _R right
    * Repaint ttk::button when its image changes
    * Wrapped text don't start lines with whitespace
    * Non-native themes properly display tri-state buttons
    * File dialog repairs for -typevariable, -initialdir, -initialfile
    * Avoid unreleasable global grab due to menu keyboard traversal
    * Fix Win regression [event generate .e ]
    * Fix [grid configure -in] to fully clear outdated info
    * Fix ttk::combobox proper style with -postoffset (test combobox-3)
    * OSX: Stop [$text bbox] returning negative width
    * Repair autoloader fragility loading procs that call tailcall
    * Correct parsing in [scan 0x1 %b], [scan 0x1 %o]
    * Fix [string replace] so test stringComp-14.5 passes
    * Invalidate VFS mounts on sytem encoding change
    * Fix [expr {NaN > "Gran"}] to return 1; string comparison
    * Stop frequent Tcl_GetTime() calls creating clock drift
    * Correct functioning of dynamic unexport of methods
    * Fix [file join a //b] and [file join //a b]
    * Compute correct warp cursor position on 2nd display
    * Enable dismissal of ttk::menubutton without hover
    * Tk_BindEvent filter events Tk ignores avoid X11 ring buffer flood
    * Allow [$photo read] to read files beginning with "-"
    * [text] redisplay calculations corrected on OSX
    * Fix drawing of long text lines on Windows
    * Disabled combobox arrow appearance (danckaert)
    * Fix {PNG -alpha} format for 16-bit color
    * Workaround X11 drawing defects in Ubuntu 16.10+
    * Fix calculation of ttk::notebook tab widths and tab user management
    * Scidb race in notebook tab selection
    * Color name parsing set to reject invalid hex color codes (#ABCZ)
    * OSX scrollbar draw position, highlights, & smooth scroll
    * Race condition on Win clipboard cleanup
    * Center image on button
    * Paneconfigure get pane heights right
    * Windows: User switch forced theme reset
    * Updated bundled packages
       - Itcl 4.1.0      (incompatible with Itk 4.0, get Itk 4.1)
       - sqlite3 3.20.0
       - Thread 2.8.1
       - tdbc* 1.0.5
       - http 2.8.11
       - tcltest 2.4.1
       - msgcat 1.6.1


Apache Tomcat HTTP/2 與 TclCurl

一閈始是設定 Apache Tomcat HTTP/2 的部份(Apache Tomcat 在 8.5 及以後的版本開始支援)。

HTTP/2 需要 Apache Tomcat Native Library 的支援才行, 所以首先是先安裝 Apache Tomcat Native Library。

Tomcat Native Library 需要 libapr1,所以如果是使用 openSUSE,
sudo zypper install libapr1-devel

再來是自己編譯 Tomcat 或者是使用 RPM 安裝

然後,需要創造 OpenSSL Certificate。 可以參考 Howto: Make Your Own Cert With OpenSSL。

如果只是要自己測試使用所以使用 self-signed,在 conf 目錄下使用下列的指令:
openssl genrsa -out ca.key 4096
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt

最後修改 conf 目錄下的 server.xml,開啟 HTTP/2 的支援並且修改如下:

    <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true" >
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
            <Certificate certificateKeyFile="conf/ca.key"
                         certificateFile="conf/ca.crt" />

再來重新開啟 Apache Tomcat server,如果 https://localhost:8443 可以瀏覽,就正確的設定好了(* 因為是 self-signed,所以會看到安全性警告)。

TclCurl 在最近的版本有支援 HTTP/2,下面是驗證 Apache Tomcat HTTP/2 (self-signed) 的範例:
package require TclCurl

set curlHandle [curl::init]
$curlHandle configure -url https://localhost:8443 -sslverifyhost 0 \
    -sslverifypeer 0 -bodyvar result
$curlHandle setopt CURLOPT_HTTP_VERSION 2TLS

catch { $curlHandle perform } curlErrorNumber
if { $curlErrorNumber != 0 } {
    puts "error [curl::easystrerror $curlErrorNumber]"

# Print result and clean up
puts $result
$curlHandle cleanup

那麼我們怎麼知道真的是使用 HTTP/2 協定呢?這只要檢查 Tomcat logs 目錄下的 log 就可以確定。

Tcl/Tk 8.6.7 Release Candidates

Tcl/Tk 8.6.7 Release Candidates

8.6.7 RC1 source package.

This collection includes release candidates of packages:
Itcl 4.1.0
http 2.8.11
Thread 2.8.1
msgcat 1.6.1
sqlite3 3.20.0
tcltest 2.4.1
tdbc* 1.0.5


TclCurl and HTTP/2


HTTP/2 預計在 Java 9 加入支援,所以我想預計會開始增加使用率。

目前 BitBucket 上的 TclCurl 已經加上 HTTP/2 的支援,所以如果要測試 HTTP/2,需要使用 TclCurl。根據 Tcler's Wiki 的資料,目前好像也只有 TclCurl 可以使用 (PS. 目前內建的 http 套件只支援到 1.1)。

Debian 方面,7.22.0+hg20160822-1 這個版本就是使用目前 BitBucket 上到最近的 source code。

openSUSE 的部份我檢查了一下,發現還停留在原作者最後一個釋出的版本,所以我把 openSUSE 的檔案拿過來,加上 BitBucket 上的 source code,然後修改 spec 的 URL 到目前的來源,試著 build 一版看會不會有問題。比較有問題的是版本號碼,因為同一個版本會造成問題(也就是我有可能會進行一些調整,只是還不知道怎麼做比較好) (更新:版本設為 7.22.0+hg20160822) (2017/08/06 更新:放上去 openSUSE build service 測試以後,將版本更新為 7.22.0_hg20160822)。

(另外一個問題是 openSUSE 42.x CURL 版本停在 7.37.0,這表示我可能需要升級 CURL)
(升級到 7.54.1,然後 TclCurl 會發生 libssh2_scp_recv2 找不到的問題,這需要升級 libssh2-1 到新的版本,我升到 libssh2-1-1.8.0-56.2.x86_64 以後解決問題)

Tools for debugging, testing and using HTTP/2
( 所以 CURL 在  7.43.0及以後的版本,使用 nghttp2 這個函式庫來支援 HTTP/2)

cURL 的文件部份:
HTTP/2 with curl

HTTP/2 解釋文件:
http2 explained

Introduction to HTTP/2
Chapter 12. HTTP/2


Swapping variables

資料來自於 Tcler's Wiki - Tcl Gems

使用 Tcl 8.5 內建命令 lassign:
lassign [list $b $a] a b

lassign 可以將一個 list unpack 然後設定其它的變數,利用這一點,就可以交換二個變數的值,很有趣的做法。


tclmonetdb v0.9.7




MonetDB is an open source column-oriented database management system developed at the Centrum Wiskunde & Informatica (CWI) in the Netherlands.

MonetDB excessively uses main memory for processing, but does not require that all data fit in the available physical memory. To handle a dataset that exceeds the available physical memory, MonetDB does not (only) rely on the available swap space, but (also) uses memory-mapped files to exploit disk storage beyond the swap space as virtual memory.

tclmonetdb is a Tcl extension by using MAPI library to connect MonetDB.


  1. Add more string to monetdbSuffixes, for Jul2017 version

這是一個 for MonetDB Jul2017 更新的版本。




The TclPro Debugger version 2.0 is an upgrade of of the debugger included in the TclPro product version 1.5 released and open-sourced by Scriptics Corporation.

FlightAware 贊助的案子,將 TclPro 的 debugger 更新到 Tcl 8.5+ 可以使用。

* 要先編譯 lib 目錄下的 tclparser 並且安裝才行


Tcl/Tk and ActiveMQ

ActiveMQ: Cross Language Clients and Protocols

網頁下面有使用的範例,其中 Tcl/Tk 的部份有二個,一個是支援 STOMP 協定的 tstomp 套件,一個則是利用 Tcl/Java 來呼叫 Java API。因為有簡單的使用範例,所以我想有需要的時候可以用來參考。

* 另外,ActiveMQ 有支援 MQTT,所以 Tcl MQTT client 可以用來測試是否可以執行,或者是使用我包裝 Paho MQTT C Client 的 Tcl extension tcl.mqttc



set var [list ls -l]
catch {exec {*}$var} result

set lines [split $result "\n"]
foreach line $lines {
    if {[string index $line 0] == "d"} {
        puts $line

只是用來練習的程式。使用 exec 來執行程式 (ls -l),取得結果以後再來處理。


Using Nashorn from Java code (TclBlend version)

package require java

java::import javax.script.ScriptEngine
java::import javax.script.ScriptEngineManager
java::import javax.script.ScriptException

set manager [java::new ScriptEngineManager]
set nashorn [$manager getEngineByName "nashorn"]
set value [$nashorn eval "10 + 20"]
puts "Result: [$value toString]"

Nashorn 是使用 Java 寫的 JavaScript runtime,for Java 8 使用。目前支援的規範是 ECMAScript 5.1。

這裡透過 Nashorn 來執行 JavaScript code。我只是使用 TclBlend 執行 sample code 測試看看。