Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 24a98533c5070ff9cd1aeaaa6143b0a956601fd86bf0c79bfd8b2783d8c54e0d
Ticket: 3d01d51bc45cf7c53938d23f7ac4a364341a878d
Tcl 9: Cannot write large strings to file
User & Date: pointsman on 2023-04-23 23:38:20
Changes

  1. closedate changed to: "2460058.48496203"
  2. closer changed to: "pointsman"
  3. icomment:
    The fix for[3d01d51bc4] with commit [186e4d9317] didn't really fix the problem.
    
    Look at 
    https://core.tcl-lang.org/tcl/artifact?udc=1&ln=4262-4278&name=ce11265346dd36a3
    
    In that loop the scr pointer will not be incrementend. Which means that after every INT_MAX bytes written it starts over from the start of the string instead of continuing. This explains the output of the examples given so far.
    
    An obvious fix is
    
    https://core.tcl-lang.org/tcl/artifact?udc=1&ln=4276&name=abf0f8ddf7519a1f
    
    But this raises the question what WriteChars(chanPtr, src, chunkSize) does if the chunkSize ends in the middle of a multibyte char?
    
    Some answers to that question doesn't look promissing (need a Tcl 9 tcltest to run this example script):
    
    set s [testbigdata string 0x7FFFFFFE]
    # The character to append in the next line is EM DASH, 
    # code point 0x2014 (decimal 8212, UTF-8 #xE2 #x80 #x94, 
    append s —
    set fd [open out.txt w+]
    puts $fd $s
    close $fd
    
    If I run this (on debian) I get:
    
    error writing "file6": invalid or incomplete multibyte or wide character
        while executing
    "puts $fd $s"
    
  4. login: "pointsman"
  5. mimetype: "text/plain"