summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-03-19 16:12:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-03-19 16:12:00 (GMT)
commita88f424879553a655aa1e52ebb0d5d30896a4e6d (patch)
treeeef639b380b170cca7cd66f4c51ec6ac69e1a03a /win
parent7fa3af79a43041a0ace5b9f1f8841db04d689406 (diff)
downloadtcl-a88f424879553a655aa1e52ebb0d5d30896a4e6d.zip
tcl-a88f424879553a655aa1e52ebb0d5d30896a4e6d.tar.gz
tcl-a88f424879553a655aa1e52ebb0d5d30896a4e6d.tar.bz2
Backport fix for [bda99f2393]: gets stdin problem when non-blocking - Windows
(cherry-pick): Fix indentation/brace usage style issues
Diffstat (limited to 'win')
-rw-r--r--win/tclWinChan.c4
-rw-r--r--win/tclWinConsole.c347
-rw-r--r--win/tclWinFCmd.c29
-rw-r--r--win/tclWinFile.c26
-rw-r--r--win/tclWinInit.c4
-rw-r--r--win/tclWinLoad.c4
-rw-r--r--win/tclWinNotify.c4
-rw-r--r--win/tclWinPipe.c4
-rw-r--r--win/tclWinReg.c3
-rw-r--r--win/tclWinSock.c6
-rw-r--r--win/tclWinTest.c9
11 files changed, 221 insertions, 219 deletions
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index a8a757d..a69ca5d 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -102,7 +102,7 @@ static int FileTruncateProc(ClientData instanceData,
long long length);
static DWORD FileGetType(HANDLE handle);
static int NativeIsComPort(const WCHAR *nativeName);
-static Tcl_Channel OpenFileChannel(HANDLE handle, char *channelName,
+static Tcl_Channel OpenFileChannel(HANDLE handle, char *channelName,
int permissions, int appendMode);
/*
@@ -1048,7 +1048,7 @@ FileGetOptionProc(
* general probe.
*/
- dictContents = Tcl_GetStringFromObj(dictObj, &dictLength);
+ dictContents = TclGetStringFromObj(dictObj, &dictLength);
Tcl_DStringAppend(dsPtr, dictContents, dictLength);
Tcl_DecrRefCount(dictObj);
return TCL_OK;
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c
index 25c4065..c7e12ae 100644
--- a/win/tclWinConsole.c
+++ b/win/tclWinConsole.c
@@ -70,14 +70,23 @@
static int gInitialized = 0;
/*
- * Permit CONSOLE_BUFFER_SIZE to be defined on build command for stress test.
- *
+ * INPUT_BUFFER_SIZE is size of buffer passed to ReadConsole in bytes.
+ * Note that ReadConsole will only allow reading of line lengths up to the
+ * max of 256 and buffer size passed to it. So dropping this below 512
+ * means user can type at most 256 chars.
+ */
+#ifndef INPUT_BUFFER_SIZE
+#define INPUT_BUFFER_SIZE 8192 /* In bytes, so 4096 chars */
+#endif
+
+/*
+ * CONSOLE_BUFFER_SIZE is size of storage used in ring buffers.
* In theory, at least sizeof(WCHAR) but note the Tcl channel bug
* https://core.tcl-lang.org/tcl/tktview/b3977d199b08e3979a8da970553d5209b3042e9c
* will cause failures in test suite if close to max input line in the suite.
*/
#ifndef CONSOLE_BUFFER_SIZE
-#define CONSOLE_BUFFER_SIZE 8000 /* In bytes */
+#define CONSOLE_BUFFER_SIZE 8192 /* In bytes */
#endif
/*
@@ -169,8 +178,8 @@ typedef struct ConsoleHandleInfo {
typedef struct ConsoleChannelInfo {
HANDLE handle; /* Console handle */
Tcl_ThreadId threadId; /* Id of owning thread */
- struct ConsoleChannelInfo
- *nextWatchingChannelPtr; /* Pointer to next channel watching events. */
+ struct ConsoleChannelInfo *nextWatchingChannelPtr;
+ /* Pointer to next channel watching events. */
Tcl_Channel channel; /* Pointer to channel structure. */
DWORD initMode; /* Initial console mode. */
int numRefs; /* See comments above */
@@ -192,50 +201,51 @@ typedef struct ConsoleChannelInfo {
*/
typedef struct {
- Tcl_Event header; /* Information that is standard for all events. */
- ConsoleChannelInfo *chanInfoPtr; /* Pointer to console info structure. Note
- * that we still have to verify that the
- * console exists before dereferencing this
- * pointer. */
+ Tcl_Event header; /* Information that is standard for all events. */
+ ConsoleChannelInfo *chanInfoPtr;
+ /* Pointer to console info structure. Note
+ * that we still have to verify that the
+ * console exists before dereferencing this
+ * pointer. */
} ConsoleEvent;
/*
* Declarations for functions used only in this file.
*/
-static int ConsoleBlockModeProc(ClientData instanceData, int mode);
-static void ConsoleCheckProc(ClientData clientData, int flags);
-static int ConsoleCloseProc(ClientData instanceData,
- Tcl_Interp *interp, int flags);
-static int ConsoleEventProc(Tcl_Event *evPtr, int flags);
-static void ConsoleExitHandler(ClientData clientData);
-static int ConsoleGetHandleProc(ClientData instanceData,
- int direction, ClientData *handlePtr);
-static int ConsoleGetOptionProc(ClientData instanceData,
- Tcl_Interp *interp, const char *optionName,
- Tcl_DString *dsPtr);
-static void ConsoleInit(void);
-static int ConsoleInputProc(ClientData instanceData, char *buf,
- int toRead, int *errorCode);
-static int ConsoleOutputProc(ClientData instanceData,
- const char *buf, int toWrite, int *errorCode);
-static int ConsoleSetOptionProc(ClientData instanceData,
- Tcl_Interp *interp, const char *optionName,
- const char *value);
-static void ConsoleSetupProc(ClientData clientData, int flags);
-static void ConsoleWatchProc(ClientData instanceData, int mask);
-static void ProcExitHandler(ClientData clientData);
-static void ConsoleThreadActionProc(ClientData instanceData, int action);
-static DWORD ReadConsoleChars(HANDLE hConsole, WCHAR *lpBuffer,
- Tcl_Size nChars, Tcl_Size *nCharsReadPtr);
-static DWORD WriteConsoleChars(HANDLE hConsole,
- const WCHAR *lpBuffer, Tcl_Size nChars,
- Tcl_Size *nCharsWritten);
-static void RingBufferInit(RingBuffer *ringPtr, Tcl_Size capacity);
-static void RingBufferClear(RingBuffer *ringPtr);
-static Tcl_Size RingBufferIn(RingBuffer *ringPtr, const char *srcPtr,
+static int ConsoleBlockModeProc(void *instanceData, int mode);
+static void ConsoleCheckProc(void *clientData, int flags);
+static int ConsoleCloseProc(void *instanceData,
+ Tcl_Interp *interp, int flags);
+static int ConsoleEventProc(Tcl_Event *evPtr, int flags);
+static void ConsoleExitHandler(void *clientData);
+static int ConsoleGetHandleProc(void *instanceData,
+ int direction, void **handlePtr);
+static int ConsoleGetOptionProc(void *instanceData,
+ Tcl_Interp *interp, const char *optionName,
+ Tcl_DString *dsPtr);
+static void ConsoleInit(void);
+static int ConsoleInputProc(void *instanceData, char *buf,
+ int toRead, int *errorCode);
+static int ConsoleOutputProc(void *instanceData,
+ const char *buf, int toWrite, int *errorCode);
+static int ConsoleSetOptionProc(void *instanceData,
+ Tcl_Interp *interp, const char *optionName,
+ const char *value);
+static void ConsoleSetupProc(void *clientData, int flags);
+static void ConsoleWatchProc(void *instanceData, int mask);
+static void ProcExitHandler(void *clientData);
+static void ConsoleThreadActionProc(void *instanceData, int action);
+static DWORD ReadConsoleChars(HANDLE hConsole, WCHAR *lpBuffer,
+ Tcl_Size nChars, Tcl_Size *nCharsReadPtr);
+static DWORD WriteConsoleChars(HANDLE hConsole,
+ const WCHAR *lpBuffer, Tcl_Size nChars,
+ Tcl_Size *nCharsWritten);
+static void RingBufferInit(RingBuffer *ringPtr, Tcl_Size capacity);
+static void RingBufferClear(RingBuffer *ringPtr);
+static Tcl_Size RingBufferIn(RingBuffer *ringPtr, const char *srcPtr,
Tcl_Size srcLen, int partialCopyOk);
-static Tcl_Size RingBufferOut(RingBuffer *ringPtr, char *dstPtr,
+static Tcl_Size RingBufferOut(RingBuffer *ringPtr, char *dstPtr,
Tcl_Size dstCapacity, int partialCopyOk);
static ConsoleHandleInfo *AllocateConsoleHandleInfo(HANDLE consoleHandle,
int permissions);
@@ -244,7 +254,7 @@ static DWORD WINAPI ConsoleReaderThread(LPVOID arg);
static DWORD WINAPI ConsoleWriterThread(LPVOID arg);
static void NudgeWatchers(HANDLE consoleHandle);
#ifndef NDEBUG
-static int RingBufferCheck(const RingBuffer *ringPtr);
+static int RingBufferCheck(const RingBuffer *ringPtr);
#endif
/*
@@ -324,12 +334,14 @@ static const Tcl_ChannelType consoleChannelType = {
*------------------------------------------------------------------------
*/
static void
-RingBufferInit(RingBuffer *ringPtr, Tcl_Size capacity)
+RingBufferInit(
+ RingBuffer *ringPtr,
+ Tcl_Size capacity)
{
if (capacity <= 0 || capacity > TCL_SIZE_MAX) {
Tcl_Panic("Internal error: invalid ring buffer capacity requested.");
}
- ringPtr->bufPtr = (char *)ckalloc(capacity);
+ ringPtr->bufPtr = (char *) ckalloc(capacity);
ringPtr->capacity = capacity;
ringPtr->start = 0;
ringPtr->length = 0;
@@ -351,7 +363,8 @@ RingBufferInit(RingBuffer *ringPtr, Tcl_Size capacity)
*------------------------------------------------------------------------
*/
static void
-RingBufferClear(RingBuffer *ringPtr)
+RingBufferClear(
+ RingBuffer *ringPtr)
{
if (ringPtr->bufPtr) {
ckfree(ringPtr->bufPtr);
@@ -380,10 +393,9 @@ RingBufferClear(RingBuffer *ringPtr)
static Tcl_Size
RingBufferIn(
RingBuffer *ringPtr,
- const char *srcPtr, /* Source to be copied */
- Tcl_Size srcLen, /* Length of source */
- int partialCopyOk /* If true, partial copy is permitted */
- )
+ const char *srcPtr, /* Source to be copied */
+ Tcl_Size srcLen, /* Length of source */
+ int partialCopyOk) /* If true, partial copy is permitted */
{
Tcl_Size freeSpace;
@@ -441,10 +453,11 @@ RingBufferIn(
*------------------------------------------------------------------------
*/
static Tcl_Size
-RingBufferOut(RingBuffer *ringPtr,
- char *dstPtr, /* Buffer for output data. May be NULL */
- Tcl_Size dstCapacity, /* Size of buffer */
- int partialCopyOk) /* If true, return what's available */
+RingBufferOut(
+ RingBuffer *ringPtr,
+ char *dstPtr, /* Buffer for output data. May be NULL */
+ Tcl_Size dstCapacity, /* Size of buffer */
+ int partialCopyOk) /* If true, return what's available */
{
Tcl_Size leadLen;
@@ -493,7 +506,8 @@ RingBufferOut(RingBuffer *ringPtr,
#ifndef NDEBUG
static int
-RingBufferCheck(const RingBuffer *ringPtr)
+RingBufferCheck(
+ const RingBuffer *ringPtr)
{
return (ringPtr->bufPtr != NULL && ringPtr->capacity == CONSOLE_BUFFER_SIZE
&& ringPtr->start < ringPtr->capacity
@@ -551,13 +565,14 @@ ReadConsoleChars(
result = ReadConsoleW(hConsole, lpBuffer, nChars, &nRead, NULL);
if (result) {
if ((nRead == 0 || nRead == (DWORD)-1)
- && GetLastError() == ERROR_OPERATION_ABORTED) {
+ && GetLastError() == ERROR_OPERATION_ABORTED) {
nRead = 0;
}
*nCharsReadPtr = nRead;
return 0;
- } else
+ } else {
return GetLastError();
+ }
}
/*
@@ -663,7 +678,7 @@ ConsoleInit(void)
static void
ConsoleExitHandler(
- TCL_UNUSED(ClientData))
+ TCL_UNUSED(void *))
{
Tcl_DeleteEventSource(ConsoleSetupProc, ConsoleCheckProc, NULL);
}
@@ -687,7 +702,7 @@ ConsoleExitHandler(
static void
ProcExitHandler(
- TCL_UNUSED(ClientData))
+ TCL_UNUSED(void *))
{
AcquireSRWLockExclusive(&gConsoleLock);
gInitialized = 0;
@@ -712,19 +727,21 @@ ProcExitHandler(
* As above.
*------------------------------------------------------------------------
*/
-void NudgeWatchers (HANDLE consoleHandle)
+static void
+NudgeWatchers(
+ HANDLE consoleHandle)
{
ConsoleChannelInfo *chanInfoPtr;
AcquireSRWLockShared(&gConsoleLock); /* Shared-read lock */
for (chanInfoPtr = gWatchingChannelList; chanInfoPtr;
- chanInfoPtr = chanInfoPtr->nextWatchingChannelPtr) {
+ chanInfoPtr = chanInfoPtr->nextWatchingChannelPtr) {
/*
* Notify channels interested in our handle AND that have
* a thread attached.
* No lock needed for chanInfoPtr. See ConsoleChannelInfo.
*/
if (chanInfoPtr->handle == consoleHandle
- && chanInfoPtr->threadId != NULL) {
+ && chanInfoPtr->threadId != NULL) {
Tcl_ThreadAlert(chanInfoPtr->threadId);
}
}
@@ -752,7 +769,7 @@ void NudgeWatchers (HANDLE consoleHandle)
void
ConsoleSetupProc(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
int flags) /* Event flags as passed to Tcl_DoOneEvent. */
{
ConsoleChannelInfo *chanInfoPtr;
@@ -770,7 +787,7 @@ ConsoleSetupProc(
AcquireSRWLockShared(&gConsoleLock); /* READ lock - no data modification */
for (chanInfoPtr = gWatchingChannelList; block && chanInfoPtr != NULL;
- chanInfoPtr = chanInfoPtr->nextWatchingChannelPtr) {
+ chanInfoPtr = chanInfoPtr->nextWatchingChannelPtr) {
ConsoleHandleInfo *handleInfoPtr;
handleInfoPtr = FindConsoleInfo(chanInfoPtr);
if (handleInfoPtr != NULL) {
@@ -778,7 +795,7 @@ ConsoleSetupProc(
/* Remember at most one of READABLE, WRITABLE set */
if (chanInfoPtr->watchMask & TCL_READABLE) {
if (RingBufferLength(&handleInfoPtr->buffer) > 0
- || handleInfoPtr->lastError != ERROR_SUCCESS) {
+ || handleInfoPtr->lastError != ERROR_SUCCESS) {
block = 0; /* Input data available */
}
} else if (chanInfoPtr->watchMask & TCL_WRITABLE) {
@@ -817,7 +834,7 @@ ConsoleSetupProc(
static void
ConsoleCheckProc(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
int flags) /* Event flags as passed to Tcl_DoOneEvent. */
{
ConsoleChannelInfo *chanInfoPtr;
@@ -865,7 +882,7 @@ ConsoleCheckProc(
/* Rememeber channel is read or write, never both */
if (chanInfoPtr->watchMask & TCL_READABLE) {
if (RingBufferLength(&handleInfoPtr->buffer) > 0
- || handleInfoPtr->lastError != ERROR_SUCCESS) {
+ || handleInfoPtr->lastError != ERROR_SUCCESS) {
needEvent = 1; /* Input data available or error/EOF */
}
/*
@@ -916,7 +933,7 @@ ConsoleCheckProc(
static int
ConsoleBlockModeProc(
- ClientData instanceData, /* Instance data for channel. */
+ void *instanceData, /* Instance data for channel. */
int mode) /* TCL_MODE_BLOCKING or
* TCL_MODE_NONBLOCKING. */
{
@@ -956,7 +973,7 @@ ConsoleBlockModeProc(
static int
ConsoleCloseProc(
- ClientData instanceData, /* Pointer to ConsoleChannelInfo structure. */
+ void *instanceData, /* Pointer to ConsoleChannelInfo structure. */
TCL_UNUSED(Tcl_Interp *),
int flags)
{
@@ -976,9 +993,9 @@ ConsoleCloseProc(
* still close the handle. That's historical behavior on all platforms.
*/
if (!TclInThreadExit()
- || ((GetStdHandle(STD_INPUT_HANDLE) != chanInfoPtr->handle)
- && (GetStdHandle(STD_OUTPUT_HANDLE) != chanInfoPtr->handle)
- && (GetStdHandle(STD_ERROR_HANDLE) != chanInfoPtr->handle))) {
+ || ( (GetStdHandle(STD_INPUT_HANDLE) != chanInfoPtr->handle)
+ && (GetStdHandle(STD_OUTPUT_HANDLE) != chanInfoPtr->handle)
+ && (GetStdHandle(STD_ERROR_HANDLE) != chanInfoPtr->handle))) {
closeHandle = 1;
} else {
closeHandle = 0;
@@ -988,7 +1005,7 @@ ConsoleCloseProc(
/* Remove channel from watchers' list */
for (nextPtrPtr = &gWatchingChannelList; *nextPtrPtr != NULL;
- nextPtrPtr = &(*nextPtrPtr)->nextWatchingChannelPtr) {
+ nextPtrPtr = &(*nextPtrPtr)->nextWatchingChannelPtr) {
if (*nextPtrPtr == (ConsoleChannelInfo *) chanInfoPtr) {
*nextPtrPtr = (*nextPtrPtr)->nextWatchingChannelPtr;
break;
@@ -1075,7 +1092,7 @@ ConsoleCloseProc(
*/
static int
ConsoleInputProc(
- ClientData instanceData, /* Console state. */
+ void *instanceData, /* Console state. */
char *bufPtr, /* Where to store data read. */
int bufSize, /* How much space is available in the
* buffer? */
@@ -1143,22 +1160,27 @@ ConsoleInputProc(
/*
* Blocking read. Just get data from directly from console. There
- * is a small complication in that we can only read even number
- * of bytes (wide-character API) and the destination buffer should be
- * WCHAR aligned. If either condition is not met, we defer to the
- * reader thread which handles these case rather than dealing with
+ * is a small complication in that
+ * 1. The destination buffer should be WCHAR aligned.
+ * 2. We can only read even number of bytes (wide-character API).
+ * 3. Caller has large enough buffer (else length of line user can
+ * enter will be limited)
+ * If any condition is not met, we defer to the
+ * reader thread which handles these cases rather than dealing with
* them here (which is a little trickier than it might sound.)
+ *
+ * TODO - not clear this block is a useful optimization. bufSize by
+ * default is 4K which is < INPUT_BUFFER_SIZE and will rarely be
+ * increased on stdin.
*/
- if ((1 & (ptrdiff_t)bufPtr) == 0 /* aligned buffer */
- && bufSize > 1 /* Not single byte read */
- ) {
+ if ((1 & (size_t)bufPtr) == 0 /* aligned buffer */
+ && (1 & bufSize) == 0 /* Even number of bytes */
+ && bufSize > INPUT_BUFFER_SIZE) {
DWORD lastError;
Tcl_Size numChars;
ReleaseSRWLockExclusive(&handleInfoPtr->lock);
lastError = ReadConsoleChars(chanInfoPtr->handle,
- (WCHAR *)bufPtr,
- bufSize / sizeof(WCHAR),
- &numChars);
+ (WCHAR *)bufPtr, bufSize / sizeof(WCHAR), &numChars);
/* NOTE lock released so DON'T break. Return instead */
if (lastError != ERROR_SUCCESS) {
Tcl_WinConvertError(lastError);
@@ -1186,9 +1208,7 @@ ConsoleInputProc(
handleInfoPtr->flags |= CONSOLE_DATA_AWAITED;
WakeConditionVariable(&handleInfoPtr->consoleThreadCV);
if (!SleepConditionVariableSRW(&handleInfoPtr->interpThreadCV,
- &handleInfoPtr->lock,
- INFINITE,
- 0)) {
+ &handleInfoPtr->lock, INFINITE, 0)) {
Tcl_WinConvertError(GetLastError());
*errorCode = Tcl_GetErrno();
numRead = -1;
@@ -1200,7 +1220,7 @@ ConsoleInputProc(
/* We read data. Ask for more if either async or watching for reads */
if ((chanInfoPtr->flags & CONSOLE_ASYNC)
- || (chanInfoPtr->watchMask & TCL_READABLE)) {
+ || (chanInfoPtr->watchMask & TCL_READABLE)) {
handleInfoPtr->flags |= CONSOLE_DATA_AWAITED;
WakeConditionVariable(&handleInfoPtr->consoleThreadCV);
}
@@ -1228,7 +1248,7 @@ ConsoleInputProc(
*/
static int
ConsoleOutputProc(
- ClientData instanceData, /* Console state. */
+ void *instanceData, /* Console state. */
const char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCode) /* Where to store error code. */
@@ -1285,15 +1305,12 @@ ConsoleOutputProc(
* The ring buffer deals with cases (3) and (4). It would be harder
* to duplicate that here.
*/
- if ((chanInfoPtr->flags & CONSOLE_ASYNC) /* Case (1) */
- || RingBufferLength(&handleInfoPtr->buffer) != 0 /* Case (2) */
- || (toWrite & 1) != 0 /* Case (3) */
- || (PTR2INT(buf) & 1) != 0 /* Case (4) */
- ) {
+ if ((chanInfoPtr->flags & CONSOLE_ASYNC) /* Case (1) */
+ || RingBufferLength(&handleInfoPtr->buffer) != 0 /* Case (2) */
+ || (toWrite & 1) != 0 /* Case (3) */
+ || (PTR2INT(buf) & 1) != 0) { /* Case (4) */
numWritten += RingBufferIn(&handleInfoPtr->buffer,
- numWritten + buf,
- toWrite - numWritten,
- 1);
+ numWritten + buf, toWrite - numWritten, 1);
if (numWritten == toWrite || chanInfoPtr->flags & CONSOLE_ASYNC) {
/* All done or async, just accept whatever was written */
break;
@@ -1305,9 +1322,7 @@ ConsoleOutputProc(
*/
WakeConditionVariable(&handleInfoPtr->consoleThreadCV);
if (!SleepConditionVariableSRW(&handleInfoPtr->interpThreadCV,
- &handleInfoPtr->lock,
- INFINITE,
- 0)) {
+ &handleInfoPtr->lock, INFINITE, 0)) {
/* Report the error */
Tcl_WinConvertError(GetLastError());
*errorCode = Tcl_GetErrno();
@@ -1320,11 +1335,10 @@ ConsoleOutputProc(
HANDLE consoleHandle = handleInfoPtr->console;
/* Unlock before blocking in WriteConsole */
ReleaseSRWLockExclusive(&handleInfoPtr->lock);
- /* UNLOCKED so return, DON'T break out of loop as it will unlock again! */
+ /* UNLOCKED so return, DON'T break out of loop as it will unlock
+ * again! */
winStatus = WriteConsoleChars(consoleHandle,
- (WCHAR *)buf,
- toWrite / sizeof(WCHAR),
- &numWritten);
+ (WCHAR *)buf, toWrite / sizeof(WCHAR), &numWritten);
if (winStatus == ERROR_SUCCESS) {
return numWritten * sizeof(WCHAR);
} else {
@@ -1398,9 +1412,8 @@ ConsoleEventProc(
* still owned by this thread AND is still watching events.
*/
if (chanInfoPtr->channel && chanInfoPtr->threadId == Tcl_GetCurrentThread()
- && (chanInfoPtr->watchMask & (TCL_READABLE|TCL_WRITABLE))) {
- ConsoleHandleInfo *handleInfoPtr;
- handleInfoPtr = FindConsoleInfo(chanInfoPtr);
+ && (chanInfoPtr->watchMask & (TCL_READABLE|TCL_WRITABLE))) {
+ ConsoleHandleInfo *handleInfoPtr = FindConsoleInfo(chanInfoPtr);
if (handleInfoPtr == NULL) {
/* Console was closed. EOF->read event only (not write) */
if (chanInfoPtr->watchMask & TCL_READABLE) {
@@ -1410,10 +1423,10 @@ ConsoleEventProc(
AcquireSRWLockShared(&handleInfoPtr->lock);
/* Remember at most one of READABLE, WRITABLE set */
if ((chanInfoPtr->watchMask & TCL_READABLE)
- && RingBufferLength(&handleInfoPtr->buffer)) {
+ && RingBufferLength(&handleInfoPtr->buffer)) {
mask = TCL_READABLE;
} else if ((chanInfoPtr->watchMask & TCL_WRITABLE)
- && RingBufferHasFreeSpace(&handleInfoPtr->buffer)) {
+ && RingBufferHasFreeSpace(&handleInfoPtr->buffer)) {
/* Generate write event space available */
mask = TCL_WRITABLE;
}
@@ -1468,10 +1481,9 @@ ConsoleEventProc(
static void
ConsoleWatchProc(
- ClientData instanceData, /* Console state. */
+ void *instanceData, /* Console state. */
int newMask) /* What events to watch for, one of
- * of TCL_READABLE, TCL_WRITABLE
- */
+ * of TCL_READABLE, TCL_WRITABLE */
{
ConsoleChannelInfo **nextPtrPtr, *ptr;
ConsoleChannelInfo *chanInfoPtr = (ConsoleChannelInfo *)instanceData;
@@ -1497,8 +1509,7 @@ ConsoleWatchProc(
* that we are looking for data since it will not do reads until
* it knows someone is awaiting.
*/
- ConsoleHandleInfo *handleInfoPtr;
- handleInfoPtr = FindConsoleInfo(chanInfoPtr);
+ ConsoleHandleInfo *handleInfoPtr = FindConsoleInfo(chanInfoPtr);
if (handleInfoPtr) {
AcquireSRWLockExclusive(&handleInfoPtr->lock);
handleInfoPtr->flags |= CONSOLE_DATA_AWAITED;
@@ -1544,9 +1555,9 @@ ConsoleWatchProc(
static int
ConsoleGetHandleProc(
- ClientData instanceData, /* The console state. */
+ void *instanceData, /* The console state. */
TCL_UNUSED(int) /*direction*/,
- ClientData *handlePtr) /* Where to store the handle. */
+ void **handlePtr) /* Where to store the handle. */
{
ConsoleChannelInfo *chanInfoPtr = (ConsoleChannelInfo *)instanceData;
@@ -1574,7 +1585,8 @@ ConsoleGetHandleProc(
*------------------------------------------------------------------------
*/
static int
- ConsoleDataAvailable (HANDLE consoleHandle)
+ ConsoleDataAvailable(
+ HANDLE consoleHandle)
{
INPUT_RECORD input[10];
DWORD count;
@@ -1583,9 +1595,8 @@ ConsoleGetHandleProc(
/*
* Need at least one keyboard event.
*/
- if (PeekConsoleInputW(
- consoleHandle, input, sizeof(input) / sizeof(input[0]), &count)
- == FALSE) {
+ if (PeekConsoleInputW(consoleHandle, input,
+ sizeof(input) / sizeof(input[0]), &count) == FALSE) {
return -1;
}
/*
@@ -1596,11 +1607,12 @@ ConsoleGetHandleProc(
* down somewhere in the unread buffer. I suppose we could expand the
* buffer but not worth...
*/
- if (count == (sizeof(input)/sizeof(input[0])))
+ if (count == (sizeof(input)/sizeof(input[0]))) {
return 1;
+ }
for (i = 0; i < count; ++i) {
if (input[i].EventType == KEY_EVENT
- && input[i].Event.KeyEvent.bKeyDown) {
+ && input[i].Event.KeyEvent.bKeyDown) {
return 1;
}
}
@@ -1630,9 +1642,11 @@ ConsoleReaderThread(
{
ConsoleHandleInfo *handleInfoPtr = (ConsoleHandleInfo *) arg;
ConsoleHandleInfo **iterator;
- char inputChars[200]; /* Temporary buffer */
Tcl_Size inputLen = 0;
Tcl_Size inputOffset = 0;
+ Tcl_Size lastReadSize = 0;
+ DWORD sleepTime;
+ char inputChars[INPUT_BUFFER_SIZE];
/*
* Keep looping until one of the following happens.
@@ -1666,11 +1680,9 @@ ConsoleReaderThread(
Tcl_Size nStored;
assert((inputLen - inputOffset) > 0);
-
nStored = RingBufferIn(&handleInfoPtr->buffer,
- inputOffset + inputChars,
- inputLen - inputOffset,
- 1);
+ inputOffset + inputChars, inputLen - inputOffset,
+ 1);
inputOffset += nStored;
if (inputOffset == inputLen) {
/* Temp buffer now empty */
@@ -1713,33 +1725,40 @@ ConsoleReaderThread(
continue;
}
+ assert(inputLen == 0);
+
/*
- * Both shared buffer and private buffer are empty. Need to go get
- * data from console but do not want to read ahead because the
- * interp thread might change the read mode, e.g. turning off echo
- * for password input. So only do so if at least one interpreter has
- * requested data.
+ * Read more data in two cases:
+ * 1. The previous read filled the buffer and there could be more
+ * data in the console internal *text* buffer. Note
+ * ConsolePendingInput (checked in ConsoleDataAvailable) will NOT
+ * show this. It holds input events not yet translated to text.
+ * 2. Tcl threads want more data AND there is data in the
+ * ConsolePendingInput buffer. The latter check necessary because
+ * we do not want to read ahead because the interp thread might
+ * change the read mode, e.g. turning off echo for password
+ * input. So only do so if at least one interpreter has requested
+ * data.
*/
- if ((handleInfoPtr->flags & CONSOLE_DATA_AWAITED)
- && ConsoleDataAvailable(handleInfoPtr->console)) {
+ if (lastReadSize == sizeof(inputChars)
+ || ((handleInfoPtr->flags & CONSOLE_DATA_AWAITED)
+ && ConsoleDataAvailable(handleInfoPtr->console))) {
DWORD error;
/* Do not hold the lock while blocked in console */
ReleaseSRWLockExclusive(&handleInfoPtr->lock);
- /*
- * Note - the temporary buffer serves two purposes. It
- */
error = ReadConsoleChars(handleInfoPtr->console,
- (WCHAR *)inputChars,
- sizeof(inputChars) / sizeof(WCHAR),
- &inputLen);
+ (WCHAR *)inputChars, sizeof(inputChars) / sizeof(WCHAR),
+ &inputLen);
AcquireSRWLockExclusive(&handleInfoPtr->lock);
if (error == 0) {
inputLen *= sizeof(WCHAR);
+ lastReadSize = inputLen;
} else {
/*
* We only store the last error. It is up to channel
* handlers whether to close or not in case of errors.
*/
+ lastReadSize = 0;
handleInfoPtr->lastError = error;
if (handleInfoPtr->lastError == ERROR_INVALID_HANDLE) {
handleInfoPtr->console = INVALID_HANDLE_VALUE;
@@ -1753,13 +1772,10 @@ ConsoleReaderThread(
* poll since ReadConsole does not support async operation.
* So sleep for a short while and loop back to retry.
*/
- DWORD sleepTime;
sleepTime =
handleInfoPtr->flags & CONSOLE_DATA_AWAITED ? 50 : INFINITE;
SleepConditionVariableSRW(&handleInfoPtr->consoleThreadCV,
- &handleInfoPtr->lock,
- sleepTime,
- 0);
+ &handleInfoPtr->lock, sleepTime, 0);
}
/* Loop again to check for exit or wait for readers to wake us */
@@ -1776,7 +1792,7 @@ ConsoleReaderThread(
ReleaseSRWLockExclusive(&handleInfoPtr->lock);
AcquireSRWLockExclusive(&gConsoleLock); /* Modifying - exclusive lock */
for (iterator = &gConsoleHandleInfoList; *iterator;
- iterator = &(*iterator)->nextPtr) {
+ iterator = &(*iterator)->nextPtr) {
if (*iterator == handleInfoPtr) {
*iterator = handleInfoPtr->nextPtr;
break;
@@ -1788,7 +1804,7 @@ ConsoleReaderThread(
RingBufferClear(&handleInfoPtr->buffer);
if (handleInfoPtr->console != INVALID_HANDLE_VALUE
- && handleInfoPtr->lastError != ERROR_INVALID_HANDLE) {
+ && handleInfoPtr->lastError != ERROR_INVALID_HANDLE) {
SetConsoleMode(handleInfoPtr->console, handleInfoPtr->initMode);
/*
* NOTE: we do not call CloseHandle(handleInfoPtr->console) here.
@@ -1821,7 +1837,8 @@ ConsoleReaderThread(
*----------------------------------------------------------------------
*/
static DWORD WINAPI
-ConsoleWriterThread(LPVOID arg)
+ConsoleWriterThread(
+ LPVOID arg)
{
ConsoleHandleInfo *handleInfoPtr = (ConsoleHandleInfo *) arg;
ConsoleHandleInfo **iterator;
@@ -1874,9 +1891,7 @@ ConsoleWriterThread(LPVOID arg)
/* Wake up any threads waiting synchronously. */
WakeConditionVariable(&handleInfoPtr->interpThreadCV);
success = SleepConditionVariableSRW(&handleInfoPtr->consoleThreadCV,
- &handleInfoPtr->lock,
- INFINITE,
- 0);
+ &handleInfoPtr->lock, INFINITE, 0);
/* Note: lock has been acquired again! */
if (!success && GetLastError() != ERROR_TIMEOUT) {
/* TODO - what can be done? Should not happen */
@@ -1900,9 +1915,7 @@ ConsoleWriterThread(LPVOID arg)
Tcl_Size numWChars = numBytes / sizeof(WCHAR);
DWORD status;
status = WriteConsoleChars(handleInfoPtr->console,
- (WCHAR *)(offset + buffer),
- numWChars,
- &numWChars);
+ (WCHAR *)(offset + buffer), numWChars, &numWChars);
if (status != 0) {
/* Only overwrite if no previous error */
if (handleInfoPtr->lastError == 0) {
@@ -1947,7 +1960,7 @@ ConsoleWriterThread(LPVOID arg)
ReleaseSRWLockExclusive(&handleInfoPtr->lock);
AcquireSRWLockExclusive(&gConsoleLock); /* Modifying - exclusive lock */
for (iterator = &gConsoleHandleInfoList; *iterator;
- iterator = &(*iterator)->nextPtr) {
+ iterator = &(*iterator)->nextPtr) {
if (*iterator == handleInfoPtr) {
*iterator = handleInfoPtr->nextPtr;
break;
@@ -1993,8 +2006,8 @@ AllocateConsoleHandleInfo(
ConsoleHandleInfo *handleInfoPtr;
DWORD consoleMode;
-
- handleInfoPtr = (ConsoleHandleInfo *)ckalloc(sizeof(*handleInfoPtr));
+ handleInfoPtr = (ConsoleHandleInfo *) ckalloc(sizeof(*handleInfoPtr));
+ memset(handleInfoPtr, 0, sizeof(*handleInfoPtr));
memset(handleInfoPtr, 0, sizeof(*handleInfoPtr));
handleInfoPtr->console = consoleHandle;
InitializeSRWLock(&handleInfoPtr->lock);
@@ -2214,7 +2227,7 @@ TclWinOpenConsoleChannel(
static void
ConsoleThreadActionProc(
- ClientData instanceData,
+ void *instanceData,
int action)
{
ConsoleChannelInfo *chanInfoPtr = (ConsoleChannelInfo *)instanceData;
@@ -2247,7 +2260,7 @@ ConsoleThreadActionProc(
*/
static int
ConsoleSetOptionProc(
- ClientData instanceData, /* File state. */
+ void *instanceData, /* File state. */
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Which option to set? */
const char *value) /* New value for option. */
@@ -2336,7 +2349,7 @@ ConsoleSetOptionProc(
static int
ConsoleGetOptionProc(
- ClientData instanceData, /* File state. */
+ void *instanceData, /* File state. */
Tcl_Interp *interp, /* For error reporting - can be NULL. */
const char *optionName, /* Option to get. */
Tcl_DString *dsPtr) /* Where to store value(s). */
@@ -2401,30 +2414,26 @@ ConsoleGetOptionProc(
valid = 1;
if (!GetConsoleScreenBufferInfo(chanInfoPtr->handle,
- &consoleInfo)) {
+ &consoleInfo)) {
Tcl_WinConvertError(GetLastError());
if (interp != NULL) {
- Tcl_SetObjResult(
- interp,
- Tcl_ObjPrintf("couldn't read console size: %s",
- Tcl_PosixError(interp)));
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't read console size: %s",
+ Tcl_PosixError(interp)));
}
return TCL_ERROR;
}
Tcl_DStringStartSublist(dsPtr);
- snprintf(buf, sizeof(buf),
- "%d",
+ snprintf(buf, sizeof(buf), "%d",
consoleInfo.srWindow.Right - consoleInfo.srWindow.Left + 1);
Tcl_DStringAppendElement(dsPtr, buf);
- snprintf(buf, sizeof(buf),
- "%d",
+ snprintf(buf, sizeof(buf), "%d",
consoleInfo.srWindow.Bottom - consoleInfo.srWindow.Top + 1);
Tcl_DStringAppendElement(dsPtr, buf);
Tcl_DStringEndSublist(dsPtr);
}
}
-
if (valid) {
return TCL_OK;
}
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index e02f6d6..5d45fe1 100644
--- a/win/tclWinFCmd.c
+++ b/win/tclWinFCmd.c
@@ -410,8 +410,7 @@ DoRenameFile(
* directory back, for completeness.
*/
- if (MoveFileW(nativeSrc,
- nativeDst) != FALSE) {
+ if (MoveFileW(nativeSrc, nativeDst) != FALSE) {
return TCL_OK;
}
@@ -696,8 +695,7 @@ DoCopyFile(
if (dstAttr & FILE_ATTRIBUTE_READONLY) {
SetFileAttributesW(nativeDst,
dstAttr & ~((DWORD)FILE_ATTRIBUTE_READONLY));
- if (CopyFileW(nativeSrc, nativeDst,
- 0) != FALSE) {
+ if (CopyFileW(nativeSrc, nativeDst, 0) != FALSE) {
return TCL_OK;
}
@@ -793,8 +791,7 @@ TclpDeleteFile(
int res = SetFileAttributesW(path,
attr & ~((DWORD) FILE_ATTRIBUTE_READONLY));
- if ((res != 0) &&
- (DeleteFileW(path) != FALSE)) {
+ if ((res != 0) && (DeleteFileW(path) != FALSE)) {
return TCL_OK;
}
Tcl_WinConvertError(GetLastError());
@@ -1081,8 +1078,7 @@ DoRemoveJustDirectory(
if (attr & FILE_ATTRIBUTE_READONLY) {
attr &= ~FILE_ATTRIBUTE_READONLY;
- if (SetFileAttributesW(nativePath,
- attr) == FALSE) {
+ if (SetFileAttributesW(nativePath, attr) == FALSE) {
goto end;
}
if (RemoveDirectoryW(nativePath) != FALSE) {
@@ -1119,7 +1115,9 @@ DoRemoveJustDirectory(
Tcl_DStringInit(errorPtr);
p = Tcl_WCharToUtfDString(nativePath, TCL_INDEX_NONE, errorPtr);
for (; *p; ++p) {
- if (*p == '\\') *p = '/';
+ if (*p == '\\') {
+ *p = '/';
+ }
}
}
return TCL_ERROR;
@@ -1380,8 +1378,7 @@ TraversalCopy(
if (DoCreateDirectory(nativeDst) == TCL_OK) {
DWORD attr = GetFileAttributesW(nativeSrc);
- if (SetFileAttributesW(nativeDst,
- attr) != FALSE) {
+ if (SetFileAttributesW(nativeDst, attr) != FALSE) {
return TCL_OK;
}
Tcl_WinConvertError(GetLastError());
@@ -1604,7 +1601,7 @@ ConvertFileNameFormat(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"could not read \"%s\": no such file or directory",
- Tcl_GetString(fileName)));
+ TclGetString(fileName)));
errno = ENOENT;
Tcl_PosixError(interp);
}
@@ -1895,7 +1892,7 @@ CannotSetAttribute(
{
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot set attribute \"%s\" for file \"%s\": attribute is readonly",
- tclpFileAttrStrings[objIndex], Tcl_GetString(fileName)));
+ tclpFileAttrStrings[objIndex], TclGetString(fileName)));
errno = EINVAL;
Tcl_PosixError(interp);
return TCL_ERROR;
@@ -2002,12 +1999,12 @@ TclpCreateTemporaryDirectory(
*/
if (dirObj) {
- Tcl_GetString(dirObj);
+ TclGetString(dirObj);
if (dirObj->length < 1) {
goto useSystemTemp;
}
Tcl_DStringInit(&base);
- Tcl_UtfToWCharDString(Tcl_GetString(dirObj), TCL_INDEX_NONE, &base);
+ Tcl_UtfToWCharDString(TclGetString(dirObj), TCL_INDEX_NONE, &base);
if (dirObj->bytes[dirObj->length - 1] != '\\') {
Tcl_UtfToWCharDString("\\", TCL_INDEX_NONE, &base);
}
@@ -2025,7 +2022,7 @@ TclpCreateTemporaryDirectory(
#define SUFFIX_LENGTH 8
if (basenameObj) {
- Tcl_UtfToWCharDString(Tcl_GetString(basenameObj), TCL_INDEX_NONE, &base);
+ Tcl_UtfToWCharDString(TclGetString(basenameObj), TCL_INDEX_NONE, &base);
} else {
Tcl_UtfToWCharDString(DEFAULT_TEMP_DIR_PREFIX, TCL_INDEX_NONE, &base);
}
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 5e47098..62cc94e 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -149,8 +149,8 @@ typedef struct {
* Other typedefs required by this code.
*/
-static time_t ToCTime(FILETIME fileTime);
-static void FromCTime(time_t posixTime, FILETIME *fileTime);
+static __time64_t ToCTime(FILETIME fileTime);
+static void FromCTime(__time64_t posixTime, FILETIME *fileTime);
/*
* Declarations for local functions defined in this file:
@@ -991,7 +991,7 @@ TclpMatchInDirectory(
attr = GetFileAttributesW(native);
if ((attr == INVALID_FILE_ATTRIBUTES)
- || ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)) {
+ || ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)) {
return TCL_OK;
}
@@ -2288,7 +2288,7 @@ NativeStatMode(
*
* ToCTime --
*
- * Converts a Windows FILETIME to a time_t in UTC.
+ * Converts a Windows FILETIME to a __time64_t in UTC.
*
* Results:
* Returns the count of seconds from the Posix epoch.
@@ -2296,7 +2296,7 @@ NativeStatMode(
*------------------------------------------------------------------------
*/
-static time_t
+static __time64_t
ToCTime(
FILETIME fileTime) /* UTC time */
{
@@ -2305,7 +2305,7 @@ ToCTime(
convertedTime.LowPart = fileTime.dwLowDateTime;
convertedTime.HighPart = (LONG) fileTime.dwHighDateTime;
- return (time_t) ((convertedTime.QuadPart -
+ return (__time64_t) ((convertedTime.QuadPart -
(long long) POSIX_EPOCH_AS_FILETIME) / (long long) 10000000);
}
@@ -2314,7 +2314,7 @@ ToCTime(
*
* FromCTime --
*
- * Converts a time_t to a Windows FILETIME
+ * Converts a __time64_t to a Windows FILETIME
*
* Results:
* Returns the count of 100-ns ticks seconds from the Windows epoch.
@@ -2324,7 +2324,7 @@ ToCTime(
static void
FromCTime(
- time_t posixTime,
+ __time64_t posixTime,
FILETIME *fileTime) /* UTC Time */
{
LARGE_INTEGER convertedTime;
@@ -2471,7 +2471,7 @@ TclpFilesystemPathType(
if (normPath == NULL) {
return NULL;
}
- path = Tcl_GetString(normPath);
+ path = TclGetString(normPath);
if (path == NULL) {
return NULL;
}
@@ -2551,7 +2551,7 @@ TclpObjNormalizePath(
Tcl_DString ds; /* Some workspace. */
Tcl_DStringInit(&dsNorm);
- path = Tcl_GetString(pathPtr);
+ path = TclGetString(pathPtr);
currentPathEndPosition = path + nextCheckpoint;
if (*currentPathEndPosition == '/') {
@@ -2649,12 +2649,12 @@ TclpObjNormalizePath(
* Convert link to forward slashes.
*/
- for (path = Tcl_GetString(to); *path != 0; path++) {
+ for (path = TclGetString(to); *path != 0; path++) {
if (*path == '\\') {
*path = '/';
}
}
- path = Tcl_GetString(to);
+ path = TclGetString(to);
currentPathEndPosition = path + nextCheckpoint;
if (temp != NULL) {
Tcl_DecrRefCount(temp);
@@ -2889,7 +2889,7 @@ TclWinVolumeRelativeNormalize(
* current volume.
*/
- const char *drive = Tcl_GetString(useThisCwd);
+ const char *drive = TclGetString(useThisCwd);
absolutePath = Tcl_NewStringObj(drive,2);
Tcl_AppendToObj(absolutePath, path, TCL_INDEX_NONE);
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 01714f0..59404d6 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -604,9 +604,7 @@ TclpFindVariable(
Tcl_UtfToUpper(nameUpper);
Tcl_DStringInit(&envString);
- for (i = 0, env = _wenviron[i];
- env != NULL;
- i++, env = _wenviron[i]) {
+ for (i = 0, env = _wenviron[i]; env != NULL; i++, env = _wenviron[i]) {
/*
* Chop the env string off after the equal sign, then Convert the name
* to all upper case, so we do not have to convert all the characters
diff --git a/win/tclWinLoad.c b/win/tclWinLoad.c
index faf80ee..4d9b578 100644
--- a/win/tclWinLoad.c
+++ b/win/tclWinLoad.c
@@ -114,14 +114,14 @@ TclpDlopen(
* first error for reporting purposes.
*/
if (firstError == ERROR_MOD_NOT_FOUND ||
- firstError == ERROR_DLL_NOT_FOUND) {
+ firstError == ERROR_DLL_NOT_FOUND) {
lastError = GetLastError();
} else {
lastError = firstError;
}
errMsg = Tcl_ObjPrintf("couldn't load library \"%s\": ",
- Tcl_GetString(pathPtr));
+ TclGetString(pathPtr));
/*
* Check for possible DLL errors. This doesn't work quite right,
diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c
index 7b7ef1e..64d739a 100644
--- a/win/tclWinNotify.c
+++ b/win/tclWinNotify.c
@@ -57,8 +57,8 @@ static CRITICAL_SECTION notifierMutex;
* Static routines defined in this file.
*/
-static LRESULT CALLBACK NotifierProc(HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam);
+static LRESULT CALLBACK NotifierProc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam);
/*
*----------------------------------------------------------------------
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 5bf5165..bb4983e 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -1316,7 +1316,7 @@ ApplicationType(
ext = strrchr(fullName, '.');
if ((ext != NULL) &&
- (strcasecmp(ext, ".cmd") == 0 || strcasecmp(ext, ".bat") == 0)) {
+ (strcasecmp(ext, ".cmd") == 0 || strcasecmp(ext, ".bat") == 0)) {
applType = APPL_DOS;
break;
}
@@ -2770,7 +2770,7 @@ Tcl_PidObjCmd(
TclNewIntObj(elemPtr, getpid());
Tcl_SetObjResult(interp, elemPtr);
} else {
- chan = Tcl_GetChannel(interp, Tcl_GetString(objv[1]),
+ chan = Tcl_GetChannel(interp, TclGetString(objv[1]),
NULL);
if (chan == (Tcl_Channel) NULL) {
return TCL_ERROR;
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index 9ef62c6..a0b4e90 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -853,7 +853,7 @@ GetValue(
Tcl_NewStringObj(Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf)));
- while (*wp++ != 0) {/* empty body */}
+ while (*wp++ != 0); /* empty loop body */
p = (char *) wp;
Tcl_DStringFree(&buf);
}
@@ -937,7 +937,6 @@ GetValueNames(
size = MAX_KEY_LENGTH;
while (RegEnumValueW(key,index, (WCHAR *)Tcl_DStringValue(&buffer),
&size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
-
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString((const WCHAR *)Tcl_DStringValue(&buffer), size, &ds);
name = Tcl_DStringValue(&ds);
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 9a3b127..4f1a9c2 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -433,7 +433,7 @@ Tcl_GetHostName(void)
*/
void
-TclInitSockets()
+TclInitSockets(void)
{
/* Then Per thread initialization. */
DWORD id;
@@ -1207,7 +1207,7 @@ TcpSetOptionProc(
return TCL_OK;
}
if ((len > 1) && (optionName[1] == 'n') &&
- (strncmp(optionName, "-nodelay", len) == 0)) {
+ (strncmp(optionName, "-nodelay", len) == 0)) {
BOOL boolVar;
int rtn;
@@ -2272,7 +2272,7 @@ Tcl_OpenTcpServerEx(
ioctlsocket(sock, (long) FIONBIO, &flag);
SendSelectMessage(tsdPtr, SELECT, statePtr);
if (Tcl_SetChannelOption(interp, statePtr->channel, "-eofchar", "")
- == TCL_ERROR) {
+ == TCL_ERROR) {
Tcl_Close(NULL, statePtr->channel);
return NULL;
}
diff --git a/win/tclWinTest.c b/win/tclWinTest.c
index 86f36b4..f2c9a86d 100644
--- a/win/tclWinTest.c
+++ b/win/tclWinTest.c
@@ -476,8 +476,8 @@ TestplatformChmod(
}
/* Get process SID */
- if (!GetTokenInformation(hToken, TokenUser, NULL, 0, &dw) &&
- GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ if (!GetTokenInformation(hToken, TokenUser, NULL, 0, &dw)
+ && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
goto done;
}
pTokenUser = (TOKEN_USER *)ckalloc(dw);
@@ -486,9 +486,8 @@ TestplatformChmod(
}
aceEntry[nSids].sidLen = GetLengthSid(pTokenUser->User.Sid);
aceEntry[nSids].pSid = ckalloc(aceEntry[nSids].sidLen);
- if (!CopySid(aceEntry[nSids].sidLen,
- aceEntry[nSids].pSid,
- pTokenUser->User.Sid)) {
+ if (!CopySid(aceEntry[nSids].sidLen, aceEntry[nSids].pSid,
+ pTokenUser->User.Sid)) {
ckfree(aceEntry[nSids].pSid); /* Since we have not ++'ed nSids */
goto done;
}