Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d32acb376657a5523f15f59b950a7c2586a5302e
Ticket: 219210ffffffffffffffffffffffffffffffffff
fcopy does not respect encodings
User & Date: andreas_kupries on 2001-03-31 20:22:45
Changes

  1. icomment:
    Logged In: YES 
    user_id=75003
    
    The fix for this report has to be done in "tclIO.c",
    "CopyData", which
    currently uses "DoRead" and "DoWrite" for reading from and
    writing to
    the channels involved in the copying. Exchanging these two
    calls
    against stripped down versions of "Tcl_ReadChars" and
    "Tcl_WriteChars"
    should do the trick. "Stripped down" means here that we have
    avoid the
    call to "CheckChannelErrors" in these two routines as this
    routine
    flags their usage for a channel used in an "fcopy" as an
    error. I
    would propose to move the meat of these two routines into
    two internal
    procedures "DoReadChars" and "DoWriteChars" which are then
    called from
    the original routines. The originals would retain the error
    checking. And "CopyData" can use the internal procedures to
    get its
    own work done.
    
    Note the following consequences of the change:
    
    - The system will use UTF-8 internally when copying data,
    meaning that it will consume more memory, or copy less data
    per buffer.
    
    - Performance will be affected negatively because of the
    additional conversions to and from UTF-8. (Side note: Do we
    have performance tests for "fcopy" in "tclbench" ?).
    
    The code of the channel system uses 'statePtr->encoding ==
    NULL' as
    signal that the encoding is binary, and the two "Tcl_*Chars"
    procedures have special provisions for that case.
    Unfortunately not
    very efficient as it involves ByteArray objects.
    
    I would propose that "CopyData" should check for binary
    translation on
    _both_ channels and fall back to the old code in such a
    case. This
    would avoid quite a lot of conversions and copying. We
    shouldn't do
    this for a mixture of binary and non-binary encodings as we
    still need
    an intermediate ByteArray to get the conversion right for
    these cases,
    causing additional complexity in the new code. Better to
    stay with the
    tried and true code for that for now.
    
    
    
  2. login: "andreas_kupries"
  3. mimetype: "text/plain"
  4. username: "andreas_kupries"