From 6941f99c78c730b92f232078e1aa3bad1b84ae1c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 1 Apr 2021 13:50:21 +0000 Subject: Add experimental "-nothrow" option to encoding convertfrom|convertto. If compiled with -DTCL_NO_DEPRECATED (meant for Tcl 9.0), -stoponerror is the default for all IO --- generic/tcl.h | 13 +++++++++++-- generic/tclCmdAH.c | 36 ++++++++++++++++++++++++++++-------- generic/tclEncoding.c | 26 ++++++++++++++++---------- tests/chanio.test | 8 +++++--- tests/cmdAH.test | 4 ++-- tests/encoding.test | 40 ++++++++++++++++++++-------------------- tests/http.test | 4 +++- tests/io.test | 11 ++++++----- tests/main.test | 4 +++- tests/safe.test | 8 ++++---- tests/source.test | 4 +++- 11 files changed, 101 insertions(+), 57 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index dfb4c3a..f6c6730 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2056,10 +2056,10 @@ typedef struct Tcl_EncodingType { * encountering an invalid byte sequence or a * source character that has no mapping in the * target encoding. If clear, the converter - * substitues the problematic character(s) with + * substitutes the problematic character(s) with * one or more "close" characters in the * destination buffer and then continues to - * convert the source. + * convert the source. Only for Tcl 8.x. * TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a * terminating NUL byte. Since it does not need * an extra byte for a terminating NUL, it fills @@ -2078,6 +2078,14 @@ typedef struct Tcl_EncodingType { * 0x00. Only valid for "utf-8", "wtf-8 and "cesu-8". * This flag is implicit for external -> internal conversions, * optional for internal -> external conversions. + * TCL_ENCODING_NO_THROW - If set, the converter + * substitutes the problematic character(s) with + * one or more "close" characters in the + * destination buffer and then continues to + * convert the source. If clear, the converter returns + * immediately upon encountering an invalid byte sequence + * or a source character that has no mapping in the + * target encoding. Only for Tcl 9.x. */ #define TCL_ENCODING_START 0x01 @@ -2086,6 +2094,7 @@ typedef struct Tcl_EncodingType { #define TCL_ENCODING_NO_TERMINATE 0x08 #define TCL_ENCODING_CHAR_LIMIT 0x10 #define TCL_ENCODING_MODIFIED 0x20 +#define TCL_ENCODING_NO_THROW 0x40 /* * The following definitions are the error codes returned by the conversion diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 1dfabd2..ca8e939 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -564,15 +564,25 @@ EncodingConvertfromObjCmd( if (objc > 3) { stopOnError = Tcl_GetString(objv[3]); if (!stopOnError[0]) { +#if TCL_MAJOR_VERSION < 9 && !defined(TCL_NO_DEPRECATED) stopOnError = NULL; - } else if (stopOnError[0] != '-' || stopOnError[1] != 's' - || strncmp(stopOnError, "-stoponerror", strlen(stopOnError))) { +#endif + } else if (stopOnError[0] == '-' && stopOnError[1] == 'n' + && !strncmp(stopOnError, "-nothrow", strlen(stopOnError))) { + stopOnError = NULL; + } else if (stopOnError[0] == '-' && stopOnError[1] == 's' + && !strncmp(stopOnError, "-stoponerror", strlen(stopOnError))) { + } else { goto encConvFromError; } +#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED) + } else { + stopOnError = ""; +#endif } } else { encConvFromError: - Tcl_WrongNumArgs(interp, 1, objv, "?encoding? data ?-stoponerror?"); + Tcl_WrongNumArgs(interp, 1, objv, "?encoding? data ?-stoponerror|-nothrow?"); return TCL_ERROR; } @@ -588,7 +598,7 @@ EncodingConvertfromObjCmd( bytesPtr = (char *) Tcl_GetByteArrayFromObj(data, &length); } result = Tcl_ExternalToUtfDStringEx(encoding, bytesPtr, length, - stopOnError ? TCL_ENCODING_STOPONERROR : 0, &ds); + stopOnError ? TCL_ENCODING_STOPONERROR : TCL_ENCODING_NO_THROW, &ds); if (stopOnError && (result != (size_t)-1)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("unexpected byte at index %" TCL_LL_MODIFIER "u: '%c' (\\x%X)", (long long)result, UCHAR(bytesPtr[result]), UCHAR(bytesPtr[result]))); @@ -654,15 +664,25 @@ EncodingConverttoObjCmd( if (objc > 3) { stopOnError = Tcl_GetString(objv[3]); if (!stopOnError[0]) { +#if TCL_MAJOR_VERSION < 9 && !defined(TCL_NO_DEPRECATED) stopOnError = NULL; - } else if (stopOnError[0] != '-' || stopOnError[1] != 's' - || strncmp(stopOnError, "-stoponerror", strlen(stopOnError))) { +#endif + } else if (stopOnError[0] == '-' && stopOnError[1] == 'n' + && !strncmp(stopOnError, "-nothrow", strlen(stopOnError))) { + stopOnError = NULL; + } else if (stopOnError[0] == '-' && stopOnError[1] == 's' + && !strncmp(stopOnError, "-stoponerror", strlen(stopOnError))) { + } else { goto encConvToError; } +#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED) + } else { + stopOnError = ""; +#endif } } else { encConvToError: - Tcl_WrongNumArgs(interp, 1, objv, "?encoding? data ?-stoponerror?"); + Tcl_WrongNumArgs(interp, 1, objv, "?encoding? data ?-stoponerror|-nothrow?"); return TCL_ERROR; } @@ -672,7 +692,7 @@ EncodingConverttoObjCmd( stringPtr = TclGetStringFromObj(data, &length); result = Tcl_UtfToExternalDStringEx(encoding, stringPtr, length, - stopOnError ? TCL_ENCODING_STOPONERROR : 0, &ds); + stopOnError ? TCL_ENCODING_STOPONERROR : TCL_ENCODING_NO_THROW, &ds); if (stopOnError && (result != (size_t)-1)) { size_t pos = Tcl_NumUtfChars(stringPtr, result); int ucs4; diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index b7c0a4f..76dbe7f 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2223,6 +2223,12 @@ BinaryProc( *------------------------------------------------------------------------- */ +#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED) +# define STOPONERROR !(flags & TCL_ENCODING_NO_THROW) +#else +# define STOPONERROR (flags & TCL_ENCODING_STOPONERROR) +#endif + static int UtfToUtfProc( ClientData clientData, /* additional flags, e.g. TCL_ENCODING_MODIFIED */ @@ -2305,7 +2311,7 @@ UtfToUtfProc( */ if (flags & TCL_ENCODING_MODIFIED) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_MULTIBYTE; break; } @@ -2320,7 +2326,7 @@ UtfToUtfProc( int low; const char *saveSrc = src; size_t len = TclUtfToUCS4(src, &ch); - if ((len < 2) && (ch != 0) && (flags & TCL_ENCODING_STOPONERROR) + if ((len < 2) && (ch != 0) && STOPONERROR && (flags & TCL_ENCODING_MODIFIED)) { result = TCL_CONVERT_SYNTAX; break; @@ -2346,7 +2352,7 @@ UtfToUtfProc( if (((low & ~0x3FF) != 0xDC00) || (ch & 0x400)) { if (!(flags & TCL_ENCODING_WTF)) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_UNKNOWN; src = saveSrc; break; @@ -2365,7 +2371,7 @@ UtfToUtfProc( dst += Tcl_UniCharToUtf(ch, dst); ch = low; } else if (!(flags & TCL_ENCODING_WTF) && !Tcl_UniCharIsUnicode(ch)) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_UNKNOWN; src = saveSrc; break; @@ -2561,7 +2567,7 @@ UtfToUtf16Proc( } len = TclUtfToUCS4(src, &ch); if (!(flags & TCL_ENCODING_WTF) && !Tcl_UniCharIsUnicode(ch)) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_UNKNOWN; break; } @@ -2781,7 +2787,7 @@ TableToUtfProc( ch = pageZero[byte]; } if ((ch == 0) && (byte != 0)) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_SYNTAX; break; } @@ -2901,7 +2907,7 @@ TableFromUtfProc( word = fromUnicode[(ch >> 8)][ch & 0xFF]; if ((word == 0) && (ch != 0)) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_UNKNOWN; break; } @@ -3089,7 +3095,7 @@ Iso88591FromUtfProc( || ((ch >= 0xD800) && (len < 3)) #endif ) { - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_UNKNOWN; break; } @@ -3316,7 +3322,7 @@ EscapeToUtfProc( if ((checked == dataPtr->numSubTables + 2) || (flags & TCL_ENCODING_END)) { - if ((flags & TCL_ENCODING_STOPONERROR) == 0) { + if (!STOPONERROR) { /* * Skip the unknown escape sequence. */ @@ -3491,7 +3497,7 @@ EscapeFromUtfProc( if (word == 0) { state = oldState; - if (flags & TCL_ENCODING_STOPONERROR) { + if (STOPONERROR) { result = TCL_CONVERT_UNKNOWN; break; } diff --git a/tests/chanio.test b/tests/chanio.test index 8dfefb7..64d67d1 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -18,6 +18,8 @@ if {"::tcltest" ni [namespace children]} { namespace import -force ::tcltest::* } +testConstraint nodep [info exists tcl_precision] + namespace eval ::tcl::test::io { if {"::tcltest" ni [namespace children]} { @@ -248,7 +250,7 @@ test chan-io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} -bod } -cleanup { chan close $f } -result "\r\n12" -test chan-io-3.4 {WriteChars: loop over stage buffer} { +test chan-io-3.4 {WriteChars: loop over stage buffer} nodep { # stage buffer maps to more than can be queued at once. set f [open $path(test1) w] chan configure $f -encoding jis0208 -buffersize 16 @@ -257,7 +259,7 @@ test chan-io-3.4 {WriteChars: loop over stage buffer} { chan close $f lappend x [contents $path(test1)] } [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"] -test chan-io-3.5 {WriteChars: saved != 0} { +test chan-io-3.5 {WriteChars: saved != 0} nodep { # Bytes produced by UtfToExternal from end of last channel buffer had to # be moved to beginning of next channel buffer to preserve requested # buffersize. @@ -284,7 +286,7 @@ test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} { chan close $f lappend x [contents $path(test1)] } [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"] -test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} { +test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} nodep { # When translating UTF-8 to external, the produced bytes went past end of # the channel buffer. This is done on purpose - we then truncate the bytes # at the end of the partial character to preserve the requested blocksize diff --git a/tests/cmdAH.test b/tests/cmdAH.test index f60068d..e9973a9 100644 --- a/tests/cmdAH.test +++ b/tests/cmdAH.test @@ -178,7 +178,7 @@ test cmdAH-4.2 {Tcl_EncodingObjCmd} -returnCodes error -body { } -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, or system} test cmdAH-4.3 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding convertto -} -result {wrong # args: should be "encoding convertto ?encoding? data ?-stoponerror?"} +} -result {wrong # args: should be "encoding convertto ?encoding? data ?-stoponerror|-nothrow?"} test cmdAH-4.4 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding convertto foo bar } -result {unknown encoding "foo"} @@ -200,7 +200,7 @@ test cmdAH-4.6 {Tcl_EncodingObjCmd} -setup { } -result 8C test cmdAH-4.7 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding convertfrom -} -result {wrong # args: should be "encoding convertfrom ?encoding? data ?-stoponerror?"} +} -result {wrong # args: should be "encoding convertfrom ?encoding? data ?-stoponerror|-nothrow?"} test cmdAH-4.8 {Tcl_EncodingObjCmd} -returnCodes error -body { encoding convertfrom foo bar } -result {unknown encoding "foo"} diff --git a/tests/encoding.test b/tests/encoding.test index 3b3f42c..0a5417e 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -291,7 +291,7 @@ test encoding-11.9 {encoding: extended Unicode UTF-16} { test encoding-12.1 {LoadTableEncoding: normal encoding} { set x [encoding convertto iso8859-3 Ġ] - append x [encoding convertto iso8859-3 Õ] + append x [encoding convertto iso8859-3 Õ -nothrow] append x [encoding convertfrom iso8859-3 Õ] } "Õ?Ġ" test encoding-12.2 {LoadTableEncoding: single-byte encoding} { @@ -400,7 +400,7 @@ test encoding-15.15 {UtfToUtfProc low surrogate character output} { } {1 3 eda882} test encoding-15.16 {UtfToUtfProc: Invalid 4-byte UTF-8, see [ed29806ba]} { set x \xF0\xA0\xA1\xC2 - set y [encoding convertfrom utf-8 \xF0\xA0\xA1\xC2] + set y [encoding convertfrom utf-8 \xF0\xA0\xA1\xC2 -nothrow] list [string length $x] $y } "4 \xF0\xA0\xA1\xC2" test encoding-15.17 {UtfToUtfProc emoji character output} { @@ -411,61 +411,61 @@ test encoding-15.17 {UtfToUtfProc emoji character output} { } {4 f09f9882} test encoding-15.18 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\uDE02\uD83D - set y [encoding convertto utf-8 \uDE02\uD83D\uDE02\uD83D] + set y [encoding convertto utf-8 \uDE02\uD83D\uDE02\uD83D -nothrow] binary scan $y H* z list [string length $y] $z } {10 efbfbdf09f9882efbfbd} test encoding-15.19 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\uD83D - set y [encoding convertto utf-8 \uDE02\uD83D\uD83D] + set y [encoding convertto utf-8 \uDE02\uD83D\uD83D -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {3 9 efbfbdefbfbdefbfbd} test encoding-15.20 {UtfToUtfProc emoji character output} { set x \uDE02\uD83D\xE9 - set y [encoding convertto utf-8 \uDE02\uD83D\xE9] + set y [encoding convertto utf-8 \uDE02\uD83D\xE9 -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {3 8 efbfbdefbfbdc3a9} test encoding-15.21 {UtfToUtfProc emoji character output} { set x \uDE02\uD83DX - set y [encoding convertto utf-8 \uDE02\uD83DX] + set y [encoding convertto utf-8 \uDE02\uD83DX -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {3 7 efbfbdefbfbd58} test encoding-15.22 {UtfToUtfProc high surrogate character output} { set x \uDE02\xE9 - set y [encoding convertto utf-8 \uDE02\xE9] + set y [encoding convertto utf-8 \uDE02\xE9 -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {2 5 efbfbdc3a9} test encoding-15.23 {UtfToUtfProc low surrogate character output} { set x \uDA02\xE9 - set y [encoding convertto utf-8 \uDA02\xE9] + set y [encoding convertto utf-8 \uDA02\xE9 -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {2 5 efbfbdc3a9} test encoding-15.24 {UtfToUtfProc high surrogate character output} { set x \uDE02Y - set y [encoding convertto utf-8 \uDE02Y] + set y [encoding convertto utf-8 \uDE02Y -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {2 4 efbfbd59} test encoding-15.25 {UtfToUtfProc low surrogate character output} { set x \uDA02Y - set y [encoding convertto utf-8 \uDA02Y] + set y [encoding convertto utf-8 \uDA02Y -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {2 4 efbfbd59} test encoding-15.26 {UtfToUtfProc high surrogate character output} { set x \uDE02 - set y [encoding convertto utf-8 \uDE02] + set y [encoding convertto utf-8 \uDE02 -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {1 3 efbfbd} test encoding-15.27 {UtfToUtfProc low surrogate character output} { set x \uDA02 - set y [encoding convertto utf-8 \uDA02] + set y [encoding convertto utf-8 \uDA02 -nothrow] binary scan $y H* z list [string length $x] [string length $y] $z } {1 3 efbfbd} @@ -509,10 +509,10 @@ test encoding-17.4 {UtfToUcs2Proc} -body { encoding convertfrom utf-16 [encoding convertto ucs-2 "\U460DC"] } -result "\uFFFD" test encoding-17.5 {UtfToUtf16Proc} -body { - encoding convertto utf-16be "\uDCDC" + encoding convertto utf-16be "\uDCDC" -nothrow } -result "\xFF\xFD" test encoding-17.6 {UtfToUtf16Proc} -body { - encoding convertto utf-16le "\uD8D8" + encoding convertto utf-16le "\uD8D8" -nothrow } -result "\xFD\xFF" test encoding-18.1 {TableToUtfProc} { @@ -631,25 +631,25 @@ test encoding-24.4 {Parse valid or invalid utf-8} { string length [encoding convertfrom utf-8 "\xC0\x80"] } 1 test encoding-24.5 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xC0\x81"] + string length [encoding convertfrom utf-8 "\xC0\x81" -nothrow] } 2 test encoding-24.6 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xC1\xBF"] + string length [encoding convertfrom utf-8 "\xC1\xBF" -nothrow] } 2 test encoding-24.7 {Parse valid or invalid utf-8} { string length [encoding convertfrom utf-8 "\xC2\x80"] } 1 test encoding-24.8 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xE0\x80\x80"] + string length [encoding convertfrom utf-8 "\xE0\x80\x80" -nothrow] } 3 test encoding-24.9 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xE0\x9F\xBF"] + string length [encoding convertfrom utf-8 "\xE0\x9F\xBF" -nothrow] } 3 test encoding-24.10 {Parse valid or invalid utf-8} { string length [encoding convertfrom utf-8 "\xE0\xA0\x80"] } 1 test encoding-24.11 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xEF\xBF\xBF"] + string length [encoding convertfrom utf-8 "\xEF\xBF\xBF" -nothrow] } 1 test encoding-24.12 {Parse valid or invalid utf-8} { string length [encoding convertfrom utf-8 "\xC0\x80" -stoponerror] @@ -833,7 +833,7 @@ test encoding-28.0 {all encodings load} -body { set string hello foreach name [encoding names] { incr count - encoding convertto $name $string + encoding convertto $name $string -nothrow # discard the cached internal representation of Tcl_Encoding # Unfortunately, without this, encoding 2-1 fails. diff --git a/tests/http.test b/tests/http.test index 2fd5af4..1275984 100644 --- a/tests/http.test +++ b/tests/http.test @@ -31,6 +31,8 @@ if {[catch {package require http 2} version]} { } } +testConstraint nodep [info exists tcl_precision] + proc bgerror {args} { global errorInfo puts stderr "http.test bgerror" @@ -661,7 +663,7 @@ test http-7.3 {http::formatQuery} -setup { } -cleanup { http::config -urlencoding $enc } -result "can't read \"formMap(∈)\": no such element in array" -test http-7.4 {http::formatQuery} -setup { +test http-7.4 {http::formatQuery} -constraints nodep -setup { set enc [http::config -urlencoding] } -body { # this would be reverting to http <=2.4 behavior w/o errors diff --git a/tests/io.test b/tests/io.test index e0a2389..329d041 100644 --- a/tests/io.test +++ b/tests/io.test @@ -48,6 +48,7 @@ testConstraint testservicemode [llength [info commands testservicemode]] testConstraint notWinCI [expr { $::tcl_platform(platform) ne "windows" || ![info exists ::env(CI)]}] testConstraint notOSX [expr {$::tcl_platform(os) ne "Darwin"}] +testConstraint nodep [info exists tcl_precision] # You need a *very* special environment to do some tests. In # particular, many file systems do not support large-files... @@ -268,7 +269,7 @@ test io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} { close $f set x } "\r\n12" -test io-3.4 {WriteChars: loop over stage buffer} { +test io-3.4 {WriteChars: loop over stage buffer} nodep { # stage buffer maps to more than can be queued at once. set f [open $path(test1) w] @@ -278,7 +279,7 @@ test io-3.4 {WriteChars: loop over stage buffer} { close $f lappend x [contents $path(test1)] } [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"] -test io-3.5 {WriteChars: saved != 0} { +test io-3.5 {WriteChars: saved != 0} nodep { # Bytes produced by UtfToExternal from end of last channel buffer # had to be moved to beginning of next channel buffer to preserve # requested buffersize. @@ -307,7 +308,7 @@ test io-3.6 {WriteChars: (stageRead + dstWrote == 0)} { close $f lappend x [contents $path(test1)] } [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"] -test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} { +test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} nodep { # When translating UTF-8 to external, the produced bytes went past end # of the channel buffer. This is done purpose -- we then truncate the # bytes at the end of the partial character to preserve the requested @@ -1532,7 +1533,7 @@ test io-12.8 {ReadChars: multibyte chars split} { close $f scan [string index $in end] %c } 160 -test io-12.9 {ReadChars: multibyte chars split} { +test io-12.9 {ReadChars: multibyte chars split} nodep { set f [open $path(test1) w] fconfigure $f -translation binary puts -nonewline $f [string repeat a 9]\xC2 @@ -1543,7 +1544,7 @@ test io-12.9 {ReadChars: multibyte chars split} { close $f scan [string index $in end] %c } 194 -test io-12.10 {ReadChars: multibyte chars split} { +test io-12.10 {ReadChars: multibyte chars split} nodep { set f [open $path(test1) w] fconfigure $f -translation binary puts -nonewline $f [string repeat a 9]\xC2 diff --git a/tests/main.test b/tests/main.test index 2d3f63c..1480bc2 100644 --- a/tests/main.test +++ b/tests/main.test @@ -5,6 +5,8 @@ if {"::tcltest" ni [namespace children]} { namespace import -force ::tcltest::* } +testConstraint nodep [info exists tcl_precision] + namespace eval ::tcl::test::main { namespace import ::tcltest::* @@ -143,7 +145,7 @@ namespace eval ::tcl::test::main { test Tcl_Main-1.8 { Tcl_Main: startup script - -encoding option - mismatched encodings } -constraints { - stdio + stdio nodep } -setup { set script [makeFile {} script] file delete $script diff --git a/tests/safe.test b/tests/safe.test index e2a9b83..b6668d7 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -1267,7 +1267,7 @@ test safe-11.7 {testing safe encoding} -setup { interp eval $i encoding convertfrom } -returnCodes error -cleanup { safe::interpDelete $i -} -result {wrong # args: should be "encoding convertfrom ?encoding? data ?-stoponerror?"} +} -result {wrong # args: should be "encoding convertfrom ?encoding? data ?-stoponerror|-nothrow?"} test safe-11.7.1 {testing safe encoding} -setup { set i [safe::interpCreate] } -body { @@ -1276,7 +1276,7 @@ test safe-11.7.1 {testing safe encoding} -setup { } -returnCodes ok -match glob -cleanup { unset -nocomplain m o safe::interpDelete $i -} -result {wrong # args: should be "encoding convertfrom ?encoding? data ?-stoponerror?" +} -result {wrong # args: should be "encoding convertfrom ?encoding? data ?-stoponerror|-nothrow?" while executing "encoding convertfrom" invoked from within @@ -1289,7 +1289,7 @@ test safe-11.8 {testing safe encoding} -setup { interp eval $i encoding convertto } -returnCodes error -cleanup { safe::interpDelete $i -} -result {wrong # args: should be "encoding convertto ?encoding? data ?-stoponerror?"} +} -result {wrong # args: should be "encoding convertto ?encoding? data ?-stoponerror|-nothrow?"} test safe-11.8.1 {testing safe encoding} -setup { set i [safe::interpCreate] } -body { @@ -1298,7 +1298,7 @@ test safe-11.8.1 {testing safe encoding} -setup { } -returnCodes ok -match glob -cleanup { unset -nocomplain m o safe::interpDelete $i -} -result {wrong # args: should be "encoding convertto ?encoding? data ?-stoponerror?" +} -result {wrong # args: should be "encoding convertto ?encoding? data ?-stoponerror|-nothrow?" while executing "encoding convertto" invoked from within diff --git a/tests/source.test b/tests/source.test index eee03ec..1748a70 100644 --- a/tests/source.test +++ b/tests/source.test @@ -20,6 +20,8 @@ if {[catch {package require tcltest 2.5}]} { namespace eval ::tcl::test::source { namespace import ::tcltest::* +testConstraint nodep [info exists tcl_precision] + test source-1.1 {source command} -setup { set x "old x value" set y "old y value" @@ -275,7 +277,7 @@ test source-7.5 {source -encoding: correct operation} -setup { removeFile source.file rename € {} } -result foo -test source-7.6 {source -encoding: mismatch encoding error} -setup { +test source-7.6 {source -encoding: mismatch encoding error} -constraints nodep -setup { set sourcefile [makeFile {} source.file] file delete $sourcefile set f [open $sourcefile w] -- cgit v0.12