Attachment "84.append.udiff" to
ticket [680143ffff]
added by
andreas_kupries
2006-03-17 01:24:37.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.1453.2.609
diff -w -u -r1.1453.2.609 ChangeLog
--- ChangeLog 16 Mar 2006 00:35:53 -0000 1.1453.2.609
+++ ChangeLog 16 Mar 2006 18:15:22 -0000
@@ -1,3 +1,13 @@
+2006-03-16 Andreas Kupries <[email protected]>
+
+ * generic/tclIOUtil.c (TclGetOpenMode): Added the flag O_APPEND to
+ the list of POSIX modes used when opening a file for
+ 'a'ppend. This enables the proper automatic seek-to-end-on-write
+ by the OS. See [Bug 680143] for longer discussion.
+
+ * tests/ioCmd.test (iocmd-13.7.*): Extended the testsuite to check
+ the new handling of 'a'.
+
2006-03-15 Andreas Kupries <[email protected]>
* tests/socket.test: Extended the timeout in socket-11.11 from 10
Index: generic/tclIOUtil.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIOUtil.c,v
retrieving revision 1.77.2.26
diff -w -u -r1.77.2.26 tclIOUtil.c
--- generic/tclIOUtil.c 15 Feb 2006 16:04:29 -0000 1.77.2.26
+++ generic/tclIOUtil.c 16 Mar 2006 18:15:22 -0000
@@ -1567,7 +1567,11 @@
mode = O_WRONLY|O_CREAT|O_TRUNC;
break;
case 'a':
- mode = O_WRONLY|O_CREAT;
+ /* [Bug 680143].
+ * Added O_APPEND for proper automatic
+ * seek-to-end-on-write by the OS.
+ */
+ mode = O_WRONLY|O_CREAT|O_APPEND;
*seekFlagPtr = 1;
break;
default:
Index: tests/ioCmd.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/ioCmd.test,v
retrieving revision 1.16.2.2
diff -w -u -r1.16.2.2 ioCmd.test
--- tests/ioCmd.test 7 Oct 2003 18:53:23 -0000 1.16.2.2
+++ tests/ioCmd.test 16 Mar 2006 18:15:22 -0000
@@ -1,3 +1,4 @@
+# -*- tcl -*-
# Commands covered: open, close, gets, read, puts, seek, tell, eof, flush,
# fblocked, fconfigure, open, channel, fcopy
#
@@ -459,6 +460,42 @@
string tolower $msg
} {1 {couldn't open "_non_existent_": no such file or directory} {posix enoent {no such file or directory}}}
+
+test iocmd-13.7.1 {open for append, a mode} -setup {
+ set log [makeFile {} out]
+ set chans {}
+} -body {
+ foreach i { 0 1 2 3 4 5 6 7 8 9 } {
+ puts [set ch [open $log a]] $i
+ lappend chans $ch
+ }
+ foreach ch $chans {catch {close $ch}}
+ lsort [split [string trim [viewFile out]] \n]
+} -cleanup {
+ removeFile out
+ # Ensure that channels are gone, even if body failed to do so
+ foreach ch $chans {catch {close $ch}}
+} -result {0 1 2 3 4 5 6 7 8 9}
+
+test iocmd-13.7.2 {open for append, O_APPEND} -setup {
+ set log [makeFile {} out]
+ set chans {}
+} -body {
+ foreach i { 0 1 2 3 4 5 6 7 8 9 } {
+ puts [set ch [open $log {WRONLY CREAT APPEND}]] $i
+ lappend chans $ch
+ }
+ foreach ch $chans {catch {close $ch}}
+ lsort [split [string trim [viewFile out]] \n]
+} -cleanup {
+ removeFile out
+ # Ensure that channels are gone, even if body failed to do so
+ foreach ch $chans {catch {close $ch}}
+} -result {0 1 2 3 4 5 6 7 8 9}
+
+
+
+
test iocmd-14.1 {file id parsing errors} {
list [catch {eof gorp} msg] $msg $errorCode
} {1 {can not find channel named "gorp"} NONE}