diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-05-04 06:38:34 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-05-04 06:38:34 (GMT) |
| commit | 32ef665a1f78d2950b72d78dea5665b07ff4f7b2 (patch) | |
| tree | aafaab9c15343abcc2943a0d97c425bd0b5dd2b1 | |
| parent | 4dd71100197de4a35b6bae123d4f32b7ca086a05 (diff) | |
| parent | e8088626602ce5407a5c8ae750dedc0605fa0caf (diff) | |
| download | tcl-32ef665a1f78d2950b72d78dea5665b07ff4f7b2.zip tcl-32ef665a1f78d2950b72d78dea5665b07ff4f7b2.tar.gz tcl-32ef665a1f78d2950b72d78dea5665b07ff4f7b2.tar.bz2 | |
Rebase to latest 9.0
| -rw-r--r-- | doc/Encoding.3 | 8 | ||||
| -rw-r--r-- | doc/OpenFileChnl.3 | 13 | ||||
| -rw-r--r-- | doc/encoding.n | 15 | ||||
| -rw-r--r-- | generic/tcl.decls | 5 | ||||
| -rw-r--r-- | generic/tcl.h | 11 | ||||
| -rw-r--r-- | generic/tclCmdAH.c | 2 | ||||
| -rw-r--r-- | generic/tclDecls.h | 8 | ||||
| -rw-r--r-- | generic/tclEncoding.c | 132 | ||||
| -rw-r--r-- | generic/tclIO.c | 107 | ||||
| -rw-r--r-- | generic/tclIOCmd.c | 15 | ||||
| -rw-r--r-- | generic/tclIOUtil.c | 1 | ||||
| -rw-r--r-- | generic/tclInt.h | 1 | ||||
| -rw-r--r-- | generic/tclStubInit.c | 2 | ||||
| -rw-r--r-- | library/http/http.tcl | 12 | ||||
| -rw-r--r-- | tests/chanio.test | 2 | ||||
| -rw-r--r-- | tests/encoding.test | 2 | ||||
| -rw-r--r-- | tests/encodingVectors.tcl | 2 | ||||
| -rw-r--r-- | tests/io.test | 28 | ||||
| -rw-r--r-- | tests/ioCmd.test | 8 | ||||
| -rw-r--r-- | tests/iogt.test | 4 | ||||
| -rw-r--r-- | tests/utfext.test | 2 | ||||
| -rw-r--r-- | tests/winConsole.test | 2 |
22 files changed, 155 insertions, 227 deletions
diff --git a/doc/Encoding.3 b/doc/Encoding.3 index a1eb265..aaf7313 100644 --- a/doc/Encoding.3 +++ b/doc/Encoding.3 @@ -105,9 +105,9 @@ byte is converted and then to reset to an initial state. The \fBTCL_PROFILE_*\fR bits defined in the \fBPROFILES\fR section below control the encoding profile to be used for dealing with invalid data or other errors in the encoding transform. -\fBTCL_ENCODING_STOPONERROR\fR is present for backward compatibility with -Tcl 8.6 and forces the encoding profile to \fBstrict\fR. - +The flag \fBTCL_ENCODING_STOPONERROR\fR has no effect, +it only has meaning in Tcl 8.x. +.PP Some flags bits may not be usable with some functions as noted in the function descriptions below. .AP Tcl_EncodingState *statePtr in/out @@ -590,7 +590,7 @@ with at most one of \fBTCL_ENCODING_PROFILE_TCL8\fR, \fBTCL_ENCODING_PROFILE_STRICT\fR or \fBTCL_ENCODING_PROFILE_REPLACE\fR. These correspond to the \fBtcl8\fR, \fBstrict\fR and \fBreplace\fR profiles respectively. If none are specified, a version-dependent default profile is used. -For Tcl 8.7, the default profile is \fBtcl8\fR. +For Tcl 9.0, the default profile is \fBstrict\fR. .PP For details about profiles, see the \fBPROFILES\fR section in the documentation of the \fBencoding\fR command. diff --git a/doc/OpenFileChnl.3 b/doc/OpenFileChnl.3 index 3a7b6ae..8709c60 100644 --- a/doc/OpenFileChnl.3 +++ b/doc/OpenFileChnl.3 @@ -9,7 +9,7 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_MakeFileChannel, Tcl_GetChannel, Tcl_GetChannelNames, Tcl_GetChannelNamesEx, Tcl_RegisterChannel, Tcl_UnregisterChannel, Tcl_DetachChannel, Tcl_IsStandardChannel, Tcl_Close, Tcl_ReadChars, Tcl_Read, Tcl_GetsObj, Tcl_Gets, Tcl_WriteObj, Tcl_WriteChars, Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_TruncateChannel, Tcl_GetChannelOption, Tcl_SetChannelOption, Tcl_Eof, Tcl_InputBlocked, Tcl_InputBuffered, Tcl_OutputBuffered, Tcl_Ungets, Tcl_ReadRaw, Tcl_WriteRaw \- buffered I/O facilities using channels +Tcl_OpenFileChannel, Tcl_OpenCommandChannel, Tcl_MakeFileChannel, Tcl_GetChannel, Tcl_GetChannelNames, Tcl_GetChannelNamesEx, Tcl_RegisterChannel, Tcl_UnregisterChannel, Tcl_DetachChannel, Tcl_IsStandardChannel, Tcl_Close, Tcl_ReadChars, Tcl_Read, Tcl_GetsObj, Tcl_Gets, Tcl_WriteObj, Tcl_WriteChars, Tcl_Write, Tcl_Flush, Tcl_Seek, Tcl_Tell, Tcl_TruncateChannel, Tcl_GetChannelOption, Tcl_SetChannelOption, Tcl_Eof, Tcl_InputBlocked, Tcl_InputBuffered, Tcl_InputEncodingError, Tcl_OutputBuffered, Tcl_Ungets, Tcl_ReadRaw, Tcl_WriteRaw \- buffered I/O facilities using channels .SH SYNOPSIS .nf \fB#include <tcl.h>\fR @@ -90,6 +90,9 @@ int \fBTcl_InputBuffered\fR(\fIchannel\fR) .sp int +\fBTcl_InputEncodingError\fR(\fIchannel\fR) +.sp +int \fBTcl_OutputBuffered\fR(\fIchannel\fR) .sp long long @@ -482,6 +485,14 @@ end-of-line character. When -1 is returned, the \fBTcl_InputBlocked\fR procedure may be invoked to determine if the channel is blocked because of input unavailability. .PP +If the channel is in blocking mode, it might be that there is data available +but - at the same time - an encoding error occurred. In that case, the +POSIX error EILSEQ will be recorded, but - since \fBTcl_Gets\fR/\fBTcl_Read\fR +didn't return TCL_INDEX_NONE we cannot be sure if the POSIX error +maybe was a left-over from an earlier error. The only way to be sure +is calling the \fBTcl_InputEncodingError\fR procedure, it will +return 1 if the channel is at an encoding error position. +.PP \fBTcl_Gets\fR is the same as \fBTcl_GetsObj\fR except the resulting characters are appended to the dynamic string given by \fIlineRead\fR rather than a Tcl value. diff --git a/doc/encoding.n b/doc/encoding.n index 793348f..255e070 100644 --- a/doc/encoding.n +++ b/doc/encoding.n @@ -111,9 +111,14 @@ encoding. The following profiles are currently implemented. .VS "TCL8.7 TIP656" .TP +\fBstrict\fR +. +The default profile. The operation fails when invalid data for the encoding +are encountered. +.TP \fBtcl8\fR . -The default profile. Provides for behaviour identical to that of Tcl 8.6: When +Provides for behaviour identical to that of Tcl 8.6: When decoding, for encodings \fBother than utf-8\fR, each invalid byte is interpreted as the Unicode value given by that one byte. For example, the byte 0x80, which is invalid in the ASCII encoding would be mapped to the Unicode value U+0080. @@ -127,10 +132,6 @@ an additional special case, the sequence 0xC0 0x80 is mapped to U+0000. When encoding, each character that cannot be represented in the encoding is replaced by an encoding-dependent character, usually the question mark \fB?\fR. .TP -\fBstrict\fR -. -The operation fails when invalid data for the encoding are encountered. -.TP \fBreplace\fR . When decoding, invalid bytes are replaced by U+FFFD, the Unicode REPLACEMENT @@ -180,7 +181,7 @@ unexpected byte sequence starting at index 1: '\ex80' Example 3: Get partial data and the error location: .PP .CS -% codepoints [encoding convertfrom -profile strict -failindex idx ascii AB\ex80] +% codepoints [encoding convertfrom -failindex idx ascii AB\ex80] U+000041 U+000042 % set idx 2 @@ -193,7 +194,7 @@ Example 4: Encode a character that is not representable in ISO8859-1: A? % encoding convertto -profile strict iso8859-1 A\eu0141 unexpected character at index 1: 'U+000141' -% encoding convertto -profile strict -failindex idx iso8859-1 A\eu0141 +% encoding convertto -failindex idx iso8859-1 A\eu0141 A % set idx 1 diff --git a/generic/tcl.decls b/generic/tcl.decls index d52b710..30e4dea 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2632,6 +2632,11 @@ declare 686 { Tcl_Size *sizePtr) } +# TIP 657 +declare 687 { + int Tcl_InputEncodingError(Tcl_Channel chan) +} + # ----- BASELINE -- FOR -- 8.7.0 / 9.0.0 ----- # declare 688 { diff --git a/generic/tcl.h b/generic/tcl.h index 1e33ba1..371cae0 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -1933,8 +1933,6 @@ typedef struct Tcl_EncodingType { * reset to an initial state. If the source * buffer contains the entire input stream to be * converted, this flag should be set. - * TCL_ENCODING_STRICT - Be more strict in accepting what - * is considered a 'invalid byte sequence'. * TCL_ENCODING_STOPONERROR - Not used any more. * TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf does not append a * terminating NUL byte. Since it does not need @@ -1974,14 +1972,9 @@ typedef struct Tcl_EncodingType { * changes, ensure ENCODING_PROFILE_* macros in tclInt.h are modified if * necessary. */ +#define TCL_ENCODING_PROFILE_STRICT TCL_ENCODING_STOPONERROR #define TCL_ENCODING_PROFILE_TCL8 0x01000000 -#define TCL_ENCODING_PROFILE_STRICT 0x02000000 -#define TCL_ENCODING_PROFILE_REPLACE 0x03000000 -#if TCL_MAJOR_VERSION < 9 -#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8 -#else -#define TCL_ENCODING_PROFILE_DEFAULT TCL_ENCODING_PROFILE_TCL8 -#endif +#define TCL_ENCODING_PROFILE_REPLACE 0x02000000 /* * The following definitions are the error codes returned by the conversion diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index e2186ed..e8eb26a 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -436,7 +436,7 @@ EncodingConvertParseOptions ( Tcl_Obj *dataObj; Tcl_Obj *failVarObj; #if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED) - int profile = TCL_ENCODING_PROFILE_TCL8; /* TODO - default for Tcl9? */ + int profile = TCL_ENCODING_PROFILE_STRICT; #else int profile = TCL_ENCODING_PROFILE_TCL8; #endif diff --git a/generic/tclDecls.h b/generic/tclDecls.h index feb7a64..2fa84c4 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1865,7 +1865,8 @@ EXTERN Tcl_Obj * Tcl_DStringToObj(Tcl_DString *dsPtr); /* 686 */ EXTERN int Tcl_GetSizeIntFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *sizePtr); -/* Slot 687 is reserved */ +/* 687 */ +EXTERN int Tcl_InputEncodingError(Tcl_Channel chan); /* 688 */ EXTERN void TclUnusedStubEntry(void); @@ -2566,7 +2567,7 @@ typedef struct TclStubs { int (*tcl_GetWideUIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_WideUInt *uwidePtr); /* 684 */ Tcl_Obj * (*tcl_DStringToObj) (Tcl_DString *dsPtr); /* 685 */ int (*tcl_GetSizeIntFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *sizePtr); /* 686 */ - void (*reserved687)(void); + int (*tcl_InputEncodingError) (Tcl_Channel chan); /* 687 */ void (*tclUnusedStubEntry) (void); /* 688 */ } TclStubs; @@ -3894,7 +3895,8 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_DStringToObj) /* 685 */ #define Tcl_GetSizeIntFromObj \ (tclStubsPtr->tcl_GetSizeIntFromObj) /* 686 */ -/* Slot 687 is reserved */ +#define Tcl_InputEncodingError \ + (tclStubsPtr->tcl_InputEncodingError) /* 687 */ #define TclUnusedStubEntry \ (tclStubsPtr->tclUnusedStubEntry) /* 688 */ diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index b794eb2..d13c923 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -10,6 +10,7 @@ */ #include "tclInt.h" +#include "tclIO.h" typedef size_t (LengthProc)(const char *src); @@ -198,18 +199,11 @@ static struct TclEncodingProfiles { {"strict", TCL_ENCODING_PROFILE_STRICT}, {"tcl8", TCL_ENCODING_PROFILE_TCL8}, }; -#define PROFILE_TCL8(flags_) \ - ((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_TCL8) \ - || (ENCODING_PROFILE_GET(flags_) == 0 \ - && TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_TCL8)) #define PROFILE_STRICT(flags_) \ - ((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_STRICT) \ - || (ENCODING_PROFILE_GET(flags_) == 0 \ - && TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_STRICT)) + (ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_STRICT) + #define PROFILE_REPLACE(flags_) \ - ((ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE) \ - || (ENCODING_PROFILE_GET(flags_) == 0 \ - && TCL_ENCODING_PROFILE_DEFAULT == TCL_ENCODING_PROFILE_REPLACE)) + (ENCODING_PROFILE_GET(flags_) == TCL_ENCODING_PROFILE_REPLACE) #define UNICODE_REPLACE_CHAR ((Tcl_UniChar)0xFFFD) #define SURROGATE(c_) (((c_) & ~0x7FF) == 0xD800) @@ -1170,10 +1164,6 @@ Tcl_ExternalToUtfDString( * Possible flags values: * target encoding. It should be composed by OR-ing the following: * - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT} - * - TCL_ENCODING_STOPONERROR: Backward compatibility. Sets the profile - * to TCL_ENCODING_PROFILE_STRICT overriding any specified profile flags - * Any other flag bits will cause an error to be returned (for future - * compatibility) * * Results: * The return value is one of @@ -1500,8 +1490,6 @@ Tcl_UtfToExternalDString( * the source buffer are invalid or cannot be represented in the * target encoding. It should be composed by OR-ing the following: * - *At most one* of TCL_ENCODING_PROFILE{DEFAULT,TCL8,STRICT} - * - TCL_ENCODING_STOPONERROR: Backward compatibility. Sets the profile - * to TCL_ENCODING_PROFILE_STRICT overriding any specified profile flags * * Results: * The return value is one of @@ -2451,7 +2439,6 @@ BinaryProc( if (dstLen < 0) { dstLen = 0; } - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_CHAR_LIMIT) && srcLen > *dstCharsPtr) { srcLen = *dstCharsPtr; } @@ -2519,7 +2506,6 @@ UtfToUtfProc( srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_END) == 0) { srcClose -= 6; } @@ -2531,16 +2517,6 @@ UtfToUtfProc( flags |= PTR2INT(clientData); dstEnd = dst + dstLen - ((flags & ENCODING_UTF) ? TCL_UTF_MAX : 6); - -#if TCL_UTF_MAX < 4 - /* Initialize the buffer so that some random data doesn't trick - * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs. - * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its - * prior non-stateful nature, this call to memset can also be removed. - */ - memset(dst, 0xff, dstLen); -#endif - profile = ENCODING_PROFILE_GET(flags); for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) { @@ -2748,22 +2724,12 @@ Utf32ToUtfProc( int result, numChars, charLimit = INT_MAX; int ch = 0, bytesLeft = srcLen % 4; - flags = TclEncodingSetProfileFlags(flags); flags |= PTR2INT(clientData); if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; } result = TCL_OK; -#if TCL_UTF_MAX < 4 - /* Initialize the buffer so that some random data doesn't trick - * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs. - * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its - * prior non-stateful nature, this call to memset can also be removed. - */ - memset(dst, 0xff, dstLen); -#endif - /* * Check alignment with utf-32 (4 == sizeof(UTF-32)) */ @@ -2928,7 +2894,6 @@ UtfToUtf32Proc( srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_END) == 0) { srcClose -= TCL_UTF_MAX; } @@ -3026,22 +2991,12 @@ Utf16ToUtfProc( int result, numChars, charLimit = INT_MAX; unsigned short ch = 0; - flags = TclEncodingSetProfileFlags(flags); flags |= PTR2INT(clientData); if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; } result = TCL_OK; -#if TCL_UTF_MAX < 4 - /* Initialize the buffer so that some random data doesn't trick - * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs. - * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its - * prior non-stateful nature, this call to memset can also be removed. - */ - memset(dst, 0xff, dstLen); -#endif - /* * Check alignment with utf-16 (2 == sizeof(UTF-16)) */ @@ -3115,7 +3070,7 @@ Utf16ToUtfProc( *dst++ = (ch & 0xFF); } else if (HIGH_SURROGATE(prev) || HIGH_SURROGATE(ch)) { dst += Tcl_UniCharToUtf(ch | TCL_COMBINE, dst); - } else if (LOW_SURROGATE(ch) && !PROFILE_TCL8(flags)) { + } else if (LOW_SURROGATE(ch) && (PROFILE_STRICT(flags) || PROFILE_REPLACE(flags))) { /* Lo surrogate not preceded by Hi surrogate and not tcl8 profile */ if (PROFILE_STRICT(flags)) { result = TCL_CONVERT_UNKNOWN; @@ -3216,7 +3171,6 @@ UtfToUtf16Proc( srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_END) == 0) { srcClose -= TCL_UTF_MAX; } @@ -3322,7 +3276,6 @@ UtfToUcs2Proc( int result, numChars, len; Tcl_UniChar ch = 0; - flags = TclEncodingSetProfileFlags(flags); flags |= PTR2INT(clientData); srcStart = src; srcEnd = src + srcLen; @@ -3445,7 +3398,6 @@ TableToUtfProc( const unsigned short *pageZero; TableEncodingData *dataPtr = (TableEncodingData *)clientData; - flags = TclEncodingSetProfileFlags(flags); if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; } @@ -3455,15 +3407,6 @@ TableToUtfProc( dstStart = dst; dstEnd = dst + dstLen - TCL_UTF_MAX; -#if TCL_UTF_MAX < 4 - /* Initialize the buffer so that some random data doesn't trick - * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs. - * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its - * prior non-stateful nature, this call to memset can also be removed. - */ - memset(dst, 0xff, dstLen); -#endif - toUnicode = (const unsigned short *const *) dataPtr->toUnicode; prefixBytes = dataPtr->prefixBytes; pageZero = toUnicode[0]; @@ -3588,7 +3531,6 @@ TableFromUtfProc( srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_END) == 0) { srcClose -= TCL_UTF_MAX; } @@ -3695,7 +3637,6 @@ Iso88591ToUtfProc( const char *dstEnd, *dstStart; int result, numChars, charLimit = INT_MAX; - flags = TclEncodingSetProfileFlags(flags); if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; } @@ -3705,15 +3646,6 @@ Iso88591ToUtfProc( dstStart = dst; dstEnd = dst + dstLen - TCL_UTF_MAX; -#if TCL_UTF_MAX < 4 - /* Initialize the buffer so that some random data doesn't trick - * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs. - * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its - * prior non-stateful nature, this call to memset can also be removed. - */ - memset(dst, 0xff, dstLen); -#endif - result = TCL_OK; for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) { Tcl_UniChar ch = 0; @@ -3789,7 +3721,6 @@ Iso88591FromUtfProc( srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_END) == 0) { srcClose -= TCL_UTF_MAX; } @@ -3937,7 +3868,6 @@ EscapeToUtfProc( int state, result, numChars, charLimit = INT_MAX; const char *dstStart, *dstEnd; - flags = TclEncodingSetProfileFlags(flags); if (flags & TCL_ENCODING_CHAR_LIMIT) { charLimit = *dstCharsPtr; } @@ -3953,15 +3883,6 @@ EscapeToUtfProc( dstStart = dst; dstEnd = dst + dstLen - TCL_UTF_MAX; -#if TCL_UTF_MAX < 4 - /* Initialize the buffer so that some random data doesn't trick - * Tcl_UniCharToUtf() into thinking it should combine surrogate pairs. - * Once TCL_UTF_MAX == 3 is removed and Tcl_UniCharToUtf restored to its - * prior non-stateful nature, this call to memset can also be removed. - */ - memset(dst, 0xff, dstLen); -#endif - state = PTR2INT(*statePtr); if (flags & TCL_ENCODING_START) { state = 0; @@ -4170,7 +4091,6 @@ EscapeFromUtfProc( srcStart = src; srcEnd = src + srcLen; srcClose = srcEnd; - flags = TclEncodingSetProfileFlags(flags); if ((flags & TCL_ENCODING_END) == 0) { srcClose -= TCL_UTF_MAX; } @@ -4619,48 +4539,6 @@ TclEncodingProfileIdToName( /* *------------------------------------------------------------------------ * - * TclEncodingSetProfileFlags -- - * - * Maps the flags supported in the encoding C API's to internal flags. - * - * For backward compatibility reasons, TCL_ENCODING_STOPONERROR is - * is mapped to the TCL_ENCODING_PROFILE_STRICT overwriting any profile - * specified. - * - * If no profile or an invalid profile is specified, it is set to - * the default. - * - * Results: - * Internal encoding flag mask. - * - * Side effects: - * None. - * - *------------------------------------------------------------------------ - */ -int TclEncodingSetProfileFlags(int flags) -{ - if (flags & TCL_ENCODING_STOPONERROR) { - ENCODING_PROFILE_SET(flags, TCL_ENCODING_PROFILE_STRICT); - } else { - int profile = ENCODING_PROFILE_GET(flags); - switch (profile) { - case TCL_ENCODING_PROFILE_TCL8: - case TCL_ENCODING_PROFILE_STRICT: - case TCL_ENCODING_PROFILE_REPLACE: - break; - case 0: /* Unspecified by caller */ - default: - ENCODING_PROFILE_SET(flags, TCL_ENCODING_PROFILE_DEFAULT); - break; - } - } - return flags; -} - -/* - *------------------------------------------------------------------------ - * * TclGetEncodingProfiles -- * * Get the list of supported encoding profiles. diff --git a/generic/tclIO.c b/generic/tclIO.c index 21aef59..e7e5b1b 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -223,8 +223,8 @@ static void StopCopy(CopyState *csPtr); static void TranslateInputEOL(ChannelState *statePtr, char *dst, const char *src, int *dstLenPtr, int *srcLenPtr); static void UpdateInterest(Channel *chanPtr); -static Tcl_Size Write(Channel *chanPtr, const char *src, - Tcl_Size srcLen, Tcl_Encoding encoding); +static int Write(Channel *chanPtr, const char *src, + int srcLen, Tcl_Encoding encoding); static Tcl_Obj * FixLevelCode(Tcl_Obj *msg); static void SpliceChannel(Tcl_Channel chan); static void CutChannel(Tcl_Channel chan); @@ -1679,12 +1679,10 @@ Tcl_CreateChannel( statePtr->encoding = Tcl_GetEncoding(NULL, name); statePtr->inputEncodingState = NULL; statePtr->inputEncodingFlags = TCL_ENCODING_START; - ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, - TCL_ENCODING_PROFILE_DEFAULT); + ENCODING_PROFILE_SET(statePtr->inputEncodingFlags, 0); statePtr->outputEncodingState = NULL; statePtr->outputEncodingFlags = TCL_ENCODING_START; - ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, - TCL_ENCODING_PROFILE_DEFAULT); + ENCODING_PROFILE_SET(statePtr->outputEncodingFlags, 0); /* * Set the channel up initially in AUTO input translation mode to accept @@ -4191,7 +4189,6 @@ Tcl_WriteChars( } objPtr = Tcl_NewStringObj(src, len); - Tcl_IncrRefCount(objPtr); src = (char *) Tcl_GetByteArrayFromObj(objPtr, &len); if (src == NULL) { Tcl_SetErrno(EILSEQ); @@ -4240,7 +4237,7 @@ Tcl_WriteObj( Channel *chanPtr; ChannelState *statePtr; /* State info for channel */ const char *src; - Tcl_Size srcLen = 0; + Tcl_Size srcLen; statePtr = ((Channel *) chan)->state; chanPtr = statePtr->topChanPtr; @@ -4249,20 +4246,31 @@ Tcl_WriteObj( return TCL_INDEX_NONE; } if (statePtr->encoding == NULL) { - Tcl_Size result; - src = (char *) Tcl_GetByteArrayFromObj(objPtr, &srcLen); if (src == NULL) { Tcl_SetErrno(EILSEQ); - result = TCL_INDEX_NONE; - } else { - result = WriteBytes(chanPtr, src, srcLen); + return TCL_INDEX_NONE; } - return result; } else { src = Tcl_GetStringFromObj(objPtr, &srcLen); - return WriteChars(chanPtr, src, srcLen); } + + size_t totalWritten = 0; + /* + * Note original code always called WriteChars even if srcLen 0 + * so we will too. + */ + do { + int chunkSize = srcLen > INT_MAX ? INT_MAX : srcLen; + int written; + written = WriteChars(chanPtr, src, chunkSize); + if (written < 0) { + return TCL_INDEX_NONE; + } + totalWritten += written; + srcLen -= chunkSize; + } while (srcLen); + return totalWritten; } static void @@ -4333,18 +4341,17 @@ WillRead( *---------------------------------------------------------------------- */ -static Tcl_Size +static int Write( Channel *chanPtr, /* The channel to buffer output for. */ const char *src, /* UTF-8 string to write. */ - Tcl_Size srcLen, /* Length of UTF-8 string in bytes. */ + int srcLen, /* Length of UTF-8 string in bytes. */ Tcl_Encoding encoding) { ChannelState *statePtr = chanPtr->state; /* State info for channel */ char *nextNewLine = NULL; - int endEncoding, needNlFlush = 0; - Tcl_Size saved = 0, total = 0, flushed = 0; + int endEncoding, saved = 0, total = 0, flushed = 0, needNlFlush = 0; char safe[BUFFER_PADDING]; int encodingError = 0; @@ -4357,6 +4364,7 @@ Write( */ endEncoding = ((statePtr->outputEncodingFlags & TCL_ENCODING_END) != 0); + if (GotFlag(statePtr, CHANNEL_LINEBUFFERED) || (statePtr->outputTranslation != TCL_TRANSLATE_LF)) { nextNewLine = (char *)memchr(src, '\n', srcLen); @@ -4365,8 +4373,7 @@ Write( while (srcLen + saved + endEncoding > 0 && !encodingError) { ChannelBuffer *bufPtr; char *dst; - int result, srcRead, dstLen, dstWrote; - Tcl_Size srcLimit = srcLen; + int result, srcRead, dstLen, dstWrote, srcLimit = srcLen; if (nextNewLine) { srcLimit = nextNewLine - src; @@ -4597,8 +4604,8 @@ Tcl_GetsObj( ChannelState *statePtr = chanPtr->state; /* State info for channel */ ChannelBuffer *bufPtr; - int inEofChar, skip, copiedTotal, oldFlags, oldRemoved; - Tcl_Size oldLength; + int inEofChar, skip, copiedTotal, oldFlags; + Tcl_Size oldLength, oldRemoved; Tcl_Encoding encoding; char *dst, *dstEnd, *eol, *eof; Tcl_EncodingState oldState; @@ -4638,7 +4645,7 @@ Tcl_GetsObj( if (statePtr->encoding == GetBinaryEncoding() && ((statePtr->inputTranslation == TCL_TRANSLATE_LF) || (statePtr->inputTranslation == TCL_TRANSLATE_CR)) - && Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL) != NULL) { + && Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL) != NULL) { return TclGetsObjBinary(chan, objPtr); } @@ -4988,11 +4995,13 @@ Tcl_GetsObj( UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && gs.bytesWrote == 0) { - bufPtr->nextRemoved = oldRemoved; + if (bufPtr->nextRemoved != oldRemoved) { + bufPtr->nextRemoved = oldRemoved; + ResetFlag(statePtr, CHANNEL_ENCODING_ERROR); + } Tcl_SetErrno(EILSEQ); copiedTotal = -1; } - ResetFlag(statePtr, CHANNEL_ENCODING_ERROR); return copiedTotal; } @@ -5454,8 +5463,7 @@ FilterInputBytes( if (result == TCL_CONVERT_UNKNOWN || result == TCL_CONVERT_SYNTAX) { SetFlag(statePtr, CHANNEL_ENCODING_ERROR); - ResetFlag(statePtr, CHANNEL_STICKY_EOF); - ResetFlag(statePtr, CHANNEL_EOF); + ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_STICKY_EOF); result = TCL_OK; } @@ -5923,14 +5931,13 @@ DoReadChars( /* State info for channel */ ChannelBuffer *bufPtr; Tcl_Size copied; - int result; + int result, copiedNow; Tcl_Encoding encoding = statePtr->encoding; int binaryMode; #define UTF_EXPANSION_FACTOR 1024 int factor = UTF_EXPANSION_FACTOR; if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) { - ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_ENCODING_ERROR); /* TODO: We don't need this call? */ UpdateInterest(chanPtr); Tcl_SetErrno(EILSEQ); @@ -5979,7 +5986,7 @@ DoReadChars( && (statePtr->inEofChar == '\0'); if (appendFlag) { - if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL))) { + if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL))) { binaryMode = 0; } } else { @@ -6000,7 +6007,7 @@ DoReadChars( ResetFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_EOF); statePtr->inputEncodingFlags &= ~TCL_ENCODING_END; for (copied = 0; toRead > 0 || toRead == TCL_INDEX_NONE; ) { - int copiedNow = -1; + copiedNow = -1; if (statePtr->inQueueHead != NULL) { if (binaryMode) { copiedNow = ReadBytes(statePtr, objPtr, toRead); @@ -6107,9 +6114,10 @@ finish: * succesfully red before the error. Return an error so that callers * like [read] can also return an error. */ - ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_ENCODING_ERROR); Tcl_SetErrno(EILSEQ); - copied = -1; + if (!copied) { + copied = -1; + } } TclChannelRelease((Tcl_Channel)chanPtr); return copied; @@ -7600,6 +7608,32 @@ Tcl_InputBuffered( return bytesBuffered; } + +/* + *---------------------------------------------------------------------- + * + * Tcl_InputEncodingError -- + * + * Returns 1 if input is in an encoding error position, 0 otherwise. + * + * Results: + * 0 or 1, always. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +Tcl_InputEncodingError( + Tcl_Channel chan) /* Is this channel blocked? */ +{ + ChannelState *statePtr = ((Channel *) chan)->state; + /* State of real channel structure. */ + + return GotFlag(statePtr, CHANNEL_ENCODING_ERROR) ? 1 : 0; +} /* *---------------------------------------------------------------------- @@ -9980,7 +10014,8 @@ CopyData( * - EOF is reached on the channel; or * - the channel is non-blocking, and we've read all we can * without blocking. - * - a channel reading error occurs (and we return TCL_INDEX_NONE) + * - a channel reading error occurs (and we return TCL_INDEX_NONE + * or - in case of encoding error - the data so far) * * Side effects: * May cause input to be buffered. @@ -10206,7 +10241,7 @@ DoRead( == (CHANNEL_EOF|CHANNEL_BLOCKED))); UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); - return (int)(p - dst); + return (Tcl_Size)(p - dst); } /* diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 93c50ec..679fe5e 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -304,7 +304,7 @@ Tcl_GetsObjCmd( TclChannelPreserve(chan); TclNewObj(linePtr); lineLen = Tcl_GetsObj(chan, linePtr); - if (lineLen == TCL_IO_FAILURE) { + if (lineLen == TCL_INDEX_NONE) { if (!Tcl_Eof(chan) && !Tcl_InputBlocked(chan)) { Tcl_DecrRefCount(linePtr); @@ -323,7 +323,7 @@ Tcl_GetsObjCmd( code = TCL_ERROR; goto done; } - lineLen = TCL_IO_FAILURE; + lineLen = TCL_INDEX_NONE; } if (objc == 3) { if (Tcl_ObjSetVar2(interp, objv[2], NULL, linePtr, @@ -432,7 +432,7 @@ Tcl_ReadObjCmd( TclNewObj(resultPtr); TclChannelPreserve(chan); charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0); - if (charactersRead == TCL_IO_FAILURE) { + if (charactersRead == TCL_INDEX_NONE) { Tcl_DecrRefCount(resultPtr); /* * TIP #219. @@ -446,6 +446,15 @@ Tcl_ReadObjCmd( "error reading \"%s\": %s", TclGetString(chanObjPtr), Tcl_PosixError(interp))); } + goto readError; + } else if (Tcl_InputEncodingError(chan)) { + Tcl_Obj *returnOpts = Tcl_NewDictObj(); + Tcl_DictObjPut(NULL, returnOpts, Tcl_NewStringObj("-data", TCL_INDEX_NONE), resultPtr); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "error reading \"%s\": %s", + TclGetString(chanObjPtr), Tcl_PosixError(interp))); + Tcl_SetReturnOptions(interp, returnOpts); + readError: TclChannelRelease(chan); return TCL_ERROR; } diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index cec6ad3..5f9dccc 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -1734,7 +1734,6 @@ Tcl_FSEvalFileEx( Tcl_CloseEx(interp,chan,0); return result; } - TclNewObj(objPtr); Tcl_IncrRefCount(objPtr); diff --git a/generic/tclInt.h b/generic/tclInt.h index 8f87523..436384e 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2893,7 +2893,6 @@ TclEncodingProfileNameToId(Tcl_Interp *interp, int *profilePtr); MODULE_SCOPE const char *TclEncodingProfileIdToName(Tcl_Interp *interp, int profileId); -MODULE_SCOPE int TclEncodingSetProfileFlags(int flags); MODULE_SCOPE void TclGetEncodingProfiles(Tcl_Interp *interp); /* diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 92632e8..a77a958 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -1513,7 +1513,7 @@ const TclStubs tclStubs = { Tcl_GetWideUIntFromObj, /* 684 */ Tcl_DStringToObj, /* 685 */ Tcl_GetSizeIntFromObj, /* 686 */ - 0, /* 687 */ + Tcl_InputEncodingError, /* 687 */ TclUnusedStubEntry, /* 688 */ }; diff --git a/library/http/http.tcl b/library/http/http.tcl index 6c3c068..20598a9 100644 --- a/library/http/http.tcl +++ b/library/http/http.tcl @@ -1747,7 +1747,7 @@ proc http::OpenSocket {token DoLater} { fconfigure $sock -translation {auto crlf} \ -buffersize $state(-blocksize) if {[package vsatisfies [package provide Tcl] 9.0-]} { - fconfigure $sock -profile tcl8 + fconfigure $sock -profile replace \ } ##Log socket opened, DONE fconfigure - token $token } @@ -2168,7 +2168,7 @@ proc http::Connected {token proto phost srvurl} { fconfigure $sock -translation [list $trRead crlf] \ -buffersize $state(-blocksize) if {[package vsatisfies [package provide Tcl] 9.0-]} { - fconfigure $sock -profile tcl8 + fconfigure $sock -profile replace \ } # The following is disallowed in safe interpreters, but the socket is @@ -2561,7 +2561,7 @@ proc http::ReceiveResponse {token} { fconfigure $sock -translation [list auto $trWrite] \ -buffersize $state(-blocksize) if {[package vsatisfies [package provide Tcl] 9.0-]} { - fconfigure $sock -profile tcl8 + fconfigure $sock -profile replace \ } Log ^D$tk begin receiving response - token $token @@ -4555,7 +4555,7 @@ proc http::Eot {token {reason {}}} { set enc [CharsetToEncoding $state(charset)] if {$enc ne "binary"} { if {[package vsatisfies [package provide Tcl] 9.0-]} { - set state(body) [encoding convertfrom -profile tcl8 $enc $state(body)] + set state(body) [encoding convertfrom -profile replace $enc $state(body)] } else { set state(body) [encoding convertfrom $enc $state(body)] } @@ -4642,7 +4642,7 @@ proc http::GuessType {token} { return 0 } if {[package vsatisfies [package provide Tcl] 9.0-]} { - set state(body) [encoding convertfrom -profile tcl8 $enc $state(body)] + set state(body) [encoding convertfrom -profile replace $enc $state(body)] } else { set state(body) [encoding convertfrom $enc $state(body)] } @@ -4727,7 +4727,7 @@ proc http::quoteString {string} { # than [regsub]/[subst]). [Bug 1020491] if {[package vsatisfies [package provide Tcl] 9.0-]} { - set string [encoding convertto -profile tcl8 $http(-urlencoding) $string] + set string [encoding convertto -profile replace $http(-urlencoding) $string] } else { set string [encoding convertto $http(-urlencoding) $string] } diff --git a/tests/chanio.test b/tests/chanio.test index 29ef1e7..e5e74cb 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -1098,7 +1098,7 @@ test chan-io-7.3 {FilterInputBytes: split up character at EOF} -setup { chan puts -nonewline $f "1234567890123\x82\x4F\x82\x50\x82" chan close $f set f [open $path(test1)] - chan configure $f -encoding shiftjis + chan configure $f -encoding shiftjis -profile tcl8 lappend x [chan gets $f line] $line lappend x [chan tell $f] [testchannel inputbuffered $f] [chan eof $f] lappend x [chan gets $f line] $line diff --git a/tests/encoding.test b/tests/encoding.test index 09f3e42..17bf6f5 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -766,7 +766,7 @@ test encoding-24.3 {EscapeFreeProc on open channels} {stdio} { } [list 3 "乎乞也 (\\u4E4E\\u4E5E\\u4E5F)"] test encoding-24.4 {Parse valid or invalid utf-8} { - string length [encoding convertfrom utf-8 "\xC0\x80"] + string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x80"] } 1 test encoding-24.5 {Parse valid or invalid utf-8} { string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x81"] diff --git a/tests/encodingVectors.tcl b/tests/encodingVectors.tcl index 1b569a1..2f97d1f 100644 --- a/tests/encodingVectors.tcl +++ b/tests/encodingVectors.tcl @@ -10,7 +10,7 @@ # List of defined encoding profiles set encProfiles {tcl8 strict replace} -set encDefaultProfile tcl8; # Should reflect the default from implementation +set encDefaultProfile strict; # Should reflect the default from implementation # encValidStrings - Table of valid strings. # diff --git a/tests/io.test b/tests/io.test index fb21535..713cf30 100644 --- a/tests/io.test +++ b/tests/io.test @@ -1195,7 +1195,7 @@ test io-7.3 {FilterInputBytes: split up character at EOF} {testchannel} { puts -nonewline $f "1234567890123\x82\x4F\x82\x50\x82" close $f set f [open $path(test1)] - fconfigure $f -encoding shiftjis + fconfigure $f -encoding shiftjis -profile tcl8 set x [list [gets $f line] $line] lappend x [tell $f] [testchannel inputbuffered $f] [eof $f] lappend x [gets $f line] $line @@ -1633,7 +1633,7 @@ test io-12.10 {ReadChars: multibyte chars split} -body { puts -nonewline $f [string repeat a 9]\xC2 close $f set f [open $path(test1)] - fconfigure $f -encoding utf-8 -buffersize 11 + fconfigure $f -encoding utf-8 -profile tcl8 -buffersize 11 set in [read $f] close $f scan [string index $in end] %c @@ -7948,6 +7948,8 @@ test io-53.5 {CopyData: error during fcopy} {socket fcopy} { set out [socket 127.0.0.1 [lindex [fconfigure $listen -sockname] 2]] catch {unset fcopyTestDone} close $listen ;# This means the socket open never really succeeds + fconfigure $in -encoding utf-8 + fconfigure $out -encoding utf-8 fcopy $in $out -command [namespace code FcopyTestDone] variable fcopyTestDone if {![info exists fcopyTestDone]} { @@ -9398,12 +9400,8 @@ test io-75.10 { puts -nonewline $f A\xC0 flush $f seek $f 0 - fconfigure $f -encoding utf-8 -buffering none + fconfigure $f -encoding utf-8 -profile strict -buffering none } -body { - catch {read $f} errmsg - lappend res $errmsg - seek $f 0 - chan configure $f -profile tcl8 set d [read $f] binary scan $d H* hd lappend res $hd @@ -9412,8 +9410,8 @@ test io-75.10 { close $f removeFile io-75.10 unset result -} -match glob -result {{error reading "file*":\ - invalid or incomplete multibyte or wide character} 41c0} +} -returnCodes 1 -match glob -result {error reading "file*":\ + invalid or incomplete multibyte or wide character} # The current result returns the orphan byte as byte. # This may be expected due to special utf-8 handling. @@ -9430,7 +9428,7 @@ test io-75.11 {shiftjis encoding error read results in raw bytes} -setup { flush $f seek $f 0 fconfigure $f -encoding shiftjis -blocking 0 -eofchar {} -translation lf \ - -profile strict + -profile tcl8 } -body { set d [read $f] binary scan $d H* hd @@ -9439,8 +9437,7 @@ test io-75.11 {shiftjis encoding error read results in raw bytes} -setup { } -cleanup { close $f removeFile io-75.11 -} -match glob -result {41 1 {error reading "file*":\ - invalid or incomplete multibyte or wide character}} +} -match glob -result {4181ff41 0 {}} test io-75.12 { invalid utf-8 encoding read is not ignored because setting the encoding to @@ -9517,8 +9514,8 @@ test io-75.14 { lappend res [gets $chan] close $chan return $res -} -match glob -result {a b 1 {error reading "*":\ - invalid or incomplete multibyte or wide character} cÀ d} +} -returnCodes 1 -match glob -result {error reading "*":\ + invalid or incomplete multibyte or wide character} test io-75.15 { invalid utf-8 encoding strict @@ -9552,8 +9549,7 @@ test io-75.15 { return $res } -cleanup { close $chan -} -match glob -result {hello AB 1 {error reading "*": invalid or incomplete multibyte or wide character}\ - 1 {error reading "*": invalid or incomplete multibyte or wide character} 43 44 c0 40 EF GHI} +} -returnCodes 1 -match glob -result {error reading "*": invalid or incomplete multibyte or wide character} # ### ### ### ######### ######### ######### diff --git a/tests/ioCmd.test b/tests/ioCmd.test index 1c06ba3..366e3fb 100644 --- a/tests/ioCmd.test +++ b/tests/ioCmd.test @@ -240,11 +240,11 @@ test iocmd-8.7 {fconfigure command} -setup { file delete $path(test1) } -body { set f1 [open $path(test1) w] - fconfigure $f1 -translation lf -eofchar {} -encoding utf-16 -profile tcl8 + fconfigure $f1 -translation lf -eofchar {} -encoding utf-16 fconfigure $f1 } -cleanup { catch {close $f1} -} -result {-blocking 1 -buffering full -buffersize 4096 -encoding utf-16 -eofchar {} -profile tcl8 -translation lf} +} -result {-blocking 1 -buffering full -buffersize 4096 -encoding utf-16 -eofchar {} -profile strict -translation lf} test iocmd-8.8 {fconfigure command} -setup { file delete $path(test1) set x {} @@ -262,11 +262,11 @@ test iocmd-8.9 {fconfigure command} -setup { } -body { set f1 [open $path(test1) w] fconfigure $f1 -translation binary -buffering none -buffersize 4040 \ - -eofchar {} -encoding binary -profile tcl8 + -eofchar {} -encoding binary fconfigure $f1 } -cleanup { catch {close $f1} -} -result {-blocking 1 -buffering none -buffersize 4040 -encoding iso8859-1 -eofchar {} -profile tcl8 -translation lf} +} -result {-blocking 1 -buffering none -buffersize 4040 -encoding iso8859-1 -eofchar {} -profile strict -translation lf} test iocmd-8.10 {fconfigure command} -returnCodes error -body { fconfigure a b } -result {can not find channel named "a"} diff --git a/tests/iogt.test b/tests/iogt.test index 5692682..cb02d40 100644 --- a/tests/iogt.test +++ b/tests/iogt.test @@ -549,8 +549,8 @@ test iogt-2.3 {basic I/O, mixed trail} {testchannel unix} { set trail [list] audit_flow trail -attach $fin audit_flow trail -attach $fout - fconfigure $fin -buffersize 20 - fconfigure $fout -buffersize 10 + fconfigure $fin -buffersize 20 -profile tcl8 + fconfigure $fout -buffersize 10 -profile tcl8 fcopy $fin $fout close $fin close $fout diff --git a/tests/utfext.test b/tests/utfext.test index b980800..de26b6f 100644 --- a/tests/utfext.test +++ b/tests/utfext.test @@ -84,7 +84,7 @@ foreach {enc utfhex hex} $utfExtMap { } # Test for insufficient space -test xx-bufferoverflow {buffer overflow Tcl_ExternalToUtf} -body { +test xx-bufferoverflow {buffer overflow Tcl_ExternalToUtf} -constraints knownBug -body { testencoding Tcl_UtfToExternal utf-16 A {start end} {} 1 } -result [list nospace {} \xFF] diff --git a/tests/winConsole.test b/tests/winConsole.test index 3104184..4eccf81 100644 --- a/tests/winConsole.test +++ b/tests/winConsole.test @@ -198,7 +198,7 @@ test console-fconfigure-get-1.0 { Console get stdin configuration } -constraints {win interactive} -body { lsort [dict keys [fconfigure stdin]] -} -result {-blocking -buffering -buffersize -encoding -eofchar -inputmode -profile -translation} +} -result {-blocking -buffering -buffersize -encoding -eofchar -profile -inputmode -translation} set testnum 0 foreach {opt result} { |
