diff options
-rw-r--r-- | ChangeLog | 67 | ||||
-rw-r--r-- | doc/Ensemble.3 | 2 | ||||
-rw-r--r-- | doc/dde.n | 8 | ||||
-rw-r--r-- | doc/expr.n | 15 | ||||
-rw-r--r-- | doc/mathop.n | 15 | ||||
-rw-r--r-- | doc/namespace.n | 5 | ||||
-rw-r--r-- | generic/tcl.decls | 8 | ||||
-rw-r--r-- | generic/tclDecls.h | 6 | ||||
-rw-r--r-- | generic/tclIO.c | 7 | ||||
-rw-r--r-- | generic/tclIO.h | 7 | ||||
-rw-r--r-- | generic/tclIORTrans.c | 3 | ||||
-rw-r--r-- | generic/tclInt.decls | 145 | ||||
-rw-r--r-- | generic/tclIntPlatDecls.h | 466 | ||||
-rw-r--r-- | generic/tclStubInit.c | 191 | ||||
-rw-r--r-- | generic/tclTimer.c | 9 | ||||
-rw-r--r-- | generic/tclZlib.c | 8 | ||||
-rw-r--r-- | library/safe.tcl | 16 | ||||
-rw-r--r-- | tests/safe.test | 48 | ||||
-rw-r--r-- | tools/genStubs.tcl | 28 | ||||
-rw-r--r-- | win/Makefile.in | 12 | ||||
-rw-r--r-- | win/tclWinDde.c | 148 | ||||
-rw-r--r-- | win/tclWinSock.c | 23 |
22 files changed, 625 insertions, 612 deletions
@@ -1,3 +1,52 @@ +2012-05-29 Donal K. Fellows <dkf@users.sf.net> + + * doc/expr.n, doc/mathop.n: [Bug 2931407]: Clarified semantics of + division and remainder operators. + +2012-05-29 Jan Nijtmans <nijtmans@users.sf.net> + + * win/tclWinDde.c: [Bug 3525762]: Encoding handling in dde. + * win/Makefile.in: Fix "make genstubs" when cross-compiling on UNIX + +2012-05-28 Donal K. Fellows <dkf@users.sf.net> + + * library/safe.tcl (safe::AliasFileSubcommand): [Bug 3529949]: Made a + more sophisticated method for preventing information leakage; it + changes references to "~user" into "./~user", which is safe. + +2012-05-25 Donal K. Fellows <dkf@users.sf.net> + + * doc/namespace.n, doc/Ensemble.3: [Bug 3528418]: Document what is + going on with respect to qualification of command prefixes in ensemble + subcommand maps. + + * generic/tclIO.h (SYNTHETIC_EVENT_TIME): Factored out the definition + of the amount of time that should be waited before firing a synthetic + event on a channel. + +2012-05-25 Jan Nijtmans <nijtmans@users.sf.net> + + * win/tclWinDde.c: [Bug 473946]: Special characters were not correctly + sent, now for XTYP_EXECUTE as well as XTYP_REQUEST. + * win/Makefile.in: Fix "make genstubs" when cross-compiling on UNIX + +2012-05-24 Jan Nijtmans <nijtmans@users.sf.net> + + * tools/genStubs.tcl: Take cygwin handling of X11 into account. + * generic/tcl*Decls.h: re-generated + * generic/tclStubInit.c: Implement TclpIsAtty, Cygwin only. + * doc/dde.n: Doc fix: "dde execute iexplore" doesn't work + without -async, because iexplore doesn't return a value + +2012-05-24 Jan Nijtmans <nijtmans@users.sf.net> + + * tools/genStubs.tcl: Let cygwin share stub table with win32 + * win/tclWinSock.c: implement TclpInetNtoa for win32 + * generic/tclInt.decls: Revert most of [3caedf05df], since when + we let cygwin share the win32 stub table this is no longer necessary + * generic/tcl*Decls.h: re-generated + * doc/dde.n: 1.3 -> 1.4 + 2012-05-23 Donal K. Fellows <dkf@users.sf.net> * generic/tclZlib.c (ZlibTransformInput): [Bug 3525907]: Ensure that @@ -7,17 +56,19 @@ 2012-05-21 Don Porter <dgp@users.sourceforge.net> - * generic/tclFileName.c: When using Tcl_SetObjLength() calls to grow - * generic/tclPathObj.c: and shrink the objPtr->bytes buffer, care must be - taken that the value cannot possibly become pure Unicode. Calling - Tcl_AppendToObj() has the possibility of making such a conversion. Bug - found while valgrinding the trunk. + * generic/tclFileName.c: When using Tcl_SetObjLength() calls to + * generic/tclPathObj.c: grow and shrink the objPtr->bytes + buffer, care must be taken that the value cannot possibly become pure + Unicode. Calling Tcl_AppendToObj() has the possibility of making such + a conversion. Bug found while valgrinding the trunk. 2012-05-21 Jan Nijtmans <nijtmans@users.sf.net> - * win/tclWinDde.c: TIP #106: Add Encoding Abilities to the [dde] - * library/dde/pkgIndex.tcl: Command. Dde version is now 1.4.0. - * tests/winDde.test: + IMPLEMENTATION OF TIP#106 + + * win/tclWinDde.c: Added encoding-related abilities to + * library/dde/pkgIndex.tcl: the [dde] command. The dde package's + * tests/winDde.test: version is now 1.4.0. * doc/dde.n: 2012-05-20 Donal K. Fellows <dkf@users.sf.net> diff --git a/doc/Ensemble.3 b/doc/Ensemble.3 index 8a8c74e..cd69bbd 100644 --- a/doc/Ensemble.3 +++ b/doc/Ensemble.3 @@ -159,6 +159,8 @@ code (\fBTCL_OK\fR, or \fBTCL_ERROR\fR if the token does not refer to an ensemble) and the dictionary obtained from \fBTcl_GetEnsembleMappingDict\fR should always be treated as immutable even if it is unshared. +All command names in prefixes set via \fBTcl_SetEnsembleMappingDict\fR +must be fully qualified. .TP \fBformal pre-subcommand parameter list\fR (read-write) .VS 8.6 @@ -6,14 +6,14 @@ '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" .so man.macros -.TH dde n 1.3 dde "Tcl Bundled Packages" +.TH dde n 1.4 dde "Tcl Bundled Packages" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME dde \- Execute a Dynamic Data Exchange command .SH SYNOPSIS .sp -\fBpackage require dde 1.3\fR +\fBpackage require dde 1.4\fR .sp \fBdde servername\fR ?\fB\-force\fR? ?\fB\-handler \fIproc\fR? ?\fB\-\|\-\fR? ?\fItopic\fR? .sp @@ -156,7 +156,7 @@ unpredictable results. .PP An external application which wishes to run a script in Tcl should have that script store its result in a variable, run the \fBdde execute\fR -command, and the run \fBdde request\fR to get the value of the +command, and then run \fBdde request\fR to get the value of the variable. .PP When using DDE, be careful to ensure that the event queue is flushed @@ -173,7 +173,7 @@ particularly important website: .PP .CS package require dde -\fBdde execute\fR iexplore WWW_OpenURL http://www.tcl.tk/ +\fBdde execute\fR -async iexplore WWW_OpenURL http://www.tcl.tk/ .CE .SH "SEE ALSO" tk(n), winfo(n), send(n) @@ -134,7 +134,20 @@ Multiply, divide, remainder. None of these operators may be applied to string operands, and remainder may be applied only to integers. The remainder will always have the same sign as the divisor and -an absolute value smaller than the divisor. +an absolute value smaller than the absolute value of the divisor. +.RS +.PP +When applied to integers, the division and remainder operators can be +considered to partition the number line into a sequence of equal-sized +adjacent non-overlapping pieces where each piece is the size of the divisor; +the division result identifies which piece the divisor lay within, and the +remainder result identifies where within that piece the divisor lay. A +consequence of this is that the result of +.QW "-57 \fB/\fR 10" +is always -6, and the result of +.QW "-57 \fB%\fR 10" +is always 3. +.RE .TP 20 \fB+\0\0\-\fR . diff --git a/doc/mathop.n b/doc/mathop.n index e359276..ac2ebc1 100644 --- a/doc/mathop.n +++ b/doc/mathop.n @@ -126,14 +126,19 @@ will be an integer. .TP \fB%\fR \fInumber number\fR . -Returns the integral modulus of the first argument with respect to the second. -Each \fInumber\fR must have an integral value. Note that Tcl defines this -operation exactly even for negative numbers, so that the following equality -holds true: +Returns the integral modulus (i.e., remainder) of the first argument +with respect to the second. +Each \fInumber\fR must have an integral value. +Also, the sign of the result will be the same as the sign of the second +\fInumber\fR, which must not be zero. .RS .PP +Note that Tcl defines this operation exactly even for negative numbers, so +that the following command returns a true value (omitting the namespace for +clarity): +.PP .CS -(\fIx \fB/ \fIy\fR) \fB* \fIy \fB== \fIx \fB\-\fR (\fIx \fB% \fIy\fR) +\fB==\fR [\fB*\fR [\fB/\fI x y\fR] \fIy\fR] [\fB\-\fI x\fR [\fB%\fI x y\fR]] .CE .RE .TP diff --git a/doc/namespace.n b/doc/namespace.n index a32c2f3..b06d27a 100644 --- a/doc/namespace.n +++ b/doc/namespace.n @@ -778,7 +778,10 @@ When non-empty, this option supplies a dictionary that provides a mapping from subcommand names to a list of prefix words to substitute in place of the ensemble command and subcommand words (in a manner similar to an alias created with \fBinterp alias\fR; the words are not -reparsed after substitution). When this option is empty, the mapping +reparsed after substitution); if the first word of any target is not +fully qualified when set, it is assumed to be relative to the +\fIcurrent\fR namespace and changed to be exactly that (that is, it is +always fully qualified when read). When this option is empty, the mapping will be from the local name of the subcommand to its fully-qualified name. Note that when this option is non-empty and the \fB\-subcommands\fR option is empty, the ensemble subcommand names diff --git a/generic/tcl.decls b/generic/tcl.decls index 69b902f..1829249 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2371,6 +2371,14 @@ export { void Tcl_Main(int argc, char **argv, Tcl_AppInitProc *appInitProc) } export { + const char *Tcl_InitStubs(Tcl_Interp *interp, const char *version, + int exact) +} +export { + const char *TclTomMathInitializeStubs(Tcl_Interp* interp, + const char* version, int epoch, int revision) +} +export { const char *Tcl_PkgInitStubsCheck(Tcl_Interp *interp, const char *version, int exact) } diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 7c3e1de..3ae8b33 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1834,7 +1834,7 @@ typedef struct TclStubs { #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ void (*tcl_CreateFileHandler) (int fd, int mask, Tcl_FileProc *proc, ClientData clientData); /* 9 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) /* WIN */ void (*reserved9)(void); #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ @@ -1843,7 +1843,7 @@ typedef struct TclStubs { #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ void (*tcl_DeleteFileHandler) (int fd); /* 10 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) /* WIN */ void (*reserved10)(void); #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ @@ -2008,7 +2008,7 @@ typedef struct TclStubs { #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ int (*tcl_GetOpenFile) (Tcl_Interp *interp, const char *chanID, int forWriting, int checkUsage, ClientData *filePtr); /* 167 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) /* WIN */ void (*reserved167)(void); #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ diff --git a/generic/tclIO.c b/generic/tclIO.c index 9e729c4..a76aba3 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8419,8 +8419,8 @@ UpdateInterest( mask &= ~TCL_EXCEPTION; if (!statePtr->timer) { - statePtr->timer = Tcl_CreateTimerHandler(0, ChannelTimerProc, - chanPtr); + statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, + ChannelTimerProc, chanPtr); } } } @@ -8461,7 +8461,8 @@ ChannelTimerProc( * before UpdateInterest gets called by Tcl_NotifyChannel. */ - statePtr->timer = Tcl_CreateTimerHandler(0, ChannelTimerProc,chanPtr); + statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, + ChannelTimerProc,chanPtr); #ifdef TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING /* diff --git a/generic/tclIO.h b/generic/tclIO.h index 3283c3e..1e89878 100644 --- a/generic/tclIO.h +++ b/generic/tclIO.h @@ -423,6 +423,13 @@ typedef struct GetsState { * appended to objPtr so far, just before the * last call to FilterInputBytes(). */ } GetsState; + +/* + * The length of time to wait between synthetic timer events. Must be zero or + * bad things tend to happen. + */ + +#define SYNTHETIC_EVENT_TIME 0 /* * Local Variables: diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index fd25f2d..8f111b0 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -2854,7 +2854,8 @@ TimerSetup( return; } - rtPtr->timer = Tcl_CreateTimerHandler(0, TimerRun, rtPtr); + rtPtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, + TimerRun, rtPtr); } /* diff --git a/generic/tclInt.decls b/generic/tclInt.decls index ad755bc..97517ea 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -126,8 +126,8 @@ declare 25 { # } # Removed in 8.5 #declare 27 { -# int TclGetDate(char *p, Tcl_WideInt now, long zone, -# Tcl_WideInt *timePtr) +# int TclGetDate(char *p, unsigned long now, long zone, +# unsigned long *timePtr) #} declare 28 { Tcl_Channel TclpGetDefaultStdChannel(int type) @@ -188,7 +188,7 @@ declare 42 { } # Removed in Tcl 8.5a2 #declare 43 { -# int TclGlobalInvoke(Tcl_Interp *interp, int argc, const char **argv, +# int TclGlobalInvoke(Tcl_Interp *interp, int argc, CONST84 char **argv, # int flags) #} declare 44 { @@ -223,7 +223,7 @@ declare 51 { } # Removed in Tcl 8.5a2 #declare 52 { -# int TclInvoke(Tcl_Interp *interp, int argc, const char **argv, +# int TclInvoke(Tcl_Interp *interp, int argc, CONST84 char **argv, # int flags) #} declare 53 { @@ -423,9 +423,6 @@ declare 103 { declare 104 { int TclSockMinimumBuffersOld(int sock, int size) } -declare 110 { - int TclSockMinimumBuffers(void *sock, int size) -} # Replaced by Tcl_FSStat in 8.4: #declare 105 { # int TclStat(const char *path, Tcl_StatBuf *buf) @@ -442,6 +439,9 @@ declare 108 { declare 109 { int TclUpdateReturnInfo(Interp *iPtr) } +declare 110 { + int TclSockMinimumBuffers(void *sock, int size) +} # Removed in 8.1: # declare 110 { # char *TclWordEnd(char *start, char *lastChar, int nested, int *semiPtr) @@ -739,6 +739,16 @@ declare 177 { # Tcl_Obj *Tcl_GetStartupScript(const char **encodingNamePtr) #} +# REMOVED +# Allocate lists without copying arrays +# declare 180 { +# Tcl_Obj *TclNewListObjDirect(int objc, Tcl_Obj **objv) +# } +#declare 181 { +# Tcl_Obj *TclDbNewListObjDirect(int objc, Tcl_Obj **objv, +# const char *file, int line) +#} + # TclpGmtime and TclpLocaltime promoted to the generic interface from unix declare 182 { @@ -1024,12 +1034,16 @@ declare 3 win { declare 4 win { HINSTANCE TclWinGetTclInstance(void) } +# new for 8.4.20+/8.5.12+ Cygwin only +declare 5 win { + int TclUnixWaitForFile(int fd, int mask, int timeout) +} # Removed in 8.1: # declare 5 win { # HINSTANCE TclWinLoadLibrary(char *name) # } declare 6 win { - u_short TclWinNToHS(u_short ns) + unsigned short TclWinNToHS(unsigned short ns) } declare 7 win { int TclWinSetSockOpt(SOCKET s, int level, int optname, @@ -1041,6 +1055,10 @@ declare 8 win { declare 9 win { int TclWinGetPlatformId(void) } +# new for 8.4.20+/8.5.12+ Cygwin only +declare 10 win { + Tcl_DirEntry *TclpReaddir(DIR *dir) +} # Removed in 8.3.1 (for Win32s only) #declare 10 win { # int TclWinSynchSpawn(void *args, int type, void **trans, Tcl_Pid *pidPtr) @@ -1062,9 +1080,13 @@ declare 14 win { int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe) } declare 15 win { - int TclpCreateProcess(Tcl_Interp *interp, int argc, const char **argv, - TclFile inputFile, TclFile outputFile, TclFile errorFile, - Tcl_Pid *pidPtr) + int TclpCreateProcess(Tcl_Interp *interp, int argc, + const char **argv, TclFile inputFile, TclFile outputFile, + TclFile errorFile, Tcl_Pid *pidPtr) +} +# new for 8.4.20+/8.5.12+ Cygwin only +declare 16 win { + int TclpIsAtty(int fd) } # Signature changed in 8.1: # declare 16 win { @@ -1082,7 +1104,10 @@ declare 19 win { declare 20 win { void TclWinAddProcess(HANDLE hProcess, DWORD id) } - +# new for 8.4.20+/8.5.12+ +declare 21 win { + char *TclpInetNtoa(struct in_addr addr) +} # removed permanently for 8.4 #declare 21 win { # void TclpAsyncMark(Tcl_AsyncHandler async) @@ -1127,51 +1152,42 @@ declare 29 win { # Pipe channel functions -# On non-cygwin, this is actually a reference to TclGetAndDetachPids declare 0 unix { - void TclWinConvertError(unsigned int errCode) + void TclGetAndDetachPids(Tcl_Interp *interp, Tcl_Channel chan) } -# On non-cygwin, this is actually a reference to TclpCloseFile declare 1 unix { - void TclWinConvertWSAError(unsigned int errCode) + int TclpCloseFile(TclFile file) } -# On non-cygwin, this is actually a reference to TclpCreateCommandChannel declare 2 unix { - struct servent *TclWinGetServByName(const char *nm, const char *proto) + Tcl_Channel TclpCreateCommandChannel(TclFile readFile, + TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr) } -# On non-cygwin, this is actually a reference to TclpCreatePipe declare 3 unix { - int TclWinGetSockOpt(void *s, int level, int optname, - char *optval, int *optlen) + int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe) } -# On non-cygwin, this is actually a reference to TclpCreateProcess declare 4 unix { - void *TclWinGetTclInstance(void) + int TclpCreateProcess(Tcl_Interp *interp, int argc, + const char **argv, TclFile inputFile, TclFile outputFile, + TclFile errorFile, Tcl_Pid *pidPtr) } # Signature changed in 8.1: # declare 5 unix { # TclFile TclpCreateTempFile(char *contents, Tcl_DString *namePtr) # } - -# On non-cygwin, this is actually a reference to TclpMakeFile declare 6 unix { - unsigned short TclWinNToHS(unsigned short ns) + TclFile TclpMakeFile(Tcl_Channel channel, int direction) } -# On non-cygwin, this is actually a reference to TclpOpenFile declare 7 unix { - int TclWinSetSockOpt(void *s, int level, int optname, - const char *optval, int optlen) + TclFile TclpOpenFile(const char *fname, int mode) } -# On non-cygwin, this is actually a reference to TclUnixWaitForFile declare 8 unix { - int TclpGetPid(Tcl_Pid pid) + int TclUnixWaitForFile(int fd, int mask, int timeout) } # Added in 8.1: -# On non-cygwin, this is actually a reference to TclpCreateTempFile declare 9 unix { - int TclWinGetPlatformId(void) + TclFile TclpCreateTempFile(const char *contents) } # Added in 8.4: @@ -1181,18 +1197,14 @@ declare 10 unix { } # Slots 11 and 12 are forwarders for functions that were promoted to # generic Stubs -# On cygwin, this is actually a reference to TclGetAndDetachPids declare 11 unix { struct tm *TclpLocaltime_unix(const time_t *clock) } -# On cygwin, this is actually a reference to TclpCloseFile declare 12 unix { struct tm *TclpGmtime_unix(const time_t *clock) } -# On cygwin, this is a reference to TclpCreateCommandChannel -# Otherwise, this is a reference to TclpInetNtoa declare 13 unix { - void TclIntPlatReserved13(void) + char *TclpInetNtoa(struct in_addr addr) } # Added in 8.5: @@ -1205,8 +1217,7 @@ declare 14 unix { ################################ # Mac OS X specific functions -#On cygwin, TclpCreateProcess is here -declare 15 {unix macosx} { +declare 15 macosx { int TclMacOSXGetFileAttribute(Tcl_Interp *interp, int objIndex, Tcl_Obj *fileName, Tcl_Obj **attributePtrPtr) } @@ -1218,67 +1229,17 @@ declare 17 macosx { int TclMacOSXCopyFileAttributes(const char *src, const char *dst, const Tcl_StatBuf *statBufPtr) } -#On cygwin, TclpMakeFile is here -declare 18 {unix macosx} { +declare 18 macosx { int TclMacOSXMatchType(Tcl_Interp *interp, const char *pathName, const char *fileName, Tcl_StatBuf *statBufPtr, Tcl_GlobTypeData *types) } -#On cygwin, TclpOpenFile is here -declare 19 {unix macosx} { +declare 19 macosx { void TclMacOSXNotifierAddRunLoopMode(const void *runLoopMode) } -declare 20 unix { - void TclWinAddProcess(void *hProcess, unsigned int id) -} -declare 22 unix { - TclFile TclpCreateTempFile(const char *contents) -} -declare 24 unix { - char *TclWinNoBackslash(char *path) -} -declare 26 unix { - void TclWinSetInterfaces(int wide) -} -declare 27 unix { - void TclWinFlushDirtyChannels(void) -} -declare 28 unix { - void TclWinResetInterfaces(void) -} declare 29 unix { int TclWinCPUID(unsigned int index, unsigned int *regs) } -declare 30 unix { - void TclGetAndDetachPids(Tcl_Interp *interp, Tcl_Channel chan) -} -declare 31 unix { - int TclpCloseFile(TclFile file) -} -declare 32 unix { - Tcl_Channel TclpCreateCommandChannel(TclFile readFile, - TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr) -} -declare 33 unix { - int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe) -} -declare 34 unix { - int TclpCreateProcess(Tcl_Interp *interp, - int argc, const char **argv, TclFile inputFile, - TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr) -} -declare 35 unix { - char *TclpInetNtoa(struct in_addr addr) -} -declare 36 unix { - TclFile TclpMakeFile(Tcl_Channel channel, int direction) -} -declare 37 unix { - TclFile TclpOpenFile(const char *fname, int mode) -} -declare 38 unix { - int TclUnixWaitForFile(int fd, int mask, int timeout) -} # Local Variables: # mode: tcl diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index bc0f4fd..a9c6e8c 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -13,6 +13,11 @@ #ifndef _TCLINTPLATDECLS #define _TCLINTPLATDECLS +#ifdef __WIN32__ +# define Tcl_DirEntry void +# define DIR void +#endif + #undef TCL_STORAGE_CLASS #ifdef BUILD_tcl # define TCL_STORAGE_CLASS DLLEXPORT @@ -36,29 +41,32 @@ * Exported function declarations: */ -#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ +#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */ /* 0 */ -EXTERN void TclWinConvertError(unsigned int errCode); +EXTERN void TclGetAndDetachPids(Tcl_Interp *interp, + Tcl_Channel chan); /* 1 */ -EXTERN void TclWinConvertWSAError(unsigned int errCode); +EXTERN int TclpCloseFile(TclFile file); /* 2 */ -EXTERN struct servent * TclWinGetServByName(const char *nm, - const char *proto); +EXTERN Tcl_Channel TclpCreateCommandChannel(TclFile readFile, + TclFile writeFile, TclFile errorFile, + int numPids, Tcl_Pid *pidPtr); /* 3 */ -EXTERN int TclWinGetSockOpt(void *s, int level, int optname, - char *optval, int *optlen); +EXTERN int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe); /* 4 */ -EXTERN void * TclWinGetTclInstance(void); +EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, + const char **argv, TclFile inputFile, + TclFile outputFile, TclFile errorFile, + Tcl_Pid *pidPtr); /* Slot 5 is reserved */ /* 6 */ -EXTERN unsigned short TclWinNToHS(unsigned short ns); +EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); /* 7 */ -EXTERN int TclWinSetSockOpt(void *s, int level, int optname, - const char *optval, int optlen); +EXTERN TclFile TclpOpenFile(const char *fname, int mode); /* 8 */ -EXTERN int TclpGetPid(Tcl_Pid pid); +EXTERN int TclUnixWaitForFile(int fd, int mask, int timeout); /* 9 */ -EXTERN int TclWinGetPlatformId(void); +EXTERN TclFile TclpCreateTempFile(const char *contents); /* 10 */ EXTERN Tcl_DirEntry * TclpReaddir(DIR *dir); /* 11 */ @@ -66,68 +74,29 @@ EXTERN struct tm * TclpLocaltime_unix(const time_t *clock); /* 12 */ EXTERN struct tm * TclpGmtime_unix(const time_t *clock); /* 13 */ -EXTERN void TclIntPlatReserved13(void); +EXTERN char * TclpInetNtoa(struct in_addr addr); /* 14 */ EXTERN int TclUnixCopyFile(const char *src, const char *dst, const Tcl_StatBuf *statBufPtr, int dontCopyAtts); -/* 15 */ -EXTERN int TclMacOSXGetFileAttribute(Tcl_Interp *interp, - int objIndex, Tcl_Obj *fileName, - Tcl_Obj **attributePtrPtr); +/* Slot 15 is reserved */ /* Slot 16 is reserved */ /* Slot 17 is reserved */ -/* 18 */ -EXTERN int TclMacOSXMatchType(Tcl_Interp *interp, - const char *pathName, const char *fileName, - Tcl_StatBuf *statBufPtr, - Tcl_GlobTypeData *types); -/* 19 */ -EXTERN void TclMacOSXNotifierAddRunLoopMode( - const void *runLoopMode); -/* 20 */ -EXTERN void TclWinAddProcess(void *hProcess, unsigned int id); +/* Slot 18 is reserved */ +/* Slot 19 is reserved */ +/* Slot 20 is reserved */ /* Slot 21 is reserved */ -/* 22 */ -EXTERN TclFile TclpCreateTempFile(const char *contents); +/* Slot 22 is reserved */ /* Slot 23 is reserved */ -/* 24 */ -EXTERN char * TclWinNoBackslash(char *path); +/* Slot 24 is reserved */ /* Slot 25 is reserved */ -/* 26 */ -EXTERN void TclWinSetInterfaces(int wide); -/* 27 */ -EXTERN void TclWinFlushDirtyChannels(void); -/* 28 */ -EXTERN void TclWinResetInterfaces(void); +/* Slot 26 is reserved */ +/* Slot 27 is reserved */ +/* Slot 28 is reserved */ /* 29 */ EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs); -/* 30 */ -EXTERN void TclGetAndDetachPids(Tcl_Interp *interp, - Tcl_Channel chan); -/* 31 */ -EXTERN int TclpCloseFile(TclFile file); -/* 32 */ -EXTERN Tcl_Channel TclpCreateCommandChannel(TclFile readFile, - TclFile writeFile, TclFile errorFile, - int numPids, Tcl_Pid *pidPtr); -/* 33 */ -EXTERN int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe); -/* 34 */ -EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, - const char **argv, TclFile inputFile, - TclFile outputFile, TclFile errorFile, - Tcl_Pid *pidPtr); -/* 35 */ -EXTERN char * TclpInetNtoa(struct in_addr addr); -/* 36 */ -EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); -/* 37 */ -EXTERN TclFile TclpOpenFile(const char *fname, int mode); -/* 38 */ -EXTERN int TclUnixWaitForFile(int fd, int mask, int timeout); #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ /* 0 */ EXTERN void TclWinConvertError(DWORD errCode); /* 1 */ @@ -140,9 +109,10 @@ EXTERN int TclWinGetSockOpt(SOCKET s, int level, int optname, char *optval, int *optlen); /* 4 */ EXTERN HINSTANCE TclWinGetTclInstance(void); -/* Slot 5 is reserved */ +/* 5 */ +EXTERN int TclUnixWaitForFile(int fd, int mask, int timeout); /* 6 */ -EXTERN u_short TclWinNToHS(u_short ns); +EXTERN unsigned short TclWinNToHS(unsigned short ns); /* 7 */ EXTERN int TclWinSetSockOpt(SOCKET s, int level, int optname, const char *optval, int optlen); @@ -150,7 +120,8 @@ EXTERN int TclWinSetSockOpt(SOCKET s, int level, int optname, EXTERN int TclpGetPid(Tcl_Pid pid); /* 9 */ EXTERN int TclWinGetPlatformId(void); -/* Slot 10 is reserved */ +/* 10 */ +EXTERN Tcl_DirEntry * TclpReaddir(DIR *dir); /* 11 */ EXTERN void TclGetAndDetachPids(Tcl_Interp *interp, Tcl_Channel chan); @@ -167,7 +138,8 @@ EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); -/* Slot 16 is reserved */ +/* 16 */ +EXTERN int TclpIsAtty(int fd); /* Slot 17 is reserved */ /* 18 */ EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); @@ -175,7 +147,8 @@ EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); EXTERN TclFile TclpOpenFile(const char *fname, int mode); /* 20 */ EXTERN void TclWinAddProcess(HANDLE hProcess, DWORD id); -/* Slot 21 is reserved */ +/* 21 */ +EXTERN char * TclpInetNtoa(struct in_addr addr); /* 22 */ EXTERN TclFile TclpCreateTempFile(const char *contents); /* Slot 23 is reserved */ @@ -193,27 +166,30 @@ EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs); #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ /* 0 */ -EXTERN void TclWinConvertError(unsigned int errCode); +EXTERN void TclGetAndDetachPids(Tcl_Interp *interp, + Tcl_Channel chan); /* 1 */ -EXTERN void TclWinConvertWSAError(unsigned int errCode); +EXTERN int TclpCloseFile(TclFile file); /* 2 */ -EXTERN struct servent * TclWinGetServByName(const char *nm, - const char *proto); +EXTERN Tcl_Channel TclpCreateCommandChannel(TclFile readFile, + TclFile writeFile, TclFile errorFile, + int numPids, Tcl_Pid *pidPtr); /* 3 */ -EXTERN int TclWinGetSockOpt(void *s, int level, int optname, - char *optval, int *optlen); +EXTERN int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe); /* 4 */ -EXTERN void * TclWinGetTclInstance(void); +EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, + const char **argv, TclFile inputFile, + TclFile outputFile, TclFile errorFile, + Tcl_Pid *pidPtr); /* Slot 5 is reserved */ /* 6 */ -EXTERN unsigned short TclWinNToHS(unsigned short ns); +EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); /* 7 */ -EXTERN int TclWinSetSockOpt(void *s, int level, int optname, - const char *optval, int optlen); +EXTERN TclFile TclpOpenFile(const char *fname, int mode); /* 8 */ -EXTERN int TclpGetPid(Tcl_Pid pid); +EXTERN int TclUnixWaitForFile(int fd, int mask, int timeout); /* 9 */ -EXTERN int TclWinGetPlatformId(void); +EXTERN TclFile TclpCreateTempFile(const char *contents); /* 10 */ EXTERN Tcl_DirEntry * TclpReaddir(DIR *dir); /* 11 */ @@ -221,7 +197,7 @@ EXTERN struct tm * TclpLocaltime_unix(const time_t *clock); /* 12 */ EXTERN struct tm * TclpGmtime_unix(const time_t *clock); /* 13 */ -EXTERN void TclIntPlatReserved13(void); +EXTERN char * TclpInetNtoa(struct in_addr addr); /* 14 */ EXTERN int TclUnixCopyFile(const char *src, const char *dst, const Tcl_StatBuf *statBufPtr, @@ -246,117 +222,78 @@ EXTERN int TclMacOSXMatchType(Tcl_Interp *interp, /* 19 */ EXTERN void TclMacOSXNotifierAddRunLoopMode( const void *runLoopMode); -/* 20 */ -EXTERN void TclWinAddProcess(void *hProcess, unsigned int id); +/* Slot 20 is reserved */ /* Slot 21 is reserved */ -/* 22 */ -EXTERN TclFile TclpCreateTempFile(const char *contents); +/* Slot 22 is reserved */ /* Slot 23 is reserved */ -/* 24 */ -EXTERN char * TclWinNoBackslash(char *path); +/* Slot 24 is reserved */ /* Slot 25 is reserved */ -/* 26 */ -EXTERN void TclWinSetInterfaces(int wide); -/* 27 */ -EXTERN void TclWinFlushDirtyChannels(void); -/* 28 */ -EXTERN void TclWinResetInterfaces(void); +/* Slot 26 is reserved */ +/* Slot 27 is reserved */ +/* Slot 28 is reserved */ /* 29 */ EXTERN int TclWinCPUID(unsigned int index, unsigned int *regs); -/* 30 */ -EXTERN void TclGetAndDetachPids(Tcl_Interp *interp, - Tcl_Channel chan); -/* 31 */ -EXTERN int TclpCloseFile(TclFile file); -/* 32 */ -EXTERN Tcl_Channel TclpCreateCommandChannel(TclFile readFile, - TclFile writeFile, TclFile errorFile, - int numPids, Tcl_Pid *pidPtr); -/* 33 */ -EXTERN int TclpCreatePipe(TclFile *readPipe, TclFile *writePipe); -/* 34 */ -EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, - const char **argv, TclFile inputFile, - TclFile outputFile, TclFile errorFile, - Tcl_Pid *pidPtr); -/* 35 */ -EXTERN char * TclpInetNtoa(struct in_addr addr); -/* 36 */ -EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); -/* 37 */ -EXTERN TclFile TclpOpenFile(const char *fname, int mode); -/* 38 */ -EXTERN int TclUnixWaitForFile(int fd, int mask, int timeout); #endif /* MACOSX */ typedef struct TclIntPlatStubs { int magic; const struct TclIntPlatStubHooks *hooks; -#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ - void (*tclWinConvertError) (unsigned int errCode); /* 0 */ - void (*tclWinConvertWSAError) (unsigned int errCode); /* 1 */ - struct servent * (*tclWinGetServByName) (const char *nm, const char *proto); /* 2 */ - int (*tclWinGetSockOpt) (void *s, int level, int optname, char *optval, int *optlen); /* 3 */ - void * (*tclWinGetTclInstance) (void); /* 4 */ +#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */ + void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 0 */ + int (*tclpCloseFile) (TclFile file); /* 1 */ + Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 2 */ + int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 3 */ + int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 4 */ void (*reserved5)(void); - unsigned short (*tclWinNToHS) (unsigned short ns); /* 6 */ - int (*tclWinSetSockOpt) (void *s, int level, int optname, const char *optval, int optlen); /* 7 */ - int (*tclpGetPid) (Tcl_Pid pid); /* 8 */ - int (*tclWinGetPlatformId) (void); /* 9 */ + TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */ + TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */ + int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 8 */ + TclFile (*tclpCreateTempFile) (const char *contents); /* 9 */ Tcl_DirEntry * (*tclpReaddir) (DIR *dir); /* 10 */ struct tm * (*tclpLocaltime_unix) (const time_t *clock); /* 11 */ struct tm * (*tclpGmtime_unix) (const time_t *clock); /* 12 */ - void (*tclIntPlatReserved13) (void); /* 13 */ + char * (*tclpInetNtoa) (struct in_addr addr); /* 13 */ int (*tclUnixCopyFile) (const char *src, const char *dst, const Tcl_StatBuf *statBufPtr, int dontCopyAtts); /* 14 */ - int (*tclMacOSXGetFileAttribute) (Tcl_Interp *interp, int objIndex, Tcl_Obj *fileName, Tcl_Obj **attributePtrPtr); /* 15 */ + void (*reserved15)(void); void (*reserved16)(void); void (*reserved17)(void); - int (*tclMacOSXMatchType) (Tcl_Interp *interp, const char *pathName, const char *fileName, Tcl_StatBuf *statBufPtr, Tcl_GlobTypeData *types); /* 18 */ - void (*tclMacOSXNotifierAddRunLoopMode) (const void *runLoopMode); /* 19 */ - void (*tclWinAddProcess) (void *hProcess, unsigned int id); /* 20 */ + void (*reserved18)(void); + void (*reserved19)(void); + void (*reserved20)(void); void (*reserved21)(void); - TclFile (*tclpCreateTempFile) (const char *contents); /* 22 */ + void (*reserved22)(void); void (*reserved23)(void); - char * (*tclWinNoBackslash) (char *path); /* 24 */ + void (*reserved24)(void); void (*reserved25)(void); - void (*tclWinSetInterfaces) (int wide); /* 26 */ - void (*tclWinFlushDirtyChannels) (void); /* 27 */ - void (*tclWinResetInterfaces) (void); /* 28 */ + void (*reserved26)(void); + void (*reserved27)(void); + void (*reserved28)(void); int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */ - void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 30 */ - int (*tclpCloseFile) (TclFile file); /* 31 */ - Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 32 */ - int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 33 */ - int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 34 */ - char * (*tclpInetNtoa) (struct in_addr addr); /* 35 */ - TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 36 */ - TclFile (*tclpOpenFile) (const char *fname, int mode); /* 37 */ - int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 38 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ void (*tclWinConvertError) (DWORD errCode); /* 0 */ void (*tclWinConvertWSAError) (DWORD errCode); /* 1 */ struct servent * (*tclWinGetServByName) (const char *nm, const char *proto); /* 2 */ int (*tclWinGetSockOpt) (SOCKET s, int level, int optname, char *optval, int *optlen); /* 3 */ HINSTANCE (*tclWinGetTclInstance) (void); /* 4 */ - void (*reserved5)(void); - u_short (*tclWinNToHS) (u_short ns); /* 6 */ + int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 5 */ + unsigned short (*tclWinNToHS) (unsigned short ns); /* 6 */ int (*tclWinSetSockOpt) (SOCKET s, int level, int optname, const char *optval, int optlen); /* 7 */ int (*tclpGetPid) (Tcl_Pid pid); /* 8 */ int (*tclWinGetPlatformId) (void); /* 9 */ - void (*reserved10)(void); + Tcl_DirEntry * (*tclpReaddir) (DIR *dir); /* 10 */ void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 11 */ int (*tclpCloseFile) (TclFile file); /* 12 */ Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 13 */ int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 14 */ int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 15 */ - void (*reserved16)(void); + int (*tclpIsAtty) (int fd); /* 16 */ void (*reserved17)(void); TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 18 */ TclFile (*tclpOpenFile) (const char *fname, int mode); /* 19 */ void (*tclWinAddProcess) (HANDLE hProcess, DWORD id); /* 20 */ - void (*reserved21)(void); + char * (*tclpInetNtoa) (struct in_addr addr); /* 21 */ TclFile (*tclpCreateTempFile) (const char *contents); /* 22 */ void (*reserved23)(void); char * (*tclWinNoBackslash) (char *path); /* 24 */ @@ -367,45 +304,36 @@ typedef struct TclIntPlatStubs { int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ - void (*tclWinConvertError) (unsigned int errCode); /* 0 */ - void (*tclWinConvertWSAError) (unsigned int errCode); /* 1 */ - struct servent * (*tclWinGetServByName) (const char *nm, const char *proto); /* 2 */ - int (*tclWinGetSockOpt) (void *s, int level, int optname, char *optval, int *optlen); /* 3 */ - void * (*tclWinGetTclInstance) (void); /* 4 */ + void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 0 */ + int (*tclpCloseFile) (TclFile file); /* 1 */ + Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 2 */ + int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 3 */ + int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 4 */ void (*reserved5)(void); - unsigned short (*tclWinNToHS) (unsigned short ns); /* 6 */ - int (*tclWinSetSockOpt) (void *s, int level, int optname, const char *optval, int optlen); /* 7 */ - int (*tclpGetPid) (Tcl_Pid pid); /* 8 */ - int (*tclWinGetPlatformId) (void); /* 9 */ + TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */ + TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */ + int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 8 */ + TclFile (*tclpCreateTempFile) (const char *contents); /* 9 */ Tcl_DirEntry * (*tclpReaddir) (DIR *dir); /* 10 */ struct tm * (*tclpLocaltime_unix) (const time_t *clock); /* 11 */ struct tm * (*tclpGmtime_unix) (const time_t *clock); /* 12 */ - void (*tclIntPlatReserved13) (void); /* 13 */ + char * (*tclpInetNtoa) (struct in_addr addr); /* 13 */ int (*tclUnixCopyFile) (const char *src, const char *dst, const Tcl_StatBuf *statBufPtr, int dontCopyAtts); /* 14 */ int (*tclMacOSXGetFileAttribute) (Tcl_Interp *interp, int objIndex, Tcl_Obj *fileName, Tcl_Obj **attributePtrPtr); /* 15 */ int (*tclMacOSXSetFileAttribute) (Tcl_Interp *interp, int objIndex, Tcl_Obj *fileName, Tcl_Obj *attributePtr); /* 16 */ int (*tclMacOSXCopyFileAttributes) (const char *src, const char *dst, const Tcl_StatBuf *statBufPtr); /* 17 */ int (*tclMacOSXMatchType) (Tcl_Interp *interp, const char *pathName, const char *fileName, Tcl_StatBuf *statBufPtr, Tcl_GlobTypeData *types); /* 18 */ void (*tclMacOSXNotifierAddRunLoopMode) (const void *runLoopMode); /* 19 */ - void (*tclWinAddProcess) (void *hProcess, unsigned int id); /* 20 */ + void (*reserved20)(void); void (*reserved21)(void); - TclFile (*tclpCreateTempFile) (const char *contents); /* 22 */ + void (*reserved22)(void); void (*reserved23)(void); - char * (*tclWinNoBackslash) (char *path); /* 24 */ + void (*reserved24)(void); void (*reserved25)(void); - void (*tclWinSetInterfaces) (int wide); /* 26 */ - void (*tclWinFlushDirtyChannels) (void); /* 27 */ - void (*tclWinResetInterfaces) (void); /* 28 */ + void (*reserved26)(void); + void (*reserved27)(void); + void (*reserved28)(void); int (*tclWinCPUID) (unsigned int index, unsigned int *regs); /* 29 */ - void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 30 */ - int (*tclpCloseFile) (TclFile file); /* 31 */ - Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 32 */ - int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 33 */ - int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 34 */ - char * (*tclpInetNtoa) (struct in_addr addr); /* 35 */ - TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 36 */ - TclFile (*tclpOpenFile) (const char *fname, int mode); /* 37 */ - int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 38 */ #endif /* MACOSX */ } TclIntPlatStubs; @@ -423,81 +351,54 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; * Inline function declarations: */ -#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ -#define TclWinConvertError \ - (tclIntPlatStubsPtr->tclWinConvertError) /* 0 */ -#define TclWinConvertWSAError \ - (tclIntPlatStubsPtr->tclWinConvertWSAError) /* 1 */ -#define TclWinGetServByName \ - (tclIntPlatStubsPtr->tclWinGetServByName) /* 2 */ -#define TclWinGetSockOpt \ - (tclIntPlatStubsPtr->tclWinGetSockOpt) /* 3 */ -#define TclWinGetTclInstance \ - (tclIntPlatStubsPtr->tclWinGetTclInstance) /* 4 */ +#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */ +#define TclGetAndDetachPids \ + (tclIntPlatStubsPtr->tclGetAndDetachPids) /* 0 */ +#define TclpCloseFile \ + (tclIntPlatStubsPtr->tclpCloseFile) /* 1 */ +#define TclpCreateCommandChannel \ + (tclIntPlatStubsPtr->tclpCreateCommandChannel) /* 2 */ +#define TclpCreatePipe \ + (tclIntPlatStubsPtr->tclpCreatePipe) /* 3 */ +#define TclpCreateProcess \ + (tclIntPlatStubsPtr->tclpCreateProcess) /* 4 */ /* Slot 5 is reserved */ -#define TclWinNToHS \ - (tclIntPlatStubsPtr->tclWinNToHS) /* 6 */ -#define TclWinSetSockOpt \ - (tclIntPlatStubsPtr->tclWinSetSockOpt) /* 7 */ -#define TclpGetPid \ - (tclIntPlatStubsPtr->tclpGetPid) /* 8 */ -#define TclWinGetPlatformId \ - (tclIntPlatStubsPtr->tclWinGetPlatformId) /* 9 */ +#define TclpMakeFile \ + (tclIntPlatStubsPtr->tclpMakeFile) /* 6 */ +#define TclpOpenFile \ + (tclIntPlatStubsPtr->tclpOpenFile) /* 7 */ +#define TclUnixWaitForFile \ + (tclIntPlatStubsPtr->tclUnixWaitForFile) /* 8 */ +#define TclpCreateTempFile \ + (tclIntPlatStubsPtr->tclpCreateTempFile) /* 9 */ #define TclpReaddir \ (tclIntPlatStubsPtr->tclpReaddir) /* 10 */ #define TclpLocaltime_unix \ (tclIntPlatStubsPtr->tclpLocaltime_unix) /* 11 */ #define TclpGmtime_unix \ (tclIntPlatStubsPtr->tclpGmtime_unix) /* 12 */ -#define TclIntPlatReserved13 \ - (tclIntPlatStubsPtr->tclIntPlatReserved13) /* 13 */ +#define TclpInetNtoa \ + (tclIntPlatStubsPtr->tclpInetNtoa) /* 13 */ #define TclUnixCopyFile \ (tclIntPlatStubsPtr->tclUnixCopyFile) /* 14 */ -#define TclMacOSXGetFileAttribute \ - (tclIntPlatStubsPtr->tclMacOSXGetFileAttribute) /* 15 */ +/* Slot 15 is reserved */ /* Slot 16 is reserved */ /* Slot 17 is reserved */ -#define TclMacOSXMatchType \ - (tclIntPlatStubsPtr->tclMacOSXMatchType) /* 18 */ -#define TclMacOSXNotifierAddRunLoopMode \ - (tclIntPlatStubsPtr->tclMacOSXNotifierAddRunLoopMode) /* 19 */ -#define TclWinAddProcess \ - (tclIntPlatStubsPtr->tclWinAddProcess) /* 20 */ +/* Slot 18 is reserved */ +/* Slot 19 is reserved */ +/* Slot 20 is reserved */ /* Slot 21 is reserved */ -#define TclpCreateTempFile \ - (tclIntPlatStubsPtr->tclpCreateTempFile) /* 22 */ +/* Slot 22 is reserved */ /* Slot 23 is reserved */ -#define TclWinNoBackslash \ - (tclIntPlatStubsPtr->tclWinNoBackslash) /* 24 */ +/* Slot 24 is reserved */ /* Slot 25 is reserved */ -#define TclWinSetInterfaces \ - (tclIntPlatStubsPtr->tclWinSetInterfaces) /* 26 */ -#define TclWinFlushDirtyChannels \ - (tclIntPlatStubsPtr->tclWinFlushDirtyChannels) /* 27 */ -#define TclWinResetInterfaces \ - (tclIntPlatStubsPtr->tclWinResetInterfaces) /* 28 */ +/* Slot 26 is reserved */ +/* Slot 27 is reserved */ +/* Slot 28 is reserved */ #define TclWinCPUID \ (tclIntPlatStubsPtr->tclWinCPUID) /* 29 */ -#define TclGetAndDetachPids \ - (tclIntPlatStubsPtr->tclGetAndDetachPids) /* 30 */ -#define TclpCloseFile \ - (tclIntPlatStubsPtr->tclpCloseFile) /* 31 */ -#define TclpCreateCommandChannel \ - (tclIntPlatStubsPtr->tclpCreateCommandChannel) /* 32 */ -#define TclpCreatePipe \ - (tclIntPlatStubsPtr->tclpCreatePipe) /* 33 */ -#define TclpCreateProcess \ - (tclIntPlatStubsPtr->tclpCreateProcess) /* 34 */ -#define TclpInetNtoa \ - (tclIntPlatStubsPtr->tclpInetNtoa) /* 35 */ -#define TclpMakeFile \ - (tclIntPlatStubsPtr->tclpMakeFile) /* 36 */ -#define TclpOpenFile \ - (tclIntPlatStubsPtr->tclpOpenFile) /* 37 */ -#define TclUnixWaitForFile \ - (tclIntPlatStubsPtr->tclUnixWaitForFile) /* 38 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ #define TclWinConvertError \ (tclIntPlatStubsPtr->tclWinConvertError) /* 0 */ #define TclWinConvertWSAError \ @@ -508,7 +409,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclWinGetSockOpt) /* 3 */ #define TclWinGetTclInstance \ (tclIntPlatStubsPtr->tclWinGetTclInstance) /* 4 */ -/* Slot 5 is reserved */ +#define TclUnixWaitForFile \ + (tclIntPlatStubsPtr->tclUnixWaitForFile) /* 5 */ #define TclWinNToHS \ (tclIntPlatStubsPtr->tclWinNToHS) /* 6 */ #define TclWinSetSockOpt \ @@ -517,7 +419,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclpGetPid) /* 8 */ #define TclWinGetPlatformId \ (tclIntPlatStubsPtr->tclWinGetPlatformId) /* 9 */ -/* Slot 10 is reserved */ +#define TclpReaddir \ + (tclIntPlatStubsPtr->tclpReaddir) /* 10 */ #define TclGetAndDetachPids \ (tclIntPlatStubsPtr->tclGetAndDetachPids) /* 11 */ #define TclpCloseFile \ @@ -528,7 +431,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclpCreatePipe) /* 14 */ #define TclpCreateProcess \ (tclIntPlatStubsPtr->tclpCreateProcess) /* 15 */ -/* Slot 16 is reserved */ +#define TclpIsAtty \ + (tclIntPlatStubsPtr->tclpIsAtty) /* 16 */ /* Slot 17 is reserved */ #define TclpMakeFile \ (tclIntPlatStubsPtr->tclpMakeFile) /* 18 */ @@ -536,7 +440,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclpOpenFile) /* 19 */ #define TclWinAddProcess \ (tclIntPlatStubsPtr->tclWinAddProcess) /* 20 */ -/* Slot 21 is reserved */ +#define TclpInetNtoa \ + (tclIntPlatStubsPtr->tclpInetNtoa) /* 21 */ #define TclpCreateTempFile \ (tclIntPlatStubsPtr->tclpCreateTempFile) /* 22 */ /* Slot 23 is reserved */ @@ -553,33 +458,33 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclWinCPUID) /* 29 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ -#define TclWinConvertError \ - (tclIntPlatStubsPtr->tclWinConvertError) /* 0 */ -#define TclWinConvertWSAError \ - (tclIntPlatStubsPtr->tclWinConvertWSAError) /* 1 */ -#define TclWinGetServByName \ - (tclIntPlatStubsPtr->tclWinGetServByName) /* 2 */ -#define TclWinGetSockOpt \ - (tclIntPlatStubsPtr->tclWinGetSockOpt) /* 3 */ -#define TclWinGetTclInstance \ - (tclIntPlatStubsPtr->tclWinGetTclInstance) /* 4 */ +#define TclGetAndDetachPids \ + (tclIntPlatStubsPtr->tclGetAndDetachPids) /* 0 */ +#define TclpCloseFile \ + (tclIntPlatStubsPtr->tclpCloseFile) /* 1 */ +#define TclpCreateCommandChannel \ + (tclIntPlatStubsPtr->tclpCreateCommandChannel) /* 2 */ +#define TclpCreatePipe \ + (tclIntPlatStubsPtr->tclpCreatePipe) /* 3 */ +#define TclpCreateProcess \ + (tclIntPlatStubsPtr->tclpCreateProcess) /* 4 */ /* Slot 5 is reserved */ -#define TclWinNToHS \ - (tclIntPlatStubsPtr->tclWinNToHS) /* 6 */ -#define TclWinSetSockOpt \ - (tclIntPlatStubsPtr->tclWinSetSockOpt) /* 7 */ -#define TclpGetPid \ - (tclIntPlatStubsPtr->tclpGetPid) /* 8 */ -#define TclWinGetPlatformId \ - (tclIntPlatStubsPtr->tclWinGetPlatformId) /* 9 */ +#define TclpMakeFile \ + (tclIntPlatStubsPtr->tclpMakeFile) /* 6 */ +#define TclpOpenFile \ + (tclIntPlatStubsPtr->tclpOpenFile) /* 7 */ +#define TclUnixWaitForFile \ + (tclIntPlatStubsPtr->tclUnixWaitForFile) /* 8 */ +#define TclpCreateTempFile \ + (tclIntPlatStubsPtr->tclpCreateTempFile) /* 9 */ #define TclpReaddir \ (tclIntPlatStubsPtr->tclpReaddir) /* 10 */ #define TclpLocaltime_unix \ (tclIntPlatStubsPtr->tclpLocaltime_unix) /* 11 */ #define TclpGmtime_unix \ (tclIntPlatStubsPtr->tclpGmtime_unix) /* 12 */ -#define TclIntPlatReserved13 \ - (tclIntPlatStubsPtr->tclIntPlatReserved13) /* 13 */ +#define TclpInetNtoa \ + (tclIntPlatStubsPtr->tclpInetNtoa) /* 13 */ #define TclUnixCopyFile \ (tclIntPlatStubsPtr->tclUnixCopyFile) /* 14 */ #define TclMacOSXGetFileAttribute \ @@ -592,41 +497,17 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclMacOSXMatchType) /* 18 */ #define TclMacOSXNotifierAddRunLoopMode \ (tclIntPlatStubsPtr->tclMacOSXNotifierAddRunLoopMode) /* 19 */ -#define TclWinAddProcess \ - (tclIntPlatStubsPtr->tclWinAddProcess) /* 20 */ +/* Slot 20 is reserved */ /* Slot 21 is reserved */ -#define TclpCreateTempFile \ - (tclIntPlatStubsPtr->tclpCreateTempFile) /* 22 */ +/* Slot 22 is reserved */ /* Slot 23 is reserved */ -#define TclWinNoBackslash \ - (tclIntPlatStubsPtr->tclWinNoBackslash) /* 24 */ +/* Slot 24 is reserved */ /* Slot 25 is reserved */ -#define TclWinSetInterfaces \ - (tclIntPlatStubsPtr->tclWinSetInterfaces) /* 26 */ -#define TclWinFlushDirtyChannels \ - (tclIntPlatStubsPtr->tclWinFlushDirtyChannels) /* 27 */ -#define TclWinResetInterfaces \ - (tclIntPlatStubsPtr->tclWinResetInterfaces) /* 28 */ +/* Slot 26 is reserved */ +/* Slot 27 is reserved */ +/* Slot 28 is reserved */ #define TclWinCPUID \ (tclIntPlatStubsPtr->tclWinCPUID) /* 29 */ -#define TclGetAndDetachPids \ - (tclIntPlatStubsPtr->tclGetAndDetachPids) /* 30 */ -#define TclpCloseFile \ - (tclIntPlatStubsPtr->tclpCloseFile) /* 31 */ -#define TclpCreateCommandChannel \ - (tclIntPlatStubsPtr->tclpCreateCommandChannel) /* 32 */ -#define TclpCreatePipe \ - (tclIntPlatStubsPtr->tclpCreatePipe) /* 33 */ -#define TclpCreateProcess \ - (tclIntPlatStubsPtr->tclpCreateProcess) /* 34 */ -#define TclpInetNtoa \ - (tclIntPlatStubsPtr->tclpInetNtoa) /* 35 */ -#define TclpMakeFile \ - (tclIntPlatStubsPtr->tclpMakeFile) /* 36 */ -#define TclpOpenFile \ - (tclIntPlatStubsPtr->tclpOpenFile) /* 37 */ -#define TclUnixWaitForFile \ - (tclIntPlatStubsPtr->tclUnixWaitForFile) /* 38 */ #endif /* MACOSX */ #endif /* defined(USE_TCL_STUBS) */ @@ -637,13 +518,12 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; #define TCL_STORAGE_CLASS DLLIMPORT #undef TclpLocaltime_unix #undef TclpGmtime_unix -#undef TclIntPlatReserved13 #undef TclWinConvertWSAError #define TclWinConvertWSAError TclWinConvertError -#if !defined(__WIN32__) -# undef TclpGetPid -# define TclpGetPid(pid) ((unsigned long) (pid)) +#if !defined(__WIN32__) && !defined(__CYGWIN__) +# undef TclpGetPid +# define TclpGetPid(pid) ((unsigned long) (pid)) #endif #endif /* _TCLINTPLATDECLS */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 9e5868a..1b671d4 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -53,26 +53,26 @@ static int TclSockMinimumBuffersOld(int sock, int size) } #endif -#ifdef __CYGWIN__ -#define TclWinGetPlatformId winGetPlatformId -#define Tcl_WinUtfToTChar winUtfToTChar -#define Tcl_WinTCharToUtf winTCharToUtf -#define TclWinGetTclInstance winGetTclInstance -#define TclWinNToHS winNToHS -#define TclWinSetSockOpt winSetSockOpt -#define TclWinGetSockOpt winGetSockOpt -#define TclWinGetServByName winGetServByName -#define TclWinNoBackslash winNoBackslash -#define TclWinSetInterfaces (void (*) (int)) doNothing -#define TclWinAddProcess (void (*) (void *, unsigned int)) doNothing -#define TclIntPlatReserved13 (void (*) ()) TclpCreateCommandChannel -#define TclWinFlushDirtyChannels doNothing -#define TclWinResetInterfaces doNothing -#define TclpGetPid getPid +#ifdef __WIN32__ +# define TclUnixWaitForFile 0 +# define TclpReaddir 0 +# define TclpIsAtty 0 +#elif defined(__CYGWIN__) +# define TclpIsAtty TclPlatIsAtty +# define TclWinSetInterfaces (void (*) (int)) doNothing +# define TclWinAddProcess (void (*) (void *, unsigned int)) doNothing +# define TclWinFlushDirtyChannels doNothing +# define TclWinResetInterfaces doNothing static Tcl_Encoding winTCharEncoding; static int +TclpIsAtty(int fd) +{ + return isatty(fd); +} + +int TclWinGetPlatformId() { /* Don't bother to determine the real platform on cygwin, @@ -80,7 +80,7 @@ TclWinGetPlatformId() return 2; /* VER_PLATFORM_WIN32_NT */; } -static void *TclWinGetTclInstance() +void *TclWinGetTclInstance() { void *hInstance = NULL; GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, @@ -88,21 +88,21 @@ static void *TclWinGetTclInstance() return hInstance; } -static unsigned short +unsigned short TclWinNToHS(unsigned short ns) { return ntohs(ns); } -static int -TclWinSetSockOpt(void *s, int level, int optname, +int +TclWinSetSockOpt(SOCKET s, int level, int optname, const char *optval, int optlen) { return setsockopt((int) s, level, optname, optval, optlen); } -static int -TclWinGetSockOpt(void *s, int level, int optname, +int +TclWinGetSockOpt(SOCKET s, int level, int optname, char *optval, int *optlen) { return getsockopt((int) s, level, optname, optval, optlen); @@ -114,7 +114,7 @@ TclWinGetServByName(const char *name, const char *proto) return getservbyname(name, proto); } -static char * +char * TclWinNoBackslash(char *path) { char *p; @@ -127,7 +127,7 @@ TclWinNoBackslash(char *path) return path; } -static int +int TclpGetPid(Tcl_Pid pid) { return (int) (size_t) pid; @@ -139,11 +139,11 @@ doNothing(void) /* dummy implementation, no need to do anything */ } -static char * -Tcl_WinUtfToTChar(string, len, dsPtr) - const char *string; - int len; - Tcl_DString *dsPtr; +char * +Tcl_WinUtfToTChar( + const char *string, + int len, + Tcl_DString *dsPtr) { if (!winTCharEncoding) { winTCharEncoding = Tcl_GetEncoding(0, "unicode"); @@ -152,7 +152,7 @@ Tcl_WinUtfToTChar(string, len, dsPtr) string, len, dsPtr); } -static char * +char * Tcl_WinTCharToUtf( const char *string, int len, @@ -173,30 +173,7 @@ Tcl_WinTCharToUtf( #define TclpLocaltime_unix (struct tm *(*) (const time_t *)) TclGetAndDetachPids #define TclpGmtime_unix (struct tm *(*) (const time_t *)) TclpCloseFile -#elif !defined(__WIN32__) /* UNIX and MAC */ -# define TclWinConvertError (void (*) (unsigned int)) TclGetAndDetachPids -# undef TclWinConvertWSAError -# define TclWinConvertWSAError (void (*) (unsigned int)) TclpCloseFile -# define TclWinGetPlatformId (int (*)()) TclpCreateTempFile -# define TclWinGetTclInstance (void *(*)()) TclpCreateProcess -# define TclWinNToHS (unsigned short (*) _ANSI_ARGS_((unsigned short ns))) TclpMakeFile -# define TclWinSetSockOpt (int (*) (void *, int, int, const char *, int)) TclpOpenFile -# define TclWinGetSockOpt (int (*) (void *, int, int, char *, int *)) TclpCreatePipe -# define TclWinGetServByName (struct servent *(*) (const char *nm, const char *proto)) TclpCreateCommandChannel -# define TclIntPlatReserved13 (void (*) ()) TclpInetNtoa -# define TclWinAddProcess 0 -# define TclWinNoBackslash 0 -# define TclWinSetInterfaces 0 -# define TclWinFlushDirtyChannels 0 -# define TclWinResetInterfaces 0 -# define TclpGetPid 0 -# ifndef MAC_OSX_TCL -# define TclMacOSXMatchType 0 -# define TclMacOSXNotifierAddRunLoopMode 0 -# define TclMacOSXGetFileAttribute 0 -# define Tcl_MacOSXOpenBundleResources 0 -# define Tcl_MacOSXOpenVersionedBundleResources 0 -# endif +#else /* UNIX and MAC */ # define TclpLocaltime_unix TclpLocaltime # define TclpGmtime_unix TclpGmtime #endif @@ -471,70 +448,61 @@ static const TclIntStubs tclIntStubs = { static const TclIntPlatStubs tclIntPlatStubs = { TCL_STUB_MAGIC, 0, -#if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ - TclWinConvertError, /* 0 */ - TclWinConvertWSAError, /* 1 */ - TclWinGetServByName, /* 2 */ - TclWinGetSockOpt, /* 3 */ - TclWinGetTclInstance, /* 4 */ +#if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */ + TclGetAndDetachPids, /* 0 */ + TclpCloseFile, /* 1 */ + TclpCreateCommandChannel, /* 2 */ + TclpCreatePipe, /* 3 */ + TclpCreateProcess, /* 4 */ 0, /* 5 */ - TclWinNToHS, /* 6 */ - TclWinSetSockOpt, /* 7 */ - TclpGetPid, /* 8 */ - TclWinGetPlatformId, /* 9 */ + TclpMakeFile, /* 6 */ + TclpOpenFile, /* 7 */ + TclUnixWaitForFile, /* 8 */ + TclpCreateTempFile, /* 9 */ TclpReaddir, /* 10 */ TclpLocaltime_unix, /* 11 */ TclpGmtime_unix, /* 12 */ - TclIntPlatReserved13, /* 13 */ + TclpInetNtoa, /* 13 */ TclUnixCopyFile, /* 14 */ - TclMacOSXGetFileAttribute, /* 15 */ + 0, /* 15 */ 0, /* 16 */ 0, /* 17 */ - TclMacOSXMatchType, /* 18 */ - TclMacOSXNotifierAddRunLoopMode, /* 19 */ - TclWinAddProcess, /* 20 */ + 0, /* 18 */ + 0, /* 19 */ + 0, /* 20 */ 0, /* 21 */ - TclpCreateTempFile, /* 22 */ + 0, /* 22 */ 0, /* 23 */ - TclWinNoBackslash, /* 24 */ + 0, /* 24 */ 0, /* 25 */ - TclWinSetInterfaces, /* 26 */ - TclWinFlushDirtyChannels, /* 27 */ - TclWinResetInterfaces, /* 28 */ + 0, /* 26 */ + 0, /* 27 */ + 0, /* 28 */ TclWinCPUID, /* 29 */ - TclGetAndDetachPids, /* 30 */ - TclpCloseFile, /* 31 */ - TclpCreateCommandChannel, /* 32 */ - TclpCreatePipe, /* 33 */ - TclpCreateProcess, /* 34 */ - TclpInetNtoa, /* 35 */ - TclpMakeFile, /* 36 */ - TclpOpenFile, /* 37 */ - TclUnixWaitForFile, /* 38 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ TclWinConvertError, /* 0 */ TclWinConvertWSAError, /* 1 */ TclWinGetServByName, /* 2 */ TclWinGetSockOpt, /* 3 */ TclWinGetTclInstance, /* 4 */ - 0, /* 5 */ + TclUnixWaitForFile, /* 5 */ TclWinNToHS, /* 6 */ TclWinSetSockOpt, /* 7 */ TclpGetPid, /* 8 */ TclWinGetPlatformId, /* 9 */ - 0, /* 10 */ + TclpReaddir, /* 10 */ TclGetAndDetachPids, /* 11 */ TclpCloseFile, /* 12 */ TclpCreateCommandChannel, /* 13 */ TclpCreatePipe, /* 14 */ TclpCreateProcess, /* 15 */ - 0, /* 16 */ + TclpIsAtty, /* 16 */ 0, /* 17 */ TclpMakeFile, /* 18 */ TclpOpenFile, /* 19 */ TclWinAddProcess, /* 20 */ - 0, /* 21 */ + TclpInetNtoa, /* 21 */ TclpCreateTempFile, /* 22 */ 0, /* 23 */ TclWinNoBackslash, /* 24 */ @@ -545,45 +513,36 @@ static const TclIntPlatStubs tclIntPlatStubs = { TclWinCPUID, /* 29 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ - TclWinConvertError, /* 0 */ - TclWinConvertWSAError, /* 1 */ - TclWinGetServByName, /* 2 */ - TclWinGetSockOpt, /* 3 */ - TclWinGetTclInstance, /* 4 */ + TclGetAndDetachPids, /* 0 */ + TclpCloseFile, /* 1 */ + TclpCreateCommandChannel, /* 2 */ + TclpCreatePipe, /* 3 */ + TclpCreateProcess, /* 4 */ 0, /* 5 */ - TclWinNToHS, /* 6 */ - TclWinSetSockOpt, /* 7 */ - TclpGetPid, /* 8 */ - TclWinGetPlatformId, /* 9 */ + TclpMakeFile, /* 6 */ + TclpOpenFile, /* 7 */ + TclUnixWaitForFile, /* 8 */ + TclpCreateTempFile, /* 9 */ TclpReaddir, /* 10 */ TclpLocaltime_unix, /* 11 */ TclpGmtime_unix, /* 12 */ - TclIntPlatReserved13, /* 13 */ + TclpInetNtoa, /* 13 */ TclUnixCopyFile, /* 14 */ TclMacOSXGetFileAttribute, /* 15 */ TclMacOSXSetFileAttribute, /* 16 */ TclMacOSXCopyFileAttributes, /* 17 */ TclMacOSXMatchType, /* 18 */ TclMacOSXNotifierAddRunLoopMode, /* 19 */ - TclWinAddProcess, /* 20 */ + 0, /* 20 */ 0, /* 21 */ - TclpCreateTempFile, /* 22 */ + 0, /* 22 */ 0, /* 23 */ - TclWinNoBackslash, /* 24 */ + 0, /* 24 */ 0, /* 25 */ - TclWinSetInterfaces, /* 26 */ - TclWinFlushDirtyChannels, /* 27 */ - TclWinResetInterfaces, /* 28 */ + 0, /* 26 */ + 0, /* 27 */ + 0, /* 28 */ TclWinCPUID, /* 29 */ - TclGetAndDetachPids, /* 30 */ - TclpCloseFile, /* 31 */ - TclpCreateCommandChannel, /* 32 */ - TclpCreatePipe, /* 33 */ - TclpCreateProcess, /* 34 */ - TclpInetNtoa, /* 35 */ - TclpMakeFile, /* 36 */ - TclpOpenFile, /* 37 */ - TclUnixWaitForFile, /* 38 */ #endif /* MACOSX */ }; @@ -690,7 +649,7 @@ const TclStubs tclStubs = { #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ Tcl_CreateFileHandler, /* 9 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) /* WIN */ 0, /* 9 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ @@ -699,7 +658,7 @@ const TclStubs tclStubs = { #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ Tcl_DeleteFileHandler, /* 10 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) /* WIN */ 0, /* 10 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ @@ -864,7 +823,7 @@ const TclStubs tclStubs = { #if !defined(__WIN32__) && !defined(MAC_OSX_TCL) /* UNIX */ Tcl_GetOpenFile, /* 167 */ #endif /* UNIX */ -#ifdef __WIN32__ /* WIN */ +#if defined(__WIN32__) /* WIN */ 0, /* 167 */ #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ diff --git a/generic/tclTimer.c b/generic/tclTimer.c index cf91dca..36adaad 100644 --- a/generic/tclTimer.c +++ b/generic/tclTimer.c @@ -182,8 +182,7 @@ static void TimerSetupProc(ClientData clientData, int flags); static ThreadSpecificData * InitTimer(void) { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - TclThreadDataKeyGet(&dataKey); + ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey); if (tsdPtr == NULL) { tsdPtr = TCL_TSD_INIT(&dataKey); @@ -214,8 +213,7 @@ static void TimerExitProc( ClientData clientData) /* Not used. */ { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - TclThreadDataKeyGet(&dataKey); + ThreadSpecificData *tsdPtr = TclThreadDataKeyGet(&dataKey); Tcl_DeleteEventSource(TimerSetupProc, TimerCheckProc, NULL); if (tsdPtr != NULL) { @@ -297,9 +295,8 @@ TclCreateAbsoluteTimerHandler( ClientData clientData) { register TimerHandler *timerHandlerPtr, *tPtr2, *prevPtr; - ThreadSpecificData *tsdPtr; + ThreadSpecificData *tsdPtr = InitTimer(); - tsdPtr = InitTimer(); timerHandlerPtr = ckalloc(sizeof(TimerHandler)); /* diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 3063b59..09cddcc 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -130,12 +130,6 @@ typedef struct { #define DEFAULT_BUFFER_SIZE 4096 /* - * Time to wait before delivering a timer event. - */ - -#define TRANSFORM_TIMEOUT 0 - -/* * Prototypes for private procedures defined later in this file: */ @@ -3126,7 +3120,7 @@ ZlibTransformWatch( if (!(mask & TCL_READABLE) || Tcl_DStringLength(&cd->decompressed) == 0) { ZlibTransformEventTimerKill(cd); } else if (cd->timer == NULL) { - cd->timer = Tcl_CreateTimerHandler(TRANSFORM_TIMEOUT, + cd->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, ZlibTransformTimerRun, cd); } } diff --git a/library/safe.tcl b/library/safe.tcl index 52f6e85..4ad5c36 100644 --- a/library/safe.tcl +++ b/library/safe.tcl @@ -467,7 +467,8 @@ proc ::safe::InterpInit { ::interp expose $slave file foreach subcommand {dirname extension rootname tail} { - ::interp alias $slave ::tcl::file::$subcommand {} file $subcommand + ::interp alias $slave ::tcl::file::$subcommand {} \ + ::safe::AliasFileSubcommand $slave $subcommand } foreach subcommand { atime attributes copy delete executable exists isdirectory isfile @@ -675,6 +676,17 @@ proc ::safe::CheckFileName {slave file} { } } +# AliasFileSubcommand handles selected subcommands of [file] in safe +# interpreters that are *almost* safe. In particular, it just acts to +# prevent discovery of what home directories exist. + +proc ::safe::AliasFileSubcommand {slave subcommand name} { + if {[string match ~* $name]} { + set name ./$name + } + tailcall $slave invokehidden tcl:file:$subcommand $name +} + # AliasGlob is the target of the "glob" alias in safe interpreters. proc ::safe::AliasGlob {slave args} { @@ -761,6 +773,8 @@ proc ::safe::AliasGlob {slave args} { foreach opt [lrange $args $at end] { if {![regexp $dirPartRE $opt -> thedir thefile]} { set thedir . + } elseif {[string match ~* $thedir]} { + set thedir ./$thedir } if {$thedir eq "*" && ($thefile eq "pkgIndex.tcl" || $thefile eq "*.tm")} { diff --git a/tests/safe.test b/tests/safe.test index 98d4543..f270248 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -27,7 +27,7 @@ set ::auto_path [info library] # Force actual loading of the safe package because we use un exported (and # thus un-autoindexed) APIs in this test result arguments: catch {safe::interpConfigure} - + # testing that nested and statics do what is advertised (we use a static # package - Tcltest - but it might be absent if we're in standard tclsh) @@ -698,6 +698,52 @@ test safe-15.1 {safe file ensemble does not surprise code} -setup { } -cleanup { interp delete $i } -result {1 {a b c} 1 {a b c} 1 {invalid command name "file"} 1 0 {a b c} 1 {not allowed to invoke subcommand isdirectory of file}} + +### ~ should have no special meaning in paths in safe interpreters +test safe-16.1 {Bug 3529949: defang ~ in paths} -setup { + set savedHOME $env(HOME) + set env(HOME) /foo/bar + set i [safe::interpCreate] +} -body { + $i eval { + set d [format %c 126] + list [file join [file dirname $d] [file tail $d]] + } +} -cleanup { + safe::interpDelete $i + set env(HOME) $savedHOME +} -result {./~} +test safe-16.2 {Bug 3529949: defang ~user in paths} -setup { + set i [safe::interpCreate] + set user $tcl_platform(user) +} -body { + string map [list $user USER] [$i eval \ + "file join \[file dirname ~$user\] \[file tail ~$user\]"] +} -cleanup { + safe::interpDelete $i +} -result {./~USER} +test safe-16.3 {Bug 3529949: defang ~ in globs} -setup { + set syntheticHOME [makeDirectory foo] + makeFile {} bar $syntheticHOME + set savedHOME $env(HOME) + set env(HOME) $syntheticHOME + set i [safe::interpCreate] +} -body { + ::safe::interpAddToAccessPath $i $syntheticHOME + $i eval {glob -nocomplain ~/*} +} -cleanup { + safe::interpDelete $i + set env(HOME) $savedHOME + removeDirectory $syntheticHOME +} -result {} +test safe-16.4 {Bug 3529949: defang ~user in globs} -setup { + set i [safe::interpCreate] +} -body { + ::safe::interpAddToAccessPath $i $~$tcl_platform(user) + $i eval [list glob -nocomplain ~$tcl_platform(user)/*] +} -cleanup { + safe::interpDelete $i +} -result {} set ::auto_path $saveAutoPath # cleanup diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index e654bf4..dea63e6 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -279,18 +279,26 @@ proc genStubs::rewriteFile {file text} { # Results: # Returns the original text inside an appropriate #ifdef. -proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { +proc genStubs::addPlatformGuard {plat iftxt {eltxt {}} {withCygwin 0}} { set text "" switch $plat { win { - append text "#ifdef __WIN32__ /* WIN */\n${iftxt}" + append text "#if defined(__WIN32__)" + if {$withCygwin} { + append text " || defined(__CYGWIN__)" + } + append text " /* WIN */\n${iftxt}" if {$eltxt ne ""} { append text "#else /* WIN */\n${eltxt}" } append text "#endif /* WIN */\n" } unix { - append text "#if !defined(__WIN32__) && !defined(MAC_OSX_TCL)\ + append text "#if !defined(__WIN32__)" + if {$withCygwin} { + append text " && !defined(__CYGWIN__)" + } + append text " && !defined(MAC_OSX_TCL)\ /* UNIX */\n${iftxt}" if {$eltxt ne ""} { append text "#else /* UNIX */\n${eltxt}" @@ -312,7 +320,11 @@ proc genStubs::addPlatformGuard {plat iftxt {eltxt {}}} { append text "#endif /* AQUA */\n" } x11 { - append text "#if !(defined(__WIN32__) || defined(MAC_OSX_TK))\ + append text "#if !(defined(__WIN32__)" + if {$withCygwin} { + append text " || defined(__CYGWIN__)" + } + append text " || defined(MAC_OSX_TK))\ /* X11 */\n${iftxt}" if {$eltxt ne ""} { append text "#else /* X11 */\n${eltxt}" @@ -799,7 +811,7 @@ proc genStubs::forAllStubs {name slotProc onAll textVar eval {append temp} $skipString } } - append text [addPlatformGuard $plat $temp] + append text [addPlatformGuard $plat $temp {} true] } ## win ## if {$block(win)} { @@ -813,7 +825,7 @@ proc genStubs::forAllStubs {name slotProc onAll textVar eval {append temp} $skipString } } - append text [addPlatformGuard $plat $temp] + append text [addPlatformGuard $plat $temp {} true] } ## macosx ## if {$block(macosx) && !$block(aqua) && !$block(x11)} { @@ -885,7 +897,7 @@ proc genStubs::forAllStubs {name slotProc onAll textVar } else { eval {set etxt} $skipString append temp [addPlatformGuard $plat [$slotProc \ - $name $stubs($name,$plat,$i) $i] $etxt] + $name $stubs($name,$plat,$i) $i] $etxt true] } set emit 1 break @@ -895,7 +907,7 @@ proc genStubs::forAllStubs {name slotProc onAll textVar eval {append temp} $skipString } } - append text [addPlatformGuard x11 $temp] + append text [addPlatformGuard x11 $temp {} true] } } } diff --git a/win/Makefile.in b/win/Makefile.in index 111f455..44ba581 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -849,14 +849,14 @@ $(GENERIC_DIR)/tclStubInit.c: $(GENERIC_DIR)/tcl.decls \ @echo "This warning can be safely ignored, do not report as a bug!" genstubs: - $(TCL_EXE) "$(ROOT_DIR_NATIVE)\tools\genStubs.tcl" \ + $(TCL_EXE) "$(ROOT_DIR_NATIVE)/tools/genStubs.tcl" \ "$(GENERIC_DIR_NATIVE)" \ - "$(GENERIC_DIR_NATIVE)\tcl.decls" \ - "$(GENERIC_DIR_NATIVE)\tclInt.decls" \ - "$(GENERIC_DIR_NATIVE)\tclTomMath.decls" - $(TCL_EXE) "$(ROOT_DIR_NATIVE)\tools\genStubs.tcl" \ + "$(GENERIC_DIR_NATIVE)/tcl.decls" \ + "$(GENERIC_DIR_NATIVE)/tclInt.decls" \ + "$(GENERIC_DIR_NATIVE)/tclTomMath.decls" + $(TCL_EXE) "$(ROOT_DIR_NATIVE)/tools/genStubs.tcl" \ "$(GENERIC_DIR_NATIVE)" \ - "$(GENERIC_DIR_NATIVE)\tclOO.decls" + "$(GENERIC_DIR_NATIVE)/tclOO.decls" # # This target creates the HTML folder for Tcl & Tk and places it in diff --git a/win/tclWinDde.c b/win/tclWinDde.c index 617e4e5..5f2ef32 100644 --- a/win/tclWinDde.c +++ b/win/tclWinDde.c @@ -13,8 +13,6 @@ #undef STATIC_BUILD #undef USE_TCL_STUBS #define USE_TCL_STUBS -#undef UNICODE -#undef _UNICODE #include "tclInt.h" #include <dde.h> #include <ddeml.h> @@ -22,6 +20,10 @@ #ifndef UNICODE # undef CP_WINUNICODE # define CP_WINUNICODE CP_WINANSI +# undef Tcl_WinTCharToUtf +# define Tcl_WinTCharToUtf(a,b,c) Tcl_ExternalToUtfDString(NULL,a,b,c) +# undef Tcl_WinUtfToTChar +# define Tcl_WinUtfToTChar(a,b,c) Tcl_UtfToExternalDString(NULL,a,b,c) #endif /* @@ -93,6 +95,10 @@ static int ddeIsServer = 0; #define TCL_DDE_SERVICE_NAME TEXT("TclEval") #define TCL_DDE_EXECUTE_RESULT TEXT("$TCLEVAL$EXECUTE$RESULT") +#define DDE_FLAG_ASYNC 1 +#define DDE_FLAG_BINARY 2 +#define DDE_FLAG_FORCE 4 + TCL_DECLARE_MUTEX(ddeMutex) /* @@ -149,6 +155,12 @@ Dde_Init( return TCL_ERROR; } +#ifdef UNICODE + if (TclWinGetPlatformId() < VER_PLATFORM_WIN32_NT) { + Tcl_AppendResult(interp, "Win32s and Windows 9x are not supported platforms", NULL); + return TCL_ERROR; + } +#endif Tcl_CreateObjCommand(interp, "dde", DdeObjCmd, NULL, NULL); Tcl_CreateExitHandler(DdeExitProc, NULL); return Tcl_PkgProvide(interp, TCL_DDE_PACKAGE_NAME, TCL_DDE_VERSION); @@ -235,7 +247,7 @@ Initialize(void) ddeIsServer = 1; Tcl_CreateExitHandler(DdeExitProc, NULL); ddeServiceGlobal = DdeCreateStringHandle(ddeInstance, - TCL_DDE_SERVICE_NAME, 0); + TCL_DDE_SERVICE_NAME, CP_WINUNICODE); DdeNameService(ddeInstance, ddeServiceGlobal, 0L, DNS_REGISTER); } else { ddeIsServer = 0; @@ -275,7 +287,7 @@ DdeSetServerName( const TCHAR *name, /* The name that will be used to refer to the * interpreter in later "send" commands. Must * be globally unique. */ - int exactName, /* Should we make a unique name? 0 = unique */ + int flags, /* DDE_FLAG_FORCE or 0 */ Tcl_Obj *handlerPtr) /* Name of the optional proc/command to handle * incoming Dde eval's */ { @@ -323,16 +335,15 @@ DdeSetServerName( return TEXT(""); } - Tcl_DStringInit(&dString); - /* * Get the list of currently registered Tcl interpreters by calling the * internal implementation of the 'dde services' command. */ + Tcl_DStringInit(&dString); actualName = name; - if (!exactName) { + if (!(flags & DDE_FLAG_FORCE)) { r = DdeGetServicesList(interp, TCL_DDE_SERVICE_NAME, NULL); if (r == TCL_OK) { srvListPtr = Tcl_GetObjResult(interp); @@ -342,7 +353,9 @@ DdeSetServerName( &srvPtrPtr); } if (r != TCL_OK) { - OutputDebugString(Tcl_GetStringResult(interp)); + Tcl_WinUtfToTChar(Tcl_GetStringResult(interp), -1, &dString); + OutputDebugString((TCHAR *) Tcl_DStringValue(&dString)); + Tcl_DStringFree(&dString); return NULL; } @@ -359,13 +372,13 @@ DdeSetServerName( lastSuffix = suffix; if (suffix > 1) { if (suffix == 2) { - Tcl_DStringAppend(&dString, name, -1); - Tcl_DStringAppend(&dString, " #", 2); + Tcl_DStringAppend(&dString, (char *)name, _tcslen(name) * sizeof(TCHAR)); + Tcl_DStringAppend(&dString, (char *)TEXT(" #"), 2 * sizeof(TCHAR)); offset = Tcl_DStringLength(&dString); - Tcl_DStringSetLength(&dString, offset + TCL_INTEGER_SPACE); - actualName = Tcl_DStringValue(&dString); + Tcl_DStringSetLength(&dString, offset + sizeof(TCHAR) * TCL_INTEGER_SPACE); + actualName = (TCHAR *) Tcl_DStringValue(&dString); } - sprintf(Tcl_DStringValue(&dString) + offset, "%d", suffix); + _stprintf((TCHAR *) (Tcl_DStringValue(&dString) + offset), TEXT("%d"), suffix); } /* @@ -374,16 +387,18 @@ DdeSetServerName( for (n = 0; n < srvCount; ++n) { Tcl_Obj* namePtr; + Tcl_DString ds; Tcl_ListObjIndex(interp, srvPtrPtr[n], 1, &namePtr); - if (_tcscmp(actualName, Tcl_GetString(namePtr)) == 0) { + Tcl_WinUtfToTChar(Tcl_GetString(namePtr), -1, &ds); + if (_tcscmp(actualName, (TCHAR *)Tcl_DStringValue(&ds)) == 0) { suffix++; + Tcl_DStringFree(&ds); break; } + Tcl_DStringFree(&ds); } } - Tcl_DStringSetLength(&dString, - offset + (int)strlen(Tcl_DStringValue(&dString)+offset)); } /* @@ -629,7 +644,7 @@ DdeServerProc( * sure we have a valid topic. */ - len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, 0); + len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, CP_WINUNICODE); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, (len + 1) * sizeof(TCHAR) - 1); utilString = (TCHAR *) Tcl_DStringValue(&dString); @@ -654,7 +669,7 @@ DdeServerProc( * result to return in an XTYP_REQUEST. */ - len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, 0); + len = DdeQueryString(ddeInstance, ddeTopic, NULL, 0, CP_WINUNICODE); Tcl_DStringInit(&dString); Tcl_DStringSetLength(&dString, (len + 1) * sizeof(TCHAR) - 1); utilString = (TCHAR *) Tcl_DStringValue(&dString); @@ -742,8 +757,11 @@ DdeServerProc( if (Tcl_IsSafe(convPtr->riPtr->interp)) { ddeReturn = NULL; } else { - Tcl_Obj *variableObjPtr = Tcl_GetVar2Ex( - convPtr->riPtr->interp, utilString, NULL, + Tcl_DString ds; + Tcl_Obj *variableObjPtr; + Tcl_WinTCharToUtf(utilString, -1, &ds); + variableObjPtr = Tcl_GetVar2Ex( + convPtr->riPtr->interp, Tcl_DStringValue(&ds), NULL, TCL_GLOBAL_ONLY); if (variableObjPtr != NULL) { if (uFmt == CF_TEXT) { @@ -760,6 +778,7 @@ DdeServerProc( } else { ddeReturn = NULL; } + Tcl_DStringFree(&ds); } } Tcl_DStringFree(&dString); @@ -773,6 +792,7 @@ DdeServerProc( */ Tcl_Obj *returnPackagePtr; + char *string; for (convPtr = tsdPtr->currentConversations; (convPtr != NULL) && (convPtr->hConv != hConv); convPtr = convPtr->nextPtr) { @@ -786,11 +806,21 @@ DdeServerProc( } utilString = (TCHAR *) DdeAccessData(hData, &dlen); - len = dlen; - if (len && !utilString[len-1]) { - len--; + string = (char *) utilString; + if (!dlen) { + /* Empty binary array. */ + ddeObjectPtr = Tcl_NewObj(); + } else if ((dlen & 1) || utilString[(dlen>>1)-1]) { + /* Cannot be unicode, so assume utf-8 */ + if (!string[dlen-1]) { + dlen--; + } + ddeObjectPtr = Tcl_NewStringObj(string, dlen); + } else { + /* unicode */ + dlen >>= 1; + ddeObjectPtr = Tcl_NewUnicodeObj((Tcl_UniChar *)utilString, dlen - 1); } - ddeObjectPtr = Tcl_NewStringObj(utilString, len); Tcl_IncrRefCount(ddeObjectPtr); DdeUnaccessData(hData); if (convPtr->returnPackagePtr != NULL) { @@ -908,8 +938,8 @@ MakeDdeConnection( HSZ ddeTopic, ddeService; HCONV ddeConv; - ddeService = DdeCreateStringHandle(ddeInstance, TCL_DDE_SERVICE_NAME, 0); - ddeTopic = DdeCreateStringHandle(ddeInstance, name, 0); + ddeService = DdeCreateStringHandle(ddeInstance, TCL_DDE_SERVICE_NAME, CP_WINUNICODE); + ddeTopic = DdeCreateStringHandle(ddeInstance, name, CP_WINUNICODE); ddeConv = DdeConnect(ddeInstance, ddeService, ddeTopic, NULL); DdeFreeStringHandle(ddeInstance, ddeService); @@ -1010,6 +1040,7 @@ DdeServicesOnAck( ATOM topic = (ATOM)HIWORD(lParam); struct DdeEnumServices *es; TCHAR sz[255]; + Tcl_DString dString; #ifdef _WIN64 es = (struct DdeEnumServices *) GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -1023,9 +1054,13 @@ DdeServicesOnAck( Tcl_Obj *resultPtr = Tcl_GetObjResult(es->interp); GlobalGetAtomName(service, sz, 255); - Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(sz, -1)); + Tcl_WinTCharToUtf(sz, -1, &dString); + Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), -1)); + Tcl_DStringFree(&dString); GlobalGetAtomName(topic, sz, 255); - Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(sz, -1)); + Tcl_WinTCharToUtf(sz, -1, &dString); + Tcl_ListObjAppendElement(NULL, matchPtr, Tcl_NewStringObj(Tcl_DStringValue(&dString), -1)); + Tcl_DStringFree(&dString); /* * Adding the hwnd as a third list element provides a unique @@ -1197,8 +1232,7 @@ DdeObjCmd( }; int index, i, length, argIndex; - int async = 0, binary = 0, exact = 0; - int result = TCL_OK, firstArg = 0; + int flags = 0, result = TCL_OK, firstArg = 0; HSZ ddeService = NULL, ddeTopic = NULL, ddeItem = NULL, ddeCookie = NULL; HDDEDATA ddeData = NULL, ddeItemData = NULL, ddeReturn; HCONV hConv = NULL; @@ -1238,7 +1272,7 @@ DdeObjCmd( break; } if (argIndex == DDE_SERVERNAME_EXACT) { - exact = 1; + flags |= DDE_FLAG_FORCE; } else if (argIndex == DDE_SERVERNAME_HANDLER) { if ((objc - i) == 1) { /* return current handler */ RegisteredInterp *riPtr = DdeGetRegistrationPtr(interp); @@ -1278,9 +1312,9 @@ DdeObjCmd( goto wrongDdeExecuteArgs; } if (argIndex == DDE_EXEC_ASYNC) { - async = 1; + flags |= DDE_FLAG_ASYNC; } else { - binary = 1; + flags |= DDE_FLAG_BINARY; } } break; @@ -1296,7 +1330,7 @@ DdeObjCmd( break; } else if ((objc == 7) && (Tcl_GetIndexFromObj(NULL, objv[2], ddeReqOptions, "option", 0, &argIndex) == TCL_OK)) { - binary = 1; + flags |= DDE_FLAG_BINARY; firstArg = 3; break; } @@ -1314,7 +1348,7 @@ DdeObjCmd( break; } else if ((objc == 6) && (Tcl_GetIndexFromObj(NULL, objv[2], ddeReqOptions, "option", 0, &argIndex) == TCL_OK)) { - binary = 1; + flags |= DDE_FLAG_BINARY; firstArg = 3; break; } @@ -1345,7 +1379,7 @@ DdeObjCmd( if (objc < 5) { goto wrongDdeEvalArgs; } - async = 1; + flags |= DDE_FLAG_ASYNC; firstArg++; } break; @@ -1355,7 +1389,11 @@ DdeObjCmd( Initialize(); if (firstArg != 1) { +#ifdef UNICODE + serviceName = Tcl_GetUnicodeFromObj(objv[firstArg], &length); +#else serviceName = Tcl_GetStringFromObj(objv[firstArg], &length); +#endif } else { length = 0; } @@ -1368,7 +1406,11 @@ DdeObjCmd( } if ((index != DDE_SERVERNAME) && (index != DDE_EVAL)) { +#ifdef UNICODE + topicName = (TCHAR *) Tcl_GetUnicodeFromObj(objv[firstArg + 1], &length); +#else topicName = Tcl_GetStringFromObj(objv[firstArg + 1], &length); +#endif if (length == 0) { topicName = NULL; } else { @@ -1379,10 +1421,10 @@ DdeObjCmd( switch ((enum DdeSubcommands) index) { case DDE_SERVERNAME: - serviceName = DdeSetServerName(interp, serviceName, exact, + serviceName = DdeSetServerName(interp, serviceName, flags, handlerPtr); if (serviceName != NULL) { - Tcl_SetObjResult(interp, Tcl_NewStringObj(serviceName, -1)); + Tcl_SetObjResult(interp, Tcl_NewUnicodeObj((Tcl_UniChar *) serviceName, -1)); } else { Tcl_ResetResult(interp); } @@ -1390,18 +1432,18 @@ DdeObjCmd( case DDE_EXECUTE: { int dataLength; - BYTE *dataString; + const char *dataString; - if (binary) { - dataString = (BYTE *) + if (flags & DDE_FLAG_BINARY) { + dataString = (const char *) Tcl_GetByteArrayFromObj(objv[firstArg + 2], &dataLength); } else { - dataString = (BYTE *) + dataString = Tcl_GetStringFromObj(objv[firstArg + 2], &dataLength); dataLength += 1; } - if (dataLength <= (binary ? 0 : sizeof(TCHAR))) { + if (dataLength <= ((flags & DDE_FLAG_BINARY) ? 0 : (int)sizeof(TCHAR))) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot execute null data", -1)); Tcl_SetErrorCode(interp, "TCL", "DDE", "NULL", NULL); @@ -1418,10 +1460,10 @@ DdeObjCmd( break; } - ddeData = DdeCreateDataHandle(ddeInstance, dataString, + ddeData = DdeCreateDataHandle(ddeInstance, (BYTE *) dataString, (DWORD) dataLength, 0, 0, CF_TEXT, 0); if (ddeData != NULL) { - if (async) { + if (flags & DDE_FLAG_ASYNC) { DdeClientTransaction((LPBYTE) ddeData, 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, TIMEOUT_ASYNC, &ddeResult); DdeAbandonTransaction(ddeInstance, hConv, ddeResult); @@ -1472,9 +1514,9 @@ DdeObjCmd( DWORD tmp; const char *dataString = (const char *) DdeAccessData(ddeData, &tmp); - if (binary) { - returnObjPtr = Tcl_NewByteArrayObj((BYTE *) dataString, - (int) tmp); + if (flags & DDE_FLAG_BINARY) { + returnObjPtr = + Tcl_NewByteArrayObj((BYTE *) dataString, (int) tmp); } else { if (tmp && !dataString[tmp-1]) { --tmp; @@ -1506,7 +1548,7 @@ DdeObjCmd( result = TCL_ERROR; goto cleanup; } - if (binary) { + if (flags & DDE_FLAG_BINARY) { dataString = (BYTE *) Tcl_GetByteArrayFromObj(objv[firstArg + 3], &length); } else { @@ -1556,8 +1598,8 @@ DdeObjCmd( goto cleanup; } - objc -= (async + 3); - objv += (async + 3); + objc -= firstArg + 1; + objv += firstArg + 1; /* * See if the target interpreter is local. If so, execute the command @@ -1674,7 +1716,7 @@ DdeObjCmd( ddeItemData = DdeCreateDataHandle(ddeInstance, (BYTE *) string, (DWORD) length+1, 0, 0, CF_TEXT, 0); - if (async) { + if (flags & DDE_FLAG_ASYNC) { ddeData = DdeClientTransaction((LPBYTE) ddeItemData, 0xFFFFFFFF, hConv, 0, CF_TEXT, XTYP_EXECUTE, TIMEOUT_ASYNC, &ddeResult); @@ -1699,7 +1741,7 @@ DdeObjCmd( goto cleanup; } - if (async == 0) { + if (!(flags & DDE_FLAG_ASYNC)) { Tcl_Obj *resultPtr; /* diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 7181701..f0c2251 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -2663,9 +2663,9 @@ TclWinSetSockOpt( return setsockopt(s, level, optname, optval, optlen); } -u_short +unsigned short TclWinNToHS( - u_short netshort) + unsigned short netshort) { /* * Check that WinSock is initialized; do not call it if not, to prevent @@ -2674,12 +2674,29 @@ TclWinNToHS( */ if (!SocketsEnabled()) { - return (u_short) -1; + return (unsigned short) -1; } return ntohs(netshort); } +char * +TclpInetNtoa( + struct in_addr addr) +{ + /* + * Check that WinSock is initialized; do not call it if not, to prevent + * system crashes. This can happen at exit time if the exit handler for + * WinSock ran before other exit handlers that want to use sockets. + */ + + if (!SocketsEnabled()) { + return NULL; + } + + return inet_ntoa(addr); +} + struct servent * TclWinGetServByName( const char *name, |