diff options
author | dgp <dgp@users.sourceforge.net> | 2014-03-10 17:58:32 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-03-10 17:58:32 (GMT) |
commit | 091096d315755aa89f28bd063b426e16a4c16e51 (patch) | |
tree | 691ed08eb28757af01a9633bc250136dc942d260 | |
parent | 62268820f73d797eebfc2a66ed3fa856c27daeb7 (diff) | |
download | tcl-091096d315755aa89f28bd063b426e16a4c16e51.zip tcl-091096d315755aa89f28bd063b426e16a4c16e51.tar.gz tcl-091096d315755aa89f28bd063b426e16a4c16e51.tar.bz2 |
Bring CRLF translation in parallel with others.
-rw-r--r-- | generic/tclIO.c | 20 | ||||
-rw-r--r-- | tests/io.test | 14 |
2 files changed, 21 insertions, 13 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 6dfdd03..2971838 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -5645,21 +5645,15 @@ TranslateInputEOL( dstLen = srcLen; break; case TCL_TRANSLATE_CRLF: { - char *dst; - const char *src, *srcEnd, *srcMax; - - if (dstLen > srcLen) { - dstLen = srcLen; - } - dst = dstStart; - src = srcStart; - srcEnd = srcStart + dstLen; - srcMax = srcStart + srcLen; + const char *srcEnd = srcStart + srcLen; + const char *dstEnd = dstStart + dstLen; + const char *src = srcStart; + char *dst = dstStart; - for ( ; src < srcEnd; ) { + for ( ; dst < dstEnd && src < srcEnd; ) { if (*src == '\r') { src++; - if (src >= srcMax) { + if (src == srcEnd) { src--; break; } else if (*src == '\n') { @@ -5710,7 +5704,7 @@ TranslateInputEOL( *dstLenPtr = dstLen; *srcLenPtr = srcLen; - if ((eof != NULL) && (srcStart + srcLen >= eof)) { + if (srcStart + srcLen == eof) { /* * EOF character was seen in EOL translated range. Leave current file * position pointing at the EOF character, but don't store the EOF diff --git a/tests/io.test b/tests/io.test index c325809..e3fff32 100644 --- a/tests/io.test +++ b/tests/io.test @@ -6858,6 +6858,20 @@ test io-52.14 {coverage of -translation crlf} { close $out file size $path(test2) } 29 +test io-52.14.1 {coverage of -translation crlf} { + file delete $path(test1) $path(test2) + set out [open $path(test1) wb] + chan configure $out -translation lf + puts -nonewline $out abcdefg\rhijklmn\nopqrstu\r\nvwxyz + close $out + set in [open $path(test1)] + chan configure $in -buffersize 8 -translation crlf + set out [open $path(test2) w] + fcopy $in $out -size 2 + close $in + close $out + file size $path(test2) +} 2 test io-52.15 {coverage of -translation crlf} { file delete $path(test1) $path(test2) set out [open $path(test1) wb] |