Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d00f5117cc86ffe58cd7de9b2418013355bdda46dd28d6260bbe65dbf8dcb1af
Ticket: b8f575aa2398b0e44b5a037326b9d75037e2da4a
Tcl 9: eof erroneously flagged with not reported encoding read error
User & Date: pooryorick on 2023-01-17 16:04:15
Changes

  1. icomment:
    [1a225bd50e984fdc] is another attempt to fix the issue for <code>read</code>:  The return value is always the characters that have been successfully read, and in the case of an error the error information is found in the <code>-errorinfo</code> entry in the return options dictionary.  This is in contrast with the earlier proposed fix, which in the case of an error placed the successfully-read characters in the <code>-result read</code> entry in the return options dictionary.
    
    I don't see many alternatives apart from these two.  One other alternative would be to restore the current access position in the file to the position it was at prior to the call to <code>read</code>, but there are so many disadvantages to this that it seems entirely unworkable.  First, it wouldn't work for non-seekable channels.  Second, it doesn't provide access to the position of the bad bytes.  Third, it doesn't allow the caller to implement their own handling of bad parts of the data.  Fourth, it doesn't provide access to all the data decoded up to the error.  Fifth, the current state of the implementation makes it difficult to implement.
    
    The other alternative is to change the semantics of <code>read</code> and <code>gets</code>, as the test cases provided with Jan's proposed fix do.  That means that all code that uses <code>read</code> would have to be modified to include a subsequent call to <code>read</code> in order to expose a latent error.  I see this as the worst of the possible solutions, and probably nearly everyone would reject this alternative (even though it is the status-quo on trunk).
    
  2. login: "pooryorick"
  3. mimetype: "text/x-fossil-wiki"