diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-29 15:52:02 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-29 15:52:02 (GMT) |
commit | f85de8a933413038cc1f868fb450de8daa02e676 (patch) | |
tree | 0be23bd05bdbf316a794b816b89e6604c5630007 | |
parent | 667676a5510ccdd2fa569d14ebaccada0090393b (diff) | |
download | tcl-f85de8a933413038cc1f868fb450de8daa02e676.zip tcl-f85de8a933413038cc1f868fb450de8daa02e676.tar.gz tcl-f85de8a933413038cc1f868fb450de8daa02e676.tar.bz2 |
Deprecate channel types 1-4
-rw-r--r-- | generic/tcl.decls | 2 | ||||
-rw-r--r-- | generic/tcl.h | 10 | ||||
-rw-r--r-- | generic/tclDecls.h | 10 | ||||
-rw-r--r-- | generic/tclIO.c | 119 | ||||
-rw-r--r-- | generic/tclIOGT.c | 55 | ||||
-rw-r--r-- | generic/tclIORChan.c | 2 | ||||
-rw-r--r-- | generic/tclIORTrans.c | 39 | ||||
-rw-r--r-- | generic/tclStubInit.c | 1 |
8 files changed, 151 insertions, 87 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls index c9488bc..8a88a04 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1431,7 +1431,7 @@ declare 404 { Tcl_DriverOutputProc *Tcl_ChannelOutputProc( const Tcl_ChannelType *chanTypePtr) } -declare 405 { +declare 405 {deprecated {Use Tcl_ChannelWideSeekProc}} { Tcl_DriverSeekProc *Tcl_ChannelSeekProc( const Tcl_ChannelType *chanTypePtr) } diff --git a/generic/tcl.h b/generic/tcl.h index 85e52f4..2639d84 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -1400,10 +1400,12 @@ typedef void (Tcl_ScaleTimeProc) (Tcl_Time *timebuf, ClientData clientData); * Channel version tag. This was introduced in 8.3.2/8.4. */ +#ifndef TCL_NO_DEPRECATED #define TCL_CHANNEL_VERSION_1 ((Tcl_ChannelTypeVersion) 0x1) #define TCL_CHANNEL_VERSION_2 ((Tcl_ChannelTypeVersion) 0x2) #define TCL_CHANNEL_VERSION_3 ((Tcl_ChannelTypeVersion) 0x3) #define TCL_CHANNEL_VERSION_4 ((Tcl_ChannelTypeVersion) 0x4) +#endif #define TCL_CHANNEL_VERSION_5 ((Tcl_ChannelTypeVersion) 0x5) /* @@ -1426,8 +1428,12 @@ typedef int (Tcl_DriverInputProc) (ClientData instanceData, char *buf, int toRead, int *errorCodePtr); typedef int (Tcl_DriverOutputProc) (ClientData instanceData, const char *buf, int toWrite, int *errorCodePtr); +#ifndef TCL_NO_DEPRECATED typedef int (Tcl_DriverSeekProc) (ClientData instanceData, long offset, int mode, int *errorCodePtr); +#else +#define Tcl_DriverSeekProc Tcl_DriverWideSeekProc +#endif typedef int (Tcl_DriverSetOptionProc) (ClientData instanceData, Tcl_Interp *interp, const char *optionName, const char *value); @@ -1478,9 +1484,13 @@ typedef struct Tcl_ChannelType { /* Function to call for input on channel. */ Tcl_DriverOutputProc *outputProc; /* Function to call for output on channel. */ +#ifdef TCL_NO_DEPRECATED + void *notUsed; +#else Tcl_DriverSeekProc *seekProc; /* Function to call to seek on the channel. * May be NULL. */ +#endif Tcl_DriverSetOptionProc *setOptionProc; /* Set an option on a channel. */ Tcl_DriverGetOptionProc *getOptionProc; diff --git a/generic/tclDecls.h b/generic/tclDecls.h index c487521..f832f78 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1218,7 +1218,8 @@ EXTERN Tcl_DriverInputProc * Tcl_ChannelInputProc( EXTERN Tcl_DriverOutputProc * Tcl_ChannelOutputProc( const Tcl_ChannelType *chanTypePtr); /* 405 */ -EXTERN Tcl_DriverSeekProc * Tcl_ChannelSeekProc( +TCL_DEPRECATED("Use Tcl_ChannelWideSeekProc") +Tcl_DriverSeekProc * Tcl_ChannelSeekProc( const Tcl_ChannelType *chanTypePtr); /* 406 */ EXTERN Tcl_DriverSetOptionProc * Tcl_ChannelSetOptionProc( @@ -2359,7 +2360,7 @@ typedef struct TclStubs { Tcl_DriverClose2Proc * (*tcl_ChannelClose2Proc) (const Tcl_ChannelType *chanTypePtr); /* 402 */ Tcl_DriverInputProc * (*tcl_ChannelInputProc) (const Tcl_ChannelType *chanTypePtr); /* 403 */ Tcl_DriverOutputProc * (*tcl_ChannelOutputProc) (const Tcl_ChannelType *chanTypePtr); /* 404 */ - Tcl_DriverSeekProc * (*tcl_ChannelSeekProc) (const Tcl_ChannelType *chanTypePtr); /* 405 */ + TCL_DEPRECATED_API("Use Tcl_ChannelWideSeekProc") Tcl_DriverSeekProc * (*tcl_ChannelSeekProc) (const Tcl_ChannelType *chanTypePtr); /* 405 */ Tcl_DriverSetOptionProc * (*tcl_ChannelSetOptionProc) (const Tcl_ChannelType *chanTypePtr); /* 406 */ Tcl_DriverGetOptionProc * (*tcl_ChannelGetOptionProc) (const Tcl_ChannelType *chanTypePtr); /* 407 */ Tcl_DriverWatchProc * (*tcl_ChannelWatchProc) (const Tcl_ChannelType *chanTypePtr); /* 408 */ @@ -4171,4 +4172,9 @@ 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 643b8f1..ad78287 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -492,18 +492,19 @@ ChanSeek( * type and non-NULL. */ - if (HaveVersion(chanPtr->typePtr, TCL_CHANNEL_VERSION_3) && - chanPtr->typePtr->wideSeekProc != NULL) { - return chanPtr->typePtr->wideSeekProc(chanPtr->instanceData, +#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, offset, mode, errnoPtr); } +#endif - if (offset<LONG_MIN || offset>LONG_MAX) { - *errnoPtr = EOVERFLOW; - return -1; - } - - return chanPtr->typePtr->seekProc(chanPtr->instanceData, + return chanPtr->typePtr->wideSeekProc(chanPtr->instanceData, offset, mode, errnoPtr); } @@ -1640,9 +1641,6 @@ Tcl_CreateChannel( if (NULL == typePtr->watchProc) { Tcl_Panic("channel type %s must define watchProc", typePtr->typeName); } - if ((NULL!=typePtr->wideSeekProc) && (NULL == typePtr->seekProc)) { - Tcl_Panic("channel type %s must define seekProc if defining wideSeekProc", typePtr->typeName); - } /* * JH: We could subsequently memset these to 0 to avoid the numerous @@ -4215,12 +4213,15 @@ WillWrite( { int inputBuffered; - if ((chanPtr->typePtr->seekProc != NULL) && - ((inputBuffered = Tcl_InputBuffered((Tcl_Channel) chanPtr)) > 0)){ - int ignore; + if (((chanPtr->typePtr->wideSeekProc != NULL) +#ifndef TCL_NO_DEPRECATED + || (chanPtr->typePtr->seekProc != NULL) +#endif + ) && ((inputBuffered = Tcl_InputBuffered((Tcl_Channel) chanPtr)) > 0)){ + int ignore; - DiscardInputQueued(chanPtr->state, 0); - ChanSeek(chanPtr, -inputBuffered, SEEK_CUR, &ignore); + DiscardInputQueued(chanPtr->state, 0); + ChanSeek(chanPtr, -inputBuffered, SEEK_CUR, &ignore); } } @@ -4237,8 +4238,11 @@ WillRead( Tcl_SetErrno(EINVAL); return -1; } - if ((chanPtr->typePtr->seekProc != NULL) - && (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) { + if (((chanPtr->typePtr->wideSeekProc != NULL) +#ifndef TCL_NO_DEPRECATED + || (chanPtr->typePtr->seekProc != NULL) +#endif + ) && (Tcl_OutputBuffered((Tcl_Channel) chanPtr) > 0)) { /* * CAVEAT - The assumption here is that FlushChannel() will push out * the bytes of any writes that are in progress. Since this is a @@ -6997,7 +7001,11 @@ Tcl_Seek( * defined. This means that the channel does not support seeking. */ - if (chanPtr->typePtr->seekProc == NULL) { + if ((chanPtr->typePtr->wideSeekProc == NULL) +#ifndef TCL_NO_DEPRECATED + && (chanPtr->typePtr->seekProc == NULL) +#endif + ) { Tcl_SetErrno(EINVAL); return -1; } @@ -7161,7 +7169,11 @@ Tcl_Tell( * defined. This means that the channel does not support seeking. */ - if (chanPtr->typePtr->seekProc == NULL) { + if ((chanPtr->typePtr->wideSeekProc == NULL) +#ifndef TCL_NO_DEPRECATED + && (chanPtr->typePtr->seekProc == NULL) +#endif + ) { Tcl_SetErrno(EINVAL); return -1; } @@ -10499,22 +10511,17 @@ 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 { +#ifndef TCL_NO_DEPRECATED + if ((chanTypePtr->version > (Tcl_ChannelTypeVersion) 0x7) + || (chanTypePtr->version < (Tcl_ChannelTypeVersion) 0x1)) { /* * In <v2 channel versions, the version field is occupied by the * Tcl_DriverBlockModeProc */ - return TCL_CHANNEL_VERSION_1; } +#endif + return chanTypePtr->version; } /* @@ -10564,15 +10571,15 @@ Tcl_ChannelBlockModeProc( const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { - if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { - return chanTypePtr->blockModeProc; +#ifndef TCL_NO_DEPRECATED + if (!HaveVersion(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; +#endif + return chanTypePtr->blockModeProc; } /* @@ -10671,6 +10678,7 @@ Tcl_ChannelOutputProc( return chanTypePtr->outputProc; } +#ifndef TCL_NO_DEPRECATED /* *---------------------------------------------------------------------- * @@ -10694,6 +10702,7 @@ Tcl_ChannelSeekProc( { return chanTypePtr->seekProc; } +#endif /* *---------------------------------------------------------------------- @@ -10812,10 +10821,12 @@ Tcl_ChannelFlushProc( const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { - if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { - return chanTypePtr->flushProc; +#ifndef TCL_NO_DEPRECATED + if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { + return NULL; } - return NULL; +#endif + return chanTypePtr->flushProc; } /* @@ -10839,10 +10850,12 @@ Tcl_ChannelHandlerProc( const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { - if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { - return chanTypePtr->handlerProc; +#ifndef TCL_NO_DEPRECATED + if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { + return NULL; } - return NULL; +#endif + return chanTypePtr->handlerProc; } /* @@ -10866,10 +10879,12 @@ Tcl_ChannelWideSeekProc( const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { - if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_3)) { - return chanTypePtr->wideSeekProc; +#ifndef TCL_NO_DEPRECATED + if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_3)) { + return NULL; } - return NULL; +#endif + return chanTypePtr->wideSeekProc; } /* @@ -10894,10 +10909,12 @@ Tcl_ChannelThreadActionProc( const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { - if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) { - return chanTypePtr->threadActionProc; +#ifndef TCL_NO_DEPRECATED + if (!HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) { + return NULL; } - return NULL; +#endif + return chanTypePtr->threadActionProc; } /* diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c index 9949a0e..ee180fa 100644 --- a/generic/tclIOGT.c +++ b/generic/tclIOGT.c @@ -27,8 +27,10 @@ static int TransformInputProc(ClientData instanceData, char *buf, int toRead, int *errorCodePtr); static int TransformOutputProc(ClientData instanceData, const char *buf, int toWrite, int *errorCodePtr); +#ifndef TCL_NO_DEPRECATED static int TransformSeekProc(ClientData instanceData, long offset, int mode, int *errorCodePtr); +#endif static int TransformSetOptionProc(ClientData instanceData, Tcl_Interp *interp, const char *optionName, const char *value); @@ -122,7 +124,11 @@ static const Tcl_ChannelType transformChannelType = { TransformCloseProc, /* Close proc. */ TransformInputProc, /* Input proc. */ TransformOutputProc, /* Output proc. */ +#ifndef TCL_NO_DEPRECATED TransformSeekProc, /* Seek proc. */ +#else + NULL, +#endif TransformSetOptionProc, /* Set option proc. */ TransformGetOptionProc, /* Get option proc. */ TransformWatchProc, /* Initialize notifier. */ @@ -808,6 +814,7 @@ TransformOutputProc( return toWrite; } +#ifndef TCL_NO_DEPRECATED /* *---------------------------------------------------------------------- * @@ -838,7 +845,7 @@ TransformSeekProc( TransformChannelData *dataPtr = instanceData; Tcl_Channel parent = Tcl_GetStackedChannel(dataPtr->self); const Tcl_ChannelType *parentType = Tcl_GetChannelType(parent); - Tcl_DriverSeekProc *parentSeekProc = Tcl_ChannelSeekProc(parentType); + Tcl_DriverSeekProc *parentSeekProc = parentType->seekProc; if ((offset == 0) && (mode == SEEK_CUR)) { /* @@ -874,6 +881,7 @@ TransformSeekProc( return parentSeekProc(Tcl_GetChannelInstanceData(parent), offset, mode, errorCodePtr); } +#endif /* *---------------------------------------------------------------------- @@ -905,7 +913,9 @@ TransformWideSeekProc( TransformChannelData *dataPtr = instanceData; Tcl_Channel parent = Tcl_GetStackedChannel(dataPtr->self); const Tcl_ChannelType *parentType = Tcl_GetChannelType(parent); - Tcl_DriverSeekProc *parentSeekProc = Tcl_ChannelSeekProc(parentType); +#ifndef TCL_NO_DEPRECATED + Tcl_DriverSeekProc *parentSeekProc = parentType->seekProc; +#endif Tcl_DriverWideSeekProc *parentWideSeekProc = Tcl_ChannelWideSeekProc(parentType); ClientData parentData = Tcl_GetChannelInstanceData(parent); @@ -916,11 +926,13 @@ TransformWideSeekProc( * location. Simply pass the request down. */ - if (parentWideSeekProc != NULL) { - return parentWideSeekProc(parentData, offset, mode, errorCodePtr); +#ifndef TCL_NO_DEPRECATED + if (parentWideSeekProc == NULL) { + return parentSeekProc(parentData, 0, mode, errorCodePtr); } +#endif - return parentSeekProc(parentData, 0, mode, errorCodePtr); + return parentWideSeekProc(parentData, offset, mode, errorCodePtr); } /* @@ -948,25 +960,26 @@ TransformWideSeekProc( * If we have a wide seek capability, we should stick with that. */ - if (parentWideSeekProc != NULL) { - return parentWideSeekProc(parentData, offset, mode, errorCodePtr); - } +#ifndef TCL_NO_DEPRECATED + if (parentWideSeekProc == NULL) { + /* + * We're transferring to narrow seeks at this point; this is a bit complex + * because we have to check whether the seek is possible first (i.e. + * whether we are losing information in truncating the bits of the + * offset). Luckily, there's a defined error for what happens when trying + * to go out of the representable range. + */ - /* - * We're transferring to narrow seeks at this point; this is a bit complex - * because we have to check whether the seek is possible first (i.e. - * whether we are losing information in truncating the bits of the - * offset). Luckily, there's a defined error for what happens when trying - * to go out of the representable range. - */ + if (offset<LONG_MIN || offset>LONG_MAX) { + *errorCodePtr = EOVERFLOW; + return -1; + } - if (offset<LONG_MIN || offset>LONG_MAX) { - *errorCodePtr = EOVERFLOW; - return -1; + return parentSeekProc(parentData, offset, + mode, errorCodePtr); } - - return parentSeekProc(parentData, offset, - mode, errorCodePtr); +#endif + return parentWideSeekProc(parentData, offset, mode, errorCodePtr); } /* diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 1d90def..99dff63 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -696,7 +696,9 @@ TclChanCreateObjCmd( clonePtr->blockModeProc = NULL; } if (!(methods & FLAG(METH_SEEK))) { +#ifndef TCL_NO_DEPRECATED clonePtr->seekProc = NULL; +#endif clonePtr->wideSeekProc = NULL; } diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 8385d88..8f6b079 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -28,8 +28,10 @@ #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. @@ -1331,14 +1333,18 @@ ReflectSeekWide( Channel *parent = (Channel *) rtPtr->parent; Tcl_WideInt curPos; /* Position on the device. */ - Tcl_DriverSeekProc *seekProc = - Tcl_ChannelSeekProc(Tcl_GetChannelType(rtPtr->parent)); + const Tcl_ChannelType *channelType = + Tcl_GetChannelType(rtPtr->parent); /* * Fail if the parent channel is not seekable. */ - if (seekProc == NULL) { + if ((channelType->wideSeekProc == NULL) +#ifndef TCL_NO_DEPRECATED + && (channelType->seekProc == NULL) +#endif + ) { Tcl_SetErrno(EINVAL); return -1; } @@ -1386,18 +1392,25 @@ ReflectSeekWide( * non-NULL... */ - if (HaveVersion(parent->typePtr, TCL_CHANNEL_VERSION_3) && - parent->typePtr->wideSeekProc != 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, + errorCodePtr); + } + } else { curPos = parent->typePtr->wideSeekProc(parent->instanceData, offset, seekMode, errorCodePtr); - } else if (offset < LONG_MIN || offset > LONG_MAX) { - *errorCodePtr = EOVERFLOW; - curPos = -1; - } else { - curPos = parent->typePtr->seekProc( - parent->instanceData, offset, seekMode, - errorCodePtr); } +#else + curPos = parent->typePtr->wideSeekProc(parent->instanceData, offset, + seekMode, errorCodePtr); +#endif if (curPos == -1) { Tcl_SetErrno(*errorCodePtr); } @@ -3407,6 +3420,7 @@ TransformLimit( *---------------------------------------------------------------------- */ +#ifndef TCL_NO_DEPRECATED static int HaveVersion( const Tcl_ChannelType *chanTypePtr, @@ -3416,6 +3430,7 @@ HaveVersion( return PTR2INT(actualVersion) >= PTR2INT(minimumVersion); } +#endif /* * Local Variables: diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 6a588a5..927f1d0 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -256,6 +256,7 @@ mp_err TclBN_mp_mul_d(const mp_int *a, unsigned int b, mp_int *c) { # define Tcl_DbNewLongObj 0 # define Tcl_BackgroundError 0 # define Tcl_FreeResult 0 +# define Tcl_ChannelSeekProc 0 #else mp_err TclBN_mp_div_3(const mp_int *a, mp_int *c, unsigned int *d) { |