summaryrefslogtreecommitdiffstats
path: root/generic/tclIOUtil.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-08-15 17:43:57 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-08-15 17:43:57 (GMT)
commitfb1aceab5c31ee41c19858ec794edca1b87341d5 (patch)
tree357eada5f16be2369d08277457a2d80e3f56758b /generic/tclIOUtil.c
parentd320d81dec73fb4809b297d876646aeec43be25e (diff)
downloadtcl-fb1aceab5c31ee41c19858ec794edca1b87341d5.zip
tcl-fb1aceab5c31ee41c19858ec794edca1b87341d5.tar.gz
tcl-fb1aceab5c31ee41c19858ec794edca1b87341d5.tar.bz2
Fix [Bug 1773127]
Diffstat (limited to 'generic/tclIOUtil.c')
-rw-r--r--generic/tclIOUtil.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index 5725e45..90cc2c4 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.145 2007/04/25 19:09:03 kennykb Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.146 2007/08/15 17:43:58 dkf Exp $
*/
#include "tclInt.h"
@@ -1569,22 +1569,16 @@ TclGetOpenModeEx(
mode = O_WRONLY|O_CREAT|O_TRUNC;
break;
case 'a':
- /* [Bug 680143].
- * Added O_APPEND for proper automatic
- * seek-to-end-on-write by the OS.
+ /*
+ * Added O_APPEND for proper automatic seek-to-end-on-write by the
+ * OS. [Bug 680143]
*/
+
mode = O_WRONLY|O_CREAT|O_APPEND;
*seekFlagPtr = 1;
break;
default:
- error:
- *seekFlagPtr = 0;
- *binaryPtr = 0;
- if (interp != NULL) {
- Tcl_AppendResult(interp, "illegal access mode \"", modeString,
- "\"", NULL);
- }
- return -1;
+ goto error;
}
i=1;
while (i<3 && modeString[i]) {
@@ -1593,7 +1587,12 @@ TclGetOpenModeEx(
}
switch (modeString[i++]) {
case '+':
- mode &= ~(O_RDONLY|O_WRONLY);
+ /*
+ * Must remove the O_APPEND flag so that the seek command
+ * works. [Bug 1773127]
+ */
+
+ mode &= ~(O_RDONLY|O_WRONLY|O_APPEND);
mode |= O_RDWR;
break;
case 'b':
@@ -1607,6 +1606,15 @@ TclGetOpenModeEx(
goto error;
}
return mode;
+
+ error:
+ *seekFlagPtr = 0;
+ *binaryPtr = 0;
+ if (interp != NULL) {
+ Tcl_AppendResult(interp, "illegal access mode \"", modeString,
+ "\"", NULL);
+ }
+ return -1;
}
/*