diff options
author | dgp <dgp@users.sourceforge.net> | 2014-02-20 21:23:33 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-02-20 21:23:33 (GMT) |
commit | 9f6aaa68fc35449d224e5a1ea5d53e09ac38e509 (patch) | |
tree | 277c45353720553835a1cdad91a7fedd6b28a516 /generic/tclIO.c | |
parent | ddaf1d27cb4ec6db78294cb42e1fd46ae6d2dbc2 (diff) | |
download | tcl-9f6aaa68fc35449d224e5a1ea5d53e09ac38e509.zip tcl-9f6aaa68fc35449d224e5a1ea5d53e09ac38e509.tar.gz tcl-9f6aaa68fc35449d224e5a1ea5d53e09ac38e509.tar.bz2 |
Switch consistently on the narrower def of binary mode.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 4d7133a..eae063b 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -5060,6 +5060,7 @@ DoReadChars( ChannelBuffer *bufPtr; int offset, factor, copied, copiedNow, result; Tcl_Encoding encoding; + int binaryMode; #define UTF_EXPANSION_FACTOR 1024 /* @@ -5070,8 +5071,12 @@ DoReadChars( encoding = statePtr->encoding; factor = UTF_EXPANSION_FACTOR; + binaryMode = (encoding == NULL) + && (statePtr->inputTranslation == TCL_TRANSLATE_LF) + && (statePtr->inEofChar == NULL); + if (appendFlag == 0) { - if (encoding == NULL) { + if (binaryMode) { Tcl_SetByteArrayLength(objPtr, 0); } else { Tcl_SetObjLength(objPtr, 0); @@ -5086,7 +5091,7 @@ DoReadChars( } offset = 0; } else { - if (encoding == NULL) { + if (binaryMode) { Tcl_GetByteArrayFromObj(objPtr, &offset); } else { TclGetStringFromObj(objPtr, &offset); @@ -5096,8 +5101,7 @@ DoReadChars( for (copied = 0; (unsigned) toRead > 0; ) { copiedNow = -1; if (statePtr->inQueueHead != NULL) { - if (encoding == NULL - && statePtr->inputTranslation == TCL_TRANSLATE_LF) { + if (binaryMode) { copiedNow = ReadBytes(statePtr, objPtr, toRead, &offset); } else { copiedNow = ReadChars(statePtr, objPtr, toRead, &offset, @@ -5146,7 +5150,7 @@ DoReadChars( } ResetFlag(statePtr, CHANNEL_BLOCKED); - if (encoding == NULL) { + if (binaryMode) { Tcl_SetByteArrayLength(objPtr, offset); } else { Tcl_SetObjLength(objPtr, offset); |