From 199e87f5e360b10f877d2830dc15ea969dad655b Mon Sep 17 00:00:00 2001 From: andreas_kupries Date: Fri, 23 May 2008 21:12:10 +0000 Subject: * win/tclWinChan.c (FileWideSeekProc): Accepted a patch by Alexandre Ferrieux to fix the [Bug 1965787]. 'tell' now works for locations > 2 GB as well instead of going negative. * generic/tclIO.c (Tcl_SetChannelBufferSize): Accepted a patch by * tests/io.test: Alexandre Ferrieux to fix the [Bug 1969953]. Buffersize outside of the supported range are now clipped to nearest boundary instead of ignored. --- ChangeLog | 12 ++++++++++++ generic/tclIO.c | 16 ++++++++-------- tests/io.test | 12 ++++++------ win/tclWinChan.c | 4 ++-- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1b5f59..ca16ddd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-05-23 Andreas Kupries + + * win/tclWinChan.c (FileWideSeekProc): Accepted a patch by + Alexandre Ferrieux to fix the + [Bug 1965787]. 'tell' now works for locations > 2 GB as well + instead of going negative. + + * generic/tclIO.c (Tcl_SetChannelBufferSize): Accepted a patch by + * tests/io.test: Alexandre Ferrieux + to fix the [Bug 1969953]. Buffersize outside of the supported + range are now clipped to nearest boundary instead of ignored. + 2008-04-26 Zoran Vasiljevic * generic/tclAsync.c: Tcl_AsyncDelete(): panic if attempt diff --git a/generic/tclIO.c b/generic/tclIO.c index 6502215..866d70a 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.61.2.28 2008/04/15 18:31:01 andreas_kupries Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.61.2.29 2008/05/23 21:12:11 andreas_kupries Exp $ */ #include "tclInt.h" @@ -159,6 +159,8 @@ static int WriteChars _ANSI_ARGS_((Channel *chanPtr, #define BUSY_STATE(st,fl) \ ((((st)->csPtrR) && ((fl) & TCL_READABLE)) || \ (((st)->csPtrW) && ((fl) & TCL_WRITABLE))) + +#define MAX_CHANNEL_BUFFER_SIZE (1024*1024) /* *--------------------------------------------------------------------------- @@ -6157,15 +6159,13 @@ Tcl_SetChannelBufferSize(chan, sz) ChannelState *statePtr; /* State of real channel structure. */ /* - * If the buffer size is smaller than 1 byte or larger than one MByte, - * do not accept the requested size and leave the current buffer size. + * Clip the buffer size to force it into the [1,1M] range */ - + if (sz < 1) { - return; - } - if (sz > (1024 * 1024)) { - return; + sz = 1; + } else if (sz > MAX_CHANNEL_BUFFER_SIZE) { + sz = MAX_CHANNEL_BUFFER_SIZE; } statePtr = ((Channel *) chan)->state; diff --git a/tests/io.test b/tests/io.test index 00c0a55..9af72bd 100644 --- a/tests/io.test +++ b/tests/io.test @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: io.test,v 1.40.2.20 2008/04/15 18:31:03 andreas_kupries Exp $ +# RCS: @(#) $Id: io.test,v 1.40.2.21 2008/05/23 21:12:11 andreas_kupries Exp $ if {[catch {package require tcltest 2}]} { puts stderr "Skipping tests in [info script]. tcltest 2 required." @@ -4877,7 +4877,7 @@ test io-38.2 {Tcl_SetChannelBufferSize, Tcl_GetChannelBufferSize} { lappend l [fconfigure $f -buffersize] close $f set l -} {4096 10000 1 1 1 100000 100000} +} {4096 10000 1 1 1 100000 1048576} test io-38.3 {Tcl_SetChannelBufferSize, changing buffersize between reads} { # This test crashes the interp if Bug #427196 is not fixed @@ -5039,22 +5039,22 @@ test io-39.10 {Tcl_SetChannelOption, blocking mode} {stdio openpipe} { close $f1 set x } {0 {} 1 {} 1 {} 1 1 hi 0 0 {} 1} -test io-39.11 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size} { +test io-39.11 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size clipped to lower bound} { file delete $path(test1) set f [open $path(test1) w] fconfigure $f -buffersize -10 set x [fconfigure $f -buffersize] close $f set x -} 4096 -test io-39.12 {Tcl_SetChannelOption, Tcl_GetChannelOption buffer size} { +} 1 +test io-39.12 {Tcl_SetChannelOption, Tcl_GetChannelOption buffer size clipped to upper bound} { file delete $path(test1) set f [open $path(test1) w] fconfigure $f -buffersize 10000000 set x [fconfigure $f -buffersize] close $f set x -} 4096 +} 1048576 test io-39.13 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size} { file delete $path(test1) set f [open $path(test1) w] diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 90c13f7..51a1c08 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinChan.c,v 1.30.2.5 2006/08/30 17:53:28 hobbs Exp $ + * RCS: @(#) $Id: tclWinChan.c,v 1.30.2.6 2008/05/23 21:12:12 andreas_kupries Exp $ */ #include "tclWinInt.h" @@ -576,7 +576,7 @@ FileWideSeekProc(instanceData, offset, mode, errorCodePtr) return -1; } } - return ((Tcl_WideInt) newPos) | (((Tcl_WideInt) newPosHigh) << 32); + return (((Tcl_WideInt)((unsigned)newPos)) | (Tcl_LongAsWide(newPosHigh) << 32)); } /* -- cgit v0.12