tDOM 0.9.0


tDOM 在很長一段時間的 0.8.3 以後,釋出了一個新版 v0.9.0。這版加入了 JSON 的支援,並且在編譯時開啟 html5 選項(需要連結 Google Gumbo html parser library)的情況下就有 html5 parser 可以用。

tDOM contains:

    *  for convenience expat 2.2.0, the XML parser originated from
       James Clark, although you're able to link tDOM with other
       expat versions or the library provided by the system.
    *  building a DOM tree from XML in one go implemented in C for
       maximum performance and minimum memory usage, and DOM I and II
       methods to work on such a tree using either a OO-like or a
       handle syntax.
    *  a Tcl interface to expat for event-like (SAX-like) XML parsing.
    *  a complete, compliant and fast XPath implementation in C
       following the November 99 W3C recommendation for navigating and
       data extraction.
    *  a fast XSLT implementation in C following the W3C Recommendation
       16 November 1999.
    *  optional DTD validation.
    *  a JSON parser which parses any possible JSON input into a DOM
       tree without losing information.
    *  an efficient and Tcl'ish way to create XML and HTML documents
       and JSON string.
    *  as build option an interface to the gumbo HTML5 parser, which
       also digests almost any other HTML.
    *  an even faster simple XML parser for trusted XML input.
    *  additional convenience methods.


tcl-rocksdb v0.1.1


RocksDB 更改了授權,從原本的 BSD+PATENTS 變成 BSD+PATENTS/GPL v2 (dual license) 然後又變成 Apache 2.0/GPL v2 (dual license)。

而會修改授權,是因為 Apache 基金會接到 Apache Cassandra Team 的請求,希望能夠釐清使用 RocksDB 是否會有版權上的疑慮以後,公佈了結果,Facebook BSD+PATENTS license 被列為 category-x,同時提出了下列的建議:
  • No new project, sub-project or codebase, which has not used Facebook BSD+patents licensed jars (or similar), are allowed to use them. In other words, if you haven't been using them, you aren't allowed to start. It is Cat-X.
  • If you have been using it, and have done so in a *release*, you have a temporary exclusion from the Cat-X classification thru August 31, 2017. At that point in time, ANY and ALL usage of these Facebook BSD+patents licensed artifacts are DISALLOWED. You must either find a suitably licensed replacement, or do without. There will be NO exceptions.
  • Any situation not covered by the above is an implicit DISALLOWAL of usage.

所以如果 RocksDB 沒有修改授權,那麼 Apache Cassandra 就無法使用 RocksDB,已經使用的 Apache Flink, Apache Samza 等各個專案也需要開始尋找替代品。而 RocksDB team 在 Apache 基金會公佈結果以後,很快就修改了授權,變成 Apache 2.0/GPL v2 (dual license)。

既然授權的疑慮清除(PATENTS 是很複雜的議題,如果可以,我會儘量避開),所以我實作了 tcl-rocksdb (prototype),實作一些最基本的操作,同時也寫了簡易的 test case 測試。因為其它的部份我不知道怎麼實作成 Tcl extension 比較好,所以目前的 v0.1.1 就是我實作上比較知道怎麼做的部份了。

加入幾個新的 command,更新版本為 v0.2。

另外,我發現 LevelDB 和 RocksDB 的基本操作長的很像,所以按照目前的資料,也寫了一個 tcl-leveldb


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 然後設定其它的變數,利用這一點,就可以交換二個變數的值,很有趣的做法。