Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-22
22:56 • Closed ticket [4c5a98f5a0]: gets with -translation auto merges lines after a &qu... artifact: 6bad4e2b7b user: jan.nijtmans
2026-11-21
22:50
Fix [4c5a98]: gets with -translation auto merged lines after a r at the end of a read check-in: 8feddbb7ca user: jan.nijtmans tags: core-8-6-branch
15:02
Fix [4c5a98]: gets with -translation auto merged lines after a "\r" at the end of a read check-in: 8c6756b9c3 user: jan.nijtmans tags: core-9-0-branch
2026-11-20
16:50
Fix [4c5a98]: gets with -translation auto merged lines after a "\r" at the end of a read check-in: 1bcbef3166 user: jan.nijtmans tags: trunk, main
2026-10-16
21:44 • Closed ticket [2953593fff]: gets $fd data returns 0 in nonblocking mode pl... artifact: 7562e15fe4 user: serhiy.storchaka
21:40 • Ticket [2953593fff]: 3 changes artifact: f5e82977a2 user: serhiy.storchaka
21:40 • Ticket [4c5a98f5a0] gets with -translation auto merges lines after a "\r&qu... artifact: 104c2074aa user: serhiy.storchaka
21:40
Fix [4c5a98f5a0]: gets with -translation auto merged lines after a "\r" at the end of a read. Reset ... closed check-in: 7d959464b9 user: serhiy.storchaka tags: gets-auto-saw-cr
21:38 • New ticket [4c5a98f5a0] gets with -translation auto merges lines after a "\... artifact: 973cabdbd3 user: serhiy.storchaka

gets with -translation auto merges lines after a "\r" at the end of a read

Closed / Fixed4c5a98f5a0d4ae30a0f1bb4d76592f3ba3551bd1Created 47 days agoUpdated 10 days ago
Descriptionwiki2026-10-16 21:38:18
With -translation auto, if a read ends with "\r" and the next read has no end of line, a "\n" at the start of a later read is dropped as if it were the LF of a CRLF pair:
lassign [chan pipe] r w
fconfigure $r -blocking 0 -translation auto
fconfigure $w -translation binary -buffering none
puts -nonewline $w "a\r"; gets $r      ;# a
puts -nonewline $w "b"; gets $r        ;# (blocked)
puts -nonewline $w "\nc\n"; gets $r    ;# bc  (8.6.12: b, then c)

LF CR input loses empty lines in the same way. Since [a3ed092aab] (8.6.13, the fix for [b3977d199b]) Tcl_GetsObj() resets INPUT_SAW_CR only when an end of line is found.

Referenced by3
  • 7562e15fe4Closed ticket [2953593fff]: [gets $fd data] returns 0 in nonblocking mode plus 4 other changes ticket2026-10-16 21:44:20
  • f5e82977a2Ticket [2953593fff] [gets $fd data] returns 0 in nonblocking mode status still Open with 3 other changes ticket2026-10-16 21:40:49
  • 7d959464b9Fix [4c5a98f5a0]: gets with -translation auto merged lines after a "\r" at the end of a read. Reset INPUT_SAW_CR as soon as data follows the "\r", and set it again if the skipped "\n" is pushed back, so that the case of [b3977d199b] still works. check-in2026-10-16 21:40:08
serhiy.storchakawiki2026-10-16 21:40:49

Proposed fix in branch gets-auto-saw-cr: Tcl_GetsObj() resets INPUT_SAW_CR as soon as data follows the "\r" and sets it again if the skipped "\n" is pushed back, so the torn CRLF case of [b3977d199b] still works (io-29.36.1, io-29.36.2). Test io-29.36.3.

jan.nijtmanswiki2026-11-22 22:56:47

Merged to [trunk], core-9-0-branch and core-8-6-branch

Many thanks!

Log in (anonymous is fine) to add a comment.