Tcl Source Code

Artifact [abe0f2536f]
Login

Artifact abe0f2536f9b35c5a2e1753ec1cbc635db4f0fef:

Attachment "tclopenbug.tcl" to ticket [1830450fff] added by legolas_a20 2007-11-12 21:28:36.
#make a testfile
set f [open "test.bin" "w"]

puts $f "ttt"
puts $f "rrr"
puts $f "ttt"

close $f

#now test it.
set f [open "test.bin" "a+"]

seek $f 5
puts $f "qqq"

close $f

#BUG BUG BUG
#on my windows XP with 8.4.16, the file has the qqq appended to it, even
#though the documentation for 'a+' says: "Set the initial access position to the end of the file."
#(as oppossed to the docs for just 'a', which says: "Set the file pointer to the end of the file prior to each write."
#But it seems that a+ acts just like a!

#this is the current workaround
#make a testfile
set f [open "test2.bin" "w"]

puts $f "ttt"
puts $f "rrr"
puts $f "ttt"

close $f

#now test it.
set f [open "test2.bin" RDWR]

seek $f 5
puts -nonewline $f "qqq"

close $f

#after this, text rrr is correctly replaced by qqq, as expected