summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tcl.h2
-rw-r--r--generic/tclDecls.h5
-rw-r--r--generic/tclIO.c97
-rw-r--r--generic/tclIOCmd.c2
-rw-r--r--generic/tclIOGT.c28
-rw-r--r--generic/tclIORChan.c10
-rw-r--r--generic/tclIORTrans.c78
-rw-r--r--generic/tclZipfs.c40
-rw-r--r--unix/tclUnixChan.c9
-rw-r--r--unix/tclUnixSock.c30
-rw-r--r--win/tclWinChan.c9
-rw-r--r--win/tclWinSock.c30
12 files changed, 154 insertions, 186 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 2639d84..d8a28a5 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -1485,7 +1485,7 @@ typedef struct Tcl_ChannelType {
Tcl_DriverOutputProc *outputProc;
/* Function to call for output on channel. */
#ifdef TCL_NO_DEPRECATED
- void *notUsed;
+ struct something_undefined *notUsed;
#else
Tcl_DriverSeekProc *seekProc;
/* Function to call to seek on the channel.
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index f832f78..6e9b391 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -4172,9 +4172,4 @@ extern const TclStubs *tclStubsPtr;
#define Tcl_GlobalEvalObj(interp, objPtr) \
Tcl_EvalObjEx(interp, objPtr, TCL_EVAL_GLOBAL)
-#ifdef TCL_NO_DEPRECATED
-#undef Tcl_ChannelSeekProc
-#define Tcl_ChannelSeekProc Tcl_ChannelWideSeekProc
-#endif
-
#endif /* _TCLDECLS */
diff --git a/generic/tclIO.c b/generic/tclIO.c
index ad78287..fccc989 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,20 +490,23 @@ ChanSeek(
* type and non-NULL.
*/
+ if (Tcl_ChannelWideSeekProc(chanPtr->typePtr) == NULL) {
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(chanPtr->typePtr, TCL_CHANNEL_VERSION_3) ||
- chanPtr->typePtr->wideSeekProc == NULL) {
if (offset<LONG_MIN || offset>LONG_MAX) {
*errnoPtr = EOVERFLOW;
return -1;
}
- return chanPtr->typePtr->seekProc(chanPtr->instanceData,
+
+ return Tcl_ChannelSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
offset, mode, errnoPtr);
- }
+#else
+ *errnoPtr = EINVAL;
+ return -1;
#endif
+ }
- return chanPtr->typePtr->wideSeekProc(chanPtr->instanceData,
- offset, mode, errnoPtr);
+ return Tcl_ChannelWideSeekProc(chanPtr->typePtr)(chanPtr->instanceData,
+ offset, mode, errnoPtr);
}
static inline void
@@ -1641,6 +1642,19 @@ Tcl_CreateChannel(
if (NULL == typePtr->watchProc) {
Tcl_Panic("channel type %s must define watchProc", typePtr->typeName);
}
+#ifndef TCL_NO_DEPRECATED
+ if ((NULL!=typePtr->wideSeekProc) && (NULL == typePtr->seekProc)) {
+ Tcl_Panic("channel type %s must define seekProc if defining wideSeekProc", typePtr->typeName);
+ }
+#elif 1 /* TODO: Too strict for backwards compatibility, just make sure for the Tcl core for now. */
+ if (NULL != typePtr->notUsed) {
+ Tcl_Panic("channel type %s cannot have seekProc", typePtr->typeName);
+ }
+#else
+ if ((NULL!=typePtr->notUsed) && (NULL == typePtr->wideSeekProc)) {
+ Tcl_Panic("channel type %s must define wideSeekProc if defining seekProc", typePtr->typeName);
+ }
+#endif
/*
* JH: We could subsequently memset these to 0 to avoid the numerous
@@ -4213,9 +4227,9 @@ WillWrite(
{
int inputBuffered;
- if (((chanPtr->typePtr->wideSeekProc != NULL)
+ if (((Tcl_ChannelWideSeekProc(chanPtr->typePtr) != NULL)
#ifndef TCL_NO_DEPRECATED
- || (chanPtr->typePtr->seekProc != NULL)
+ || (Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL)
#endif
) && ((inputBuffered = Tcl_InputBuffered((Tcl_Channel) chanPtr)) > 0)){
int ignore;
@@ -4238,9 +4252,9 @@ WillRead(
Tcl_SetErrno(EINVAL);
return -1;
}
- if (((chanPtr->typePtr->wideSeekProc != NULL)
+ if (((Tcl_ChannelWideSeekProc(chanPtr->typePtr) != NULL)
#ifndef TCL_NO_DEPRECATED
- || (chanPtr->typePtr->seekProc != NULL)
+ || (Tcl_ChannelSeekProc(chanPtr->typePtr) != NULL)
#endif
) && (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) {
/*
@@ -7001,9 +7015,9 @@ Tcl_Seek(
* defined. This means that the channel does not support seeking.
*/
- if ((chanPtr->typePtr->wideSeekProc == NULL)
+ if ((Tcl_ChannelWideSeekProc(chanPtr->typePtr) == NULL)
#ifndef TCL_NO_DEPRECATED
- && (chanPtr->typePtr->seekProc == NULL)
+ && (Tcl_ChannelSeekProc(chanPtr->typePtr) == NULL)
#endif
) {
Tcl_SetErrno(EINVAL);
@@ -7169,11 +7183,11 @@ Tcl_Tell(
* defined. This means that the channel does not support seeking.
*/
- if ((chanPtr->typePtr->wideSeekProc == NULL)
+ if ((Tcl_ChannelWideSeekProc(chanPtr->typePtr) == NULL)
#ifndef TCL_NO_DEPRECATED
- && (chanPtr->typePtr->seekProc == NULL)
+ && (Tcl_ChannelSeekProc(chanPtr->typePtr) == NULL)
#endif
- ) {
+ ) {
Tcl_SetErrno(EINVAL);
return -1;
}
@@ -10512,8 +10526,8 @@ Tcl_ChannelVersion(
/* Pointer to channel type. */
{
#ifndef TCL_NO_DEPRECATED
- if ((chanTypePtr->version > (Tcl_ChannelTypeVersion) 0x7)
- || (chanTypePtr->version < (Tcl_ChannelTypeVersion) 0x1)) {
+ 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
@@ -10527,33 +10541,6 @@ Tcl_ChannelVersion(
/*
*----------------------------------------------------------------------
*
- * 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));
-}
-
-/*
- *----------------------------------------------------------------------
- *
* Tcl_ChannelBlockModeProc --
*
* Return the Tcl_DriverBlockModeProc of the channel type.
@@ -10572,7 +10559,7 @@ Tcl_ChannelBlockModeProc(
/* Pointer to channel type. */
{
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
/*
* The v1 structure had the blockModeProc in a different place.
*/
@@ -10678,7 +10665,6 @@ Tcl_ChannelOutputProc(
return chanTypePtr->outputProc;
}
-#ifndef TCL_NO_DEPRECATED
/*
*----------------------------------------------------------------------
*
@@ -10695,6 +10681,7 @@ Tcl_ChannelOutputProc(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
Tcl_DriverSeekProc *
Tcl_ChannelSeekProc(
const Tcl_ChannelType *chanTypePtr)
@@ -10822,7 +10809,7 @@ Tcl_ChannelFlushProc(
/* Pointer to channel type. */
{
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
return NULL;
}
#endif
@@ -10851,7 +10838,7 @@ Tcl_ChannelHandlerProc(
/* Pointer to channel type. */
{
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) {
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_2) {
return NULL;
}
#endif
@@ -10880,7 +10867,7 @@ Tcl_ChannelWideSeekProc(
/* Pointer to channel type. */
{
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_3)) {
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_3) {
return NULL;
}
#endif
@@ -10910,7 +10897,7 @@ Tcl_ChannelThreadActionProc(
/* Pointer to channel type. */
{
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) {
+ if (Tcl_ChannelVersion(chanTypePtr) < TCL_CHANNEL_VERSION_4) {
return NULL;
}
#endif
@@ -11226,10 +11213,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;
}
/*
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 271fc57..af276eb 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -711,7 +711,7 @@ Tcl_CloseObjCmd(
/*
* Special handling is needed if and only if the channel mode supports
* more than the direction to close. Because if the close the last
- * direction suppported we can and will go through the regular
+ * direction supported we can and will go through the regular
* process.
*/
diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c
index ee180fa..4195256 100644
--- a/generic/tclIOGT.c
+++ b/generic/tclIOGT.c
@@ -127,7 +127,7 @@ static const Tcl_ChannelType transformChannelType = {
#ifndef TCL_NO_DEPRECATED
TransformSeekProc, /* Seek proc. */
#else
- NULL,
+ NULL, /* Seek proc. */
#endif
TransformSetOptionProc, /* Set option proc. */
TransformGetOptionProc, /* Get option proc. */
@@ -814,7 +814,6 @@ TransformOutputProc(
return toWrite;
}
-#ifndef TCL_NO_DEPRECATED
/*
*----------------------------------------------------------------------
*
@@ -835,6 +834,7 @@ TransformOutputProc(
*----------------------------------------------------------------------
*/
+#ifndef TCL_NO_DEPRECATED
static int
TransformSeekProc(
ClientData instanceData, /* The channel to manipulate. */
@@ -845,7 +845,7 @@ TransformSeekProc(
TransformChannelData *dataPtr = instanceData;
Tcl_Channel parent = Tcl_GetStackedChannel(dataPtr->self);
const Tcl_ChannelType *parentType = Tcl_GetChannelType(parent);
- Tcl_DriverSeekProc *parentSeekProc = parentType->seekProc;
+ Tcl_DriverSeekProc *parentSeekProc = Tcl_ChannelSeekProc(parentType);
if ((offset == 0) && (mode == SEEK_CUR)) {
/*
@@ -914,7 +914,7 @@ TransformWideSeekProc(
Tcl_Channel parent = Tcl_GetStackedChannel(dataPtr->self);
const Tcl_ChannelType *parentType = Tcl_GetChannelType(parent);
#ifndef TCL_NO_DEPRECATED
- Tcl_DriverSeekProc *parentSeekProc = parentType->seekProc;
+ Tcl_DriverSeekProc *parentSeekProc = Tcl_ChannelSeekProc(parentType);
#endif
Tcl_DriverWideSeekProc *parentWideSeekProc =
Tcl_ChannelWideSeekProc(parentType);
@@ -926,13 +926,16 @@ TransformWideSeekProc(
* location. Simply pass the request down.
*/
+ if (parentWideSeekProc != NULL) {
+ return parentWideSeekProc(parentData, offset, mode, errorCodePtr);
#ifndef TCL_NO_DEPRECATED
- if (parentWideSeekProc == NULL) {
+ } else if (parentSeekProc) {
return parentSeekProc(parentData, 0, mode, errorCodePtr);
- }
#endif
-
- return parentWideSeekProc(parentData, offset, mode, errorCodePtr);
+ } else {
+ *errorCodePtr = EINVAL;
+ return -1;
+ }
}
/*
@@ -960,7 +963,6 @@ TransformWideSeekProc(
* If we have a wide seek capability, we should stick with that.
*/
-#ifndef TCL_NO_DEPRECATED
if (parentWideSeekProc == NULL) {
/*
* We're transferring to narrow seeks at this point; this is a bit complex
@@ -970,6 +972,7 @@ TransformWideSeekProc(
* to go out of the representable range.
*/
+#ifndef TCL_NO_DEPRECATED
if (offset<LONG_MIN || offset>LONG_MAX) {
*errorCodePtr = EOVERFLOW;
return -1;
@@ -977,9 +980,12 @@ TransformWideSeekProc(
return parentSeekProc(parentData, offset,
mode, errorCodePtr);
- }
+#else
+ *errorCodePtr = EINVAL;
+ return -1;
#endif
- return parentWideSeekProc(parentData, offset, mode, errorCodePtr);
+ }
+ return parentWideSeekProc(parentData, offset, mode, errorCodePtr);
}
/*
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 99dff63..3baf8f3 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -46,8 +46,10 @@ static int ReflectEventDelete(Tcl_Event *ev, ClientData cd);
#endif
static Tcl_WideInt ReflectSeekWide(ClientData clientData,
Tcl_WideInt offset, int mode, int *errorCodePtr);
+#ifndef TCL_NO_DEPRECATED
static int ReflectSeek(ClientData clientData, long offset,
int mode, int *errorCodePtr);
+#endif
static int ReflectGetOption(ClientData clientData,
Tcl_Interp *interp, const char *optionName,
Tcl_DString *dsPtr);
@@ -68,7 +70,11 @@ static const Tcl_ChannelType tclRChannelType = {
ReflectClose, /* Close channel, clean instance data */
ReflectInput, /* Handle read request */
ReflectOutput, /* Handle write request */
+#ifndef TCL_NO_DEPRECATED
ReflectSeek, /* Move location of access point. NULL'able */
+#else
+ NULL,
+#endif
ReflectSetOption, /* Set options. NULL'able */
ReflectGetOption, /* Get options. NULL'able */
ReflectWatch, /* Initialize notifier */
@@ -81,7 +87,7 @@ static const Tcl_ChannelType tclRChannelType = {
#if TCL_THREADS
ReflectThread, /* thread action, tracking owner */
#else
- NULL, /* thread action */
+ (void *)-1, /* thread action */
#endif
NULL /* truncate */
};
@@ -1616,6 +1622,7 @@ ReflectSeekWide(
goto stop;
}
+#ifndef TCL_NO_DEPRECATED
static int
ReflectSeek(
ClientData clientData,
@@ -1633,6 +1640,7 @@ ReflectSeek(
return ReflectSeekWide(clientData, offset, seekMode,
errorCodePtr);
}
+#endif
/*
*----------------------------------------------------------------------
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 8f6b079..70dd640 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -27,12 +27,6 @@
#define EOK 0
#endif
-/* DUPLICATE of HaveVersion() in tclIO.c // TODO - MODULE_SCOPE */
-#ifndef TCL_NO_DEPRECATED
-static int HaveVersion(const Tcl_ChannelType *typePtr,
- Tcl_ChannelTypeVersion minimumVersion);
-#endif
-
/*
* Signatures of all functions used in the C layer of the reflection.
*/
@@ -47,8 +41,10 @@ static void ReflectWatch(ClientData clientData, int mask);
static int ReflectBlock(ClientData clientData, int mode);
static Tcl_WideInt ReflectSeekWide(ClientData clientData,
Tcl_WideInt offset, int mode, int *errorCodePtr);
+#ifndef TCL_NO_DEPRECATED
static int ReflectSeek(ClientData clientData, long offset,
int mode, int *errorCodePtr);
+#endif
static int ReflectGetOption(ClientData clientData,
Tcl_Interp *interp, const char *optionName,
Tcl_DString *dsPtr);
@@ -69,7 +65,11 @@ static const Tcl_ChannelType tclRTransformType = {
ReflectClose, /* Close channel, clean instance data. */
ReflectInput, /* Handle read request. */
ReflectOutput, /* Handle write request. */
+#ifndef TCL_NO_DEPRECATED
ReflectSeek, /* Move location of access point. */
+#else
+ NULL, /* Move location of access point. */
+#endif
ReflectSetOption, /* Set options. */
ReflectGetOption, /* Get options. */
ReflectWatch, /* Initialize notifier. */
@@ -1333,22 +1333,6 @@ ReflectSeekWide(
Channel *parent = (Channel *) rtPtr->parent;
Tcl_WideInt curPos; /* Position on the device. */
- const Tcl_ChannelType *channelType =
- Tcl_GetChannelType(rtPtr->parent);
-
- /*
- * Fail if the parent channel is not seekable.
- */
-
- if ((channelType->wideSeekProc == NULL)
-#ifndef TCL_NO_DEPRECATED
- && (channelType->seekProc == NULL)
-#endif
- ) {
- Tcl_SetErrno(EINVAL);
- return -1;
- }
-
/*
* Check if we can leave out involving the Tcl level, i.e. transformation
* handler. This is true for tell requests, and transformations which
@@ -1392,25 +1376,24 @@ ReflectSeekWide(
* non-NULL...
*/
+ if (Tcl_ChannelWideSeekProc(parent->typePtr) == NULL) {
#ifndef TCL_NO_DEPRECATED
- if (!HaveVersion(parent->typePtr, TCL_CHANNEL_VERSION_3) ||
- parent->typePtr->wideSeekProc == NULL) {
if (offset < LONG_MIN || offset > LONG_MAX) {
*errorCodePtr = EOVERFLOW;
curPos = -1;
} else {
- curPos = parent->typePtr->seekProc(
- parent->instanceData, offset, seekMode,
+ curPos = Tcl_ChannelSeekProc(parent->typePtr)(
+ parent->instanceData, offset, seekMode,
errorCodePtr);
}
- } else {
- curPos = parent->typePtr->wideSeekProc(parent->instanceData, offset,
- seekMode, errorCodePtr);
- }
#else
- curPos = parent->typePtr->wideSeekProc(parent->instanceData, offset,
- seekMode, errorCodePtr);
+ *errorCodePtr = EINVAL;
+ curPos = -1;
#endif
+ } else {
+ curPos = Tcl_ChannelWideSeekProc(parent->typePtr)(parent->instanceData, offset,
+ seekMode, errorCodePtr);
+ }
if (curPos == -1) {
Tcl_SetErrno(*errorCodePtr);
}
@@ -1420,6 +1403,7 @@ ReflectSeekWide(
return curPos;
}
+#ifndef TCL_NO_DEPRECATED
static int
ReflectSeek(
ClientData clientData,
@@ -1437,6 +1421,7 @@ ReflectSeek(
return ReflectSeekWide(clientData, offset, seekMode,
errorCodePtr);
}
+#endif
/*
*----------------------------------------------------------------------
@@ -3403,35 +3388,6 @@ TransformLimit(
return 1;
}
-/* DUPLICATE of HaveVersion() in tclIO.c
- *----------------------------------------------------------------------
- *
- * 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.
- *
- *----------------------------------------------------------------------
- */
-
-#ifndef TCL_NO_DEPRECATED
-static int
-HaveVersion(
- const Tcl_ChannelType *chanTypePtr,
- Tcl_ChannelTypeVersion minimumVersion)
-{
- Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr);
-
- return PTR2INT(actualVersion) >= PTR2INT(minimumVersion);
-}
-#endif
-
/*
* Local Variables:
* mode: c
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 9aa26d9..4dce3f8 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -390,8 +390,12 @@ static int ZipChannelGetFile(void *instanceData,
int direction, void **handlePtr);
static int ZipChannelRead(void *instanceData, char *buf,
int toRead, int *errloc);
+#ifndef TCL_NO_DEPRECATED
static int ZipChannelSeek(void *instanceData, long offset,
int mode, int *errloc);
+#endif
+static Tcl_WideInt ZipChannelWideSeek(void *instanceData, Tcl_WideInt offset,
+ int mode, int *errloc);
static void ZipChannelWatchChannel(void *instanceData,
int mask);
static int ZipChannelWrite(void *instanceData,
@@ -445,7 +449,11 @@ static Tcl_ChannelType ZipChannelType = {
ZipChannelClose, /* Close channel, clean instance data */
ZipChannelRead, /* Handle read request */
ZipChannelWrite, /* Handle write request */
+#ifndef TCL_NO_DEPRECATED
ZipChannelSeek, /* Move location of access point, NULL'able */
+#else
+ NULL, /* Move location of access point, NULL'able */
+#endif
NULL, /* Set options, NULL'able */
NULL, /* Get options, NULL'able */
ZipChannelWatchChannel, /* Initialize notifier */
@@ -454,7 +462,7 @@ static Tcl_ChannelType ZipChannelType = {
NULL, /* Set blocking mode for raw channel, NULL'able */
NULL, /* Function to flush channel, NULL'able */
NULL, /* Function to handle event, NULL'able */
- NULL, /* Wide seek function, NULL'able */
+ ZipChannelWideSeek, /* Wide seek function, NULL'able */
NULL, /* Thread action function, NULL'able */
NULL, /* Truncate function, NULL'able */
};
@@ -3472,7 +3480,7 @@ ZipChannelWrite(
/*
*-------------------------------------------------------------------------
*
- * ZipChannelSeek --
+ * ZipChannelWideSeek --
*
* This function is called to position file pointer of channel.
*
@@ -3485,15 +3493,15 @@ ZipChannelWrite(
*-------------------------------------------------------------------------
*/
-static int
-ZipChannelSeek(
+static Tcl_WideInt
+ZipChannelWideSeek(
void *instanceData,
- long offset,
+ Tcl_WideInt offset,
int mode,
int *errloc)
{
ZipChannel *info = (ZipChannel *) instanceData;
- unsigned long end;
+ size_t end;
if (!info->isWriting && (info->isDirectory < 0)) {
/*
@@ -3525,20 +3533,32 @@ ZipChannelSeek(
return -1;
}
if (info->isWriting) {
- if ((unsigned long) offset > info->maxWrite) {
+ if ((size_t) offset > info->maxWrite) {
*errloc = EINVAL;
return -1;
}
- if ((unsigned long) offset > info->numBytes) {
+ if ((size_t) offset > info->numBytes) {
info->numBytes = offset;
}
- } else if ((unsigned long) offset > end) {
+ } else if ((size_t) offset > end) {
*errloc = EINVAL;
return -1;
}
- info->numRead = (unsigned long) offset;
+ info->numRead = (size_t) offset;
return info->numRead;
}
+
+#ifndef TCL_NO_DEPRECATED
+static int
+ZipChannelSeek(
+ void *instanceData,
+ long offset,
+ int mode,
+ int *errloc)
+{
+ return ZipChannelWideSeek(instanceData, offset, mode, errloc);
+}
+#endif
/*
*-------------------------------------------------------------------------
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 5e757ee..56a0276 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -128,8 +128,10 @@ static int FileInputProc(ClientData instanceData, char *buf,
int toRead, int *errorCode);
static int FileOutputProc(ClientData instanceData,
const char *buf, int toWrite, int *errorCode);
+#ifndef TCL_NO_DEPRECATED
static int FileSeekProc(ClientData instanceData, long offset,
int mode, int *errorCode);
+#endif
static int FileTruncateProc(ClientData instanceData,
Tcl_WideInt length);
static Tcl_WideInt FileWideSeekProc(ClientData instanceData,
@@ -164,7 +166,11 @@ static const Tcl_ChannelType fileChannelType = {
FileCloseProc, /* Close proc. */
FileInputProc, /* Input proc. */
FileOutputProc, /* Output proc. */
+#ifndef TCL_NO_DEPRECATED
FileSeekProc, /* Seek proc. */
+#else
+ NULL,
+#endif
NULL, /* Set option proc. */
NULL, /* Get option proc. */
FileWatchProc, /* Initialize notifier. */
@@ -432,7 +438,7 @@ TtyCloseProc(
*
*----------------------------------------------------------------------
*/
-
+#ifndef TCL_NO_DEPRECATED
static int
FileSeekProc(
ClientData instanceData, /* File state. */
@@ -473,6 +479,7 @@ FileSeekProc(
}
return (int) newLoc;
}
+#endif
/*
*----------------------------------------------------------------------
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 62e4756..57735da 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -686,32 +686,22 @@ TcpClose2Proc(
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = instanceData;
- int errorCode = 0;
- int sd;
+ int readError = 0;
+ int writeError = 0;
/*
* Shutdown the OS socket handle.
*/
-
- switch(flags) {
- case TCL_CLOSE_READ:
- sd = SHUT_RD;
- break;
- case TCL_CLOSE_WRITE:
- sd = SHUT_WR;
- break;
- default:
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "socket close2proc called bidirectionally", -1));
- }
- return TCL_ERROR;
+ if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) {
+ return TcpCloseProc(instanceData, interp);
}
- if (shutdown(statePtr->fds.fd,sd) < 0) {
- errorCode = errno;
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->fds.fd, SHUT_RD) < 0)) {
+ readError = errno;
}
-
- return errorCode;
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->fds.fd, SHUT_WR) < 0)) {
+ writeError = errno;
+ }
+ return (readError != 0) ? readError : writeError;
}
/*
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index b08db5d..829cc74 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -85,8 +85,10 @@ static int FileInputProc(ClientData instanceData, char *buf,
int toRead, int *errorCode);
static int FileOutputProc(ClientData instanceData,
const char *buf, int toWrite, int *errorCode);
+#ifndef TCL_NO_DEPRECATED
static int FileSeekProc(ClientData instanceData, long offset,
int mode, int *errorCode);
+#endif
static Tcl_WideInt FileWideSeekProc(ClientData instanceData,
Tcl_WideInt offset, int mode, int *errorCode);
static void FileSetupProc(ClientData clientData, int flags);
@@ -108,7 +110,11 @@ static const Tcl_ChannelType fileChannelType = {
FileCloseProc, /* Close proc. */
FileInputProc, /* Input proc. */
FileOutputProc, /* Output proc. */
+#ifndef TCL_NO_DEPRECATED
FileSeekProc, /* Seek proc. */
+#else
+ NULL,
+#endif
NULL, /* Set option proc. */
NULL, /* Get option proc. */
FileWatchProc, /* Set up the notifier to watch the channel. */
@@ -455,7 +461,7 @@ FileCloseProc(
*
*----------------------------------------------------------------------
*/
-
+#ifndef TCL_NO_DEPRECATED
static int
FileSeekProc(
ClientData instanceData, /* File state. */
@@ -515,6 +521,7 @@ FileSeekProc(
}
return (int) newPos;
}
+#endif
/*
*----------------------------------------------------------------------
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 61af337..8b42b9b 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -1136,26 +1136,15 @@ TcpClose2Proc(
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = instanceData;
- int errorCode = 0;
- int sd;
+ int readError = 0;
+ int writeError = 0;
/*
* Shutdown the OS socket handle.
*/
- switch(flags) {
- case TCL_CLOSE_READ:
- sd = SD_RECEIVE;
- break;
- case TCL_CLOSE_WRITE:
- sd = SD_SEND;
- break;
- default:
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "socket close2proc called bidirectionally", -1));
- }
- return TCL_ERROR;
+ if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) {
+ return TcpCloseProc(instanceData, interp);
}
/*
@@ -1163,12 +1152,15 @@ TcpClose2Proc(
* TCL_WRITABLE so this should never be called for a server socket.
*/
- if (shutdown(statePtr->sockets->fd, sd) == SOCKET_ERROR) {
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
TclWinConvertError((DWORD) WSAGetLastError());
- errorCode = Tcl_GetErrno();
+ readError = Tcl_GetErrno();
}
-
- return errorCode;
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR)) {
+ TclWinConvertError((DWORD) WSAGetLastError());
+ writeError = Tcl_GetErrno();
+ }
+ return (readError != 0) ? readError : writeError;
}
/*