summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-01-30 13:21:38 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-01-30 13:21:38 (GMT)
commit64fdac4aec06a54d95bb8916c7a8e3cebf2cde20 (patch)
tree4facd544ce40b633d4c88f9300cbeae31fb012f9 /generic/tclIO.c
parent667676a5510ccdd2fa569d14ebaccada0090393b (diff)
parentee66478056af217424f2052723fbd89ee0d0f933 (diff)
downloadtcl-64fdac4aec06a54d95bb8916c7a8e3cebf2cde20.zip
tcl-64fdac4aec06a54d95bb8916c7a8e3cebf2cde20.tar.gz
tcl-64fdac4aec06a54d95bb8916c7a8e3cebf2cde20.tar.bz2
Merge 8.6
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c100
1 files changed, 31 insertions, 69 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 643b8f1..99d7010 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -204,8 +204,6 @@ static Tcl_Encoding GetBinaryEncoding();
static void FreeBinaryEncoding(ClientData clientData);
static Tcl_HashTable * GetChannelTable(Tcl_Interp *interp);
static int GetInput(Channel *chanPtr);
-static int HaveVersion(const Tcl_ChannelType *typePtr,
- Tcl_ChannelTypeVersion minimumVersion);
static void PeekAhead(Channel *chanPtr, char **dstEndPtr,
GetsState *gsPtr);
static int ReadBytes(ChannelState *statePtr, Tcl_Obj *objPtr,
@@ -492,9 +490,8 @@ ChanSeek(
* type and non-NULL.
*/
- if (HaveVersion(chanPtr->typePtr, TCL_CHANNEL_VERSION_3) &&
- chanPtr->typePtr->wideSeekProc != NULL) {
- return chanPtr->typePtr->wideSeekProc(chanPtr->instanceData,
+ if (Tcl_ChannelWideSeekProc(chanPtr->typePtr) != NULL) {
+ return Tcl_ChannelWideSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
offset, mode, errnoPtr);
}
@@ -503,7 +500,7 @@ ChanSeek(
return -1;
}
- return chanPtr->typePtr->seekProc(chanPtr->instanceData,
+ return Tcl_ChannelSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
offset, mode, errnoPtr);
}
@@ -4215,7 +4212,7 @@ WillWrite(
{
int inputBuffered;
- if ((chanPtr->typePtr->seekProc != NULL) &&
+ if ((Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL) &&
((inputBuffered = Tcl_InputBuffered((Tcl_Channel) chanPtr)) > 0)){
int ignore;
@@ -4237,7 +4234,7 @@ WillRead(
Tcl_SetErrno(EINVAL);
return -1;
}
- if ((chanPtr->typePtr->seekProc != NULL)
+ if ((Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL)
&& (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) {
/*
* CAVEAT - The assumption here is that FlushChannel() will push out
@@ -6997,7 +6994,7 @@ Tcl_Seek(
* defined. This means that the channel does not support seeking.
*/
- if (chanPtr->typePtr->seekProc == NULL) {
+ if (Tcl_ChannelSeekProc(chanPtr->typePtr) == NULL) {
Tcl_SetErrno(EINVAL);
return -1;
}
@@ -7161,7 +7158,7 @@ Tcl_Tell(
* defined. This means that the channel does not support seeking.
*/
- if (chanPtr->typePtr->seekProc == NULL) {
+ if (Tcl_ChannelSeekProc(chanPtr->typePtr) == NULL) {
Tcl_SetErrno(EINVAL);
return -1;
}
@@ -10499,49 +10496,15 @@ Tcl_ChannelVersion(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (chanTypePtr->version == TCL_CHANNEL_VERSION_2) {
- return TCL_CHANNEL_VERSION_2;
- } else if (chanTypePtr->version == TCL_CHANNEL_VERSION_3) {
- return TCL_CHANNEL_VERSION_3;
- } else if (chanTypePtr->version == TCL_CHANNEL_VERSION_4) {
- return TCL_CHANNEL_VERSION_4;
- } else if (chanTypePtr->version == TCL_CHANNEL_VERSION_5) {
- return TCL_CHANNEL_VERSION_5;
- } else {
+ if ((chanTypePtr->version < TCL_CHANNEL_VERSION_2)
+ || (chanTypePtr->version > TCL_CHANNEL_VERSION_5)) {
/*
* In <v2 channel versions, the version field is occupied by the
* Tcl_DriverBlockModeProc
*/
-
return TCL_CHANNEL_VERSION_1;
}
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * HaveVersion --
- *
- * Return whether a channel type is (at least) of a given version.
- *
- * Results:
- * True if the minimum version is exceeded by the version actually
- * present.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-HaveVersion(
- const Tcl_ChannelType *chanTypePtr,
- Tcl_ChannelTypeVersion minimumVersion)
-{
- Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr);
-
- return (PTR2INT(actualVersion)) >= (PTR2INT(minimumVersion));
+ return chanTypePtr->version;
}
/*
@@ -10564,15 +10527,14 @@ Tcl_ChannelBlockModeProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
- return chanTypePtr->blockModeProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
+ /*
+ * The v1 structure had the blockModeProc in a different place.
+ */
+ return (Tcl_DriverBlockModeProc *) chanTypePtr->version;
}
- /*
- * The v1 structure had the blockModeProc in a different place.
- */
-
- return (Tcl_DriverBlockModeProc *) chanTypePtr->version;
+ return chanTypePtr->blockModeProc;
}
/*
@@ -10812,10 +10774,10 @@ Tcl_ChannelFlushProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
- return chanTypePtr->flushProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->flushProc;
}
/*
@@ -10839,10 +10801,10 @@ Tcl_ChannelHandlerProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
- return chanTypePtr->handlerProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->handlerProc;
}
/*
@@ -10866,10 +10828,10 @@ Tcl_ChannelWideSeekProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_3)) {
- return chanTypePtr->wideSeekProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_3) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->wideSeekProc;
}
/*
@@ -10894,10 +10856,10 @@ Tcl_ChannelThreadActionProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) {
- return chanTypePtr->threadActionProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_4) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->threadActionProc;
}
/*
@@ -11209,10 +11171,10 @@ Tcl_ChannelTruncateProc(
const Tcl_ChannelType *chanTypePtr)
/* Pointer to channel type. */
{
- if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_5)) {
- return chanTypePtr->truncateProc;
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_5) {
+ return NULL;
}
- return NULL;
+ return chanTypePtr->truncateProc;
}
/*