Tcl Source Code

View Ticket
Login
Ticket UUID: 1830450
Title: open file treats a+ as a (append)
Type: Bug Version: obsolete: 8.4.16
Submitter: legolas_a20 Created on: 2007-11-12 14:28:36
Subsystem: None Assigned To: nobody
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-12-14 09:34:53
Resolution: Duplicate Closed By: hobbs
    Closed on: 2007-12-14 02:34:53
Description:
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).
User Comments: hobbs added on 2007-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.

legolas_a20 added on 2007-11-12 21:28:36:

File Added - 253930: tclopenbug.tcl

Attachments: