Skip to content
Tcl Source Code View Ticket
Login

View Ticket

open file treats a+ as a (append)

Closed / Duplicate1830450fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-11-12 14:28:36
when opening a file, specifying "a+" as mode acts just like "a" when it comes to setting the file pointer before a puts, after a seek. Both act like "a", which, as the docs say: "Set the file pointer to the end of the file prior to each write." "A+" should, according to the docs "Set the initial access position to the end of the file."

so if I open f with a+, and then do:

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

the qqq should end up at file position 5. It ends up at file position 'end' instead.

See the attachment for a script that reproduces this, and a workaround: using RDWR as mode works as "a+" should work. The script writes a file called test.bin, and then attempts to update the middle of it as described above (and fails to do that on my 8.4.16 on windows xp sp2), followed by doing the same thing with the workaround, on a file named test2.bin (and that does work).
legolas_a20plain2007-11-12 21:28:36
File Added - 253930: tclopenbug.tcl
hobbsplain2007-12-14 09:34:53
Logged In: YES 
user_id=72656
Originator: NO

Fixed in 8.4.17, dup of 1773127 that just didn't get backported.
Log in (anonymous is fine) to add a comment.

Attachments: