summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 6a9c306..4002934 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -4655,7 +4655,8 @@ Tcl_GetsObj(
ChannelState *statePtr = chanPtr->state;
/* State info for channel */
ChannelBuffer *bufPtr;
- int inEofChar, skip, copiedTotal, oldLength, oldFlags, oldRemoved;
+ int inEofChar, skip, copiedTotal, oldFlags, oldRemoved;
+ int oldLength;
Tcl_Encoding encoding;
char *dst, *dstEnd, *eol, *eof;
Tcl_EncodingState oldState;
@@ -8156,7 +8157,7 @@ Tcl_SetChannelOption(
/* State info for channel */
size_t len; /* Length of optionName string. */
int argc;
- const char **argv;
+ const char **argv = NULL;
/*
* If the channel is in the middle of a background copy, fail.
@@ -8262,16 +8263,19 @@ Tcl_SetChannelOption(
UpdateInterest(chanPtr);
return TCL_OK;
} else if (HaveOpt(2, "-eofchar")) {
- if (Tcl_SplitList(interp, newValue, &argc, &argv) == TCL_ERROR) {
+ if (!newValue[0] || (!(newValue[0] & 0x80) && !newValue[1])) {
+ if (GotFlag(statePtr, TCL_READABLE)) {
+ statePtr->inEofChar = newValue[0];
+ }
+ statePtr->outEofChar = 0;
+ } else if (Tcl_SplitList(interp, newValue, &argc, &argv) == TCL_ERROR) {
return TCL_ERROR;
- }
- if (argc == 0) {
+ } else if (argc == 0) {
statePtr->inEofChar = 0;
statePtr->outEofChar = 0;
} else if (argc == 1 || argc == 2) {
- int outIndex = (argc - 1);
int inValue = (int) argv[0][0];
- int outValue = (int) argv[outIndex][0];
+ int outValue = (argc == 2) ? (int) argv[1][0] : 0;
if (inValue & 0x80 || outValue & 0x80) {
if (interp) {