Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Merge 9.0 |
|---|---|
| Timelines: | family | ancestors | descendants | both | novem |
| Files: | files | file ages | folders |
| SHA3-256: |
c15675d5afb03411f3616c38841d34e7 |
| User & Date: | jan.nijtmans 2021-04-08 14:42:44.098 |
Context
|
2021-04-08
| ||
| 15:07 | Merge 9.0 check-in: be1a68e282 user: jan.nijtmans tags: novem | |
| 14:42 | Merge 9.0 check-in: c15675d5af user: jan.nijtmans tags: novem | |
| 14:26 | Merge 8.7 check-in: 652f6ffee1 user: jan.nijtmans tags: trunk, main | |
|
2021-04-07
| ||
| 10:47 | Merge 9.0 check-in: 8eeef33e6c user: jan.nijtmans tags: novem | |
Changes
Changes to changes.
| ︙ | ︙ | |||
9014 9015 9016 9017 9018 9019 9020 | 2020-01-30 (bug) Reset WSAGetLastError()/errno in channel close (nijtmans) 2020-02-17 (bug) Win: avoid create of legacy error-vars on init phase (sebres) 2020-02-25 (bug) release refs when setting class's superclasses fails (dkf) 2020-02-26 (bug) C++ compiler compatibility for registry and dde (nijtmans) | | | | 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 | 2020-01-30 (bug) Reset WSAGetLastError()/errno in channel close (nijtmans) 2020-02-17 (bug) Win: avoid create of legacy error-vars on init phase (sebres) 2020-02-25 (bug) release refs when setting class's superclasses fails (dkf) 2020-02-26 (bug) C++ compiler compatibility for registry and dde (nijtmans) => registry 1.3.5 => dde 1.4.3 2020-03-05 (new) Update to Unicode-13 (nijtmans) 2020-03-16 (bug)[8f89e2] Win: env var encoding, env-2.5 (sebres, nijtmans) 2020-03-27 (bug)[767e07] Tcl_Get(Range|UniChar) validate index inputs (nijtmans) |
| ︙ | ︙ |
Changes to doc/StaticLibrary.3.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | .AS Tcl_LibraryInitProc *safeInitProc .AP Tcl_Interp *interp in If not NULL, points to an interpreter into which the library has already been incorporated (i.e., the caller has already invoked the appropriate initialization procedure). NULL means the library has not yet been incorporated into any interpreter. .AP "const char" *prefix in | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | .AS Tcl_LibraryInitProc *safeInitProc .AP Tcl_Interp *interp in If not NULL, points to an interpreter into which the library has already been incorporated (i.e., the caller has already invoked the appropriate initialization procedure). NULL means the library has not yet been incorporated into any interpreter. .AP "const char" *prefix in Prefix for library initialization function. Normally in titlecase (first letter upper-case, all others lower-case), but this is no longer required. .AP Tcl_LibraryInitProc *initProc in Procedure to invoke to incorporate this library into a trusted interpreter. .AP Tcl_LibraryInitProc *safeInitProc in Procedure to call to incorporate this library into a safe interpreter (one that will execute untrusted scripts). NULL means the library cannot be used in safe interpreters. |
| ︙ | ︙ |
Changes to doc/load.n.
| ︙ | ︙ | |||
34 35 36 37 38 39 40 | Once the file has been loaded into the application's address space, one of two initialization procedures will be invoked in the new code. Typically the initialization procedure will add new commands to a Tcl interpreter. The name of the initialization procedure is determined by \fIprefix\fR and whether or not the target interpreter is a safe one. For normal interpreters the name of the initialization | | < < < | | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | Once the file has been loaded into the application's address space, one of two initialization procedures will be invoked in the new code. Typically the initialization procedure will add new commands to a Tcl interpreter. The name of the initialization procedure is determined by \fIprefix\fR and whether or not the target interpreter is a safe one. For normal interpreters the name of the initialization procedure will have the form \fIprefix\fB_Init\fR. For example, if \fIprefix\fR is \fBFoo\fR, the initialization procedure's name will be \fBFoo_Init\fR. .PP If the target interpreter is a safe interpreter, then the name of the initialization procedure will be \fIprefix\fB_SafeInit\fR instead of \fIprefix\fB_Init\fR. The \fIprefix\fB_SafeInit\fR function should be written carefully, so that it initializes the safe interpreter only with partial functionality provided by the library that is safe for use by untrusted code. For more information on Safe\-Tcl, see the \fBsafe\fR manual entry. .PP The initialization procedure must match the following prototype: .PP .CS |
| ︙ | ︙ | |||
80 81 82 83 84 85 86 | The \fBload\fR command also supports libraries that are statically linked with the application, if those libraries have been registered by calling the \fBTcl_StaticLibrary\fR procedure. If \fIfileName\fR is an empty string, then \fIprefix\fR must be specified. .PP If \fIprefix\fR is omitted or specified as an empty string, | | < < | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
The \fBload\fR command also supports libraries that are statically
linked with the application, if those libraries have been registered
by calling the \fBTcl_StaticLibrary\fR procedure.
If \fIfileName\fR is an empty string, then \fIprefix\fR must
be specified.
.PP
If \fIprefix\fR is omitted or specified as an empty string,
Tcl tries to guess the prefix by taking the last element of
\fIfileName\fR, strip off the first three characters if they
are \fBlib\fR, then strip off the next three characters if
they are \fBtcl9\fR, and use any following wordchars but not digits,
converted to titlecase as the prefix.
For example, the command \fBload libxyz4.2.so\fR uses the prefix
\fBXyz\fR and the command \fBload bin/last.so {}\fR uses the
prefix \fBLast\fR.
.PP
If \fIfileName\fR is an empty string, then \fIprefix\fR must
be specified.
The \fBload\fR command first searches for a statically loaded library
|
| ︙ | ︙ |
Changes to doc/unload.n.
| ︙ | ︙ | |||
119 120 121 122 123 124 125 | .PP If \fIprefix\fR is omitted or specified as an empty string, Tcl tries to guess the prefix. This may be done differently on different platforms. The default guess, which is used on most UNIX platforms, is to take the last element of \fIfileName\fR, strip off the first three characters if they are \fBlib\fR, then strip off the next three characters if they | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
.PP
If \fIprefix\fR is omitted or specified as an empty string,
Tcl tries to guess the prefix. This may be done differently on
different platforms. The default guess, which is used on most
UNIX platforms, is to take the last element of
\fIfileName\fR, strip off the first three characters if they
are \fBlib\fR, then strip off the next three characters if they
are \fBtcl9\fR, and use any following wordchars but not digits,
converted to titlecase as the prefix.
For example, the command \fBunload libxyz4.2.so\fR uses the prefix
\fBXyz\fR and the command \fBunload bin/last.so {}\fR uses the
prefix \fBLast\fR.
.SH "PORTABILITY ISSUES"
.TP
\fBUnix\fR\0\0\0\0\0
.
|
| ︙ | ︙ |
Changes to generic/tcl.decls.
| ︙ | ︙ | |||
2498 2499 2500 2501 2502 2503 2504 | interface tclPlat ################################ # Unix specific functions # (none) | < < < < > > > > > > | 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 |
interface tclPlat
################################
# Unix specific functions
# (none)
################################
# Mac OS X specific functions
declare 1 {
int Tcl_MacOSXOpenVersionedBundleResources(Tcl_Interp *interp,
const char *bundleName, const char *bundleVersion,
int hasResourceFile, size_t maxPathLen, char *libraryPath)
}
declare 2 {
void Tcl_MacOSXNotifierAddRunLoopMode(const void *runLoopMode)
}
################################
# Windows specific functions
declare 3 {
void Tcl_WinConvertError(unsigned errCode)
}
##############################################################################
# Public functions that are not accessible via the stubs table.
export {
void Tcl_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc,
|
| ︙ | ︙ |
Changes to generic/tclInt.decls.
| ︙ | ︙ | |||
599 600 601 602 603 604 605 |
interface tclIntPlat
################################
# Platform specific functions
declare 0 {unix win} {
| | | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
interface tclIntPlat
################################
# Platform specific functions
declare 0 {unix win} {
void TclWinConvertError(unsigned errCode)
}
declare 1 {unix win} {
int TclpCloseFile(TclFile file)
}
declare 2 {unix win} {
Tcl_Channel TclpCreateCommandChannel(TclFile readFile,
TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr)
|
| ︙ | ︙ |
Changes to generic/tclIntPlatDecls.h.
| ︙ | ︙ | |||
27 28 29 30 31 32 33 | /* * Exported function declarations: */ #if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */ /* 0 */ | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* * Exported function declarations: */ #if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */ /* 0 */ TCLAPI void TclWinConvertError(unsigned errCode); /* 1 */ TCLAPI int TclpCloseFile(TclFile file); /* 2 */ TCLAPI Tcl_Channel TclpCreateCommandChannel(TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 3 */ |
| ︙ | ︙ | |||
94 95 96 97 98 99 100 | /* 30 */ TCLAPI int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); #endif /* UNIX */ #if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ /* 0 */ | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | /* 30 */ TCLAPI int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); #endif /* UNIX */ #if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ /* 0 */ TCLAPI void TclWinConvertError(unsigned errCode); /* 1 */ TCLAPI int TclpCloseFile(TclFile file); /* 2 */ TCLAPI Tcl_Channel TclpCreateCommandChannel(TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 3 */ |
| ︙ | ︙ | |||
165 166 167 168 169 170 171 | /* 30 */ TCLAPI int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ /* 0 */ | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | /* 30 */ TCLAPI int TclUnixOpenTemporaryFile(Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); #endif /* WIN */ #ifdef MAC_OSX_TCL /* MACOSX */ /* 0 */ TCLAPI void TclWinConvertError(unsigned errCode); /* 1 */ TCLAPI int TclpCloseFile(TclFile file); /* 2 */ TCLAPI Tcl_Channel TclpCreateCommandChannel(TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 3 */ |
| ︙ | ︙ | |||
236 237 238 239 240 241 242 |
#endif /* MACOSX */
typedef struct TclIntPlatStubs {
int magic;
void *hooks;
#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
| | | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
#endif /* MACOSX */
typedef struct TclIntPlatStubs {
int magic;
void *hooks;
#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
void (*tclWinConvertError) (unsigned errCode); /* 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 */
void * (*tclWinGetTclInstance) (void); /* 4 */
int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 5 */
TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */
TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */
|
| ︙ | ︙ | |||
269 270 271 272 273 274 275 |
void (*reserved26)(void);
void (*tclWinFlushDirtyChannels) (void); /* 27 */
void (*reserved28)(void);
int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* UNIX */
#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */
| | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
void (*reserved26)(void);
void (*tclWinFlushDirtyChannels) (void); /* 27 */
void (*reserved28)(void);
int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* UNIX */
#if defined(_WIN32) || defined(__CYGWIN__) /* WIN */
void (*tclWinConvertError) (unsigned errCode); /* 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 */
void * (*tclWinGetTclInstance) (void); /* 4 */
int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 5 */
TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */
TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */
|
| ︙ | ︙ | |||
302 303 304 305 306 307 308 |
void (*reserved26)(void);
void (*tclWinFlushDirtyChannels) (void); /* 27 */
void (*reserved28)(void);
int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* WIN */
#ifdef MAC_OSX_TCL /* MACOSX */
| | | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
void (*reserved26)(void);
void (*tclWinFlushDirtyChannels) (void); /* 27 */
void (*reserved28)(void);
int (*tclWinCPUID) (int index, int *regs); /* 29 */
int (*tclUnixOpenTemporaryFile) (Tcl_Obj *dirObj, Tcl_Obj *basenameObj, Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj); /* 30 */
#endif /* WIN */
#ifdef MAC_OSX_TCL /* MACOSX */
void (*tclWinConvertError) (unsigned errCode); /* 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 */
void * (*tclWinGetTclInstance) (void); /* 4 */
int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 5 */
TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */
TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */
|
| ︙ | ︙ |
Changes to generic/tclLoad.c.
| ︙ | ︙ | |||
12 13 14 15 16 17 18 | #include "tclInt.h" /* * The following structure describes a library that has been loaded either * dynamically (with the "load" command) or statically (as indicated by a call * to Tcl_StaticLibrary). All such libraries are linked together into a | | < < | < < | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include "tclInt.h"
/*
* The following structure describes a library that has been loaded either
* dynamically (with the "load" command) or statically (as indicated by a call
* to Tcl_StaticLibrary). All such libraries are linked together into a
* single list for the process.
*/
typedef struct LoadedLibrary {
char *fileName; /* Name of the file from which the library was
* loaded. An empty string means the library
* is loaded statically. Malloc-ed. */
char *prefix; /* Prefix for the library.
* Malloc-ed. */
Tcl_LoadHandle loadHandle; /* Token for the loaded file which should be
* passed to (*unLoadProcPtr)() when the file
* is no longer needed. If fileName is NULL,
* then this field is irrelevant. */
Tcl_LibraryInitProc *initProc;
/* Initialization function to call to
|
| ︙ | ︙ | |||
222 223 224 225 226 227 228 |
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
Tcl_DStringAppend(&pfx, prefix, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, libraryPtr->prefix, -1);
| < < | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
Tcl_DStringAppend(&pfx, prefix, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, libraryPtr->prefix, -1);
if (strcmp(Tcl_DStringValue(&tmp),
Tcl_DStringValue(&pfx)) == 0) {
namesMatch = 1;
} else {
namesMatch = 0;
}
}
|
| ︙ | ︙ | |||
309 310 311 312 313 314 315 | /* * Threading note - this call used to be protected by a mutex. */ /* * The platform-specific code couldn't figure out the prefix. * Make a guess by taking the last element of the file | | > > > > | | | < | | | < | | | | | | | > > | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
/*
* Threading note - this call used to be protected by a mutex.
*/
/*
* The platform-specific code couldn't figure out the prefix.
* Make a guess by taking the last element of the file
* name, stripping off any leading "lib" and/or "tcl9", and
* then using all of the alphabetic and underline characters
* that follow that.
*/
splitPtr = Tcl_FSSplitPath(objv[1], &pElements);
Tcl_ListObjIndex(NULL, splitPtr, pElements -1, &pkgGuessPtr);
pkgGuess = TclGetString(pkgGuessPtr);
if ((pkgGuess[0] == 'l') && (pkgGuess[1] == 'i')
&& (pkgGuess[2] == 'b')) {
pkgGuess += 3;
}
#ifdef __CYGWIN__
else if ((pkgGuess[0] == 'c') && (pkgGuess[1] == 'y')
&& (pkgGuess[2] == 'g')) {
pkgGuess += 3;
}
#endif /* __CYGWIN__ */
if (((pkgGuess[0] == 't')
#ifdef MAC_OS_TCL
|| (pkgGuess[0] == 'T')
#endif
) && (pkgGuess[1] == 'c')
&& (pkgGuess[2] == 'l') && (pkgGuess[3] == '9')) {
pkgGuess += 4;
}
for (p = pkgGuess; *p != 0; p += offset) {
offset = TclUtfToUniChar(p, &ch);
if (!Tcl_UniCharIsWordChar(UCHAR(ch))
|| Tcl_UniCharIsDigit(UCHAR(ch))) {
break;
}
}
if (p == pkgGuess) {
Tcl_DecrRefCount(splitPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't figure out prefix for %s",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"WHATLIBRARY", NULL);
code = TCL_ERROR;
goto done;
}
Tcl_DStringAppend(&pfx, pkgGuess, p - pkgGuess);
Tcl_DecrRefCount(splitPtr);
/*
* Fix the capitalization in the prefix so that the first
* character is in caps (or title case) but the others are all
* lower-case.
*/
Tcl_DStringSetLength(&pfx,
Tcl_UtfToTitle(Tcl_DStringValue(&pfx)));
}
/*
* Compute the names of the two initialization functions, based on the
* prefix.
*/
TclDStringAppendDString(&initName, &pfx);
|
| ︙ | ︙ | |||
656 657 658 659 660 661 662 |
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
Tcl_DStringAppend(&pfx, prefix, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, libraryPtr->prefix, -1);
| < < | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
if (prefix == NULL) {
namesMatch = 0;
} else {
TclDStringClear(&pfx);
Tcl_DStringAppend(&pfx, prefix, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, libraryPtr->prefix, -1);
if (strcmp(Tcl_DStringValue(&tmp),
Tcl_DStringValue(&pfx)) == 0) {
namesMatch = 1;
} else {
namesMatch = 0;
}
}
|
| ︙ | ︙ | |||
938 939 940 941 942 943 944 |
void
Tcl_StaticLibrary(
Tcl_Interp *interp, /* If not NULL, it means that the library has
* already been loaded into the given
* interpreter by calling the appropriate init
* proc. */
| | < < | 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 |
void
Tcl_StaticLibrary(
Tcl_Interp *interp, /* If not NULL, it means that the library has
* already been loaded into the given
* interpreter by calling the appropriate init
* proc. */
const char *prefix, /* Prefix. */
Tcl_LibraryInitProc *initProc,
/* Function to call to incorporate this
* library into a trusted interpreter. */
Tcl_LibraryInitProc *safeInitProc)
/* Function to call to incorporate this
* library into a safe interpreter (one that
* will execute untrusted scripts). NULL means
|
| ︙ | ︙ |
Changes to generic/tclPlatDecls.h.
| ︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
Tcl_Interp *interp, const char *bundleName,
const char *bundleVersion,
int hasResourceFile, size_t maxPathLen,
char *libraryPath);
/* 2 */
TCLAPI void Tcl_MacOSXNotifierAddRunLoopMode(
const void *runLoopMode);
typedef struct TclPlatStubs {
int magic;
void *hooks;
void (*reserved0)(void);
int (*tcl_MacOSXOpenVersionedBundleResources) (Tcl_Interp *interp, const char *bundleName, const char *bundleVersion, int hasResourceFile, size_t maxPathLen, char *libraryPath); /* 1 */
void (*tcl_MacOSXNotifierAddRunLoopMode) (const void *runLoopMode); /* 2 */
} TclPlatStubs;
extern const TclPlatStubs *tclPlatStubsPtr;
#ifdef __cplusplus
}
#endif
#if defined(USE_TCL_STUBS)
/*
* Inline function declarations:
*/
/* Slot 0 is reserved */
#define Tcl_MacOSXOpenVersionedBundleResources \
(tclPlatStubsPtr->tcl_MacOSXOpenVersionedBundleResources) /* 1 */
#define Tcl_MacOSXNotifierAddRunLoopMode \
(tclPlatStubsPtr->tcl_MacOSXNotifierAddRunLoopMode) /* 2 */
#endif /* defined(USE_TCL_STUBS) */
/* !END!: Do not edit above this line. */
#if defined(USE_TCL_STUBS) && defined(_WIN32) && !defined(TCL_NO_DEPRECATED)
#define Tcl_WinUtfToTChar(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
(TCHAR *)Tcl_UtfToChar16DString((string), (len), (dsPtr)))
#define Tcl_WinTCharToUtf(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
(char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr)))
#endif
#endif /* _TCLPLATDECLS */
| > > > > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
Tcl_Interp *interp, const char *bundleName,
const char *bundleVersion,
int hasResourceFile, size_t maxPathLen,
char *libraryPath);
/* 2 */
TCLAPI void Tcl_MacOSXNotifierAddRunLoopMode(
const void *runLoopMode);
/* 3 */
TCLAPI void Tcl_WinConvertError(unsigned errCode);
typedef struct TclPlatStubs {
int magic;
void *hooks;
void (*reserved0)(void);
int (*tcl_MacOSXOpenVersionedBundleResources) (Tcl_Interp *interp, const char *bundleName, const char *bundleVersion, int hasResourceFile, size_t maxPathLen, char *libraryPath); /* 1 */
void (*tcl_MacOSXNotifierAddRunLoopMode) (const void *runLoopMode); /* 2 */
void (*tcl_WinConvertError) (unsigned errCode); /* 3 */
} TclPlatStubs;
extern const TclPlatStubs *tclPlatStubsPtr;
#ifdef __cplusplus
}
#endif
#if defined(USE_TCL_STUBS)
/*
* Inline function declarations:
*/
/* Slot 0 is reserved */
#define Tcl_MacOSXOpenVersionedBundleResources \
(tclPlatStubsPtr->tcl_MacOSXOpenVersionedBundleResources) /* 1 */
#define Tcl_MacOSXNotifierAddRunLoopMode \
(tclPlatStubsPtr->tcl_MacOSXNotifierAddRunLoopMode) /* 2 */
#define Tcl_WinConvertError \
(tclPlatStubsPtr->tcl_WinConvertError) /* 3 */
#endif /* defined(USE_TCL_STUBS) */
/* !END!: Do not edit above this line. */
#if defined(USE_TCL_STUBS) && defined(_WIN32) && !defined(TCL_NO_DEPRECATED)
#define Tcl_WinUtfToTChar(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
(TCHAR *)Tcl_UtfToChar16DString((string), (len), (dsPtr)))
#define Tcl_WinTCharToUtf(string, len, dsPtr) (Tcl_DStringInit(dsPtr), \
(char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr)))
#endif
#endif /* _TCLPLATDECLS */
|
Changes to generic/tclStubInit.c.
| ︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
#undef TclStaticLibrary
#undef Tcl_BackgroundError
#define TclStaticLibrary Tcl_StaticLibrary
#undef Tcl_UniCharToUtfDString
#undef Tcl_UtfToUniCharDString
#undef Tcl_UtfToUniChar
#define TclUnusedStubEntry 0
#if TCL_UTF_MAX <= 3
static void uniCodePanic() {
Tcl_Panic("This extension uses a deprecated function, not available now: Tcl is compiled with -DTCL_UTF_MAX==%d", TCL_UTF_MAX);
}
# define Tcl_GetUnicode (int *(*)(Tcl_Obj *))(void *)uniCodePanic
# define Tcl_GetUnicodeFromObj (Tcl_UniChar *(*)(Tcl_Obj *, size_t *))(void *)uniCodePanic
| > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#undef TclStaticLibrary
#undef Tcl_BackgroundError
#define TclStaticLibrary Tcl_StaticLibrary
#undef Tcl_UniCharToUtfDString
#undef Tcl_UtfToUniCharDString
#undef Tcl_UtfToUniChar
#define TclUnusedStubEntry 0
#undef TclWinConvertError
#define TclWinConvertError 0
#if TCL_UTF_MAX <= 3
static void uniCodePanic() {
Tcl_Panic("This extension uses a deprecated function, not available now: Tcl is compiled with -DTCL_UTF_MAX==%d", TCL_UTF_MAX);
}
# define Tcl_GetUnicode (int *(*)(Tcl_Obj *))(void *)uniCodePanic
# define Tcl_GetUnicodeFromObj (Tcl_UniChar *(*)(Tcl_Obj *, size_t *))(void *)uniCodePanic
|
| ︙ | ︙ | |||
271 272 273 274 275 276 277 278 279 280 281 282 283 284 | #define Tcl_UtfNcasecmp (int(*)(const char*,const char*,unsigned long))(void *)utfNcasecmp #endif /* TCL_WIDE_INT_IS_LONG */ #else /* __CYGWIN__ */ # define TclWinGetTclInstance (void *(*)(void))(void *)TclpCreateProcess # define TclpGetPid (size_t(*)(Tcl_Pid))(void *)TclUnixWaitForFile # define TclWinConvertError (void(*)(int))(void *)TclGetAndDetachPids # define TclWinFlushDirtyChannels 0 # define TclWinNoBackslash 0 # define TclWinAddProcess 0 #endif /* | > | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | #define Tcl_UtfNcasecmp (int(*)(const char*,const char*,unsigned long))(void *)utfNcasecmp #endif /* TCL_WIDE_INT_IS_LONG */ #else /* __CYGWIN__ */ # define TclWinGetTclInstance (void *(*)(void))(void *)TclpCreateProcess # define TclpGetPid (size_t(*)(Tcl_Pid))(void *)TclUnixWaitForFile # undef TclWinConvertError # define TclWinConvertError (void(*)(int))(void *)TclGetAndDetachPids # define TclWinFlushDirtyChannels 0 # define TclWinNoBackslash 0 # define TclWinAddProcess 0 #endif /* |
| ︙ | ︙ | |||
672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
static const TclPlatStubs tclPlatStubs = {
TCL_STUB_MAGIC,
0,
0, /* 0 */
Tcl_MacOSXOpenVersionedBundleResources, /* 1 */
Tcl_MacOSXNotifierAddRunLoopMode, /* 2 */
};
const TclTomMathStubs tclTomMathStubs = {
TCL_STUB_MAGIC,
0,
TclBN_epoch, /* 0 */
TclBN_revision, /* 1 */
| > | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
static const TclPlatStubs tclPlatStubs = {
TCL_STUB_MAGIC,
0,
0, /* 0 */
Tcl_MacOSXOpenVersionedBundleResources, /* 1 */
Tcl_MacOSXNotifierAddRunLoopMode, /* 2 */
Tcl_WinConvertError, /* 3 */
};
const TclTomMathStubs tclTomMathStubs = {
TCL_STUB_MAGIC,
0,
TclBN_epoch, /* 0 */
TclBN_revision, /* 1 */
|
| ︙ | ︙ |
Changes to library/dde/pkgIndex.tcl.
|
| < > | > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 |
if {[info sharedlibextension] != ".dll"} return
if {[package vsatisfies [package provide Tcl] 9.0-]} {
package ifneeded dde 1.4.4 \
[list load [file join $dir tcl9dde14.dll] Dde]
} elseif {![package vsatisfies [package provide Tcl] 8.7]
&& [::tcl::pkgconfig get debug]} {
package ifneeded dde 1.4.4 \
[list load [file join $dir tcldde14g.dll] Dde]
} else {
package ifneeded dde 1.4.4 \
[list load [file join $dir tcldde14.dll] Dde]
}
|
Changes to library/registry/pkgIndex.tcl.
1 2 |
if {![package vsatisfies [package provide Tcl] 8.5-]} return
if {[info sharedlibextension] != ".dll"} return
| > | > > > | > | 1 2 3 4 5 6 7 8 9 |
if {![package vsatisfies [package provide Tcl] 8.5-]} return
if {[info sharedlibextension] != ".dll"} return
if {[package vsatisfies [package provide Tcl] 9.0-]} {
package ifneeded registry 1.3.6 \
[list load [file join $dir tcl9registry13.dll] Registry]
} else {
package ifneeded registry 1.3.6 \
[list load [file join $dir tclregistry13.dll] Registry]
}
|
Changes to tests/load.test.
| ︙ | ︙ | |||
170 171 172 173 174 175 176 |
teststaticlibrary More 0 1
load {} More
set x
} {not loaded}
catch {load [file join $testDir pkga$ext] Pkga}
catch {load [file join $testDir pkgb$ext] Pkgb}
catch {load [file join $testDir pkge$ext] Pkge}
| | | | | | | | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
teststaticlibrary More 0 1
load {} More
set x
} {not loaded}
catch {load [file join $testDir pkga$ext] Pkga}
catch {load [file join $testDir pkgb$ext] Pkgb}
catch {load [file join $testDir pkge$ext] Pkge}
set currentRealLibraries [list [list [file join $testDir pkge$ext] Pkge] [list [file join $testDir pkgb$ext] Pkgb] [list [file join $testDir pkga$ext] Pkga]]
test load-7.4 {Tcl_StaticLibrary procedure, redundant calls} -setup {
teststaticlibrary Test 1 0
teststaticlibrary Another 0 0
teststaticlibrary More 0 1
} -constraints [list teststaticlibrary $dll $loaded] -body {
teststaticlibrary Double 0 1
teststaticlibrary Double 0 1
info loaded
} -result [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealLibraries {*}$alreadyTotalLoaded]
testConstraint teststaticlibrary_8.x 0
if {[testConstraint teststaticlibrary]} {
catch {
teststaticlibrary Test 1 1
teststaticlibrary Another 0 1
teststaticlibrary More 0 1
teststaticlibrary Double 0 1
testConstraint teststaticlibrary_8.x 1
}
}
test load-8.1 {TclGetLoadedLibraries procedure} [list teststaticlibrary_8.x $dll $loaded] {
lsort -index 1 [info loaded]
} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealLibraries {*}$alreadyTotalLoaded]]
test load-8.2 {TclGetLoadedLibraries procedure} -constraints {teststaticlibrary_8.x} -body {
info loaded gorp
} -returnCodes error -result {could not find interpreter "gorp"}
test load-8.3a {TclGetLoadedLibraries procedure} [list teststaticlibrary_8.x $dll $loaded] {
lsort -index 1 [info loaded {}]
} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga] [list [file join $testDir pkgb$ext] Pkgb] {*}$alreadyLoaded]]
test load-8.3b {TclGetLoadedLibraries procedure} [list teststaticlibrary_8.x $dll $loaded] {
lsort -index 1 [info loaded child]
} [lsort -index 1 [list {{} Test} [list [file join $testDir pkgb$ext] Pkgb]]]
test load-8.4 {TclGetLoadedLibraries procedure} [list teststaticlibrary_8.x $dll $loaded] {
load [file join $testDir pkgb$ext] Pkgb
list [lsort -index 1 [info loaded {}]] [lsort [info commands pkgb_*]]
} [list [lsort -index 1 [concat [list [list [file join $testDir pkgb$ext] Pkgb] {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga]] $alreadyLoaded]] {pkgb_demo pkgb_sub pkgb_unsafe}]
interp delete child
test load-9.1 {Tcl_StaticLibrary, load already-loaded package into another interp} -setup {
interp create child1
|
| ︙ | ︙ |
Changes to unix/dltest/Makefile.in.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 |
LDFLAGS_DEBUG = @LDFLAGS_DEBUG@
LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
LDFLAGS = @LDFLAGS_DEFAULT@ @LDFLAGS@
CC_SWITCHES = $(CFLAGS) -I${SRC_DIR}/../../generic -DTCL_MEM_DEBUG \
${SHLIB_CFLAGS} -DUSE_TCL_STUBS ${AC_FLAGS}
| | | > > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
LDFLAGS_DEBUG = @LDFLAGS_DEBUG@
LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
LDFLAGS = @LDFLAGS_DEFAULT@ @LDFLAGS@
CC_SWITCHES = $(CFLAGS) -I${SRC_DIR}/../../generic -DTCL_MEM_DEBUG \
${SHLIB_CFLAGS} -DUSE_TCL_STUBS ${AC_FLAGS}
all: tcl9pkgπ${SHLIB_SUFFIX} tcl9pkga${SHLIB_SUFFIX} tcl9pkgb${SHLIB_SUFFIX} tcl9pkgc${SHLIB_SUFFIX} tcl9pkgd${SHLIB_SUFFIX} tcl9pkge${SHLIB_SUFFIX} tcl9pkgua${SHLIB_SUFFIX} tcl9pkgooa${SHLIB_SUFFIX}
@if test -n "$(DLTEST_SUFFIX)"; then $(MAKE) dltest_suffix; fi
@touch ../dltest.marker
dltest_suffix: tcl9pkgπ${DLTEST_SUFFIX} tcl9pkga${DLTEST_SUFFIX} tcl9pkgb${DLTEST_SUFFIX} tcl9pkgc${DLTEST_SUFFIX} tcl9pkgd${DLTEST_SUFFIX} tcl9pkge${DLTEST_SUFFIX} tcl9pkgua${DLTEST_SUFFIX} tcl9pkgooa${DLTEST_SUFFIX}
@touch ../dltest.marker
pkgπ.o: $(SRC_DIR)/pkgπ.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgπ.c
pkga.o: $(SRC_DIR)/pkga.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkga.c
pkgb.o: $(SRC_DIR)/pkgb.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgb.c
pkgc.o: $(SRC_DIR)/pkgc.c
|
| ︙ | ︙ | |||
49 50 51 52 53 54 55 | pkgua.o: $(SRC_DIR)/pkgua.c $(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgua.c pkgooa.o: $(SRC_DIR)/pkgooa.c $(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgooa.c | > > > | | | | | | | | | | | | | | > > > | | | | | | | | | | | | | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
pkgua.o: $(SRC_DIR)/pkgua.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgua.c
pkgooa.o: $(SRC_DIR)/pkgooa.c
$(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgooa.c
tcl9pkgπ${SHLIB_SUFFIX}: pkgπ.o
${SHLIB_LD} -o $@ pkgπ.o ${SHLIB_LD_LIBS}
tcl9pkga${SHLIB_SUFFIX}: pkga.o
${SHLIB_LD} -o $@ pkga.o ${SHLIB_LD_LIBS}
tcl9pkgb${SHLIB_SUFFIX}: pkgb.o
${SHLIB_LD} -o $@ pkgb.o ${SHLIB_LD_LIBS}
tcl9pkgc${SHLIB_SUFFIX}: pkgc.o
${SHLIB_LD} -o $@ pkgc.o ${SHLIB_LD_LIBS}
tcl9pkgd${SHLIB_SUFFIX}: pkgd.o
${SHLIB_LD} -o $@ pkgd.o ${SHLIB_LD_LIBS}
tcl9pkge${SHLIB_SUFFIX}: pkge.o
${SHLIB_LD} -o $@ pkge.o ${SHLIB_LD_LIBS}
tcl9pkgua${SHLIB_SUFFIX}: pkgua.o
${SHLIB_LD} -o $@ pkgua.o ${SHLIB_LD_LIBS}
tcl9pkgooa${SHLIB_SUFFIX}: pkgooa.o
${SHLIB_LD} -o $@ pkgooa.o ${SHLIB_LD_LIBS}
tcl9pkgπ${DLTEST_SUFFIX}: pkgπ.o
${DLTEST_LD} -o $@ pkgπ.o ${SHLIB_LD_LIBS}
tcl9pkga${DLTEST_SUFFIX}: pkga.o
${DLTEST_LD} -o $@ pkga.o ${SHLIB_LD_LIBS}
tcl9pkgb${DLTEST_SUFFIX}: pkgb.o
${DLTEST_LD} -o $@ pkgb.o ${SHLIB_LD_LIBS}
tcl9pkgc${DLTEST_SUFFIX}: pkgc.o
${DLTEST_LD} -o $@ pkgc.o ${SHLIB_LD_LIBS}
tcl9pkgd${DLTEST_SUFFIX}: pkgd.o
${DLTEST_LD} -o $@ pkgd.o ${SHLIB_LD_LIBS}
tcl9pkge${DLTEST_SUFFIX}: pkge.o
${DLTEST_LD} -o $@ pkge.o ${SHLIB_LD_LIBS}
tcl9pkgua${DLTEST_SUFFIX}: pkgua.o
${DLTEST_LD} -o $@ pkgua.o ${SHLIB_LD_LIBS}
tcl9pkgooa${DLTEST_SUFFIX}: pkgooa.o
${DLTEST_LD} -o $@ pkgooa.o ${SHLIB_LD_LIBS}
clean:
rm -f *.o lib.exp ../dltest.marker
@if test "$(SHLIB_SUFFIX)" != ""; then \
echo "rm -f *${SHLIB_SUFFIX}" ; \
rm -f *${SHLIB_SUFFIX} ; \
fi
|
| ︙ | ︙ |
Added unix/dltest/pkgπ.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
/*
* pkgπ.c --
*
* This file contains a simple Tcl package "pkgπ" that is intended for
* testing the Tcl dynamic loading facilities.
*
* Copyright © 1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#undef STATIC_BUILD
#include "tcl.h"
/*
* Prototypes for procedures defined later in this file:
*/
static int Pkg\u03C0_\u03A0ObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
/*
*----------------------------------------------------------------------
*
* Pkga_EqObjCmd --
*
* This procedure is invoked to process the "pkga_eq" Tcl command. It
* expects two arguments and returns 1 if they are the same, 0 if they
* are different.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*----------------------------------------------------------------------
*/
static int
Pkg\u03C0_\u03A0ObjCmd(
void *dummy, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int result;
const char *str1, *str2;
int len1, len2;
(void)dummy;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, "");
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(3.14159));
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Pkgπ_Init --
*
* This is a package initialization procedure, which is called by Tcl
* when this package is to be added to an interpreter.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
DLLEXPORT int
Pkg\u03C0_Init(
Tcl_Interp *interp) /* Interpreter in which the package is to be
* made available. */
{
int code;
if (Tcl_InitStubs(interp, "9.0", 0) == NULL) {
return TCL_ERROR;
}
code = Tcl_PkgProvide(interp, "pkgπ", "1.0");
if (code != TCL_OK) {
return code;
}
Tcl_CreateObjCommand(interp, "Ï€", Pkg\u03C0_\u03A0ObjCmd, NULL, NULL);
return TCL_OK;
}
|
Changes to unix/tclSelectNotfy.c.
| ︙ | ︙ | |||
373 374 375 376 377 378 379 | * notifier instance. * *---------------------------------------------------------------------- */ void TclpFinalizeNotifier( | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
* notifier instance.
*
*----------------------------------------------------------------------
*/
void
TclpFinalizeNotifier(
TCL_UNUSED(void *))
{
#if TCL_THREADS
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
pthread_mutex_lock(¬ifierInitMutex);
notifierCount--;
|
| ︙ | ︙ |
Changes to unix/tclUnixFCmd.c.
| ︙ | ︙ | |||
2352 2353 2354 2355 2356 2357 2358 |
static void
StatError(
Tcl_Interp *interp, /* The interp that has the error */
Tcl_Obj *fileName) /* The name of the file which caused the
* error. */
{
| | | 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 |
static void
StatError(
Tcl_Interp *interp, /* The interp that has the error */
Tcl_Obj *fileName) /* The name of the file which caused the
* error. */
{
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf("could not read \"%s\": %s",
TclGetString(fileName), Tcl_PosixError(interp)));
}
static WCHAR *
winPathFromObj(
Tcl_Obj *fileName)
|
| ︙ | ︙ |
Changes to unix/tclUnixNotfy.c.
| ︙ | ︙ | |||
207 208 209 210 211 212 213 | * None. * *---------------------------------------------------------------------- */ void TclpSetTimer( | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
* None.
*
*----------------------------------------------------------------------
*/
void
TclpSetTimer(
TCL_UNUSED(const Tcl_Time *)) /* Timeout value, may be NULL. */
{
/*
* The interval timer doesn't do anything in this implementation, because
* the only event loop is via Tcl_DoOneEvent, which passes timeout values
* to Tcl_WaitForEvent.
*/
}
|
| ︙ | ︙ |
Changes to win/Makefile.in.
| ︙ | ︙ | |||
144 145 146 147 148 149 150 | TCL_VFS_PATH = libtcl.vfs/tcl_library TCL_VFS_ROOT = libtcl.vfs TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@ TCL_DLL_FILE = @TCL_DLL_FILE@ TCL_LIB_FILE = @TCL_LIB_FILE@ | | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
TCL_VFS_PATH = libtcl.vfs/tcl_library
TCL_VFS_ROOT = libtcl.vfs
TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@
TCL_DLL_FILE = @TCL_DLL_FILE@
TCL_LIB_FILE = @TCL_LIB_FILE@
DDE_DLL_FILE = tcl9dde$(DDEVER)${DLLSUFFIX}
DDE_LIB_FILE = @LIBPREFIX@tcldde$(DDEVER)${DLLSUFFIX}${LIBSUFFIX}
REG_DLL_FILE = tcl9registry$(REGVER)${DLLSUFFIX}
REG_LIB_FILE = @LIBPREFIX@tclregistry$(REGVER)${DLLSUFFIX}${LIBSUFFIX}
TEST_DLL_FILE = tcltest$(VER)${DLLSUFFIX}
TEST_EXE_FILE = tcltest${EXESUFFIX}
TEST_LIB_FILE = @LIBPREFIX@tcltest$(VER)${DLLSUFFIX}${LIBSUFFIX}
TEST_LOAD_PRMS = lappend ::auto_path {$(ROOT_DIR_WIN_NATIVE)/tests};\
package ifneeded dde 1.4.4 [list load [file normalize ${DDE_DLL_FILE}]];\
package ifneeded registry 1.3.6 [list load [file normalize ${REG_DLL_FILE}]]
|
| ︙ | ︙ |
Changes to win/makefile.vc.
| ︙ | ︙ | |||
202 203 204 205 206 207 208 | DDEDOTVERSION = 1.4 DDEVERSION = $(DDEDOTVERSION:.=) REGDOTVERSION = 1.3 REGVERSION = $(REGDOTVERSION:.=) | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | DDEDOTVERSION = 1.4 DDEVERSION = $(DDEDOTVERSION:.=) REGDOTVERSION = 1.3 REGVERSION = $(REGDOTVERSION:.=) TCLREGLIBNAME = $(PROJECT)9registry$(REGVERSION)$(SUFX:t=).$(EXT) TCLREGLIB = $(OUT_DIR)\$(TCLREGLIBNAME) TCLDDELIBNAME = $(PROJECT)9dde$(DDEVERSION)$(SUFX:t=).$(EXT) TCLDDELIB = $(OUT_DIR)\$(TCLDDELIBNAME) TCLTEST = $(OUT_DIR)\$(PROJECT)test.exe TCLSHOBJS = \ $(TMP_DIR)\tclAppInit.obj \ $(TMP_DIR)\tclsh.res |
| ︙ | ︙ |
Changes to win/tclWinChan.c.
| ︙ | ︙ | |||
409 410 411 412 413 414 415 |
*/
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != fileInfoPtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != fileInfoPtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != fileInfoPtr->handle))) {
if (CloseHandle(fileInfoPtr->handle) == FALSE) {
| | | 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
*/
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != fileInfoPtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != fileInfoPtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != fileInfoPtr->handle))) {
if (CloseHandle(fileInfoPtr->handle) == FALSE) {
Tcl_WinConvertError(GetLastError());
errorCode = errno;
}
}
/*
* See if this FileInfo* is still on the thread local list.
*/
|
| ︙ | ︙ | |||
482 483 484 485 486 487 488 |
newPosHigh = (LONG)(offset >> 32);
newPos = SetFilePointer(infoPtr->handle, (LONG)offset,
&newPosHigh, moveMethod);
if (newPos == (LONG) INVALID_SET_FILE_POINTER) {
DWORD winError = GetLastError();
if (winError != NO_ERROR) {
| | | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
newPosHigh = (LONG)(offset >> 32);
newPos = SetFilePointer(infoPtr->handle, (LONG)offset,
&newPosHigh, moveMethod);
if (newPos == (LONG) INVALID_SET_FILE_POINTER) {
DWORD winError = GetLastError();
if (winError != NO_ERROR) {
Tcl_WinConvertError(winError);
*errorCodePtr = errno;
return -1;
}
}
return (((long long)((unsigned)newPos))
| ((long long)newPosHigh << 32));
}
|
| ︙ | ︙ | |||
525 526 527 528 529 530 531 |
oldPosHigh = 0;
oldPos = SetFilePointer(infoPtr->handle, 0, &oldPosHigh, FILE_CURRENT);
if (oldPos == (LONG) INVALID_SET_FILE_POINTER) {
DWORD winError = GetLastError();
if (winError != NO_ERROR) {
| | | | | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
oldPosHigh = 0;
oldPos = SetFilePointer(infoPtr->handle, 0, &oldPosHigh, FILE_CURRENT);
if (oldPos == (LONG) INVALID_SET_FILE_POINTER) {
DWORD winError = GetLastError();
if (winError != NO_ERROR) {
Tcl_WinConvertError(winError);
return errno;
}
}
/*
* Move to where we want to truncate
*/
newPosHigh = (LONG)(length >> 32);
newPos = SetFilePointer(infoPtr->handle, (LONG)length,
&newPosHigh, FILE_BEGIN);
if (newPos == (LONG) INVALID_SET_FILE_POINTER) {
DWORD winError = GetLastError();
if (winError != NO_ERROR) {
Tcl_WinConvertError(winError);
return errno;
}
}
/*
* Perform the truncation (unlike POSIX ftruncate(), we needed to move to
* the location to truncate at first).
*/
if (!SetEndOfFile(infoPtr->handle)) {
Tcl_WinConvertError(GetLastError());
return errno;
}
/*
* Move back. If this last step fails, we don't care; it's just a "best
* effort" attempt to restore our file pointer to where it was.
*/
|
| ︙ | ︙ | |||
612 613 614 615 616 617 618 |
*/
if (ReadFile(infoPtr->handle, (LPVOID) buf, (DWORD) bufSize, &bytesRead,
(LPOVERLAPPED) NULL) != FALSE) {
return bytesRead;
}
| | | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
*/
if (ReadFile(infoPtr->handle, (LPVOID) buf, (DWORD) bufSize, &bytesRead,
(LPOVERLAPPED) NULL) != FALSE) {
return bytesRead;
}
Tcl_WinConvertError(GetLastError());
*errorCode = errno;
if (errno == EPIPE) {
return 0;
}
return -1;
}
|
| ︙ | ︙ | |||
661 662 663 664 665 666 667 |
if (TEST_FLAG(infoPtr->flags, FILE_APPEND)) {
SetFilePointer(infoPtr->handle, 0, NULL, FILE_END);
}
if (WriteFile(infoPtr->handle, (LPVOID) buf, (DWORD) toWrite,
&bytesWritten, (LPOVERLAPPED) NULL) == FALSE) {
| | | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
if (TEST_FLAG(infoPtr->flags, FILE_APPEND)) {
SetFilePointer(infoPtr->handle, 0, NULL, FILE_END);
}
if (WriteFile(infoPtr->handle, (LPVOID) buf, (DWORD) toWrite,
&bytesWritten, (LPOVERLAPPED) NULL) == FALSE) {
Tcl_WinConvertError(GetLastError());
*errorCode = errno;
return -1;
}
infoPtr->dirty = 1;
return bytesWritten;
}
|
| ︙ | ︙ | |||
836 837 838 839 840 841 842 |
* handling for Windows serial ports by a "name-hint" to directly open it
* with the OVERLAPPED flag set.
*/
if (NativeIsComPort(nativeName)) {
handle = TclWinSerialOpen(INVALID_HANDLE_VALUE, nativeName, accessMode);
if (handle == INVALID_HANDLE_VALUE) {
| | | 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
* handling for Windows serial ports by a "name-hint" to directly open it
* with the OVERLAPPED flag set.
*/
if (NativeIsComPort(nativeName)) {
handle = TclWinSerialOpen(INVALID_HANDLE_VALUE, nativeName, accessMode);
if (handle == INVALID_HANDLE_VALUE) {
Tcl_WinConvertError(GetLastError());
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't open serial \"%s\": %s",
TclGetString(pathPtr), Tcl_PosixError(interp)));
}
return NULL;
}
|
| ︙ | ︙ | |||
893 894 895 896 897 898 899 |
if (handle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
if ((err & 0xFFFFL) == ERROR_OPEN_FAILED) {
err = TEST_FLAG(mode, O_CREAT) ? ERROR_FILE_EXISTS
: ERROR_FILE_NOT_FOUND;
}
| | | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
if (handle == INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
if ((err & 0xFFFFL) == ERROR_OPEN_FAILED) {
err = TEST_FLAG(mode, O_CREAT) ? ERROR_FILE_EXISTS
: ERROR_FILE_NOT_FOUND;
}
Tcl_WinConvertError(err);
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't open \"%s\": %s",
TclGetString(pathPtr), Tcl_PosixError(interp)));
}
return NULL;
}
|
| ︙ | ︙ | |||
917 918 919 920 921 922 923 |
*
* Reopen channel for OVERLAPPED operation. Normally this shouldn't
* fail, because the channel exists.
*/
handle = TclWinSerialOpen(handle, nativeName, accessMode);
if (handle == INVALID_HANDLE_VALUE) {
| | | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
*
* Reopen channel for OVERLAPPED operation. Normally this shouldn't
* fail, because the channel exists.
*/
handle = TclWinSerialOpen(handle, nativeName, accessMode);
if (handle == INVALID_HANDLE_VALUE) {
Tcl_WinConvertError(GetLastError());
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't reopen serial \"%s\": %s",
TclGetString(pathPtr), Tcl_PosixError(interp)));
}
return NULL;
}
|
| ︙ | ︙ |
Changes to win/tclWinConsole.c.
| ︙ | ︙ | |||
598 599 600 601 602 603 604 |
*/
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != consolePtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != consolePtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != consolePtr->handle))) {
if (CloseHandle(consolePtr->handle) == FALSE) {
| | | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
*/
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != consolePtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != consolePtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != consolePtr->handle))) {
if (CloseHandle(consolePtr->handle) == FALSE) {
Tcl_WinConvertError(GetLastError());
errorCode = errno;
}
}
consolePtr->watchMask &= consolePtr->validMask;
/*
|
| ︙ | ︙ | |||
768 769 770 771 772 773 774 |
}
/*
* Check for a background error on the last write.
*/
if (infoPtr->writeError) {
| | | 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
}
/*
* Check for a background error on the last write.
*/
if (infoPtr->writeError) {
Tcl_WinConvertError(infoPtr->writeError);
infoPtr->writeError = 0;
goto error;
}
if (infoPtr->flags & CONSOLE_ASYNC) {
/*
* The console is non-blocking, so copy the data into the output
|
| ︙ | ︙ | |||
803 804 805 806 807 808 809 |
/*
* In the blocking case, just try to write the buffer directly. This
* avoids an unnecessary copy.
*/
if (WriteConsoleBytes(infoPtr->handle, buf, (DWORD) toWrite,
&bytesWritten) == FALSE) {
| | | 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
/*
* In the blocking case, just try to write the buffer directly. This
* avoids an unnecessary copy.
*/
if (WriteConsoleBytes(infoPtr->handle, buf, (DWORD) toWrite,
&bytesWritten) == FALSE) {
Tcl_WinConvertError(GetLastError());
goto error;
}
}
return bytesWritten;
error:
*errorCode = errno;
|
| ︙ | ︙ | |||
1061 1062 1063 1064 1065 1066 1067 |
}
if (PeekConsoleInputW(handle, &input, 1, &count) == FALSE) {
/*
* Check to see if the peek failed because of EOF.
*/
| | | 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 |
}
if (PeekConsoleInputW(handle, &input, 1, &count) == FALSE) {
/*
* Check to see if the peek failed because of EOF.
*/
Tcl_WinConvertError(GetLastError());
if (errno == EOF) {
infoPtr->readFlags |= CONSOLE_EOF;
return 1;
}
/*
|
| ︙ | ︙ | |||
1473 1474 1475 1476 1477 1478 1479 |
*/
if ((infoPtr->flags & CONSOLE_READ_OPS) && (len > 1) &&
(strncmp(optionName, "-inputmode", len) == 0)) {
DWORD mode;
if (GetConsoleMode(infoPtr->handle, &mode) == 0) {
| | | 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 |
*/
if ((infoPtr->flags & CONSOLE_READ_OPS) && (len > 1) &&
(strncmp(optionName, "-inputmode", len) == 0)) {
DWORD mode;
if (GetConsoleMode(infoPtr->handle, &mode) == 0) {
Tcl_WinConvertError(GetLastError());
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't read console mode: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1505 1506 1507 1508 1509 1510 1511 |
" normal, password, raw, or reset", value));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE",
"VALUE", NULL);
}
return TCL_ERROR;
}
if (SetConsoleMode(infoPtr->handle, mode) == 0) {
| | | 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 |
" normal, password, raw, or reset", value));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE",
"VALUE", NULL);
}
return TCL_ERROR;
}
if (SetConsoleMode(infoPtr->handle, mode) == 0) {
Tcl_WinConvertError(GetLastError());
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't set console mode: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1585 1586 1587 1588 1589 1590 1591 |
Tcl_DStringAppendElement(dsPtr, "-inputmode");
}
if (len==0 || (len>1 && strncmp(optionName, "-inputmode", len)==0)) {
DWORD mode;
valid = 1;
if (GetConsoleMode(infoPtr->handle, &mode) == 0) {
| | | 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 |
Tcl_DStringAppendElement(dsPtr, "-inputmode");
}
if (len==0 || (len>1 && strncmp(optionName, "-inputmode", len)==0)) {
DWORD mode;
valid = 1;
if (GetConsoleMode(infoPtr->handle, &mode) == 0) {
Tcl_WinConvertError(GetLastError());
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't read console mode: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1616 1617 1618 1619 1620 1621 1622 |
*/
if ((len > 1) && (strncmp(optionName, "-winsize", len) == 0)) {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
valid = 1;
if (!GetConsoleScreenBufferInfo(infoPtr->handle, &consoleInfo)) {
| | | 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 |
*/
if ((len > 1) && (strncmp(optionName, "-winsize", len) == 0)) {
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
valid = 1;
if (!GetConsoleScreenBufferInfo(infoPtr->handle, &consoleInfo)) {
Tcl_WinConvertError(GetLastError());
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't read console size: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ |
Changes to win/tclWinError.c.
| ︙ | ︙ | |||
330 331 332 333 334 335 336 |
ESTALE, /* WSAESTALE */
EREMOTE /* WSAEREMOTE */
};
/*
*----------------------------------------------------------------------
*
| | | | | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
ESTALE, /* WSAESTALE */
EREMOTE /* WSAEREMOTE */
};
/*
*----------------------------------------------------------------------
*
* Tcl_WinConvertError --
*
* This routine converts a Win32 error into an errno value.
*
* Results:
* None.
*
* Side effects:
* Sets the errno global variable.
*
*----------------------------------------------------------------------
*/
void
Tcl_WinConvertError(
unsigned errCode) /* Win32 error code. */
{
if ((unsigned)errCode >= sizeof(errorTable)/sizeof(errorTable[0])) {
errCode -= WSAEWOULDBLOCK;
if ((unsigned)errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) {
Tcl_SetErrno(errorTable[1]);
} else {
Tcl_SetErrno(wsaErrorTable[errCode]);
|
| ︙ | ︙ |
Changes to win/tclWinFCmd.c.
| ︙ | ︙ | |||
275 276 277 278 279 280 281 |
#endif
#endif
if (retval != -1) {
return retval;
}
| | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
#endif
#endif
if (retval != -1) {
return retval;
}
Tcl_WinConvertError(GetLastError());
srcAttr = GetFileAttributesW(nativeSrc);
dstAttr = GetFileAttributesW(nativeDst);
if (srcAttr == 0xFFFFFFFF) {
if (GetFullPathNameW(nativeSrc, 0, NULL,
NULL) >= MAX_PATH) {
errno = ENAMETOOLONG;
|
| ︙ | ︙ | |||
416 417 418 419 420 421 422 | } /* * Some new error has occurred. Don't know what it could * be, but report this one. */ | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
}
/*
* Some new error has occurred. Don't know what it could
* be, but report this one.
*/
Tcl_WinConvertError(GetLastError());
CreateDirectoryW(nativeDst, NULL);
SetFileAttributesW(nativeDst, dstAttr);
if (Tcl_GetErrno() == EACCES) {
/*
* Decode the EACCES to a more meaningful error.
*/
|
| ︙ | ︙ | |||
484 485 486 487 488 489 490 | } /* * Can't backup dst file or move src file. Return that * error. Could happen if an open file refers to dst. */ | | | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
}
/*
* Can't backup dst file or move src file. Return that
* error. Could happen if an open file refers to dst.
*/
Tcl_WinConvertError(GetLastError());
if (Tcl_GetErrno() == EACCES) {
/*
* Decode the EACCES to a more meaningful error.
*/
goto decode;
}
|
| ︙ | ︙ | |||
665 666 667 668 669 670 671 |
#endif
#endif
if (retval != -1) {
return retval;
}
| | | 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
#endif
#endif
if (retval != -1) {
return retval;
}
Tcl_WinConvertError(GetLastError());
if (Tcl_GetErrno() == EBADF) {
Tcl_SetErrno(EACCES);
return TCL_ERROR;
}
if (Tcl_GetErrno() == EACCES) {
DWORD srcAttr, dstAttr;
|
| ︙ | ︙ | |||
702 703 704 705 706 707 708 | } /* * Still can't copy onto dst. Return that error, and restore * attributes of dst. */ | | | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 |
}
/*
* Still can't copy onto dst. Return that error, and restore
* attributes of dst.
*/
Tcl_WinConvertError(GetLastError());
SetFileAttributesW(nativeDst, dstAttr);
}
}
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
762 763 764 765 766 767 768 |
Tcl_SetErrno(ENOENT);
return TCL_ERROR;
}
if (DeleteFileW(path) != FALSE) {
return TCL_OK;
}
| | | 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
Tcl_SetErrno(ENOENT);
return TCL_ERROR;
}
if (DeleteFileW(path) != FALSE) {
return TCL_OK;
}
Tcl_WinConvertError(GetLastError());
if (Tcl_GetErrno() == EACCES) {
attr = GetFileAttributesW(path);
if (attr != 0xFFFFFFFF) {
if (attr & FILE_ATTRIBUTE_DIRECTORY) {
if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
/*
|
| ︙ | ︙ | |||
793 794 795 796 797 798 799 |
int res = SetFileAttributesW(path,
attr & ~((DWORD) FILE_ATTRIBUTE_READONLY));
if ((res != 0) &&
(DeleteFileW(path) != FALSE)) {
return TCL_OK;
}
| | | 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 |
int res = SetFileAttributesW(path,
attr & ~((DWORD) FILE_ATTRIBUTE_READONLY));
if ((res != 0) &&
(DeleteFileW(path) != FALSE)) {
return TCL_OK;
}
Tcl_WinConvertError(GetLastError());
if (res != 0) {
SetFileAttributesW(path, attr);
}
}
}
} else if (Tcl_GetErrno() == ENOENT) {
attr = GetFileAttributesW(path);
|
| ︙ | ︙ | |||
862 863 864 865 866 867 868 |
static int
DoCreateDirectory(
const WCHAR *nativePath) /* Pathname of directory to create (native). */
{
if (CreateDirectoryW(nativePath, NULL) == 0) {
DWORD error = GetLastError();
| | | 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 |
static int
DoCreateDirectory(
const WCHAR *nativePath) /* Pathname of directory to create (native). */
{
if (CreateDirectoryW(nativePath, NULL) == 0) {
DWORD error = GetLastError();
Tcl_WinConvertError(error);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*---------------------------------------------------------------------------
|
| ︙ | ︙ | |||
1050 1051 1052 1053 1054 1055 1056 |
*/
if (RemoveDirectoryW(nativePath) != FALSE) {
return TCL_OK;
}
}
| | | 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 |
*/
if (RemoveDirectoryW(nativePath) != FALSE) {
return TCL_OK;
}
}
Tcl_WinConvertError(GetLastError());
if (Tcl_GetErrno() == EACCES) {
attr = GetFileAttributesW(nativePath);
if (attr != 0xFFFFFFFF) {
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
/*
* Windows 95 reports calling RemoveDirectory on a file as an
|
| ︙ | ︙ | |||
1084 1085 1086 1087 1088 1089 1090 |
if (SetFileAttributesW(nativePath,
attr) == FALSE) {
goto end;
}
if (RemoveDirectoryW(nativePath) != FALSE) {
return TCL_OK;
}
| | | 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
if (SetFileAttributesW(nativePath,
attr) == FALSE) {
goto end;
}
if (RemoveDirectoryW(nativePath) != FALSE) {
return TCL_OK;
}
Tcl_WinConvertError(GetLastError());
SetFileAttributesW(nativePath,
attr | FILE_ATTRIBUTE_READONLY);
}
}
}
if (Tcl_GetErrno() == ENOTEMPTY) {
|
| ︙ | ︙ | |||
1231 1232 1233 1234 1235 1236 1237 |
nativeSource = (WCHAR *) Tcl_DStringValue(sourcePtr);
handle = FindFirstFileW(nativeSource, &data);
if (handle == INVALID_HANDLE_VALUE) {
/*
* Can't read directory.
*/
| | | 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 |
nativeSource = (WCHAR *) Tcl_DStringValue(sourcePtr);
handle = FindFirstFileW(nativeSource, &data);
if (handle == INVALID_HANDLE_VALUE) {
/*
* Can't read directory.
*/
Tcl_WinConvertError(GetLastError());
nativeErrfile = nativeSource;
goto end;
}
Tcl_DStringSetLength(sourcePtr, oldSourceLen + 1);
Tcl_DStringSetLength(sourcePtr, oldSourceLen);
result = traverseProc(nativeSource, nativeTarget, DOTREE_PRED,
|
| ︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 |
result = traverseProc((const WCHAR *)Tcl_DStringValue(sourcePtr),
(const WCHAR *)(targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)),
DOTREE_POSTD, errorPtr);
}
end:
if (nativeErrfile != NULL) {
| | | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 |
result = traverseProc((const WCHAR *)Tcl_DStringValue(sourcePtr),
(const WCHAR *)(targetPtr == NULL ? NULL : Tcl_DStringValue(targetPtr)),
DOTREE_POSTD, errorPtr);
}
end:
if (nativeErrfile != NULL) {
Tcl_WinConvertError(GetLastError());
if (errorPtr != NULL) {
Tcl_DStringInit(errorPtr);
Tcl_WCharToUtfDString(nativeErrfile, -1, errorPtr);
}
result = TCL_ERROR;
}
|
| ︙ | ︙ | |||
1380 1381 1382 1383 1384 1385 1386 |
if (DoCreateDirectory(nativeDst) == TCL_OK) {
DWORD attr = GetFileAttributesW(nativeSrc);
if (SetFileAttributesW(nativeDst,
attr) != FALSE) {
return TCL_OK;
}
| | | 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 |
if (DoCreateDirectory(nativeDst) == TCL_OK) {
DWORD attr = GetFileAttributesW(nativeSrc);
if (SetFileAttributesW(nativeDst,
attr) != FALSE) {
return TCL_OK;
}
Tcl_WinConvertError(GetLastError());
}
break;
case DOTREE_POSTD:
return TCL_OK;
}
/*
|
| ︙ | ︙ | |||
1478 1479 1480 1481 1482 1483 1484 |
static void
StatError(
Tcl_Interp *interp, /* The interp that has the error */
Tcl_Obj *fileName) /* The name of the file which caused the
* error. */
{
| | | 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 |
static void
StatError(
Tcl_Interp *interp, /* The interp that has the error */
Tcl_Obj *fileName) /* The name of the file which caused the
* error. */
{
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf("could not read \"%s\": %s",
TclGetString(fileName), Tcl_PosixError(interp)));
}
/*
*----------------------------------------------------------------------
*
|
| ︙ | ︙ | |||
2063 2064 2065 2066 2067 2068 2069 |
/*
* Check for other errors. The big ones are ERROR_PATH_NOT_FOUND and
* ERROR_ACCESS_DENIED.
*/
if (error != ERROR_SUCCESS) {
| | | 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 |
/*
* Check for other errors. The big ones are ERROR_PATH_NOT_FOUND and
* ERROR_ACCESS_DENIED.
*/
if (error != ERROR_SUCCESS) {
Tcl_WinConvertError(error);
Tcl_DStringFree(&base);
return NULL;
}
/*
* We actually made the directory, so we're done! Report what we made back
* as a (clean) Tcl_Obj.
|
| ︙ | ︙ |
Changes to win/tclWinFile.c.
| ︙ | ︙ | |||
205 206 207 208 209 210 211 |
if (!GetFullPathNameW(linkTargetPath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
*/
| | | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
if (!GetFullPathNameW(linkTargetPath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
*/
Tcl_WinConvertError(GetLastError());
return -1;
}
/*
* Make sure source file doesn't exist.
*/
|
| ︙ | ︙ | |||
229 230 231 232 233 234 235 |
if (!GetFullPathNameW(linkSourcePath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
*/
| | | | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
if (!GetFullPathNameW(linkSourcePath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
*/
Tcl_WinConvertError(GetLastError());
return -1;
}
/*
* Check the target.
*/
attr = GetFileAttributesW(linkTargetPath);
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* The target doesn't exist.
*/
Tcl_WinConvertError(GetLastError());
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
/*
* It is a file.
*/
if (linkAction & TCL_CREATE_HARD_LINK) {
if (CreateHardLinkW(linkSourcePath, linkTargetPath, NULL)) {
/*
* Success!
*/
return 0;
}
Tcl_WinConvertError(GetLastError());
} else if (linkAction & TCL_CREATE_SYMBOLIC_LINK) {
if (CreateSymbolicLinkW(linkSourcePath, linkTargetPath,
0x2 /* SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE */)) {
/*
* Success!
*/
return 0;
} else {
Tcl_WinConvertError(GetLastError());
}
} else {
Tcl_SetErrno(ENODEV);
}
} else {
/*
* We've got a directory. Now check whether what we're trying to do is
|
| ︙ | ︙ | |||
323 324 325 326 327 328 329 |
if (!GetFullPathNameW(linkSourcePath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
*/
| | | | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
if (!GetFullPathNameW(linkSourcePath, MAX_PATH, tempFileName,
&tempFilePart)) {
/*
* Invalid file.
*/
Tcl_WinConvertError(GetLastError());
return NULL;
}
/*
* Make sure source file does exist.
*/
attr = GetFileAttributesW(linkSourcePath);
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* The source doesn't exist.
*/
Tcl_WinConvertError(GetLastError());
return NULL;
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
/*
* It is a file - this is not yet supported.
*/
|
| ︙ | ︙ | |||
498 499 500 501 502 503 504 |
if (hFile != INVALID_HANDLE_VALUE) {
if (!DeviceIoControl(hFile, FSCTL_DELETE_REPARSE_POINT, reparseBuffer,
REPARSE_MOUNTPOINT_HEADER_SIZE,NULL,0,&returnedLength,NULL)) {
/*
* Error setting junction.
*/
| | | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
if (hFile != INVALID_HANDLE_VALUE) {
if (!DeviceIoControl(hFile, FSCTL_DELETE_REPARSE_POINT, reparseBuffer,
REPARSE_MOUNTPOINT_HEADER_SIZE,NULL,0,&returnedLength,NULL)) {
/*
* Error setting junction.
*/
Tcl_WinConvertError(GetLastError());
CloseHandle(hFile);
} else {
CloseHandle(hFile);
if (!linkOnly) {
RemoveDirectoryW(linkOrigPath);
}
return 0;
|
| ︙ | ︙ | |||
691 692 693 694 695 696 697 |
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
/*
* Error creating directory.
*/
| | | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
/*
* Error creating directory.
*/
Tcl_WinConvertError(GetLastError());
return -1;
}
/*
* Get the link.
*/
if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer,
sizeof(DUMMY_REPARSE_BUFFER), &returnedLength, NULL)) {
/*
* Error setting junction.
*/
Tcl_WinConvertError(GetLastError());
CloseHandle(hFile);
return -1;
}
CloseHandle(hFile);
if (!IsReparseTagValid(buffer->ReparseTag)) {
Tcl_SetErrno(EINVAL);
|
| ︙ | ︙ | |||
747 748 749 750 751 752 753 |
*/
if (CreateDirectoryW(linkDirPath, NULL) == 0) {
/*
* Error creating directory.
*/
| | | | | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 |
*/
if (CreateDirectoryW(linkDirPath, NULL) == 0) {
/*
* Error creating directory.
*/
Tcl_WinConvertError(GetLastError());
return -1;
}
hFile = CreateFileW(linkDirPath, GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT
| FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
/*
* Error creating directory.
*/
Tcl_WinConvertError(GetLastError());
return -1;
}
/*
* Set the link.
*/
if (!DeviceIoControl(hFile, FSCTL_SET_REPARSE_POINT, buffer,
(DWORD) buffer->ReparseDataLength + REPARSE_MOUNTPOINT_HEADER_SIZE,
NULL, 0, &returnedLength, NULL)) {
/*
* Error setting junction.
*/
Tcl_WinConvertError(GetLastError());
CloseHandle(hFile);
RemoveDirectoryW(linkDirPath);
return -1;
}
CloseHandle(hFile);
/*
|
| ︙ | ︙ | |||
1034 1035 1036 1037 1038 1039 1040 | * means we just return TCL_OK, indicating no results found. */ Tcl_DStringFree(&dsOrig); return TCL_OK; } | | | 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 |
* means we just return TCL_OK, indicating no results found.
*/
Tcl_DStringFree(&dsOrig);
return TCL_OK;
}
Tcl_WinConvertError(err);
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't read directory \"%s\": %s",
Tcl_DStringValue(&dsOrig), Tcl_PosixError(interp)));
}
Tcl_DStringFree(&dsOrig);
return TCL_ERROR;
|
| ︙ | ︙ | |||
1583 1584 1585 1586 1587 1588 1589 |
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* File might not exist.
*/
DWORD lasterror = GetLastError();
if (lasterror != ERROR_SHARING_VIOLATION) {
| | | 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 |
if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* File might not exist.
*/
DWORD lasterror = GetLastError();
if (lasterror != ERROR_SHARING_VIOLATION) {
Tcl_WinConvertError(lasterror);
return -1;
}
}
if (mode == F_OK) {
/*
* File exists, nothing else to check.
|
| ︙ | ︙ | |||
1709 1710 1711 1712 1713 1714 1715 |
error = GetLastError();
if (error != ERROR_INSUFFICIENT_BUFFER) {
/*
* Most likely case is ERROR_ACCESS_DENIED, which we will convert
* to EACCES - just what we want!
*/
| | | 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 |
error = GetLastError();
if (error != ERROR_INSUFFICIENT_BUFFER) {
/*
* Most likely case is ERROR_ACCESS_DENIED, which we will convert
* to EACCES - just what we want!
*/
Tcl_WinConvertError((DWORD) error);
return -1;
}
/*
* Now size contains the size of buffer needed.
*/
|
| ︙ | ︙ | |||
1814 1815 1816 1817 1818 1819 1820 |
&genMap, &privSet, &privSetSize, &grantedAccess,
&accessYesNo)) {
/*
* Unable to perform access check.
*/
accessError:
| | | 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 |
&genMap, &privSet, &privSetSize, &grantedAccess,
&accessYesNo)) {
/*
* Unable to perform access check.
*/
accessError:
Tcl_WinConvertError(GetLastError());
if (sdPtr != NULL) {
HeapFree(GetProcessHeap(), 0, sdPtr);
}
if (hToken != NULL) {
CloseHandle(hToken);
}
return -1;
|
| ︙ | ︙ | |||
1909 1910 1911 1912 1913 1914 1915 |
if (!nativePath) {
return -1;
}
result = SetCurrentDirectoryW(nativePath);
if (result == 0) {
| | | 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 |
if (!nativePath) {
return -1;
}
result = SetCurrentDirectoryW(nativePath);
if (result == 0) {
Tcl_WinConvertError(GetLastError());
return -1;
}
return 0;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1948 1949 1950 1951 1952 1953 1954 |
* name of current directory. */
{
WCHAR buffer[MAX_PATH];
char *p;
WCHAR *native;
if (GetCurrentDirectoryW(MAX_PATH, buffer) == 0) {
| | | 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 |
* name of current directory. */
{
WCHAR buffer[MAX_PATH];
char *p;
WCHAR *native;
if (GetCurrentDirectoryW(MAX_PATH, buffer) == 0) {
Tcl_WinConvertError(GetLastError());
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error getting working directory name: %s",
Tcl_PosixError(interp)));
}
return NULL;
}
|
| ︙ | ︙ | |||
2113 2114 2115 2116 2117 2118 2119 |
if (GetFileAttributesExW(nativePath,
GetFileExInfoStandard, &data) != TRUE) {
HANDLE hFind;
WIN32_FIND_DATAW ffd;
DWORD lasterror = GetLastError();
if (lasterror != ERROR_SHARING_VIOLATION) {
| | | | 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 |
if (GetFileAttributesExW(nativePath,
GetFileExInfoStandard, &data) != TRUE) {
HANDLE hFind;
WIN32_FIND_DATAW ffd;
DWORD lasterror = GetLastError();
if (lasterror != ERROR_SHARING_VIOLATION) {
Tcl_WinConvertError(lasterror);
return -1;
}
hFind = FindFirstFileW(nativePath, &ffd);
if (hFind == INVALID_HANDLE_VALUE) {
Tcl_WinConvertError(GetLastError());
return -1;
}
memcpy(&data, &ffd, sizeof(data));
FindClose(hFind);
}
attr = data.dwFileAttributes;
|
| ︙ | ︙ | |||
2347 2348 2349 2350 2351 2352 2353 |
ClientData
TclpGetNativeCwd(
ClientData clientData)
{
WCHAR buffer[MAX_PATH];
if (GetCurrentDirectoryW(MAX_PATH, buffer) == 0) {
| | | 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 |
ClientData
TclpGetNativeCwd(
ClientData clientData)
{
WCHAR buffer[MAX_PATH];
if (GetCurrentDirectoryW(MAX_PATH, buffer) == 0) {
Tcl_WinConvertError(GetLastError());
return NULL;
}
if (clientData != NULL) {
if (wcscmp((const WCHAR *) clientData, buffer) == 0) {
return clientData;
}
|
| ︙ | ︙ | |||
3247 3248 3249 3250 3251 3252 3253 |
*/
fileHandle = CreateFileW(native, FILE_WRITE_ATTRIBUTES, 0, NULL,
OPEN_EXISTING, flags, NULL);
if (fileHandle == INVALID_HANDLE_VALUE ||
!SetFileTime(fileHandle, NULL, &lastAccessTime, &lastModTime)) {
| | | 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 |
*/
fileHandle = CreateFileW(native, FILE_WRITE_ATTRIBUTES, 0, NULL,
OPEN_EXISTING, flags, NULL);
if (fileHandle == INVALID_HANDLE_VALUE ||
!SetFileTime(fileHandle, NULL, &lastAccessTime, &lastModTime)) {
Tcl_WinConvertError(GetLastError());
res = -1;
}
if (fileHandle != INVALID_HANDLE_VALUE) {
CloseHandle(fileHandle);
}
return res;
}
|
| ︙ | ︙ |
Changes to win/tclWinLoad.c.
| ︙ | ︙ | |||
155 156 157 158 159 160 161 |
" routine failed", -1);
break;
case ERROR_BAD_EXE_FORMAT:
Tcl_SetErrorCode(interp, "WIN_LOAD", "BAD_EXE_FORMAT", NULL);
Tcl_AppendToObj(errMsg, "Bad exe format. Possibly a 32/64-bit mismatch.", -1);
break;
default:
| | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
" routine failed", -1);
break;
case ERROR_BAD_EXE_FORMAT:
Tcl_SetErrorCode(interp, "WIN_LOAD", "BAD_EXE_FORMAT", NULL);
Tcl_AppendToObj(errMsg, "Bad exe format. Possibly a 32/64-bit mismatch.", -1);
break;
default:
Tcl_WinConvertError(lastError);
Tcl_AppendToObj(errMsg, Tcl_PosixError(interp), -1);
}
Tcl_SetObjResult(interp, errMsg);
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
375 376 377 378 379 380 381 |
lastError = GetLastError();
if (lastError != ERROR_ALREADY_EXISTS) {
break;
}
id *= 16777619;
}
| | | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
lastError = GetLastError();
if (lastError != ERROR_ALREADY_EXISTS) {
break;
}
id *= 16777619;
}
Tcl_WinConvertError(lastError);
return TCL_ERROR;
/*
* Store our computed value in the global.
*/
copyToGlobalBuffer:
|
| ︙ | ︙ |
Changes to win/tclWinNotify.c.
| ︙ | ︙ | |||
575 576 577 578 579 580 581 |
vdelay.sec = desired.sec - now.sec;
vdelay.usec = desired.usec - now.usec;
TclScaleTime(&vdelay);
sleepTime = vdelay.sec * 1000 + vdelay.usec / 1000;
}
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
vdelay.sec = desired.sec - now.sec;
vdelay.usec = desired.usec - now.usec;
TclScaleTime(&vdelay);
sleepTime = vdelay.sec * 1000 + vdelay.usec / 1000;
}
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
|
| ︙ | ︙ |
Changes to win/tclWinPipe.c.
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
case O_WRONLY:
accessMode = GENERIC_WRITE;
break;
case O_RDWR:
accessMode = (GENERIC_READ | GENERIC_WRITE);
break;
default:
| | | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
case O_WRONLY:
accessMode = GENERIC_WRITE;
break;
case O_RDWR:
accessMode = (GENERIC_READ | GENERIC_WRITE);
break;
default:
Tcl_WinConvertError(ERROR_INVALID_FUNCTION);
return NULL;
}
/*
* Map the creation flags to the NT create mode.
*/
|
| ︙ | ︙ | |||
609 610 611 612 613 614 615 |
if (handle == INVALID_HANDLE_VALUE) {
DWORD err;
err = GetLastError();
if ((err & 0xFFFFL) == ERROR_OPEN_FAILED) {
err = (mode & O_CREAT) ? ERROR_FILE_EXISTS : ERROR_FILE_NOT_FOUND;
}
| | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
if (handle == INVALID_HANDLE_VALUE) {
DWORD err;
err = GetLastError();
if ((err & 0xFFFFL) == ERROR_OPEN_FAILED) {
err = (mode & O_CREAT) ? ERROR_FILE_EXISTS : ERROR_FILE_NOT_FOUND;
}
Tcl_WinConvertError(err);
return NULL;
}
/*
* Seek to the end of file if we are writing.
*/
|
| ︙ | ︙ | |||
715 716 717 718 719 720 721 |
* Free the native representation of the contents if necessary.
*/
if (contents != NULL) {
Tcl_DStringFree(&dstring);
}
| | | 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
* Free the native representation of the contents if necessary.
*/
if (contents != NULL) {
Tcl_DStringFree(&dstring);
}
Tcl_WinConvertError(GetLastError());
CloseHandle(handle);
DeleteFileW(name);
return NULL;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
780 781 782 783 784 785 786 |
if (CreatePipe(&readHandle, &writeHandle, NULL, 0) != 0) {
*readPipe = TclWinMakeFile(readHandle);
*writePipe = TclWinMakeFile(writeHandle);
return 1;
}
| | | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
if (CreatePipe(&readHandle, &writeHandle, NULL, 0) != 0) {
*readPipe = TclWinMakeFile(readHandle);
*writePipe = TclWinMakeFile(writeHandle);
return 1;
}
Tcl_WinConvertError(GetLastError());
return 0;
}
/*
*----------------------------------------------------------------------
*
* TclpCloseFile --
|
| ︙ | ︙ | |||
821 822 823 824 825 826 827 |
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != filePtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != filePtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != filePtr->handle))) {
if (filePtr->handle != NULL &&
CloseHandle(filePtr->handle) == FALSE) {
| | | 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 |
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != filePtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != filePtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != filePtr->handle))) {
if (filePtr->handle != NULL &&
CloseHandle(filePtr->handle) == FALSE) {
Tcl_WinConvertError(GetLastError());
Tcl_Free(filePtr);
return -1;
}
}
break;
default:
|
| ︙ | ︙ | |||
1022 1023 1024 1025 1026 1027 1028 |
CloseHandle(h);
}
} else {
DuplicateHandle(hProcess, inputHandle, hProcess, &startInfo.hStdInput,
0, TRUE, DUPLICATE_SAME_ACCESS);
}
if (startInfo.hStdInput == INVALID_HANDLE_VALUE) {
| | | 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
CloseHandle(h);
}
} else {
DuplicateHandle(hProcess, inputHandle, hProcess, &startInfo.hStdInput,
0, TRUE, DUPLICATE_SAME_ACCESS);
}
if (startInfo.hStdInput == INVALID_HANDLE_VALUE) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't duplicate input handle: %s",
Tcl_PosixError(interp)));
goto end;
}
if (outputHandle == INVALID_HANDLE_VALUE) {
|
| ︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 |
startInfo.hStdOutput = CreateFileW(L"NUL:", GENERIC_WRITE, 0,
&secAtts, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
DuplicateHandle(hProcess, outputHandle, hProcess,
&startInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
}
if (startInfo.hStdOutput == INVALID_HANDLE_VALUE) {
| | | | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
startInfo.hStdOutput = CreateFileW(L"NUL:", GENERIC_WRITE, 0,
&secAtts, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
DuplicateHandle(hProcess, outputHandle, hProcess,
&startInfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
}
if (startInfo.hStdOutput == INVALID_HANDLE_VALUE) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't duplicate output handle: %s",
Tcl_PosixError(interp)));
goto end;
}
if (errorHandle == INVALID_HANDLE_VALUE) {
/*
* If handle was not set, errors should be sent to an infinitely deep
* sink.
*/
startInfo.hStdError = CreateFileW(L"NUL:", GENERIC_WRITE, 0,
&secAtts, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
DuplicateHandle(hProcess, errorHandle, hProcess, &startInfo.hStdError,
0, TRUE, DUPLICATE_SAME_ACCESS);
}
if (startInfo.hStdError == INVALID_HANDLE_VALUE) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't duplicate error handle: %s",
Tcl_PosixError(interp)));
goto end;
}
/*
|
| ︙ | ︙ | |||
1133 1134 1135 1136 1137 1138 1139 |
*/
BuildCommandLine(execPath, argc, argv, &cmdLine);
if (CreateProcessW(NULL, (WCHAR *) Tcl_DStringValue(&cmdLine),
NULL, NULL, TRUE, (DWORD) createFlags, NULL, NULL, &startInfo,
&procInfo) == 0) {
| | | 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
*/
BuildCommandLine(execPath, argc, argv, &cmdLine);
if (CreateProcessW(NULL, (WCHAR *) Tcl_DStringValue(&cmdLine),
NULL, NULL, TRUE, (DWORD) createFlags, NULL, NULL, &startInfo,
&procInfo) == 0) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf("couldn't execute \"%s\": %s",
argv[0], Tcl_PosixError(interp)));
goto end;
}
/*
* This wait is used to force the OS to give some time to the DOS process.
|
| ︙ | ︙ | |||
1383 1384 1385 1386 1387 1388 1389 |
applType = APPL_DOS;
}
break;
}
Tcl_DStringFree(&nameBuf);
if (applType == APPL_NONE) {
| | | 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 |
applType = APPL_DOS;
}
break;
}
Tcl_DStringFree(&nameBuf);
if (applType == APPL_NONE) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf("couldn't execute \"%s\": %s",
originalName, Tcl_PosixError(interp)));
return APPL_NONE;
}
if (applType == APPL_WIN3X) {
/*
|
| ︙ | ︙ | |||
1862 1863 1864 1865 1866 1867 1868 |
SECURITY_ATTRIBUTES sec;
sec.nLength = sizeof(SECURITY_ATTRIBUTES);
sec.lpSecurityDescriptor = NULL;
sec.bInheritHandle = FALSE;
if (!CreatePipe(&readHandle, &writeHandle, &sec, 0)) {
| | | 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 |
SECURITY_ATTRIBUTES sec;
sec.nLength = sizeof(SECURITY_ATTRIBUTES);
sec.lpSecurityDescriptor = NULL;
sec.bInheritHandle = FALSE;
if (!CreatePipe(&readHandle, &writeHandle, &sec, 0)) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"pipe creation failed: %s", Tcl_PosixError(interp)));
return TCL_ERROR;
}
*rchan = Tcl_MakeFileChannel((ClientData) readHandle, TCL_READABLE);
Tcl_RegisterChannel(interp, *rchan);
|
| ︙ | ︙ | |||
2220 2221 2222 2223 2224 2225 2226 |
/*
* Ignore errors if we have data to return.
*/
return bytesRead;
}
| | | 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 |
/*
* Ignore errors if we have data to return.
*/
return bytesRead;
}
Tcl_WinConvertError(GetLastError());
if (errno == EPIPE) {
infoPtr->readFlags |= PIPE_EOF;
return 0;
}
*errorCode = errno;
return -1;
}
|
| ︙ | ︙ | |||
2279 2280 2281 2282 2283 2284 2285 |
}
/*
* Check for a background error on the last write.
*/
if (infoPtr->writeError) {
| | | 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 |
}
/*
* Check for a background error on the last write.
*/
if (infoPtr->writeError) {
Tcl_WinConvertError(infoPtr->writeError);
infoPtr->writeError = 0;
goto error;
}
if (infoPtr->flags & PIPE_ASYNC) {
/*
* The pipe is non-blocking, so copy the data into the output buffer
|
| ︙ | ︙ | |||
2314 2315 2316 2317 2318 2319 2320 |
/*
* In the blocking case, just try to write the buffer directly. This
* avoids an unnecessary copy.
*/
if (WriteFile(filePtr->handle, (LPVOID) buf, (DWORD) toWrite,
&bytesWritten, (LPOVERLAPPED) NULL) == FALSE) {
| | | 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 |
/*
* In the blocking case, just try to write the buffer directly. This
* avoids an unnecessary copy.
*/
if (WriteFile(filePtr->handle, (LPVOID) buf, (DWORD) toWrite,
&bytesWritten, (LPOVERLAPPED) NULL) == FALSE) {
Tcl_WinConvertError(GetLastError());
goto error;
}
}
return bytesWritten;
error:
*errorCode = errno;
|
| ︙ | ︙ | |||
2846 2847 2848 2849 2850 2851 2852 |
/*
* Check to see if there is any data sitting in the pipe.
*/
if (PeekNamedPipe(handle, (LPVOID) NULL, (DWORD) 0,
(LPDWORD) NULL, &count, (LPDWORD) NULL) != TRUE) {
| | | 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 |
/*
* Check to see if there is any data sitting in the pipe.
*/
if (PeekNamedPipe(handle, (LPVOID) NULL, (DWORD) 0,
(LPDWORD) NULL, &count, (LPDWORD) NULL) != TRUE) {
Tcl_WinConvertError(GetLastError());
/*
* Check to see if the peek failed because of EOF.
*/
if (errno == EPIPE) {
infoPtr->readFlags |= PIPE_EOF;
|
| ︙ | ︙ | |||
3257 3258 3259 3260 3261 3262 3263 |
TclDecrRefCount(tmpObj);
}
return Tcl_MakeFileChannel((ClientData) handle,
TCL_READABLE|TCL_WRITABLE);
gotError:
| | | 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 |
TclDecrRefCount(tmpObj);
}
return Tcl_MakeFileChannel((ClientData) handle,
TCL_READABLE|TCL_WRITABLE);
gotError:
Tcl_WinConvertError(GetLastError());
return NULL;
}
/*
*----------------------------------------------------------------------
*
* TclPipeThreadCreateTI --
|
| ︙ | ︙ |
Changes to win/tclWinSerial.c.
| ︙ | ︙ | |||
641 642 643 644 645 646 647 |
*/
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != serialPtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != serialPtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != serialPtr->handle))) {
if (CloseHandle(serialPtr->handle) == FALSE) {
| | | 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
*/
if (!TclInThreadExit()
|| ((GetStdHandle(STD_INPUT_HANDLE) != serialPtr->handle)
&& (GetStdHandle(STD_OUTPUT_HANDLE) != serialPtr->handle)
&& (GetStdHandle(STD_ERROR_HANDLE) != serialPtr->handle))) {
if (CloseHandle(serialPtr->handle) == FALSE) {
Tcl_WinConvertError(GetLastError());
errorCode = errno;
}
}
serialPtr->watchMask &= serialPtr->validMask;
/*
|
| ︙ | ︙ | |||
924 925 926 927 928 929 930 |
/*
* Perform blocking read. Doesn't block in non-blocking mode, because we
* checked the number of available bytes.
*/
if (SerialBlockingRead(infoPtr, (LPVOID) buf, (DWORD) bufSize, &bytesRead,
&infoPtr->osRead) == FALSE) {
| | | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
/*
* Perform blocking read. Doesn't block in non-blocking mode, because we
* checked the number of available bytes.
*/
if (SerialBlockingRead(infoPtr, (LPVOID) buf, (DWORD) bufSize, &bytesRead,
&infoPtr->osRead) == FALSE) {
Tcl_WinConvertError(GetLastError());
*errorCode = errno;
return -1;
}
return bytesRead;
commError:
infoPtr->lastError = infoPtr->error;
|
| ︙ | ︙ | |||
1006 1007 1008 1009 1010 1011 1012 |
}
/*
* Check for a background error on the last write.
*/
if (infoPtr->writeError) {
| | | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
}
/*
* Check for a background error on the last write.
*/
if (infoPtr->writeError) {
Tcl_WinConvertError(infoPtr->writeError);
infoPtr->writeError = 0;
goto error1;
}
/*
* Remember the number of bytes in output queue
*/
|
| ︙ | ︙ | |||
1065 1066 1067 1068 1069 1070 1071 |
goto error;
}
}
return (int) bytesWritten;
writeError:
| | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
goto error;
}
}
return (int) bytesWritten;
writeError:
Tcl_WinConvertError(GetLastError());
error:
/*
* Reset the output queue counter on error during blocking output
*/
/*
|
| ︙ | ︙ | |||
1932 1933 1934 1935 1936 1937 1938 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "SYS_BUFFER", NULL);
}
return TCL_ERROR;
}
if (!SetupComm(infoPtr->handle, inSize, outSize)) {
if (interp != NULL) {
| | | 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "SYS_BUFFER", NULL);
}
return TCL_ERROR;
}
if (!SetupComm(infoPtr->handle, inSize, outSize)) {
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't setup comm buffers: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
infoPtr->sysBufRead = inSize;
|
| ︙ | ︙ | |||
1983 1984 1985 1986 1987 1988 1989 |
if (Tcl_GetInt(interp, value, &msec) != TCL_OK) {
return TCL_ERROR;
}
tout.ReadTotalTimeoutConstant = msec;
if (!SetCommTimeouts(infoPtr->handle, &tout)) {
if (interp != NULL) {
| | | | | 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 |
if (Tcl_GetInt(interp, value, &msec) != TCL_OK) {
return TCL_ERROR;
}
tout.ReadTotalTimeoutConstant = msec;
if (!SetCommTimeouts(infoPtr->handle, &tout)) {
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't set comm timeouts: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
return TCL_OK;
}
return Tcl_BadChannelOption(interp, optionName,
"closemode mode handshake pollinterval sysbuffer timeout "
"ttycontrol xchar");
getStateFailed:
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't get comm state: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
setStateFailed:
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't set comm state: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
/*
|
| ︙ | ︙ | |||
2091 2092 2093 2094 2095 2096 2097 |
if (len==0 || (len>2 && (strncmp(optionName, "-mode", len) == 0))) {
char parity;
const char *stop;
char buf[2 * TCL_INTEGER_SPACE + 16];
if (!GetCommState(infoPtr->handle, &dcb)) {
if (interp != NULL) {
| | | 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 |
if (len==0 || (len>2 && (strncmp(optionName, "-mode", len) == 0))) {
char parity;
const char *stop;
char buf[2 * TCL_INTEGER_SPACE + 16];
if (!GetCommState(infoPtr->handle, &dcb)) {
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't get comm state: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
valid = 1;
|
| ︙ | ︙ | |||
2161 2162 2163 2164 2165 2166 2167 |
}
if (len==0 || (len>1 && strncmp(optionName, "-xchar", len) == 0)) {
char buf[4];
valid = 1;
if (!GetCommState(infoPtr->handle, &dcb)) {
if (interp != NULL) {
| | | 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 |
}
if (len==0 || (len>1 && strncmp(optionName, "-xchar", len) == 0)) {
char buf[4];
valid = 1;
if (!GetCommState(infoPtr->handle, &dcb)) {
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't get comm state: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
buf[Tcl_UniCharToUtf(UCHAR(dcb.XonChar), buf)] = '\0';
Tcl_DStringAppendElement(dsPtr, buf);
|
| ︙ | ︙ | |||
2239 2240 2241 2242 2243 2244 2245 |
*/
if (len>4 && strncmp(optionName, "-ttystatus", len)==0) {
DWORD status;
if (!GetCommModemStatus(infoPtr->handle, &status)) {
if (interp != NULL) {
| | | 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 |
*/
if (len>4 && strncmp(optionName, "-ttystatus", len)==0) {
DWORD status;
if (!GetCommModemStatus(infoPtr->handle, &status)) {
if (interp != NULL) {
Tcl_WinConvertError(GetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't get tty status: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
valid = 1;
SerialModemStatusStr(status, dsPtr);
|
| ︙ | ︙ |
Changes to win/tclWinSock.c.
| ︙ | ︙ | |||
874 875 876 877 878 879 880 |
/*
* Check for error condition or underflow in non-blocking case.
*/
if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)
|| (error != WSAEWOULDBLOCK)) {
| | | 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
/*
* Check for error condition or underflow in non-blocking case.
*/
if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)
|| (error != WSAEWOULDBLOCK)) {
Tcl_WinConvertError(error);
*errorCodePtr = Tcl_GetErrno();
bytesRead = -1;
break;
}
/*
* In the blocking case, wait until the file becomes readable or
|
| ︙ | ︙ | |||
988 989 990 991 992 993 994 |
CLEAR_BITS(statePtr->readyEvents, FD_WRITE);
if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
*errorCodePtr = EWOULDBLOCK;
written = -1;
break;
}
} else {
| | | 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 |
CLEAR_BITS(statePtr->readyEvents, FD_WRITE);
if (GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
*errorCodePtr = EWOULDBLOCK;
written = -1;
break;
}
} else {
Tcl_WinConvertError(error);
*errorCodePtr = Tcl_GetErrno();
written = -1;
break;
}
/*
* In the blocking case, wait until the file becomes writable or
|
| ︙ | ︙ | |||
1056 1057 1058 1059 1060 1061 1062 |
*/
while (statePtr->sockets != NULL) {
TcpFdList *thisfd = statePtr->sockets;
statePtr->sockets = thisfd->next;
if (closesocket(thisfd->fd) == SOCKET_ERROR) {
| | | 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
*/
while (statePtr->sockets != NULL) {
TcpFdList *thisfd = statePtr->sockets;
statePtr->sockets = thisfd->next;
if (closesocket(thisfd->fd) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
errorCode = Tcl_GetErrno();
}
Tcl_Free(thisfd);
}
}
if (statePtr->addrlist != NULL) {
|
| ︙ | ︙ | |||
1146 1147 1148 1149 1150 1151 1152 |
/*
* Single fd operation: Tcl_OpenTcpServer() does not set TCL_READABLE or
* TCL_WRITABLE so this should never be called for a server socket.
*/
if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
| | | | 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
/*
* Single fd operation: Tcl_OpenTcpServer() does not set TCL_READABLE or
* TCL_WRITABLE so this should never be called for a server socket.
*/
if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
readError = Tcl_GetErrno();
}
if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR)) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
writeError = Tcl_GetErrno();
}
return (readError != 0) ? readError : writeError;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 |
}
if (boolVar) {
val = TRUE;
}
rtn = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
(const char *) &val, sizeof(BOOL));
if (rtn != 0) {
| | | 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 |
}
if (boolVar) {
val = TRUE;
}
rtn = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
(const char *) &val, sizeof(BOOL));
if (rtn != 0) {
Tcl_WinConvertError(WSAGetLastError());
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't set socket option: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1239 1240 1241 1242 1243 1244 1245 |
}
if (!boolVar) {
val = TRUE;
}
rtn = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(const char *) &val, sizeof(BOOL));
if (rtn != 0) {
| | | 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 |
}
if (!boolVar) {
val = TRUE;
}
rtn = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
(const char *) &val, sizeof(BOOL));
if (rtn != 0) {
Tcl_WinConvertError(WSAGetLastError());
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't set socket option: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1374 1375 1376 1377 1378 1379 1380 |
}
/*
* Return error message.
*/
if (err) {
| | | 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 |
}
/*
* Return error message.
*/
if (err) {
Tcl_WinConvertError(err);
Tcl_DStringAppend(dsPtr, Tcl_ErrnoMsg(Tcl_GetErrno()),
-1);
}
}
}
return TCL_OK;
}
|
| ︙ | ︙ | |||
1444 1445 1446 1447 1448 1449 1450 |
* getpeername failed - but if we were asked for all the options
* (len==0), don't flag an error at that point because it could be
* an fconfigure request on a server socket (such sockets have no
* peer). {Copied from unix/tclUnixChan.c}
*/
if (len) {
| | | 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
* getpeername failed - but if we were asked for all the options
* (len==0), don't flag an error at that point because it could be
* an fconfigure request on a server socket (such sockets have no
* peer). {Copied from unix/tclUnixChan.c}
*/
if (len) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't get peername: %s",
Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
|
| ︙ | ︙ | |||
1520 1521 1522 1523 1524 1525 1526 |
if (found) {
if (len) {
return TCL_OK;
}
Tcl_DStringEndSublist(dsPtr);
} else {
if (interp) {
| | | 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
if (found) {
if (len) {
return TCL_OK;
}
Tcl_DStringEndSublist(dsPtr);
} else {
if (interp) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't get sockname: %s", Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
}
|
| ︙ | ︙ | |||
1772 1773 1774 1775 1776 1777 1778 |
SetEvent(tsdPtr->socketListLock);
/*
* Continue on socket creation error.
*/
if (statePtr->sockets->fd == INVALID_SOCKET) {
| | | 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 |
SetEvent(tsdPtr->socketListLock);
/*
* Continue on socket creation error.
*/
if (statePtr->sockets->fd == INVALID_SOCKET) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
continue;
}
/*
* Win-NT has a misfeature that sockets are inherited in child
* processes by default. Turn off the inherit bit.
*/
|
| ︙ | ︙ | |||
1797 1798 1799 1800 1801 1802 1803 |
/*
* Try to bind to a local port.
*/
if (bind(statePtr->sockets->fd, statePtr->myaddr->ai_addr,
statePtr->myaddr->ai_addrlen) == SOCKET_ERROR) {
| | | 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 |
/*
* Try to bind to a local port.
*/
if (bind(statePtr->sockets->fd, statePtr->myaddr->ai_addr,
statePtr->myaddr->ai_addrlen) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
continue;
}
/*
* For asynchroneous connect set the socket in nonblocking mode
* and activate connect notification
*/
|
| ︙ | ︙ | |||
1868 1869 1870 1871 1872 1873 1874 | * Attempt to connect to the remote socket. */ connect(statePtr->sockets->fd, statePtr->addr->ai_addr, statePtr->addr->ai_addrlen); error = WSAGetLastError(); | | | 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 |
* Attempt to connect to the remote socket.
*/
connect(statePtr->sockets->fd, statePtr->addr->ai_addr,
statePtr->addr->ai_addrlen);
error = WSAGetLastError();
Tcl_WinConvertError(error);
if (async_connect && error == WSAEWOULDBLOCK) {
/*
* Asynchroneous connect
*
* Remember that we jump back behind this next round
*/
|
| ︙ | ︙ | |||
1900 1901 1902 1903 1904 1905 1906 |
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
/*
* Get signaled connect error.
*/
| | | 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 |
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
/*
* Get signaled connect error.
*/
Tcl_WinConvertError((DWORD) statePtr->notifierConnectError);
/*
* Clear eventual connect flag.
*/
CLEAR_BITS(statePtr->selectEvents, FD_CONNECT);
|
| ︙ | ︙ | |||
2229 2230 2231 2232 2233 2234 2235 |
goto error;
}
for (addrPtr = addrlist; addrPtr != NULL; addrPtr = addrPtr->ai_next) {
sock = socket(addrPtr->ai_family, addrPtr->ai_socktype,
addrPtr->ai_protocol);
if (sock == INVALID_SOCKET) {
| | | 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 |
goto error;
}
for (addrPtr = addrlist; addrPtr != NULL; addrPtr = addrPtr->ai_next) {
sock = socket(addrPtr->ai_family, addrPtr->ai_socktype,
addrPtr->ai_protocol);
if (sock == INVALID_SOCKET) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
continue;
}
/*
* Win-NT has a misfeature that sockets are inherited in child
* processes by default. Turn off the inherit bit.
*/
|
| ︙ | ︙ | |||
2280 2281 2282 2283 2284 2285 2286 |
* Bind should not be affected by the socket having already been
* set into nonblocking mode. If there is trouble, this is one
* place to look for bugs.
*/
if (bind(sock, addrPtr->ai_addr,
addrPtr->ai_addrlen) == SOCKET_ERROR) {
| | | 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 |
* Bind should not be affected by the socket having already been
* set into nonblocking mode. If there is trouble, this is one
* place to look for bugs.
*/
if (bind(sock, addrPtr->ai_addr,
addrPtr->ai_addrlen) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
continue;
}
if (port == 0 && chosenport == 0) {
address sockname;
socklen_t namelen = sizeof(sockname);
|
| ︙ | ︙ | |||
2305 2306 2307 2308 2309 2310 2311 |
/*
* Set the maximum number of pending connect requests to the max
* value allowed on each platform (Win32 and Win32s may be
* different, and there may be differences between TCP/IP stacks).
*/
if (listen(sock, SOMAXCONN) == SOCKET_ERROR) {
| | | 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 |
/*
* Set the maximum number of pending connect requests to the max
* value allowed on each platform (Win32 and Win32s may be
* different, and there may be differences between TCP/IP stacks).
*/
if (listen(sock, SOMAXCONN) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
continue;
}
if (statePtr == NULL) {
/*
* Add this socket to the global list of sockets.
|
| ︙ | ︙ | |||
2490 2491 2492 2493 2494 2495 2496 |
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = className;
windowClass.lpfnWndProc = SocketProc;
windowClass.hIcon = NULL;
windowClass.hCursor = NULL;
if (!RegisterClassW(&windowClass)) {
| | | 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 |
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = className;
windowClass.lpfnWndProc = SocketProc;
windowClass.hIcon = NULL;
windowClass.hCursor = NULL;
if (!RegisterClassW(&windowClass)) {
Tcl_WinConvertError(GetLastError());
goto initFailure;
}
}
/*
* Check for per-thread initialization.
*/
|
| ︙ | ︙ |
Changes to win/tclWinTest.c.
| ︙ | ︙ | |||
202 203 204 205 206 207 208 |
}
found = GetVolumeInformationA(path, NULL, 0, NULL, NULL, NULL, volType,
VOL_BUF_SIZE);
if (found == 0) {
Tcl_AppendResult(interp, "could not get volume type for \"",
(path?path:""), "\"", NULL);
| | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
}
found = GetVolumeInformationA(path, NULL, 0, NULL, NULL, NULL, volType,
VOL_BUF_SIZE);
if (found == 0) {
Tcl_AppendResult(interp, "could not get volume type for \"",
(path?path:""), "\"", NULL);
Tcl_WinConvertError(GetLastError());
return TCL_ERROR;
}
Tcl_AppendResult(interp, volType, NULL);
return TCL_OK;
#undef VOL_BUF_SIZE
}
|
| ︙ | ︙ |