Tcl Source Code

View Ticket
Login
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

Ticket UUID: 4c5a98f5a0d4ae30a0f1bb4d76592f3ba3551bd1
Title: gets with -translation auto merges lines after a "\r" at the end of a read
Type: Bug Created on: 2026-10-16 21:38:18
Submitter: serhiy.storchaka Assigned to:
Subsystem: 25. Channel System Severity: Minor
Priority: 5 Medium Last modified: 2026-10-16 21:40:49
Status: Open Closed by:
Resolution: None Closed on:
Version: 8.6.18, 9.0.5, 9.1.0
Description:

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.

User Comments:
serhiy.storchaka added on 2026-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.