Tcl Library Source Code

View Ticket
Login
2026-11-16
00:06 • Ticket [69d33816bb] yencode ignores the -file option and can't read using -file status still Open with 3 other changes artifact: 143964b1d3 user: serhiy.storchaka
2026-11-15
23:36
Fix [69d33816bb]: ydecode accepted only all-digit file names, so it nearly always returned default.bin; ydecode -file read in text mode (an error on Tcl 9, corrupted data on 8.6); and the bad-option error message itself failed. leaf check-in: 7053d9a68b user: serhiy.storchaka tags: yencode-ydecode-fixes
2026-02-03
09:37 • New ticket [69d33816bb] yencode ignores the -file option and can't read using -file. artifact: d45d634768 user: m.n.summerfield

Ticket UUID: 69d33816bb17a2740201dc74cc20dcf7a32c2be3
Title: yencode ignores the -file option and can't read using -file
Type: Bug Version: Tcl 9.0.3; yencode 1
Submitter: m.n.summerfield Created on: 2026-02-03 09:37:27
Subsystem: base64 Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-11-16 00:06:15
Resolution: None Closed By: nobody
    Closed on:
Description:
Bug #1: The -file option is ignored; the output filename is always default.bin.
Bug #2: When the -file option is used to read data from a file it throws on the same data when that data is passed as a binary string.

Example program:
```
#!/usr/bin/env tclsh9
package require yencode
const FILENAME test.y
set ency [::yencode::yencode -name $FILENAME Abc123]
foreach lst [::yencode::ydecode $ency] {
    lassign $lst name size decy
    puts "#1 (name ignored): name=$name size=$size decy='$decy'"
}
writeFile $FILENAME binary $ency
foreach lst [::yencode::ydecode [readFile $FILENAME binary]] {
    lassign $lst name size decy
    puts "#2 (name ignored): name=$name size=$size decy='$decy'"
}
puts "#3 crash"
foreach lst [::yencode::ydecode -file $FILENAME] {
    lassign $lst name size decy
    puts "name=$name size=$size decy='$decy'"
}
```
Output:
```
$ ./y.tcl 
#1 (name ignored): name=default.bin size=6 decy='Abc123'
#2 (name ignored): name=default.bin size=6 decy='Abc123'
#3 crash
error reading "file5": invalid or incomplete multibyte or wide character
    while executing
"read $f"
    (procedure "::yencode::ydecode" line 17)
    invoked from within
"::yencode::ydecode -file $FILENAME"
    invoked from within
"foreach lst [::yencode::ydecode -file $FILENAME] {
    lassign $lst name size decy
    puts "name=$name size=$size decy='$decy'"
}"
    (file "./y.tcl" line 15)
```
User Comments: serhiy.storchaka added on 2026-11-16 00:06:15:

Proposed fix in branch yencode-ydecode-fixes:

  • ydecode takes the name from the rest of the =ybegin line, instead of accepting only digits;
  • -file is opened in binary mode;
  • the bad-option error message no longer fails.
Tests yencode-6.0 to 6.2.