Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 351fab46007aa9bcf914abab4636137de8f2824af58caf290986f934775e278f
Ticket: 3d01d51bc45cf7c53938d23f7ac4a364341a878d
Tcl 9: Cannot write large strings to file
User & Date: pointsman on 2023-04-23 23:44:35
Changes

  1. closedate changed to: "2460058.48930185"
  2. icomment:
    [Sorry, hadn't changed from plain text to links only. For your convenience here the same again:]
    
    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"
    
  3. login: "pointsman"
  4. mimetype: "text/x-fossil-plain"