Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 8f2709c2460c33ce577d8966b9253d9bbecd6c3f85fac0665a23ea788f00794e
Ticket: b3977d199b08e3979a8da970553d5209b3042e9c
Channel gets inserts spurious empty lines on receiving torn CR-LF
User & Date: apnadkarni on 2022-07-03 06:42:53
Changes

  1. icomment:
    Here is my analysis of what is happening (most action is inside Tcl_GetObj)
    
    When a CR is read from the channel buffer but the accompanying LF has not arrived, the channel code passes up the line as the `gets` result and also remembers that a CR has been seen by [setting a flag](https://core.tcl-lang.org/tcl/file?ci=651b1008fbc7f7ed&name=generic/tclIO.c&ln=4794)
    
    When subsequently the LF is received, the channel subsystem correctly 
    [skips](https://core.tcl-lang.org/tcl/file?ci=651b1008fbc7f7ed&name=generic/tclIO.c&ln=4753-4773) it by [bumping the pointer](https://core.tcl-lang.org/tcl/file?ci=651b1008fbc7f7ed&name=generic/tclIO.c&ln=4766) into the receive buffer past the LF.
    
    However, later in the code, the pointer offset is [reset to its old value](https://core.tcl-lang.org/tcl/file?ci=651b1008fbc7f7ed&name=generic/tclIO.c&ln=4900) which means the next gets sees it as a new line and in auto translation mode returns an empty line as a result.
    
    This last reset of value is the root of the problem. I do not understand all the manipulations of the buffers and offsets and why that is necessary so hesitant to suggest a fix.
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"