Tcl Library Source Code

View Ticket
Login
Ticket UUID: dc1e1ba10ec786bbafcf5bf75def9b5ab6f14199
Title: yencode-1.0 failure w/Tcl 9.0 (trunk)
Type: Bug Version: 1.1.4
Submitter: anonymous Created on: 2023-11-15 00:54:19
Subsystem: base64 Assigned To:
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2024-01-06 01:00:43
Resolution: Fixed Closed By: pointsman
    Closed on: 2024-01-06 01:00:43
Description:
Platform: Linux


@@ Testsuite modules/base64/yencode.test
@@ StartFile 1699998934
- tcllib::testutils 1.2
* yencode 1.1.4
> pure tcl
---- yencode-1.0 start


==== yencode-1.0 yencode yEnc test file FAILED
==== Contents of test case:

    set enc [::yencode::yencode -file $datafile]
    set dec [::yencode::ydecode $enc]
    set chk [::yencode::loaddata $datafile]
    string equal $dec $chk

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error reading "file5": invalid or incomplete multibyte or wide character
    while executing
"read $f"
    (procedure "::yencode::loaddata" line 4)
    invoked from within
"::yencode::loaddata $datafile"
    ("uplevel" body line 4)
    invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EILSEQ {invalid or incomplete multibyte or wide character}
==== yencode-1.0 FAILED
User Comments: pointsman added on 2024-01-06 01:00:43:
This was a "fall-out" of making the Tcl 9 I/O default profile -strict (which was
done after the basically port of tcllib to Tcl 9.) Fixed with [648ae400f9].
Thanks for reporting.

anonymous added on 2023-11-26 18:22:17:
Proposed fix:

Index: modules/base64/yencode.tcl
==================================================================
--- modules/base64/yencode.tcl
+++ modules/base64/yencode.tcl
@@ -190,12 +190,12 @@
     if {! [string is boolean $opts(crc32)]} {
         return -code error "bad option -crc32: argument must be true or false"
     }
 
     if {$opts(filename) != {}} {
-        set f [open $opts(filename) r]
-        fconfigure $f -translation binary
+        set f [open $opts(filename) rb]
+        #fconfigure $f -translation binary
         set data [read $f]
         close $f
     } else {
         if {[llength $args] != 1} {
             return -code error "wrong \# args: should be\
@@ -302,6 +302,5 @@
 #
 # Local variables:
 #   mode: tcl
 #   indent-tabs-mode: nil
 # End:
-

Index: modules/base64/yencode.test
==================================================================
--- modules/base64/yencode.test
+++ modules/base64/yencode.test
@@ -29,11 +29,11 @@
 } else {
     puts "> pure tcl"
 }
 
 proc ::yencode::loaddata {filename {translation auto}} {
-    set f [open $filename r]
+    set f [open $filename rb]
     fconfigure $f -translation $translation
     set data [read $f]
     close $f
     return $data
 }