summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--doc/chan.n5
-rw-r--r--doc/fconfigure.n5
-rw-r--r--generic/tclIO.c31
-rw-r--r--tests/chan.test8
5 files changed, 41 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f1a1b1..95c1a17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-27 Don Porter <dgp@users.sourceforge.net>
+
+ * doc/chan.n: "Fix" the limitation on channel -eofchar
+ * doc/fconfigure.n: values to single byte characters by documenting
+ * generic/tclIO.c: it and making it fail loudly. Thanks to
+ * tests/chan.test: Stuart Cassoff for contributing the fix.
+ [Bug 800753]
+
2007-11-26 Miguel Sofer <msofer@users.sf.net>
* generic/tclBasic.c:
diff --git a/doc/chan.n b/doc/chan.n
index d5ca932..633e859 100644
--- a/doc/chan.n
+++ b/doc/chan.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: chan.n,v 1.15 2007/11/01 13:43:14 dkf Exp $
+'\" RCS: @(#) $Id: chan.n,v 1.16 2007/11/27 19:48:07 dgp Exp $
.so man.macros
.TH chan n 8.5 Tcl "Tcl Built-In Commands"
.BS
@@ -173,6 +173,9 @@ returned. The default value for \fB\-eofchar\fR is the empty string
in all cases except for files under Windows. In that case the
\fB\-eofchar\fR is Control-z (\ex1a) for reading and the empty string
for writing.
+The acceptable range for \fB\-eofchar\fR values is \ex01 - \ex7f;
+attempting to set \fB\-eofchar\fR to a value outside of this range will
+generate an error.
.TP
\fB\-translation\fR \fImode\fR
.TP
diff --git a/doc/fconfigure.n b/doc/fconfigure.n
index 3ce53e0..b8fb397 100644
--- a/doc/fconfigure.n
+++ b/doc/fconfigure.n
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: fconfigure.n,v 1.18 2007/07/04 13:51:29 dkf Exp $
+'\" RCS: @(#) $Id: fconfigure.n,v 1.19 2007/11/27 19:48:07 dgp Exp $
'\"
.so man.macros
.TH fconfigure n 8.3 Tcl "Tcl Built-In Commands"
@@ -120,6 +120,9 @@ channel, a two-element list will always be returned. The default value
for \fB\-eofchar\fR is the empty string in all cases except for files
under Windows. In that case the \fB\-eofchar\fR is Control-z (\ex1a) for
reading and the empty string for writing.
+The acceptable range for \fB\-eofchar\fR values is \ex01 - \ex7f;
+attempting to set \fB\-eofchar\fR to a value outside of this range will
+generate an error.
.TP
\fB\-translation\fR \fImode\fR
.TP
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);
diff --git a/tests/chan.test b/tests/chan.test
index 1108216..f86ffb5 100644
--- a/tests/chan.test
+++ b/tests/chan.test
@@ -7,7 +7,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: chan.test,v 1.8 2006/12/17 03:44:03 das Exp $
+# RCS: @(#) $Id: chan.test,v 1.9 2007/11/27 19:48:13 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -37,6 +37,12 @@ test chan-3.1 {chan command: close subcommand} -body {
test chan-4.1 {chan command: configure subcommand} -body {
chan configure
} -returnCodes error -result "wrong # args: should be \"chan configure channelId ?optionName? ?value? ?optionName value?...\""
+test chan-4.2 {chan command: [Bug 800753]} -body {
+ chan configure stdout -eofchar \u0100
+} -returnCodes error -match glob -result {bad value*}
+test chan-4.3 {chan command: [Bug 800753]} -body {
+ chan configure stdout -eofchar \u0000
+} -returnCodes error -match glob -result {bad value*}
test chan-5.1 {chan command: copy subcommand} -body {
chan copy foo