diff options
| -rw-r--r-- | generic/tclDecls.h | 2 | ||||
| -rw-r--r-- | unix/tclUnixChan.c | 24 | ||||
| -rw-r--r-- | unix/tclUnixPipe.c | 27 |
3 files changed, 41 insertions, 12 deletions
diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 65444fa..78eba87 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -4149,6 +4149,7 @@ extern const TclStubs *tclStubsPtr; # define Tcl_Init(interp) (tclStubsPtr->tcl_Init(interp)) # define Tcl_ObjSetVar2(interp, part1, part2, newValue, flags) \ (tclStubsPtr->tcl_ObjSetVar2(interp, part1, part2, newValue, flags)) +#ifndef __cplusplus # undef Tcl_EventuallyFree # define Tcl_EventuallyFree \ ((void (*)(void *,void *))(void *)(tclStubsPtr->tcl_EventuallyFree)) /* 132 */ @@ -4156,6 +4157,7 @@ extern const TclStubs *tclStubsPtr; # define Tcl_SetResult \ ((void (*)(Tcl_Interp *, char *, void *))(void *)(tclStubsPtr->tcl_SetResult)) /* 232 */ #endif +#endif #if defined(_WIN32) && defined(UNICODE) # if defined(TCL_NO_DEPRECATED) diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 8785ff7..696d938 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -286,7 +286,7 @@ FileInputProc( */ do { - bytesRead = read(fsPtr->fd, buf, (size_t)toRead); + bytesRead = read(fsPtr->fd, buf, toRead); } while ((bytesRead < 0) && (errno == EINTR)); if (bytesRead < 0) { @@ -335,7 +335,7 @@ FileOutputProc( return 0; } - written = write(fsPtr->fd, buf, (size_t)toWrite); + written = write(fsPtr->fd, buf, toWrite); if (written >= 0) { return written; } @@ -549,6 +549,20 @@ FileWideSeekProc( *---------------------------------------------------------------------- */ +/* + * Bug ad5a57f2f271: Tcl_NotifyChannel is not a Tcl_FileProc, + * so do not pass it to directly to Tcl_CreateFileHandler. + * Instead, pass a wrapper which is a Tcl_FileProc. + */ +static void +FileWatchNotifyChannelWrapper( + void *clientData, + int mask) +{ + Tcl_Channel channel = (Tcl_Channel)clientData; + Tcl_NotifyChannel(channel, mask); +} + static void FileWatchProc( void *instanceData, /* The file state. */ @@ -559,15 +573,13 @@ FileWatchProc( FileState *fsPtr = (FileState *)instanceData; /* - * Make sure we only register for events that are valid on this file. Note - * that we are passing Tcl_NotifyChannel directly to Tcl_CreateFileHandler - * with the channel pointer as the client data. + * Make sure we only register for events that are valid on this file. */ mask &= fsPtr->validMask; if (mask) { Tcl_CreateFileHandler(fsPtr->fd, mask, - (Tcl_FileProc *) Tcl_NotifyChannel, fsPtr->channel); + FileWatchNotifyChannelWrapper, fsPtr->channel); } else { Tcl_DeleteFileHandler(fsPtr->fd); } diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 92cd168..63e576b 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -421,7 +421,8 @@ TclpCreateProcess( char errSpace[200 + TCL_INTEGER_SPACE]; Tcl_DString *dsArray; char **newArgv; - int pid, i; + int pid; + int i; #if defined(HAVE_POSIX_SPAWNP) int childErrno; static int use_spawn = -1; @@ -608,7 +609,7 @@ TclpCreateProcess( errPipeOut = NULL; fd = GetFd(errPipeIn); - count = read(fd, errSpace, (size_t) (sizeof(errSpace) - 1)); + count = read(fd, errSpace, sizeof(errSpace) - 1); if (count > 0) { char *end; @@ -1142,7 +1143,7 @@ PipeInputProc( */ do { - bytesRead = read(GetFd(psPtr->inFile), buf, (size_t) toRead); + bytesRead = read(GetFd(psPtr->inFile), buf, toRead); } while ((bytesRead < 0) && (errno == EINTR)); if (bytesRead < 0) { @@ -1188,7 +1189,7 @@ PipeOutputProc( */ do { - written = write(GetFd(psPtr->outFile), buf, (size_t) toWrite); + written = write(GetFd(psPtr->outFile), buf, toWrite); } while ((written < 0) && (errno == EINTR)); if (written < 0) { @@ -1215,6 +1216,20 @@ PipeOutputProc( *---------------------------------------------------------------------- */ +/* + * Bug ad5a57f2f271: Tcl_NotifyChannel is not a Tcl_FileProc, + * so do not pass it to directly to Tcl_CreateFileHandler. + * Instead, pass a wrapper which is a Tcl_FileProc. + */ +static void +PipeWatchNotifyChannelWrapper( + void *clientData, + int mask) +{ + Tcl_Channel channel = (Tcl_Channel)clientData; + Tcl_NotifyChannel(channel, mask); +} + static void PipeWatchProc( void *instanceData, /* The pipe state. */ @@ -1229,7 +1244,7 @@ PipeWatchProc( newmask = mask & (TCL_READABLE | TCL_EXCEPTION); if (newmask) { Tcl_CreateFileHandler(GetFd(psPtr->inFile), newmask, - (Tcl_FileProc *) Tcl_NotifyChannel, psPtr->channel); + PipeWatchNotifyChannelWrapper, psPtr->channel); } else { Tcl_DeleteFileHandler(GetFd(psPtr->inFile)); } @@ -1238,7 +1253,7 @@ PipeWatchProc( newmask = mask & (TCL_WRITABLE | TCL_EXCEPTION); if (newmask) { Tcl_CreateFileHandler(GetFd(psPtr->outFile), newmask, - (Tcl_FileProc *) Tcl_NotifyChannel, psPtr->channel); + PipeWatchNotifyChannelWrapper, psPtr->channel); } else { Tcl_DeleteFileHandler(GetFd(psPtr->outFile)); } |
