summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-28 11:18:53 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-28 11:18:53 (GMT)
commit18fb3780723b2613640a274c1b76831ebceadfeb (patch)
tree0aae6637315656922453c773719a21ec0eee98ad /generic/tclIO.c
parentd1e2a1ab3ccfb141e5336357b90666f94789c20d (diff)
downloadtcl-18fb3780723b2613640a274c1b76831ebceadfeb.zip
tcl-18fb3780723b2613640a274c1b76831ebceadfeb.tar.gz
tcl-18fb3780723b2613640a274c1b76831ebceadfeb.tar.bz2
TIP #646 correction: let "fconfigure $chan -eofchar" return a single character, not a list element
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 374f770..b3b62ed 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -7930,20 +7930,18 @@ Tcl_GetChannelOption(
}
}
if (len == 0 || HaveOpt(2, "-eofchar")) {
+ char buf[4] = "";
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-eofchar");
}
- if (!(flags & TCL_READABLE) || (statePtr->inEofChar == 0)) {
- Tcl_DStringAppendElement(dsPtr, "");
- } else {
- char buf[4];
-
+ if ((flags & TCL_READABLE) && (statePtr->inEofChar != 0)) {
sprintf(buf, "%c", statePtr->inEofChar);
- Tcl_DStringAppendElement(dsPtr, buf);
}
if (len > 0) {
+ Tcl_DStringAppend(dsPtr, buf, TCL_INDEX_NONE);
return TCL_OK;
}
+ Tcl_DStringAppendElement(dsPtr, buf);
}
if (len == 0 || HaveOpt(1, "-nocomplainencoding")) {
if (len == 0) {
@@ -8181,6 +8179,7 @@ Tcl_SetChannelOption(
if (GotFlag(statePtr, TCL_READABLE)) {
statePtr->inEofChar = newValue[0];
}
+#ifndef TCL_NO_DEPRECATED
} else if (Tcl_SplitList(interp, newValue, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
} else if (argc == 0) {
@@ -8201,11 +8200,12 @@ Tcl_SetChannelOption(
if (GotFlag(statePtr, TCL_READABLE)) {
statePtr->inEofChar = inValue;
}
+#endif
} else {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "bad value for -eofchar: should be a list of zero,"
- " one, or two elements", -1));
+ "bad value for -eofchar: must be non-NUL ASCII"
+ " character", -1));
}
Tcl_Free((void *)argv);
return TCL_ERROR;