summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-03-19 21:43:31 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-03-19 21:43:31 (GMT)
commita174107efac416856e4183ea90821edac8c266b2 (patch)
treedbd4bcae7d280628825a2274844f6b00593f1dd4 /generic
parent69b5edf8708c05f4abdb039c64ea28932478b400 (diff)
downloadtcl-a174107efac416856e4183ea90821edac8c266b2.zip
tcl-a174107efac416856e4183ea90821edac8c266b2.tar.gz
tcl-a174107efac416856e4183ea90821edac8c266b2.tar.bz2
Let TranslateInputEOL handle the "\r$eofChar" sequence in CRLF mode.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 2d22942..267b659 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -5362,7 +5362,7 @@ ReadChars(
* record \r or \n yet.
*/
-// assert(dstRead + 1 == dstDecoded);
+ assert(dstRead + 1 == dstDecoded);
assert(dst[dstRead] == '\r');
assert(statePtr->inputTranslation == TCL_TRANSLATE_CRLF);
@@ -5383,7 +5383,7 @@ ReadChars(
assert(dstWrote == 0);
assert(dstRead == 0);
-// assert(dstDecoded == 1);
+ assert(dstDecoded == 1);
/*
* We decoded only the bare cr, and we cannot read a
@@ -5620,10 +5620,14 @@ TranslateInputEOL(
src += numBytes; srcLen -= numBytes;
if (srcLen == 1) {
/* valid src bytes end in \r */
- lesser = 0;
- break;
- }
- if (src[1] == '\n') {
+ if (eof) {
+ *dst++ = '\r';
+ src++; srcLen--;
+ } else {
+ lesser = 0;
+ break;
+ }
+ } else if (src[1] == '\n') {
*dst++ = '\n';
src += 2; srcLen -= 2;
} else {
@@ -8708,11 +8712,6 @@ DoRead(
int bytesRead = BytesLeft(bufPtr);
int bytesWritten = bytesToRead;
- if (bytesRead == 0 && statePtr->flags & CHANNEL_NONBLOCKING
- && statePtr->flags & CHANNEL_BLOCKED) {
- break;
- }
-
TranslateInputEOL(statePtr, p, RemovePoint(bufPtr),
&bytesWritten, &bytesRead);
bufPtr->nextRemoved += bytesRead;
@@ -8743,26 +8742,12 @@ DoRead(
}
/*
- * 2) The buffer holds a \r while in CRLF translation, followed
- * by either the end of the buffer, or the eof char.
+ * 2) The buffer holds a \r while in CRLF translation,
+ * followed by the end of the buffer.
*/
assert(statePtr->inputTranslation == TCL_TRANSLATE_CRLF);
assert(RemovePoint(bufPtr)[0] == '\r');
-
- if (BytesLeft(bufPtr) > 1) {
-
- /* TODO: shift this to TIEOL */
- assert(statePtr->inEofChar);
- assert(RemovePoint(bufPtr)[1] == statePtr->inEofChar);
-
- bufPtr->nextRemoved++;
- *p++ = '\r';
- bytesToRead--;
- UpdateInterest(chanPtr);
- break;
- }
-
assert(BytesLeft(bufPtr) == 1);
if (bufPtr->nextPtr == NULL) {
@@ -8803,6 +8788,11 @@ DoRead(
}
RecycleBuffer(statePtr, bufPtr, 0);
}
+
+ if (statePtr->flags & CHANNEL_NONBLOCKING
+ && statePtr->flags & CHANNEL_BLOCKED) {
+ break;
+ }
}
return (int)(p - dst);