Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b93703622c527bcc53f2330df6e5f5e958b3264c
Ticket: 218481ffffffffffffffffffffffffffffffffff
Append mode "a" does not agree with APPEND mode
User & Date: nobody on 2000-10-26 01:01:05
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 681 Bug
    Version: 8.0p2
    SubmitDate: '1998-09-23'
    LastModified: '1999-11-05'
    Severity: MED
    Status: Released
    Submitter: welch
    ChangedBy: hobbs
    OS: All
    OSVersion: NA
    Machine: NA
    FixedDate: '1999-11-05'
    FixedInVersion: 8.3b1
    ClosedDate: '2000-10-25'
    
    
    According to open(3tcl):
           a              Open  the  file for writing only.  The file
                          must already exist, and the file  is  posi=AD
                          tioned  so that new data is appended to the
                          file.
    
    The semantics of this are unclear from this documentation, but I
    contend that they should be the same as those of ANSI C "a", which are
    to position the file pointer at the end of the file prior to each
    write.
    
    Otherwise, programs which want this (correct) behaviour will all have
    to use the POSIX-derived {... APPEND ...} syntax.
    
    (This bug/misfeature also exists in my private debianisation of
    upstream 8.1a2.)
    
    Ian.
    
    -anarres:~/junk> cat t.tcl
    foreach {fn mode} {t a  u {WRONLY APPEND CREAT}} {
        puts "testing $fn with mode $mode"
        file delete -force $fn
        set f1 [open $fn $mode]
        set f2 [open $fn $mode]
        fconfigure $f1 -buffering none
        fconfigure $f2 -buffering none
        puts $f2 "data f2"
        puts $f1 "DATA WRITTEN WITH F1"
        puts $f2 "more f2"
        close $f1
        close $f2
    }
    -anarres:~/junk> rm -f t.strace; strace -ot.strace tclsh8.0 t.tcl
    testing t with mode a
    testing u with mode WRONLY APPEND CREAT
    -anarres:~/junk> cat t
    DATA WRImore f2
    H F1
    -anarres:~/junk> cat u
    data f2
    DATA WRITTEN WITH F1
    more f2
    -anarres:~/junk> dpkg -S `type -p tclsh8.0`
    tcl8.0: /usr/bin/tclsh8.0
    -anarres:~/junk> dpkg -s tcl8.0
    Package: tcl8.0
    Status: install ok installed
    Priority: optional
    Section: libs
    Installed-Size: 641
    Maintainer: David Engel <[email protected]>
    Version: 8.0p2-3
    Provides: tclsh
    Depends: libc6, libreadlineg2 (>=3D 2.1-4), ncurses3.4, tcl8.0
    Conflicts: tcl, tcl74 (<=3D 7.4p3-2)
    Description: The Tool Command Language (TCL) v8.0 - Run-Time Package.
     TCL is a powerful, easy to use, interpreted scripting language.
    
    
    The only problem here is the bug in the docs for "a", in that
    we should (and do) follow POSIX fopen, where "a" doesn't care
    whether the file exists or not.  However, there is a standard
    difference between "a" and "APPEND", in that APPEND moves to
    the end of the file on EACH write, while "a" only sets the
    INITIAL postion to the end. 
    -- 11/05/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.0p2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "37. File System"
  10. title changed to: "Append mode "a" does not agree with APPEND mode"
  11. type changed to: "Bug"