summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/Encoding.38
-rw-r--r--generic/tcl.decls4
-rw-r--r--generic/tclCmdAH.c15
-rw-r--r--generic/tclDecls.h8
-rw-r--r--generic/tclEncoding.c16
-rw-r--r--tests/chanio.test30
-rw-r--r--tests/cmdAH.test44
-rw-r--r--tests/encoding.test16
-rw-r--r--tests/http.test1
-rw-r--r--tests/io.test30
10 files changed, 96 insertions, 76 deletions
diff --git a/doc/Encoding.3 b/doc/Encoding.3
index dc37519..86c5a78 100644
--- a/doc/Encoding.3
+++ b/doc/Encoding.3
@@ -25,13 +25,13 @@ int
char *
\fBTcl_ExternalToUtfDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
.sp
-size_t
+int
\fBTcl_ExternalToUtfDStringEx\fR(\fIencoding, src, srcLen, flags, dstPtr\fR)
.sp
char *
\fBTcl_UtfToExternalDString\fR(\fIencoding, src, srcLen, dstPtr\fR)
.sp
-size_t
+int
\fBTcl_UtfToExternalDStringEx\fR(\fIencoding, src, srcLen, flags, dstPtr\fR)
.sp
int
@@ -220,7 +220,7 @@ used. The return value is a pointer to the value stored in the DString.
\fBTcl_ExternalToUtfDStringEx\fR is the same as \fBTcl_ExternalToUtfDString\fR,
but it has an additional flags parameter. The return value is the index of
the first byte in the input string causing a conversion error.
-Or (size_t)-1 if all is OK.
+Or TCL_INDEX_NONE if all is OK.
.PP
\fBTcl_ExternalToUtf\fR converts a source buffer \fIsrc\fR from the specified
\fIencoding\fR into UTF-8. Up to \fIsrcLen\fR bytes are converted from the
@@ -263,7 +263,7 @@ a pointer to the value stored in the DString.
\fBTcl_UtfToExternalDStringEx\fR is the same as \fBTcl_UtfToExternalDString\fR,
but it has an additional flags parameter. The return value is the index of
the first byte of an utf-8 byte-sequence in the input string causing a
-conversion error. Or (size_t)-1 if all is OK.
+conversion error. Or TCL_INDEX_NONE if all is OK.
.PP
\fBTcl_UtfToExternal\fR converts a source buffer \fIsrc\fR from UTF-8 into
the specified \fIencoding\fR. Up to \fIsrcLen\fR bytes are converted from
diff --git a/generic/tcl.decls b/generic/tcl.decls
index a33ea56..3cf794e 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -2437,11 +2437,11 @@ declare 657 {
int Tcl_UniCharIsUnicode(int ch)
}
declare 658 {
- size_t Tcl_ExternalToUtfDStringEx(Tcl_Encoding encoding,
+ int Tcl_ExternalToUtfDStringEx(Tcl_Encoding encoding,
const char *src, int srcLen, int flags, Tcl_DString *dsPtr)
}
declare 659 {
- size_t Tcl_UtfToExternalDStringEx(Tcl_Encoding encoding,
+ int Tcl_UtfToExternalDStringEx(Tcl_Encoding encoding,
const char *src, int srcLen, int flags, Tcl_DString *dsPtr)
}
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 264e6ae..7746b2f 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -555,7 +555,7 @@ EncodingConvertfromObjCmd(
#else
int flags = TCL_ENCODING_NOCOMPLAIN;
#endif
- size_t result;
+ int result;
Tcl_Obj *failVarObj = NULL;
/*
* Decode parameters:
@@ -621,17 +621,16 @@ EncodingConvertfromObjCmd(
}
result = Tcl_ExternalToUtfDStringEx(encoding, bytesPtr, length,
flags, &ds);
- if (!(flags & TCL_ENCODING_NOCOMPLAIN) && (result != (size_t)-1)) {
+ if (!(flags & TCL_ENCODING_NOCOMPLAIN) && (result != TCL_INDEX_NONE)) {
if (failVarObj != NULL) {
- /* I hope, wide int will cover size_t data type */
if (Tcl_ObjSetVar2(interp, failVarObj, NULL, Tcl_NewWideIntObj(result), TCL_LEAVE_ERR_MSG) == NULL) {
return TCL_ERROR;
}
} else {
char buf[TCL_INTEGER_SPACE];
- sprintf(buf, "%" TCL_Z_MODIFIER "u", result);
+ sprintf(buf, "%u", result);
Tcl_SetObjResult(interp, Tcl_ObjPrintf("unexpected byte sequence starting at index %"
- TCL_Z_MODIFIER "u: '\\x%X'", result, UCHAR(bytesPtr[result])));
+ "u: '\\x%X'", result, UCHAR(bytesPtr[result])));
Tcl_SetErrorCode(interp, "TCL", "ENCODING", "ILLEGALSEQUENCE",
buf, NULL);
Tcl_DStringFree(&ds);
@@ -685,7 +684,7 @@ EncodingConverttoObjCmd(
Tcl_Encoding encoding; /* Encoding to use */
int length; /* Length of the string being converted */
const char *stringPtr; /* Pointer to the first byte of the string */
- size_t result;
+ int result;
#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED)
int flags = TCL_ENCODING_STOPONERROR;
#else
@@ -750,7 +749,7 @@ EncodingConverttoObjCmd(
stringPtr = TclGetStringFromObj(data, &length);
result = Tcl_UtfToExternalDStringEx(encoding, stringPtr, length,
flags, &ds);
- if (!(flags & TCL_ENCODING_NOCOMPLAIN) && (result != (size_t)-1)) {
+ if (!(flags & TCL_ENCODING_NOCOMPLAIN) && (result != TCL_INDEX_NONE)) {
if (failVarObj != NULL) {
/* I hope, wide int will cover size_t data type */
if (Tcl_ObjSetVar2(interp, failVarObj, NULL, Tcl_NewWideIntObj(result), TCL_LEAVE_ERR_MSG) == NULL) {
@@ -761,7 +760,7 @@ EncodingConverttoObjCmd(
int ucs4;
char buf[TCL_INTEGER_SPACE];
TclUtfToUCS4(&stringPtr[result], &ucs4);
- sprintf(buf, "%" TCL_Z_MODIFIER "u", result);
+ sprintf(buf, "%u", result);
Tcl_SetObjResult(interp, Tcl_ObjPrintf("unexpected character at index %"
TCL_Z_MODIFIER "u: 'U+%06X'", pos, ucs4));
Tcl_SetErrorCode(interp, "TCL", "ENCODING", "ILLEGALSEQUENCE",
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 0830a11..57574b8 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -1944,11 +1944,11 @@ EXTERN const char * Tcl_UtfPrev(const char *src, const char *start);
/* 657 */
EXTERN int Tcl_UniCharIsUnicode(int ch);
/* 658 */
-EXTERN size_t Tcl_ExternalToUtfDStringEx(Tcl_Encoding encoding,
+EXTERN int Tcl_ExternalToUtfDStringEx(Tcl_Encoding encoding,
const char *src, int srcLen, int flags,
Tcl_DString *dsPtr);
/* 659 */
-EXTERN size_t Tcl_UtfToExternalDStringEx(Tcl_Encoding encoding,
+EXTERN int Tcl_UtfToExternalDStringEx(Tcl_Encoding encoding,
const char *src, int srcLen, int flags,
Tcl_DString *dsPtr);
/* 660 */
@@ -2656,8 +2656,8 @@ typedef struct TclStubs {
const char * (*tcl_UtfNext) (const char *src); /* 655 */
const char * (*tcl_UtfPrev) (const char *src, const char *start); /* 656 */
int (*tcl_UniCharIsUnicode) (int ch); /* 657 */
- size_t (*tcl_ExternalToUtfDStringEx) (Tcl_Encoding encoding, const char *src, int srcLen, int flags, Tcl_DString *dsPtr); /* 658 */
- size_t (*tcl_UtfToExternalDStringEx) (Tcl_Encoding encoding, const char *src, int srcLen, int flags, Tcl_DString *dsPtr); /* 659 */
+ int (*tcl_ExternalToUtfDStringEx) (Tcl_Encoding encoding, const char *src, int srcLen, int flags, Tcl_DString *dsPtr); /* 658 */
+ int (*tcl_UtfToExternalDStringEx) (Tcl_Encoding encoding, const char *src, int srcLen, int flags, Tcl_DString *dsPtr); /* 659 */
int (*tcl_AsyncMarkFromSignal) (Tcl_AsyncHandler async, int sigNumber); /* 660 */
void (*reserved661)(void);
void (*reserved662)(void);
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index b6d5dcf..fd0386c 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1142,7 +1142,7 @@ Tcl_ExternalToUtfDString(
Tcl_DString *dstPtr) /* Uninitialized or free DString in which the
* converted string is stored. */
{
- Tcl_ExternalToUtfDStringEx(encoding, src, srcLen, 0, dstPtr);
+ Tcl_ExternalToUtfDStringEx(encoding, src, srcLen, TCL_ENCODING_NOCOMPLAIN, dstPtr);
return Tcl_DStringValue(dstPtr);
}
@@ -1176,7 +1176,7 @@ Tcl_ExternalToUtfDString(
*-------------------------------------------------------------------------
*/
-size_t
+int
Tcl_ExternalToUtfDStringEx(
Tcl_Encoding encoding, /* The encoding for the source string, or NULL
* for the default system encoding. */
@@ -1221,7 +1221,7 @@ Tcl_ExternalToUtfDStringEx(
src += srcRead;
if (result != TCL_CONVERT_NOSPACE) {
Tcl_DStringSetLength(dstPtr, soFar);
- return (result == TCL_OK) ? (size_t)-1 : (size_t)(src - srcStart);
+ return (result == TCL_OK) ? TCL_INDEX_NONE : (int)(src - srcStart);
}
flags &= ~TCL_ENCODING_START;
srcLen -= srcRead;
@@ -1380,7 +1380,7 @@ Tcl_UtfToExternalDString(
Tcl_DString *dstPtr) /* Uninitialized or free DString in which the
* converted string is stored. */
{
- Tcl_UtfToExternalDStringEx(encoding, src, srcLen, 0, dstPtr);
+ Tcl_UtfToExternalDStringEx(encoding, src, srcLen, TCL_ENCODING_NOCOMPLAIN, dstPtr);
return Tcl_DStringValue(dstPtr);
}
@@ -1415,7 +1415,7 @@ Tcl_UtfToExternalDString(
*-------------------------------------------------------------------------
*/
-size_t
+int
Tcl_UtfToExternalDStringEx(
Tcl_Encoding encoding, /* The encoding for the converted string, or
* NULL for the default system encoding. */
@@ -1459,7 +1459,7 @@ Tcl_UtfToExternalDStringEx(
while (i >= soFar) {
Tcl_DStringSetLength(dstPtr, i--);
}
- return (result == TCL_OK) ? (size_t)-1 : (size_t)(src - srcStart);
+ return (result == TCL_OK) ? TCL_INDEX_NONE : (int)(src - srcStart);
}
flags &= ~TCL_ENCODING_START;
@@ -2375,7 +2375,7 @@ UtfToUtfProc(
*/
if (flags & TCL_ENCODING_MODIFIED) {
- if (STOPONERROR) {
+ if ((STOPONERROR) && (flags & TCL_ENCODING_CHAR_LIMIT)) {
result = TCL_CONVERT_MULTIBYTE;
break;
}
@@ -3156,7 +3156,7 @@ TableFromUtfProc(
word = fromUnicode[(ch >> 8)][ch & 0xFF];
if ((word == 0) && (ch != 0)) {
- if (STOPONERROR) {
+ if ((STOPONERROR) && (flags & TCL_ENCODING_CHAR_LIMIT)) {
result = TCL_CONVERT_UNKNOWN;
break;
}
diff --git a/tests/chanio.test b/tests/chanio.test
index 578dc9f..8d922a2 100644
--- a/tests/chanio.test
+++ b/tests/chanio.test
@@ -249,7 +249,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} deprecated {
+test chan-io-3.4 {WriteChars: loop over stage buffer} -body {
# 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,8 +257,10 @@ test chan-io-3.4 {WriteChars: loop over stage buffer} deprecated {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test chan-io-3.5 {WriteChars: saved != 0} deprecated {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test chan-io-3.5 {WriteChars: saved != 0} -body {
# Bytes produced by UtfToExternal from end of last channel buffer had to
# be moved to beginning of next channel buffer to preserve requested
# buffersize.
@@ -268,8 +270,10 @@ test chan-io-3.5 {WriteChars: saved != 0} deprecated {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} -body {
# One incomplete UTF-8 character at end of staging buffer. Backup in src
# to the beginning of that UTF-8 character and try again.
#
@@ -284,8 +288,10 @@ test chan-io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
set x [list [contents $path(test1)]]
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)} deprecated {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"]
+test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} -body {
# 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
@@ -297,8 +303,10 @@ test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} deprecated {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test chan-io-3.8 {WriteChars: reset sawLF after each buffer} {
+} -cleanup {
+ catch {chan close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test chan-io-3.8 {WriteChars: reset sawLF after each buffer} -body {
set f [open $path(test1) w]
chan configure $f -encoding ascii -buffering line -translation lf \
-buffersize 16
@@ -306,7 +314,9 @@ test chan-io-3.8 {WriteChars: reset sawLF after each buffer} {
set x [list [contents $path(test1)]]
chan close $f
lappend x [contents $path(test1)]
-} [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]
+} -cleanup {
+ catch {chan close $f}
+} -result [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]
test chan-io-4.1 {TranslateOutputEOL: lf} {
# search for \n
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index bb0e4bc..ab1a8e6 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -235,34 +235,34 @@ test cmdAH-4.13 {Tcl_EncodingObjCmd} -setup {
encoding system $system
} -result iso8859-1
-test encoding-4.14.1 {Syntax error, -nocomplain and -failindex, no encoding} -body {
+test cmdAH-4.14.1 {Syntax error, -nocomplain and -failindex, no encoding} -body {
encoding convertfrom -nocomplain -failindex 2 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.14.2 {Syntax error, -nocomplain and -failindex, no encoding} -body {
+test cmdAH-4.14.2 {Syntax error, -nocomplain and -failindex, no encoding} -body {
encoding convertto -nocomplain -failindex 2 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.15.1 {Syntax error, -failindex and -nocomplain, no encoding} -body {
+test cmdAH-4.15.1 {Syntax error, -failindex and -nocomplain, no encoding} -body {
encoding convertfrom -failindex 2 -nocomplain ABC
} -returnCodes 1 -result {unknown encoding "-nocomplain"}
-test encoding-4.15.2 {Syntax error, -failindex and -nocomplain, no encoding} -body {
+test cmdAH-4.15.2 {Syntax error, -failindex and -nocomplain, no encoding} -body {
encoding convertto -failindex 2 -nocomplain ABC
} -returnCodes 1 -result {unknown encoding "-nocomplain"}
-test encoding-4.16.1 {Syntax error, -nocomplain and -failindex, encoding} -body {
+test cmdAH-4.16.1 {Syntax error, -nocomplain and -failindex, encoding} -body {
encoding convertfrom -nocomplain -failindex 2 utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.16.2 {Syntax error, -nocomplain and -failindex, encoding} -body {
+test cmdAH-4.16.2 {Syntax error, -nocomplain and -failindex, encoding} -body {
encoding convertto -nocomplain -failindex 2 utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.17.1 {Syntax error, -failindex and -nocomplain, encoding} -body {
+test cmdAH-4.17.1 {Syntax error, -failindex and -nocomplain, encoding} -body {
encoding convertfrom -failindex 2 -nocomplain utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.17.2 {Syntax error, -failindex and -nocomplain, encoding} -body {
+test cmdAH-4.17.2 {Syntax error, -failindex and -nocomplain, encoding} -body {
encoding convertto -failindex 2 -nocomplain utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.18.1 {Syntax error, -failindex with no var, no encoding} -body {
+test cmdAH-4.18.1 {Syntax error, -failindex with no var, no encoding} -body {
encoding convertfrom -failindex ABC
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.18.2 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
+test cmdAH-4.18.2 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
proc encoding_test {} {
encoding convertfrom -failindex ABC
}
@@ -272,10 +272,10 @@ test encoding-4.18.2 {Syntax error, -failindex with no var, no encoding (byte co
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-nocomplain? ?-failindex var? ?encoding? data"} -cleanup {
rename encoding_test ""
}
-test encoding-4.18.3 {Syntax error, -failindex with no var, no encoding} -body {
+test cmdAH-4.18.3 {Syntax error, -failindex with no var, no encoding} -body {
encoding convertto -failindex ABC
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-failindex var? ?encoding? data"}
-test encoding-4.18.4 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
+test cmdAH-4.18.4 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
proc encoding_test {} {
encoding convertto -failindex ABC
}
@@ -285,11 +285,11 @@ test encoding-4.18.4 {Syntax error, -failindex with no var, no encoding (byte co
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-nocomplain? ?-failindex var? ?encoding? data"} -cleanup {
rename encoding_test ""
}
-test encoding-4.19.1 {convertrom -failindex with correct data} -body {
+test cmdAH-4.19.1 {convertrom -failindex with correct data} -body {
encoding convertfrom -failindex test ABC
set test
} -returnCodes 0 -result -1
-test encoding-4.19.2 {convertrom -failindex with correct data (byt compiled)} -setup {
+test cmdAH-4.19.2 {convertrom -failindex with correct data (byt compiled)} -setup {
proc encoding_test {} {
encoding convertfrom -failindex test ABC
set test
@@ -300,11 +300,11 @@ test encoding-4.19.2 {convertrom -failindex with correct data (byt compiled)} -s
} -returnCodes 0 -result -1 -cleanup {
rename encoding_test ""
}
-test encoding-4.19.3 {convertrom -failindex with correct data} -body {
+test cmdAH-4.19.3 {convertrom -failindex with correct data} -body {
encoding convertto -failindex test ABC
set test
} -returnCodes 0 -result -1
-test encoding-4.19.4 {convertrom -failindex with correct data (byt compiled)} -setup {
+test cmdAH-4.19.4 {convertrom -failindex with correct data (byt compiled)} -setup {
proc encoding_test {} {
encoding convertto -failindex test ABC
set test
@@ -315,12 +315,12 @@ test encoding-4.19.4 {convertrom -failindex with correct data (byt compiled)} -s
} -returnCodes 0 -result -1 -cleanup {
rename encoding_test ""
}
-test encoding-4.20.1 {convertrom -failindex with incomplete utf8} -body {
+test cmdAH-4.20.1 {convertrom -failindex with incomplete utf8} -body {
set x [encoding convertfrom -failindex i utf-8 A\xc3]
binary scan $x H* y
list $y $i
-} -returnCodes 0 -result {41 1}
-test encoding-4.20.2 {convertrom -failindex with incomplete utf8 (byte compiled)} -setup {
+} -returnCodes 0 -result {41c3 -1}
+test cmdAH-4.20.2 {convertrom -failindex with incomplete utf8 (byte compiled)} -setup {
proc encoding_test {} {
set x [encoding convertfrom -failindex i utf-8 A\xc3]
binary scan $x H* y
@@ -329,15 +329,15 @@ test encoding-4.20.2 {convertrom -failindex with incomplete utf8 (byte compiled)
} -body {
# Compile and execute
encoding_test
-} -returnCodes 0 -result {41 1} -cleanup {
+} -returnCodes 0 -result {41c3 -1} -cleanup {
rename encoding_test ""
}
-test encoding-4.21.1 {convertto -failindex with wrong character} -body {
+test cmdAH-4.21.1 {convertto -failindex with wrong character} -body {
set x [encoding convertto -failindex i iso8859-1 A\u0141]
binary scan $x H* y
list $y $i
} -returnCodes 0 -result {41 1}
-test encoding-4.20.2 {convertto -failindex with wrong character (byte compiled)} -setup {
+test cmdAH-4.21.2 {convertto -failindex with wrong character (byte compiled)} -setup {
proc encoding_test {} {
set x [encoding convertto -failindex i iso8859-1 A\u0141]
binary scan $x H* y
diff --git a/tests/encoding.test b/tests/encoding.test
index fbf5a2c..6f11968 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -22,7 +22,7 @@ catch {
package require -exact tcl::test [info patchlevel]
}
-testConstraint deprecated [expr {![info exists tcl_precision]}]
+package require tcltests
proc toutf {args} {
variable x
@@ -639,28 +639,28 @@ test encoding-24.11 {Parse valid or invalid utf-8} {
} 1
test encoding-24.12 {Parse valid or invalid utf-8} -constraints deprecated -body {
encoding convertfrom utf-8 "\xC0\x81"
-} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'}
+} -result \xC0\x81
test encoding-24.13 {Parse valid or invalid utf-8} -constraints deprecated -body {
encoding convertfrom utf-8 "\xC1\xBF"
-} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC1'}
+} -result \xC1\xBF
test encoding-24.14 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xC2\x80"]
} 1
test encoding-24.15 {Parse valid or invalid utf-8} -constraints deprecated -body {
encoding convertfrom utf-8 "Z\xE0\x80"
-} -returnCodes 1 -result {unexpected byte sequence starting at index 1: '\xE0'}
-test encoding-24.16 {Parse valid or invalid utf-8} -constraints {testbytestring deprecated} -body {
+} -result Z\xE0\x80
+test encoding-24.16 {Parse valid or invalid utf-8} -constraints testbytestring -body {
encoding convertto utf-8 [testbytestring "Z\u4343\x80"]
} -returnCodes 1 -result {expected byte sequence but character 1 was '䍃€' (U+004343)}
-test encoding-24.17 {Parse valid or invalid utf-8} -constraints {testbytestring deprecated} -body {
+test encoding-24.17 {Parse valid or invalid utf-8} -constraints testbytestring -body {
encoding convertto utf-8 [testbytestring "Z\xE0\x80"]
} -result "Z\xC3\xA0\xE2\x82\xAC"
-test encoding-24.18 {Parse valid or invalid utf-8} -constraints {testbytestring deprecated} -body {
+test encoding-24.18 {Parse valid or invalid utf-8} -constraints testbytestring -body {
encoding convertto utf-8 [testbytestring "Z\xE0\x80xxxxxx"]
} -result "Z\xC3\xA0\xE2\x82\xACxxxxxx"
test encoding-24.19 {Parse valid or invalid utf-8} -constraints deprecated -body {
encoding convertto utf-8 "ZX\uD800"
-} -returnCodes 1 -match glob -result "unexpected character at index 2: 'U+00D800'"
+} -result ZX\xED\xA0\x80
test encoding-24.20 {Parse with -nocomplain but without providing encoding} {
string length [encoding convertfrom -nocomplain "\x20"]
} 1
diff --git a/tests/http.test b/tests/http.test
index 93998fe..a34b168 100644
--- a/tests/http.test
+++ b/tests/http.test
@@ -15,6 +15,7 @@ if {"::tcltest" ni [namespace children]} {
package require tcltest 2.5
namespace import -force ::tcltest::*
}
+package require tcltests
if {[catch {package require http 2} version]} {
if {[info exists http2]} {
diff --git a/tests/io.test b/tests/io.test
index 821b11e..f07fa8d 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -268,7 +268,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} deprecated {
+test io-3.4 {WriteChars: loop over stage buffer} -body {
# stage buffer maps to more than can be queued at once.
set f [open $path(test1) w]
@@ -277,8 +277,10 @@ test io-3.4 {WriteChars: loop over stage buffer} deprecated {
set x [list [contents $path(test1)]]
close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test io-3.5 {WriteChars: saved != 0} deprecated {
+} -cleanup {
+ catch {close $f}
+} -result [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+test io-3.5 {WriteChars: saved != 0} -body {
# Bytes produced by UtfToExternal from end of last channel buffer
# had to be moved to beginning of next channel buffer to preserve
# requested buffersize.
@@ -289,7 +291,9 @@ test io-3.5 {WriteChars: saved != 0} deprecated {
set x [list [contents $path(test1)]]
close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+} -cleanup {
+ catch {close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
test io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
# One incomplete UTF-8 character at end of staging buffer. Backup
# in src to the beginning of that UTF-8 character and try again.
@@ -307,7 +311,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)} deprecated {
+test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} -body {
# 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
@@ -320,7 +324,9 @@ test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} deprecated {
set x [list [contents $path(test1)]]
close $f
lappend x [contents $path(test1)]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
+} -cleanup {
+ catch {close $f}
+} -result [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
test io-3.8 {WriteChars: reset sawLF after each buffer} {
set f [open $path(test1) w]
fconfigure $f -encoding ascii -buffering line -translation lf \
@@ -1532,7 +1538,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} deprecated {
+test io-12.9 {ReadChars: multibyte chars split} -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
@@ -1542,8 +1548,10 @@ test io-12.9 {ReadChars: multibyte chars split} deprecated {
set in [read $f]
close $f
scan [string index $in end] %c
-} 194
-test io-12.10 {ReadChars: multibyte chars split} deprecated {
+} -cleanup {
+ catch {close $f}
+} -result 194
+test io-12.10 {ReadChars: multibyte chars split} -body {
set f [open $path(test1) w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat a 9]\xC2
@@ -1553,7 +1561,9 @@ test io-12.10 {ReadChars: multibyte chars split} deprecated {
set in [read $f]
close $f
scan [string index $in end] %c
-} 194
+} -cleanup {
+ catch {close $f}
+} -result 194
test io-13.1 {TranslateInputEOL: cr mode} {} {
set f [open $path(test1) w]