summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2005-04-14 07:09:34 (GMT)
committerdavygrvy <davygrvy@pobox.com>2005-04-14 07:09:34 (GMT)
commita67b1b3bbeb88556675d7fde92fea842d50ef35f (patch)
tree45f3edbd2ca5e0a925aa37e989cdde6b5976ea97
parentf1157acccf54ea62a06c14c775142b095cfb2276 (diff)
downloadtcl-a67b1b3bbeb88556675d7fde92fea842d50ef35f.zip
tcl-a67b1b3bbeb88556675d7fde92fea842d50ef35f.tar.gz
tcl-a67b1b3bbeb88556675d7fde92fea842d50ef35f.tar.bz2
* generic/tclIO.c (Tcl_SetChannelBufferSize): Lowest size limit
* tests/io.test: changed from ten bytes to one byte. Need * tests/iogt.test: for this change was proven by Ross Cartlidge <rossc@cisco.com> where [read stdin 1] was grabbing 10 bytes followed by starting a child process that was intended to continue reading from stdin. Even with -buffersize set to one, nine chars were getting lost by the buffersize over reading for the native read() caused by [read].
-rw-r--r--ChangeLog11
-rw-r--r--generic/tclIO.c17
-rw-r--r--tests/io.test4
-rw-r--r--tests/iogt.test6
4 files changed, 25 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a78308..b4f0907 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-04-13 David Gravereaux <davygrvy@pobox.com>
+
+ * generic/tclIO.c (Tcl_SetChannelBufferSize): Lowest size limit
+ * tests/io.test: changed from ten bytes to one byte. Need
+ * tests/iogt.test: for this change was proven by
+ Ross Cartlidge <rossc@cisco.com> where [read stdin 1] was grabbing
+ 10 bytes followed by starting a child process that was intended to
+ continue reading from stdin. Even with -buffersize set to one,
+ nine chars were getting lost by the buffersize over reading for
+ the native read() caused by [read].
+
2005-04-12 Kevin B. Kenny <kennykb@acm.org>
* compat/strstr.c: Added default definition of NULL to
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 90451c1..46ebf28 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.9 2005/01/27 22:53:32 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.61.2.10 2005/04/14 07:10:06 davygrvy Exp $
*/
#include "tclInt.h"
@@ -5998,7 +5998,7 @@ Tcl_ChannelBuffered(chan)
* Tcl_SetChannelBufferSize --
*
* Sets the size of buffers to allocate to store input or output
- * in the channel. The size must be between 10 bytes and 1 MByte.
+ * in the channel. The size must be between 1 byte and 1 MByte.
*
* Results:
* None.
@@ -6018,11 +6018,11 @@ Tcl_SetChannelBufferSize(chan, sz)
ChannelState *statePtr; /* State of real channel structure. */
/*
- * If the buffer size is smaller than 10 bytes or larger than one MByte,
+ * 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.
*/
- if (sz < 10) {
+ if (sz < 1) {
return;
}
if (sz > (1024 * 1024)) {
@@ -6473,10 +6473,11 @@ Tcl_SetChannelOption(interp, chan, optionName, newValue)
return TCL_OK;
} else if ((len > 7) && (optionName[1] == 'b') &&
(strncmp(optionName, "-buffersize", len) == 0)) {
- statePtr->bufSize = atoi(newValue); /* INTL: "C", UTF safe. */
- if ((statePtr->bufSize < 10) || (statePtr->bufSize > (1024 * 1024))) {
- statePtr->bufSize = CHANNELBUFFER_DEFAULT_SIZE;
- }
+ int newBufferSize;
+ if (Tcl_GetInt(interp, newValue, &newBufferSize) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ Tcl_SetChannelBufferSize(chan, newBufferSize);
} else if ((len > 2) && (optionName[1] == 'e') &&
(strncmp(optionName, "-encoding", len) == 0)) {
Tcl_Encoding encoding;
diff --git a/tests/io.test b/tests/io.test
index ce9fce1..50ba5c6 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -12,7 +12,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.9 2005/01/27 22:53:34 andreas_kupries Exp $
+# RCS: @(#) $Id: io.test,v 1.40.2.10 2005/04/14 07:10:52 davygrvy Exp $
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
@@ -4816,7 +4816,7 @@ test io-38.2 {Tcl_SetChannelBufferSize, Tcl_GetChannelBufferSize} {
lappend l [fconfigure $f -buffersize]
close $f
set l
-} {4096 10000 4096 4096 4096 100000 4096}
+} {4096 10000 1 1 1 100000 100000}
test io-38.3 {Tcl_SetChannelBufferSize, changing buffersize between reads} {
# This test crashes the interp if Bug #427196 is not fixed
diff --git a/tests/iogt.test b/tests/iogt.test
index 2494b91..f64b49a 100644
--- a/tests/iogt.test
+++ b/tests/iogt.test
@@ -10,7 +10,7 @@
# Copyright (c) 2000 Andreas Kupries.
# All rights reserved.
#
-# RCS: @(#) $Id: iogt.test,v 1.7 2002/07/04 15:46:55 andreas_kupries Exp $
+# RCS: @(#) $Id: iogt.test,v 1.7.2.1 2005/04/14 07:10:57 davygrvy Exp $
if {[catch {package require tcltest 2.1}]} {
puts stderr "Skipping tests in [info script]. tcltest 2.1 required."
@@ -498,7 +498,7 @@ test iogt-2.1 {basic I/O, operation trail} {testchannel unixOnly} {
audit_ops aout -attach $fout
fconfigure $fin -buffersize 10
- fconfigure $fout -buffersize 5
+ fconfigure $fout -buffersize 10
fcopy $fin $fout
@@ -548,7 +548,7 @@ test iogt-2.2 {basic I/O, data trail} {testchannel unixOnly} {
audit_flow aout -attach $fout
fconfigure $fin -buffersize 10
- fconfigure $fout -buffersize 5
+ fconfigure $fout -buffersize 10
fcopy $fin $fout