summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-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;
}
/*