From 50f141d888ff2170dfd1a6bfe34c65a4df087307 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Apr 2023 16:55:51 +0000 Subject: re-generate unix/configure --- unix/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/configure b/unix/configure index e0777f3..54e3ae6 100755 --- a/unix/configure +++ b/unix/configure @@ -2458,7 +2458,7 @@ esac #-------------------------------------------------------------------- # Supply substitutes for missing POSIX header files. Special notes: # - stdlib.h doesn't define strtol, strtoul, or -# strtod insome versions of SunOS +# strtod in some versions of SunOS # - some versions of string.h don't declare procedures such # as strstr # Do this early, otherwise an autoconf bug throws errors on configure -- cgit v0.12 From d3bb4906d1397f0b5adbeb1da10ce5f6c60a8c1e Mon Sep 17 00:00:00 2001 From: pooryorick Date: Fri, 14 Apr 2023 07:21:48 +0000 Subject: Fix for [0cd1ae596e709259], under strict encoding, [gets] returns an error even though a complete line is available. --- generic/tclIO.c | 3 +-- tests/io.test | 70 +++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index a1c13ac..aa82f89 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4997,8 +4997,7 @@ Tcl_GetsObj( } UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); - if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && - (copiedTotal == 0 || !GotFlag(statePtr, CHANNEL_NONBLOCKING))) { + if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && gs.bytesWrote == 0) { Tcl_SetErrno(EILSEQ); copiedTotal = -1; } diff --git a/tests/io.test b/tests/io.test index ae87a79..f0de5b2 100644 --- a/tests/io.test +++ b/tests/io.test @@ -9270,7 +9270,8 @@ test io-75.6 {invalid utf-8 encoding, gets is not ignored (-profile strict)} -se puts -nonewline $f A\x81 flush $f seek $f 0 - fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict + fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ + -translation lf -profile strict } -body { gets $f } -cleanup { @@ -9279,7 +9280,9 @@ test io-75.6 {invalid utf-8 encoding, gets is not ignored (-profile strict)} -se } -match glob -returnCodes 1 -result {error reading "file*":\ invalid or incomplete multibyte or wide character} -test io-75.7 {invalid utf-8 encoding gets is not ignored (-profile strict)} -setup { +test io-75.7 { + invalid utf-8 encoding gets is not ignored (-profile strict) +} -setup { set fn [makeFile {} io-75.7] set f [open $fn w+] fconfigure $f -encoding binary @@ -9287,7 +9290,8 @@ test io-75.7 {invalid utf-8 encoding gets is not ignored (-profile strict)} -set puts -nonewline $f A\x81 flush $f seek $f 0 - fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict + fconfigure $f -encoding utf-8 -buffering none -eofchar {} -translation lf \ + -profile strict } -body { read $f } -cleanup { @@ -9300,11 +9304,13 @@ test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup { set fn [makeFile {} io-75.8] set f [open $fn w+] fconfigure $f -encoding binary - # \x81 is invalid in utf-8, but since \x1A comes first, -eofchar takes precedence. + # \x81 is invalid in utf-8, but since \x1A comes first, -eofchar takes + # precedence. puts -nonewline $f A\x1A\x81 flush $f seek $f 0 - fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A -translation lf -profile strict + fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A \ + -translation lf -profile strict } -body { set d [read $f] binary scan $d H* hd @@ -9328,7 +9334,8 @@ test io-75.9 {unrepresentable character write passes and is replaced by ?} -setu } -cleanup { close $f removeFile io-75.9 -} -match glob -result [list {A} {error writing "*": invalid or incomplete multibyte or wide character}] +} -match glob -result [list {A} {error writing "*":\ + invalid or incomplete multibyte or wide character}] test io-75.10 { incomplete multibyte encoding read is not ignored because "binary" sets @@ -9372,7 +9379,8 @@ test io-75.11 {shiftjis encoding error read results in raw bytes} -setup { puts -nonewline $f A\x81\xFFA flush $f seek $f 0 - fconfigure $f -encoding shiftjis -blocking 0 -eofchar "" -translation lf -profile strict + fconfigure $f -encoding shiftjis -blocking 0 -eofchar {} -translation lf \ + -profile strict } -body { set d [read $f] binary scan $d H* hd @@ -9395,7 +9403,7 @@ test io-75.12 { puts -nonewline $f A\x81 flush $f seek $f 0 - fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf + fconfigure $f -encoding utf-8 -buffering none -eofchar {} -translation lf } -body { catch {read $f} errmsg lappend res $errmsg @@ -9423,7 +9431,8 @@ test io-75.13 { puts -nonewline $f A\x81 flush $f seek $f 0 - fconfigure $f -encoding utf-8 -blocking 0 -eofchar "" -translation lf -profile strict + fconfigure $f -encoding utf-8 -blocking 0 -eofchar {} -translation lf \ + -profile strict } -body { set d [read $f] binary scan $d H* hd @@ -9432,7 +9441,36 @@ test io-75.13 { } -cleanup { close $f removeFile io-75.13 -} -match glob -result {41 1 {error reading "file*": invalid or incomplete multibyte or wide character}} +} -match glob -result {41 1 {error reading "file*":\ + invalid or incomplete multibyte or wide character}} + +test io-75.14 { + [gets] succesfully returns lines prior to error + + invalid utf-8 encoding [gets] continues in non-strict mode after error +} -setup { + set fn [makeFile {} io-75.14] + set f [open $fn w+] + fconfigure $f -encoding binary + # \xc0 is invalid in utf-8 + puts -nonewline $f a\nb\xc0\nc\n + flush $f + seek $f 0 + fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ + -translation lf -profile strict +} -body { + lappend res [gets $f] + set status [catch {gets $f} cres copts] + lappend res $status $cres + chan configure $f -profile tcl8 + lappend res [gets $f] + lappend res [gets $f] + close $f + return $res +} -cleanup { + removeFile io-75.14 +} -match glob -result {a 1 {error reading "*":\ + invalid or incomplete multibyte or wide character} bÀ c} # ### ### ### ######### ######### ######### @@ -9487,7 +9525,8 @@ test io-76.4 {channel mode dropping} -setup { } -returnCodes error -cleanup { close $f removeFile dummy -} -match glob -result {Tcl_RemoveChannelMode error: Bad mode, would make channel inacessible. Channel: "*"} +} -match glob -result {Tcl_RemoveChannelMode error:\ + Bad mode, would make channel inacessible. Channel: "*"} test io-76.5 {channel mode dropping} -setup { set datafile [makeFile {some characters} dummy] @@ -9508,7 +9547,8 @@ test io-76.6 {channel mode dropping} -setup { } -returnCodes error -cleanup { close $f removeFile dummy -} -match glob -result {Tcl_RemoveChannelMode error: Bad mode, would make channel inacessible. Channel: "*"} +} -match glob -result {Tcl_RemoveChannelMode error:\ + Bad mode, would make channel inacessible. Channel: "*"} test io-76.7 {channel mode dropping} -setup { set datafile [makeFile {some characters} dummy] @@ -9541,7 +9581,8 @@ test io-76.9 {channel mode dropping} -setup { } -returnCodes error -cleanup { close $f removeFile dummy -} -match glob -result {Tcl_RemoveChannelMode error: Bad mode, would make channel inacessible. Channel: "*"} +} -match glob -result {Tcl_RemoveChannelMode error: + Bad mode, would make channel inacessible. Channel: "*"} test io-76.10 {channel mode dropping} -setup { set datafile [makeFile {some characters} dummy] @@ -9552,7 +9593,8 @@ test io-76.10 {channel mode dropping} -setup { } -returnCodes error -cleanup { close $f removeFile dummy -} -match glob -result {Tcl_RemoveChannelMode error: Bad mode, would make channel inacessible. Channel: "*"} +} -match glob -result {Tcl_RemoveChannelMode error:\ + Bad mode, would make channel inacessible. Channel: "*"} # cleanup foreach file [list fooBar longfile script script2 output test1 pipe my_script \ -- cgit v0.12 From c8259f4fec6e8f919b3acd7952b80d8f66bd2ef2 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Fri, 14 Apr 2023 09:19:32 +0000 Subject: New test for [gets] with strict encoding. Also add "\" in io-76.9, missing in last commit. --- tests/io.test | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/io.test b/tests/io.test index f0de5b2..286a136 100644 --- a/tests/io.test +++ b/tests/io.test @@ -9449,10 +9449,9 @@ test io-75.14 { invalid utf-8 encoding [gets] continues in non-strict mode after error } -setup { - set fn [makeFile {} io-75.14] - set f [open $fn w+] + set chan [file tempfile] fconfigure $f -encoding binary - # \xc0 is invalid in utf-8 + # \xc0\n is an invalid utf-8 sequence puts -nonewline $f a\nb\xc0\nc\n flush $f seek $f 0 @@ -9466,12 +9465,38 @@ test io-75.14 { lappend res [gets $f] lappend res [gets $f] close $f - return $res -} -cleanup { - removeFile io-75.14 + return $res } -match glob -result {a 1 {error reading "*":\ invalid or incomplete multibyte or wide character} bÀ c} +test io-75.15 { + invalid utf-8 encoding strict gets does not hang + after error reconfigure and read +} -setup { + set res {} + set chan [file tempfile] + fconfigure $chan -encoding binary + # \xc0\x40 is an invalid utf-8 sequence + puts $chan hello\nAB\xc0\x40CD\nEFG + seek $chan 0 +} -body { + #Now try to read it with [gets] + fconfigure $chan -encoding utf-8 -profile strict + lappend res [gets $chan] + set status [catch {gets $chan} cres copts] + lappend res $status $cres + set status [catch {gets $chan} cres copts] + lappend res $status $cres + chan configure $chan -encoding binary + foreach char [split [read $chan 6] {}] { + lappend res [format %x [scan $char %c]] + } + return $res +} -cleanup { + close $chan +} -match glob -result {hello 1 {error reading "*": invalid or incomplete multibyte or wide character}\ + 1 {error reading "*": invalid or incomplete multibyte or wide character} 41 42 c0 40 43 44} + # ### ### ### ######### ######### ######### @@ -9581,7 +9606,7 @@ test io-76.9 {channel mode dropping} -setup { } -returnCodes error -cleanup { close $f removeFile dummy -} -match glob -result {Tcl_RemoveChannelMode error: +} -match glob -result {Tcl_RemoveChannelMode error:\ Bad mode, would make channel inacessible. Channel: "*"} test io-76.10 {channel mode dropping} -setup { -- cgit v0.12 From 0000e98387b76863afc7e061f08b41fbc5a77762 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Fri, 14 Apr 2023 11:40:11 +0000 Subject: Fix for issue [718de2132f487cf2], "review use of strip on the stubs library". --- unix/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unix/Makefile.in b/unix/Makefile.in index 21d4085..2f28fcf 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -151,7 +151,8 @@ SHELL = @MAKEFILE_SHELL@ # distribution, which is slower but guaranteed to work. INSTALL_STRIP_PROGRAM = -s -INSTALL_STRIP_LIBRARY = -S -x +# Use --strip-unneeded instead of -x. See issue 718de2132f487cf2 +INSTALL_STRIP_LIBRARY = -S --strip-unneeded INSTALL = $(SHELL) $(UNIX_DIR)/install-sh -c INSTALL_PROGRAM = ${INSTALL} -- cgit v0.12 From f82e6059dce38a482b9db9366d2edf71cb5ea917 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 14 Apr 2023 21:40:50 +0000 Subject: int -> Tcl_Size where appropriate in tcl.decls (reducing the diff against Tcl 9.0) --- generic/tcl.decls | 12 ++++++------ generic/tclDecls.h | 24 ++++++++++++------------ unix/tclAppInit.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index 6278bd3..4e8f20a 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1159,7 +1159,7 @@ declare 323 { int Tcl_UniCharToUpper(int ch) } declare 324 { - int Tcl_UniCharToUtf(int ch, char *buf) + Tcl_Size Tcl_UniCharToUtf(int ch, char *buf) } declare 325 { const char *Tcl_UtfAtIndex(const char *src, Tcl_Size index) @@ -1193,16 +1193,16 @@ declare 333 { const char *src, Tcl_Size srcLen, Tcl_DString *dsPtr) } declare 334 { - int Tcl_UtfToLower(char *src) + Tcl_Size Tcl_UtfToLower(char *src) } declare 335 { - int Tcl_UtfToTitle(char *src) + Tcl_Size Tcl_UtfToTitle(char *src) } declare 336 { - int Tcl_UtfToChar16(const char *src, unsigned short *chPtr) + Tcl_Size Tcl_UtfToChar16(const char *src, unsigned short *chPtr) } declare 337 { - int Tcl_UtfToUpper(char *src) + Tcl_Size Tcl_UtfToUpper(char *src) } declare 338 { Tcl_Size Tcl_WriteChars(Tcl_Channel chan, const char *src, Tcl_Size srcLen) @@ -2395,7 +2395,7 @@ declare 645 { # TIP #548 declare 646 { - int Tcl_UtfToUniChar(const char *src, int *chPtr) + Tcl_Size Tcl_UtfToUniChar(const char *src, int *chPtr) } declare 647 { char *Tcl_UniCharToUtfDString(const int *uniStr, diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 84c2b4d..e2901fb 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1007,7 +1007,7 @@ EXTERN int Tcl_UniCharToTitle(int ch); /* 323 */ EXTERN int Tcl_UniCharToUpper(int ch); /* 324 */ -EXTERN int Tcl_UniCharToUtf(int ch, char *buf); +EXTERN Tcl_Size Tcl_UniCharToUtf(int ch, char *buf); /* 325 */ EXTERN const char * Tcl_UtfAtIndex(const char *src, Tcl_Size index); /* 326 */ @@ -1035,14 +1035,14 @@ EXTERN char * Tcl_UtfToExternalDString(Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, Tcl_DString *dsPtr); /* 334 */ -EXTERN int Tcl_UtfToLower(char *src); +EXTERN Tcl_Size Tcl_UtfToLower(char *src); /* 335 */ -EXTERN int Tcl_UtfToTitle(char *src); +EXTERN Tcl_Size Tcl_UtfToTitle(char *src); /* 336 */ -EXTERN int Tcl_UtfToChar16(const char *src, +EXTERN Tcl_Size Tcl_UtfToChar16(const char *src, unsigned short *chPtr); /* 337 */ -EXTERN int Tcl_UtfToUpper(char *src); +EXTERN Tcl_Size Tcl_UtfToUpper(char *src); /* 338 */ EXTERN Tcl_Size Tcl_WriteChars(Tcl_Channel chan, const char *src, Tcl_Size srcLen); @@ -1924,7 +1924,7 @@ EXTERN int Tcl_GetIntForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size endValue, Tcl_Size *indexPtr); /* 646 */ -EXTERN int Tcl_UtfToUniChar(const char *src, int *chPtr); +EXTERN Tcl_Size Tcl_UtfToUniChar(const char *src, int *chPtr); /* 647 */ EXTERN char * Tcl_UniCharToUtfDString(const int *uniStr, Tcl_Size uniLength, Tcl_DString *dsPtr); @@ -2411,7 +2411,7 @@ typedef struct TclStubs { int (*tcl_UniCharToLower) (int ch); /* 321 */ int (*tcl_UniCharToTitle) (int ch); /* 322 */ int (*tcl_UniCharToUpper) (int ch); /* 323 */ - int (*tcl_UniCharToUtf) (int ch, char *buf); /* 324 */ + Tcl_Size (*tcl_UniCharToUtf) (int ch, char *buf); /* 324 */ const char * (*tcl_UtfAtIndex) (const char *src, Tcl_Size index); /* 325 */ int (*tclUtfCharComplete) (const char *src, Tcl_Size length); /* 326 */ Tcl_Size (*tcl_UtfBackslash) (const char *src, int *readPtr, char *dst); /* 327 */ @@ -2421,10 +2421,10 @@ typedef struct TclStubs { const char * (*tclUtfPrev) (const char *src, const char *start); /* 331 */ int (*tcl_UtfToExternal) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, Tcl_Size dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); /* 332 */ char * (*tcl_UtfToExternalDString) (Tcl_Encoding encoding, const char *src, Tcl_Size srcLen, Tcl_DString *dsPtr); /* 333 */ - int (*tcl_UtfToLower) (char *src); /* 334 */ - int (*tcl_UtfToTitle) (char *src); /* 335 */ - int (*tcl_UtfToChar16) (const char *src, unsigned short *chPtr); /* 336 */ - int (*tcl_UtfToUpper) (char *src); /* 337 */ + Tcl_Size (*tcl_UtfToLower) (char *src); /* 334 */ + Tcl_Size (*tcl_UtfToTitle) (char *src); /* 335 */ + Tcl_Size (*tcl_UtfToChar16) (const char *src, unsigned short *chPtr); /* 336 */ + Tcl_Size (*tcl_UtfToUpper) (char *src); /* 337 */ Tcl_Size (*tcl_WriteChars) (Tcl_Channel chan, const char *src, Tcl_Size srcLen); /* 338 */ Tcl_Size (*tcl_WriteObj) (Tcl_Channel chan, Tcl_Obj *objPtr); /* 339 */ char * (*tcl_GetString) (Tcl_Obj *objPtr); /* 340 */ @@ -2733,7 +2733,7 @@ typedef struct TclStubs { int (*tcl_IsShared) (Tcl_Obj *objPtr); /* 643 */ int (*tcl_LinkArray) (Tcl_Interp *interp, const char *varName, void *addr, int type, Tcl_Size size); /* 644 */ int (*tcl_GetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size endValue, Tcl_Size *indexPtr); /* 645 */ - int (*tcl_UtfToUniChar) (const char *src, int *chPtr); /* 646 */ + Tcl_Size (*tcl_UtfToUniChar) (const char *src, int *chPtr); /* 646 */ char * (*tcl_UniCharToUtfDString) (const int *uniStr, Tcl_Size uniLength, Tcl_DString *dsPtr); /* 647 */ int * (*tcl_UtfToUniCharDString) (const char *src, Tcl_Size length, Tcl_DString *dsPtr); /* 648 */ unsigned char * (*tclGetBytesFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *numBytesPtr); /* 649 */ diff --git a/unix/tclAppInit.c b/unix/tclAppInit.c index 05d25de..b203487 100644 --- a/unix/tclAppInit.c +++ b/unix/tclAppInit.c @@ -91,7 +91,7 @@ main( TclZipfs_AppHook(&argc, &argv); #endif - Tcl_Main((size_t)argc, argv, TCL_LOCAL_APPINIT); + Tcl_Main(argc, argv, TCL_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ } -- cgit v0.12 From afacee3f07729501638d6afc6f21bee9c01ef7f2 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Sat, 15 Apr 2023 11:54:27 +0000 Subject: Fix for [a7a89d422a4f5dd3], Under strict encoding, [gets] returns an error instead of returning the second line. Also, ensure that position in file does not change if [gets] return an error. --- generic/tclIO.c | 9 +++++++-- tests/io.test | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index aa82f89..3fd8d48 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4616,6 +4616,7 @@ Tcl_GetsObj( if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) { UpdateInterest(chanPtr); + ResetFlag(statePtr, CHANNEL_ENCODING_ERROR); Tcl_SetErrno(EILSEQ); return TCL_INDEX_NONE; } @@ -4632,7 +4633,7 @@ Tcl_GetsObj( if (GotFlag(statePtr, CHANNEL_STICKY_EOF)) { SetFlag(statePtr, CHANNEL_EOF); assert(statePtr->inputEncodingFlags & TCL_ENCODING_END); - assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR)); +assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR)); /* TODO: Do we need this? */ UpdateInterest(chanPtr); @@ -4998,9 +4999,11 @@ Tcl_GetsObj( UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && gs.bytesWrote == 0) { + bufPtr->nextRemoved = oldRemoved; Tcl_SetErrno(EILSEQ); copiedTotal = -1; } + ResetFlag(statePtr, CHANNEL_ENCODING_ERROR); return copiedTotal; } @@ -5462,6 +5465,8 @@ FilterInputBytes( if (result == TCL_CONVERT_UNKNOWN || result == TCL_CONVERT_SYNTAX) { SetFlag(statePtr, CHANNEL_ENCODING_ERROR); + ResetFlag(statePtr, CHANNEL_STICKY_EOF); + ResetFlag(statePtr, CHANNEL_EOF); result = TCL_OK; } @@ -7589,7 +7594,7 @@ Tcl_InputBuffered( } /* - * Don't forget the bytes in the topmost pushback area. + * Remember the bytes in the topmost pushback area. */ for (bufPtr = statePtr->topChanPtr->inQueueHead; bufPtr != NULL; diff --git a/tests/io.test b/tests/io.test index 286a136..7a35e0e 100644 --- a/tests/io.test +++ b/tests/io.test @@ -9266,13 +9266,14 @@ test io-75.6 {invalid utf-8 encoding, gets is not ignored (-profile strict)} -se set fn [makeFile {} io-75.6] set f [open $fn w+] fconfigure $f -encoding binary - # \x81 is invalid in utf-8 + # \x81 is an incomplete byte sequence in utf-8 puts -nonewline $f A\x81 flush $f seek $f 0 fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ -translation lf -profile strict } -body { +after 1 gets $f } -cleanup { close $f @@ -9452,13 +9453,14 @@ test io-75.14 { set chan [file tempfile] fconfigure $f -encoding binary # \xc0\n is an invalid utf-8 sequence - puts -nonewline $f a\nb\xc0\nc\n + puts -nonewline $f a\nb\nc\xc0\nd\n flush $f seek $f 0 fconfigure $f -encoding utf-8 -buffering none -eofchar {} \ -translation lf -profile strict } -body { lappend res [gets $f] + lappend res [gets $f] set status [catch {gets $f} cres copts] lappend res $status $cres chan configure $f -profile tcl8 @@ -9466,36 +9468,34 @@ test io-75.14 { lappend res [gets $f] close $f return $res -} -match glob -result {a 1 {error reading "*":\ - invalid or incomplete multibyte or wide character} bÀ c} +} -match glob -result {a b 1 {error reading "*":\ + invalid or incomplete multibyte or wide character} cÀ d} test io-75.15 { - invalid utf-8 encoding strict gets does not hang - after error reconfigure and read + invalid utf-8 encoding strict + gets does not hang + gets succeeds for the first two lines } -setup { set res {} set chan [file tempfile] fconfigure $chan -encoding binary # \xc0\x40 is an invalid utf-8 sequence - puts $chan hello\nAB\xc0\x40CD\nEFG + puts $chan hello\nAB\nCD\xc0\x40EF\nGHI seek $chan 0 } -body { #Now try to read it with [gets] fconfigure $chan -encoding utf-8 -profile strict lappend res [gets $chan] + lappend res [gets $chan] set status [catch {gets $chan} cres copts] lappend res $status $cres set status [catch {gets $chan} cres copts] lappend res $status $cres - chan configure $chan -encoding binary - foreach char [split [read $chan 6] {}] { - lappend res [format %x [scan $char %c]] - } return $res } -cleanup { close $chan -} -match glob -result {hello 1 {error reading "*": invalid or incomplete multibyte or wide character}\ - 1 {error reading "*": invalid or incomplete multibyte or wide character} 41 42 c0 40 43 44} +} -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}} # ### ### ### ######### ######### ######### -- cgit v0.12 From 7962f209ac44d657c1c2d251a2647711f5add87f Mon Sep 17 00:00:00 2001 From: pooryorick Date: Sat, 15 Apr 2023 13:25:28 +0000 Subject: Extend test io-75.15 to read invalid bytes in binary mode and then use [gets] to retrieve last two lines. --- tests/io.test | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/io.test b/tests/io.test index 7a35e0e..d98317a 100644 --- a/tests/io.test +++ b/tests/io.test @@ -9491,11 +9491,20 @@ test io-75.15 { lappend res $status $cres set status [catch {gets $chan} cres copts] lappend res $status $cres + chan configure $chan -translation binary + set data [read $chan 4] + foreach char [split $data {}] { + scan $char %c ord + lappend res [format %x $ord] + } + fconfigure $chan -encoding utf-8 -profile strict + lappend res [gets $chan] + lappend res [gets $chan] 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}} + 1 {error reading "*": invalid or incomplete multibyte or wide character} 43 44 c0 40 EF GHI} # ### ### ### ######### ######### ######### -- cgit v0.12 From 788236542834710698cace10523d24ae7143279d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 15 Apr 2023 19:02:44 +0000 Subject: Backout fix for [718de2132f487cf2]: It breaks on MacOS and other systems which don't support the --strip-unneeded option --- unix/Makefile.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unix/Makefile.in b/unix/Makefile.in index 2f28fcf..21d4085 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -151,8 +151,7 @@ SHELL = @MAKEFILE_SHELL@ # distribution, which is slower but guaranteed to work. INSTALL_STRIP_PROGRAM = -s -# Use --strip-unneeded instead of -x. See issue 718de2132f487cf2 -INSTALL_STRIP_LIBRARY = -S --strip-unneeded +INSTALL_STRIP_LIBRARY = -S -x INSTALL = $(SHELL) $(UNIX_DIR)/install-sh -c INSTALL_PROGRAM = ${INSTALL} -- cgit v0.12 From 52425dcf5d50616645b90e2acee65ef733962afa Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 15 Apr 2023 19:09:41 +0000 Subject: Add one more unused stub entry --- generic/tcl.decls | 2 +- generic/tclDecls.h | 9 ++++++--- generic/tclStubInit.c | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/generic/tcl.decls b/generic/tcl.decls index c3d5073..58b7400 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2339,7 +2339,7 @@ declare 653 { # ----- BASELINE -- FOR -- 8.7.0 / 9.0.0 ----- # -declare 687 { +declare 688 { void TclUnusedStubEntry(void) } diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 078974c..11e8e59 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1877,7 +1877,8 @@ EXTERN unsigned char * TclGetByteArrayFromObj_(Tcl_Obj *objPtr, /* Slot 684 is reserved */ /* Slot 685 is reserved */ /* Slot 686 is reserved */ -/* 687 */ +/* Slot 687 is reserved */ +/* 688 */ EXTERN void TclUnusedStubEntry(void); typedef struct { @@ -2601,7 +2602,8 @@ typedef struct TclStubs { void (*reserved684)(void); void (*reserved685)(void); void (*reserved686)(void); - void (*tclUnusedStubEntry) (void); /* 687 */ + void (*reserved687)(void); + void (*tclUnusedStubEntry) (void); /* 688 */ } TclStubs; extern const TclStubs *tclStubsPtr; @@ -3953,8 +3955,9 @@ extern const TclStubs *tclStubsPtr; /* Slot 684 is reserved */ /* Slot 685 is reserved */ /* Slot 686 is reserved */ +/* Slot 687 is reserved */ #define TclUnusedStubEntry \ - (tclStubsPtr->tclUnusedStubEntry) /* 687 */ + (tclStubsPtr->tclUnusedStubEntry) /* 688 */ #endif /* defined(USE_TCL_STUBS) */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index c504586..d6621b6 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -1726,7 +1726,8 @@ const TclStubs tclStubs = { 0, /* 684 */ 0, /* 685 */ 0, /* 686 */ - TclUnusedStubEntry, /* 687 */ + 0, /* 687 */ + TclUnusedStubEntry, /* 688 */ }; /* !END!: Do not edit above this line. */ -- cgit v0.12 From 9224a1a6c26782979168ca12a6163a55f3946605 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 15 Apr 2023 19:50:28 +0000 Subject: Fix SetResult doc --- doc/SetResult.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/SetResult.3 b/doc/SetResult.3 index 94990d7..9be3ef0 100644 --- a/doc/SetResult.3 +++ b/doc/SetResult.3 @@ -114,7 +114,7 @@ efficient. \fBTcl_AppendElement\fR is like \fBTcl_AppendResult\fR, but it appends only one piece, and also appends that piece as a list item. \fBTcl_AppendElement\fR adds backslashes or braces as necessary to ensure that -f\Ielement\fR is properly formatted as a list item. Under normal conditions, +\fIelement\fR is properly formatted as a list item. Under normal conditions, \fBTcl_AppendElement\fR adds a space character to \fIinterp\fR's result just before adding the new list element, so that the list elements in the result are properly separated. However if the new list element is the first item in the -- cgit v0.12 From b37682866bd66ee69010f4794dce2c24f02844df Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 15 Apr 2023 22:11:48 +0000 Subject: Fix indenting --- generic/tclIO.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 3fd8d48..4a88f52 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4633,7 +4633,7 @@ Tcl_GetsObj( if (GotFlag(statePtr, CHANNEL_STICKY_EOF)) { SetFlag(statePtr, CHANNEL_EOF); assert(statePtr->inputEncodingFlags & TCL_ENCODING_END); -assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR)); + assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR)); /* TODO: Do we need this? */ UpdateInterest(chanPtr); -- cgit v0.12