From: Vitaly Chikunov Date: Sun, 10 Nov 2019 01:34:01 +0000 (+0300) Subject: tcl_tests: Make utf-8 encoding work X-Git-Tag: v3.0.0~255 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=b0f5bce10dcc05198e2e58ee08e1cc3dcd3d1aea;p=openssl-gost%2Fengine.git tcl_tests: Make utf-8 encoding work - Remove emacs coding: cp1251 tag - Change stats file encoding to utf-8 - Change packages source to have -encoding utf-8 - Run tclsh with -encoding utf-8 - Make `proc rus' noop. This will make Tcl automatically translate scripts output from utf-8 to system encoding. --- diff --git a/tcl_tests/ca.try b/tcl_tests/ca.try index c84088c..6d76283 100644 --- a/tcl_tests/ca.try +++ b/tcl_tests/ca.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/calchash.tcl b/tcl_tests/calchash.tcl index ec68961..b943bef 100755 --- a/tcl_tests/calchash.tcl +++ b/tcl_tests/calchash.tcl @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require test diff --git a/tcl_tests/calcstat b/tcl_tests/calcstat index 3e59eb6..c2a19da 100644 --- a/tcl_tests/calcstat +++ b/tcl_tests/calcstat @@ -4,7 +4,7 @@ if {$tcl_platform(platform) == "unix"} { } lappend auto_path [file dirname [info script]] proc rus {string} { - return [encoding convertfrom cp1251 [encoding convertto $string]] + return $string } proc compare_order {el1 el2} { global order @@ -13,7 +13,7 @@ proc compare_order {el1 el2} { set statsfile stats if {$argc} {set statsfile [lindex $argv 0]} set f [open $statsfile] -fconfigure $f -encoding cp1251 +fconfigure $f -encoding utf-8 set ordno 0 while {[gets $f line] >=0} { set script [lindex $line 0] @@ -34,7 +34,7 @@ proc output {line} { if {$argc > 1} { set out [open [lindex $argv 1] w] - fconfigure $out -encoding cp1251 + fconfigure $out -encoding utf-8 } output [format "%-12s %-41s%5s %4s %4s %4s %4s" File "Test name" Total ok fail skip ign] diff --git a/tcl_tests/client.try b/tcl_tests/client.try index d6abcb3..2658ce6 100644 --- a/tcl_tests/client.try +++ b/tcl_tests/client.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest diff --git a/tcl_tests/cms.try b/tcl_tests/cms.try index 476da0d..2db2958 100644 --- a/tcl_tests/cms.try +++ b/tcl_tests/cms.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/cms2.try b/tcl_tests/cms2.try index 1233d55..884f1ec 100644 --- a/tcl_tests/cms2.try +++ b/tcl_tests/cms2.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/cms_cs.try b/tcl_tests/cms_cs.try index d246fe8..2a619b2 100644 --- a/tcl_tests/cms_cs.try +++ b/tcl_tests/cms_cs.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/cms_io.try b/tcl_tests/cms_io.try index 92c3619..0283419 100644 --- a/tcl_tests/cms_io.try +++ b/tcl_tests/cms_io.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/cmsenc.try b/tcl_tests/cmsenc.try index 6608226..3203765 100644 --- a/tcl_tests/cmsenc.try +++ b/tcl_tests/cmsenc.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/cmsenc_cs.try b/tcl_tests/cmsenc_cs.try index 3ae497e..10cb08a 100644 --- a/tcl_tests/cmsenc_cs.try +++ b/tcl_tests/cmsenc_cs.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest package require test diff --git a/tcl_tests/cmsenc_io.try b/tcl_tests/cmsenc_io.try index a78e113..01eac8a 100644 --- a/tcl_tests/cmsenc_io.try +++ b/tcl_tests/cmsenc_io.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/cmsenc_sc.try b/tcl_tests/cmsenc_sc.try index dbd4c2b..ab489d0 100644 --- a/tcl_tests/cmsenc_sc.try +++ b/tcl_tests/cmsenc_sc.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest package require test diff --git a/tcl_tests/dgst.try b/tcl_tests/dgst.try index 148e1d6..21c2ca7 100644 --- a/tcl_tests/dgst.try +++ b/tcl_tests/dgst.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/enc.try b/tcl_tests/enc.try index 2f682a7..1398d13 100644 --- a/tcl_tests/enc.try +++ b/tcl_tests/enc.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh/ -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest set plain0 [getFile plain.enc] diff --git a/tcl_tests/engine.try b/tcl_tests/engine.try index 2090e59..347cc31 100644 --- a/tcl_tests/engine.try +++ b/tcl_tests/engine.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/http.tcl b/tcl_tests/http.tcl index 6121617..37277b9 100644 --- a/tcl_tests/http.tcl +++ b/tcl_tests/http.tcl @@ -1,4 +1,3 @@ -# -*- coding: cp1251 -*- # # Получает в командной строке URL и (опционально) строку для поиска # сертификата. Выполняет HTTP-запрос и возрвщает результат diff --git a/tcl_tests/hwkeys.tcl b/tcl_tests/hwkeys.tcl index 8c86a82..8543213 100644 --- a/tcl_tests/hwkeys.tcl +++ b/tcl_tests/hwkeys.tcl @@ -1,4 +1,3 @@ -# -*- coding: cp1251 -*- package require testlib start_tests "Работа с аппаратными носителями" diff --git a/tcl_tests/mac.try b/tcl_tests/mac.try index de2cb6b..9b261e8 100644 --- a/tcl_tests/mac.try +++ b/tcl_tests/mac.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/make_other.sh b/tcl_tests/make_other.sh index ed9d9e8..ea8ad85 100755 --- a/tcl_tests/make_other.sh +++ b/tcl_tests/make_other.sh @@ -1,5 +1,4 @@ #!/bin/sh -# -*- coding: cp1251 -*- # Создает подкаталог OtherVersion, копирует в него данные для тестирования # совместимости с другими версиями. diff --git a/tcl_tests/nopath.try b/tcl_tests/nopath.try index c3664ae..d78a14d 100644 --- a/tcl_tests/nopath.try +++ b/tcl_tests/nopath.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/ocsp.try b/tcl_tests/ocsp.try index 30c1218..a1b2c68 100644 --- a/tcl_tests/ocsp.try +++ b/tcl_tests/ocsp.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/pkcs12.try b/tcl_tests/pkcs12.try index 52e23d6..6fc7ecb 100644 --- a/tcl_tests/pkcs12.try +++ b/tcl_tests/pkcs12.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/pkgIndex.tcl b/tcl_tests/pkgIndex.tcl index f4a3345..cb3f9d4 100644 --- a/tcl_tests/pkgIndex.tcl +++ b/tcl_tests/pkgIndex.tcl @@ -1,6 +1,6 @@ -package ifneeded test 0.2 [list source [file join $dir test.tcl]] -package ifneeded testlib 0.1 [list source [file join $dir testlib.tcl]] -package ifneeded fgetopt 0.1 [list source [file join $dir fgetopt.tcl]] -package ifneeded asn 0.7.1 [list source [file join $dir asn.tcl]] -package ifneeded base64 2.3.2 [list source [file join $dir base64.tcl]] -package ifneeded ossltest 0.7 [list source [file join $dir ossltest.tcl]] +package ifneeded test 0.2 [list source -encoding utf-8 [file join $dir test.tcl]] +package ifneeded testlib 0.1 [list source -encoding utf-8 [file join $dir testlib.tcl]] +package ifneeded fgetopt 0.1 [list source -encoding utf-8 [file join $dir fgetopt.tcl]] +package ifneeded asn 0.7.1 [list source -encoding utf-8 [file join $dir asn.tcl]] +package ifneeded base64 2.3.2 [list source -encoding utf-8 [file join $dir base64.tcl]] +package ifneeded ossltest 0.7 [list source -encoding utf-8 [file join $dir ossltest.tcl]] diff --git a/tcl_tests/req-genpkey.try b/tcl_tests/req-genpkey.try index e333dc0..a368ced 100644 --- a/tcl_tests/req-genpkey.try +++ b/tcl_tests/req-genpkey.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- # создание секретного ключа # создание заявки и самоподписанного сертификата командой req # проверка OIDов алгоритма во всех структурах diff --git a/tcl_tests/req-newkey.try b/tcl_tests/req-newkey.try index fe05fa6..3c4a8a8 100644 --- a/tcl_tests/req-newkey.try +++ b/tcl_tests/req-newkey.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- if {[info exists env(PKG_PATH)]} { lappend auto_path $env(PKG_PATH) } else { diff --git a/tcl_tests/runtest.sh b/tcl_tests/runtest.sh index a59c946..11fdeda 100644 --- a/tcl_tests/runtest.sh +++ b/tcl_tests/runtest.sh @@ -1,5 +1,4 @@ #!/bin/sh -# -*- coding: cp1251 -*- # Состав набора тестов # 1. Этот скрипт @@ -65,6 +64,7 @@ if [ -z "$TCLSH" ]; then else echo "Using $TCLSH as tclsh" fi +TCLSH="$TCLSH -encoding utf-8" APP_SUFFIX=`basename $OPENSSL_APP .exe|sed s/openssl//` [ -n "$OPENSSL_APP" ]&& export OPENSSL_APP diff --git a/tcl_tests/server.try b/tcl_tests/server.try index bc12638..5c4048a 100644 --- a/tcl_tests/server.try +++ b/tcl_tests/server.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] diff --git a/tcl_tests/smime.try b/tcl_tests/smime.try index cd610ba..3fd722a 100644 --- a/tcl_tests/smime.try +++ b/tcl_tests/smime.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/smime2.try b/tcl_tests/smime2.try index c3bdd12..071ad85 100644 --- a/tcl_tests/smime2.try +++ b/tcl_tests/smime2.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/smime_cs.try b/tcl_tests/smime_cs.try index 1a01451..3792bc4 100644 --- a/tcl_tests/smime_cs.try +++ b/tcl_tests/smime_cs.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/smime_io.try b/tcl_tests/smime_io.try index ec4df2d..daf76b2 100644 --- a/tcl_tests/smime_io.try +++ b/tcl_tests/smime_io.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/smimeenc.try b/tcl_tests/smimeenc.try index ea8be82..0f341bf 100644 --- a/tcl_tests/smimeenc.try +++ b/tcl_tests/smimeenc.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/smimeenc_io.try b/tcl_tests/smimeenc_io.try index fa991ce..0c17b8e 100644 --- a/tcl_tests/smimeenc_io.try +++ b/tcl_tests/smimeenc_io.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/ssl.try b/tcl_tests/ssl.try index 54672bc..16f61d1 100644 --- a/tcl_tests/ssl.try +++ b/tcl_tests/ssl.try @@ -1,5 +1,5 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- + lappend auto_path [file dirname [info script]] package require ossltest if {$argc==2} { diff --git a/tcl_tests/test.tcl b/tcl_tests/test.tcl index 8e2b45a..cf7c2b7 100644 --- a/tcl_tests/test.tcl +++ b/tcl_tests/test.tcl @@ -1,4 +1,3 @@ -# -*- coding: cp1251 -*- # Установка номера тестового ПРА namespace eval vizir { @@ -109,7 +108,7 @@ namespace eval test { } set test_id [file rootname [file tail [info script]]]$suffix set stat [open "stats" a] - fconfigure $stat -encoding cp1251 + fconfigure $stat -encoding utf-8 puts $stat [list $test_id [rus $t_name] $no $ok $failed $p_skip $c_skip] close $stat if {!$failed} { @@ -263,21 +262,8 @@ proc listcompare {list1 list2 time} { } return 1 } -# Перекодирует строку из кодировки скрипта (assumed 1251) -# в текущую системную - -if {[encoding system] == "utf-8" } { - proc rus {string} { - return [encoding convertfrom cp1251 $string] -} - -} else { - -proc rus {string} " - return \[encoding convertfrom cp1251 \[encoding convertto [encoding system] \$string\]\] -" - + return $string } # # Пишет строку в лог diff --git a/tcl_tests/ts.try b/tcl_tests/ts.try index fe8fa04..e3a4bad 100644 --- a/tcl_tests/ts.try +++ b/tcl_tests/ts.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest cd $::test::dir diff --git a/tcl_tests/wcli.try b/tcl_tests/wcli.try index 35ed578..230ee8e 100644 --- a/tcl_tests/wcli.try +++ b/tcl_tests/wcli.try @@ -1,5 +1,4 @@ #!/usr/bin/tclsh -# -*- coding: cp1251 -*- lappend auto_path [file dirname [info script]] package require ossltest