summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index bdc3110..9af2e19 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.129 2007/11/19 14:04:24 dkf Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.130 2007/11/27 19:48:12 dgp Exp $
*/
#include "tclInt.h"
@@ -7314,14 +7314,26 @@ Tcl_SetChannelOption(
if (argc == 0) {
statePtr->inEofChar = 0;
statePtr->outEofChar = 0;
- } else if (argc == 1) {
- if (statePtr->flags & TCL_WRITABLE) {
- statePtr->outEofChar = (int) argv[0][0];
+ } else if (argc == 1 || argc == 2) {
+ int outIndex = (argc - 1);
+ int inValue = (int) argv[0][0];
+ int outValue = (int) argv[outIndex][0];
+ if ((inValue < 0x01 || inValue > 0x7f) || (outValue < 0x01 || outValue > 0x7f)) {
+ if (interp) {
+ Tcl_AppendResult(interp,
+ "bad value for -eofchar: must be between 0x01 and 0x7f",
+ NULL);
+ }
+ ckfree((char *) argv);
+ return TCL_ERROR;
}
if (statePtr->flags & TCL_READABLE) {
- statePtr->inEofChar = (int) argv[0][0];
+ statePtr->inEofChar = inValue;
}
- } else if (argc != 2) {
+ if (statePtr->flags & TCL_WRITABLE) {
+ statePtr->outEofChar = outValue;
+ }
+ } else {
if (interp) {
Tcl_AppendResult(interp,
"bad value for -eofchar: should be a list of zero,"
@@ -7329,13 +7341,6 @@ Tcl_SetChannelOption(
}
ckfree((char *) argv);
return TCL_ERROR;
- } else {
- if (statePtr->flags & TCL_READABLE) {
- statePtr->inEofChar = (int) argv[0][0];
- }
- if (statePtr->flags & TCL_WRITABLE) {
- statePtr->outEofChar = (int) argv[1][0];
- }
}
if (argv != NULL) {
ckfree((char *) argv);