summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/Makefile.in4
-rw-r--r--win/makefile.vc2
-rw-r--r--win/nmakehlp.c10
-rw-r--r--win/rules.vc2
-rw-r--r--win/tcl.m44
-rw-r--r--win/tclAppInit.c2
-rw-r--r--win/tclWinChan.c24
-rw-r--r--win/tclWinConsole.c6
-rw-r--r--win/tclWinDde.c9
-rw-r--r--win/tclWinFCmd.c8
-rw-r--r--win/tclWinFile.c8
-rw-r--r--win/tclWinInit.c30
-rw-r--r--win/tclWinInt.h2
-rw-r--r--win/tclWinNotify.c2
-rw-r--r--win/tclWinPipe.c14
-rw-r--r--win/tclWinReg.c18
-rw-r--r--win/tclWinSerial.c32
-rw-r--r--win/tclWinSock.c40
-rw-r--r--win/tclWinThrd.c4
-rw-r--r--win/tclWinTime.c10
20 files changed, 117 insertions, 114 deletions
diff --git a/win/Makefile.in b/win/Makefile.in
index e16a08e..edfda72 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -613,7 +613,7 @@ ${TEST_EXE_FILE}: ${TCL_STUB_LIB_FILE} ${TCLTEST_OBJS} tclTestMain.${OBJEXT}
tclsh.$(RES) $(CC_EXENAME) $(LDFLAGS_CONSOLE)
$(COPY) tclsh.exe.manifest ${TEST_EXE_FILE}.manifest
-# use pre-built zlib1.dll
+# use prebuilt zlib1.dll
${ZLIB_DLL_FILE}: ${TCL_STUB_LIB_FILE}
@if test "@ZLIB_LIBS@set" = "${ZLIB_DIR_NATIVE}/win64-arm/zdll.libset" ; then \
$(COPY) $(ZLIB_DIR)/win64-arm/${ZLIB_DLL_FILE} ${ZLIB_DLL_FILE}; \
@@ -702,6 +702,8 @@ tclPkgConfig.${OBJEXT}: tclPkgConfig.c
tclEvent.${OBJEXT}: tclEvent.c tclUuid.h
+tclTest.${OBJEXT}: tclTest.c tclUuid.h
+
$(TOP_DIR)/manifest.uuid:
printf "git-" >$(TOP_DIR)/manifest.uuid
(cd $(TOP_DIR); git rev-parse HEAD >>$(TOP_DIR)/manifest.uuid || \
diff --git a/win/makefile.vc b/win/makefile.vc
index 20875ef..4333a2a 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -110,7 +110,7 @@
# Hooks to allow the intermediate and output directories to be
# changed. $(OUT_DIR) is assumed to be
# $(BINROOT)\(Release|Debug) based on if symbols are requested.
-# $(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
+# $(TMP_DIR) will be $(OUT_DIR)\<buildtype> by default.
#
# TESTPAT=<file>
# Reads the tests requested to be run from this file.
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index fc40da4..e0941e3 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -210,13 +210,13 @@ CheckForCompilerFeature(
sa.bInheritHandle = FALSE;
/*
- * Create a non-inheritible pipe.
+ * Create a non-inheritable pipe.
*/
CreatePipe(&Out.pipe, &h, &sa, 0);
/*
- * Dupe the write side, make it inheritible, and close the original.
+ * Dupe the write side, make it inheritable, and close the original.
*/
DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
@@ -352,7 +352,7 @@ CheckForLinkerFeature(
CreatePipe(&Out.pipe, &h, &sa, 0);
/*
- * Dupe the write side, make it inheritible, and close the original.
+ * Dupe the write side, make it inheritable, and close the original.
*/
DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
@@ -584,7 +584,7 @@ list_free(list_item_t **listPtrPtr)
* SubstituteFile --
* As windows doesn't provide anything useful like sed and it's unreliable
* to use the tclsh you are building against (consider x-platform builds -
- * eg compiling AMD64 target from IX86) we provide a simple substitution
+ * e.g. compiling AMD64 target from IX86) we provide a simple substitution
* option here to handle autoconf style substitutions.
* The substitution file is whitespace and line delimited. The file should
* consist of lines matching the regular expression:
@@ -610,7 +610,7 @@ SubstituteFile(
if (fp != NULL) {
/*
- * Build a list of substutitions from the first filename
+ * Build a list of substitutions from the first filename
*/
sp = fopen(substitutions, "rt");
diff --git a/win/rules.vc b/win/rules.vc
index 0dd6ef2..d8b3b12 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -1369,7 +1369,7 @@ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include
# and switches are specific to it.
# The following macros are defined, names are for historical compatibility:
# OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS
-# COMPILERFLAGS - /Dxxx C macro flags independent of any configuration opttions
+# COMPILERFLAGS - /Dxxx C macro flags independent of any configuration options
# crt - Compiler switch that selects the appropriate C runtime
# cdebug - Compiler switches related to debug AND optimizations
# cwarn - Compiler switches that set warning levels
diff --git a/win/tcl.m4 b/win/tcl.m4
index fa9d4a9..2a40db4 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -1044,7 +1044,7 @@ AC_DEFUN([SC_WITH_TCL], [
# none
#
# Results
-# Subst's the following values:
+# Substitutes the following values:
# TCLSH_PROG
#------------------------------------------------------------------------
@@ -1090,7 +1090,7 @@ AC_DEFUN([SC_PROG_TCLSH], [
# none
#
# Results
-# Subst's the following values:
+# Substitutes the following values:
# BUILD_TCLSH
#------------------------------------------------------------------------
diff --git a/win/tclAppInit.c b/win/tclAppInit.c
index 077500a..126b3a7 100644
--- a/win/tclAppInit.c
+++ b/win/tclAppInit.c
@@ -141,7 +141,7 @@ _tmain(
TclZipfs_AppHook(&argc, &argv);
#endif
- Tcl_Main((size_t)argc, argv, TCL_LOCAL_APPINIT);
+ Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
return 0; /* Needed only to prevent compiler warning. */
}
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index ca79e42..9535fdd 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.c
@@ -95,6 +95,8 @@ static int FileTruncateProc(void *instanceData,
long long length);
static DWORD FileGetType(HANDLE handle);
static int NativeIsComPort(const WCHAR *nativeName);
+static Tcl_Channel OpenFileChannel(HANDLE handle, char *channelName,
+ int permissions, int appendMode);
/*
* This structure describes the channel type structure for file based IO.
@@ -850,7 +852,7 @@ TclpOpenFileChannel(
}
/*
- * For natively named Windows serial ports we are done.
+ * For natively-named Windows serial ports we are done.
*/
channel = TclWinOpenSerialChannel(handle, channelName,
@@ -948,7 +950,7 @@ TclpOpenFileChannel(
case FILE_TYPE_CHAR:
case FILE_TYPE_DISK:
case FILE_TYPE_UNKNOWN:
- channel = TclWinOpenFileChannel(handle, channelName,
+ channel = OpenFileChannel(handle, channelName,
channelPermissions,
TEST_FLAG(mode, O_APPEND) ? FILE_APPEND : 0);
break;
@@ -990,7 +992,7 @@ TclpOpenFileChannel(
Tcl_Channel
Tcl_MakeFileChannel(
void *rawHandle, /* OS level handle */
- int mode) /* ORed combination of TCL_READABLE and
+ int mode) /* OR'ed combination of TCL_READABLE and
* TCL_WRITABLE to indicate file mode. */
{
#if defined(HAVE_NO_SEH) && !defined(_WIN64) && !defined(__clang__)
@@ -1003,7 +1005,7 @@ Tcl_MakeFileChannel(
TclFile readFile = NULL, writeFile = NULL;
BOOL result;
- if (mode == 0) {
+ if ((mode & (TCL_READABLE|TCL_WRITABLE)) == 0) {
return NULL;
}
@@ -1026,7 +1028,7 @@ Tcl_MakeFileChannel(
case FILE_TYPE_DISK:
case FILE_TYPE_CHAR:
- channel = TclWinOpenFileChannel(handle, channelName, mode, 0);
+ channel = OpenFileChannel(handle, channelName, mode, 0);
break;
case FILE_TYPE_UNKNOWN:
@@ -1160,7 +1162,7 @@ Tcl_MakeFileChannel(
* is valid to something.
*/
- channel = TclWinOpenFileChannel(handle, channelName, mode, 0);
+ channel = OpenFileChannel(handle, channelName, mode, 0);
}
return channel;
@@ -1248,7 +1250,7 @@ TclpGetDefaultStdChannel(
/*
*----------------------------------------------------------------------
*
- * TclWinOpenFileChannel --
+ * OpenFileChannel --
*
* Constructs a File channel for the specified standard OS handle. This
* is a helper function to break up the construction of channels into
@@ -1265,7 +1267,7 @@ TclpGetDefaultStdChannel(
*/
Tcl_Channel
-TclWinOpenFileChannel(
+OpenFileChannel(
HANDLE handle, /* Win32 HANDLE to swallow */
char *channelName, /* Buffer to receive channel name */
int permissions, /* OR'ed combination of TCL_READABLE,
@@ -1285,7 +1287,7 @@ TclWinOpenFileChannel(
for (infoPtr = tsdPtr->firstFilePtr; infoPtr != NULL;
infoPtr = infoPtr->nextPtr) {
if (infoPtr->handle == (HANDLE) handle) {
- return (permissions==infoPtr->validMask) ? infoPtr->channel : NULL;
+ return ((permissions & (TCL_READABLE|TCL_WRITABLE|TCL_EXCEPTION))==infoPtr->validMask) ? infoPtr->channel : NULL;
}
}
@@ -1298,12 +1300,12 @@ TclWinOpenFileChannel(
*/
infoPtr->nextPtr = NULL;
- infoPtr->validMask = permissions;
+ infoPtr->validMask = permissions & (TCL_READABLE|TCL_WRITABLE|TCL_EXCEPTION);
infoPtr->watchMask = 0;
infoPtr->flags = appendMode;
infoPtr->handle = handle;
infoPtr->dirty = 0;
- sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
+ snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
infoPtr->channel = Tcl_CreateChannel(&fileChannelType, channelName,
infoPtr, permissions);
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c
index 59b56f4..4b49b7a 100644
--- a/win/tclWinConsole.c
+++ b/win/tclWinConsole.c
@@ -2123,7 +2123,7 @@ TclWinOpenConsoleChannel(
* for instance).
*/
- sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t) chanInfoPtr);
+ snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) chanInfoPtr);
if (permissions & TCL_READABLE) {
/*
@@ -2419,11 +2419,11 @@ ConsoleGetOptionProc(
return TCL_ERROR;
}
Tcl_DStringStartSublist(dsPtr);
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"%d",
consoleInfo.srWindow.Right - consoleInfo.srWindow.Left + 1);
Tcl_DStringAppendElement(dsPtr, buf);
- sprintf(buf,
+ snprintf(buf, sizeof(buf),
"%d",
consoleInfo.srWindow.Bottom - consoleInfo.srWindow.Top + 1);
Tcl_DStringAppendElement(dsPtr, buf);
diff --git a/win/tclWinDde.c b/win/tclWinDde.c
index fb2be99..697aae6 100644
--- a/win/tclWinDde.c
+++ b/win/tclWinDde.c
@@ -318,7 +318,8 @@ DdeSetServerName(
Tcl_DString dString;
const WCHAR *actualName;
Tcl_Obj *srvListPtr = NULL, **srvPtrPtr = NULL;
- int n, srvCount = 0, lastSuffix, r = TCL_OK;
+ Tcl_Size n, srvCount = 0;
+ int lastSuffix, r = TCL_OK;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
/*
@@ -870,7 +871,7 @@ DdeServerProc(
case XTYP_EXECUTE: {
/*
* Execute this script. The results will be saved into a list object
- * which will be retreived later. See ExecuteRemoteObject.
+ * which will be retrieved later. See ExecuteRemoteObject.
*/
Tcl_Obj *returnPackagePtr;
@@ -893,13 +894,13 @@ DdeServerProc(
/* Empty binary array. */
ddeObjectPtr = Tcl_NewObj();
} else if ((dlen & 1) || utilString[(dlen>>1)-1]) {
- /* Cannot be unicode, so assume utf-8 */
+ /* Cannot be Unicode, so assume utf-8 */
if (!string[dlen-1]) {
dlen--;
}
ddeObjectPtr = Tcl_NewStringObj(string, dlen);
} else {
- /* unicode */
+ /* Unicode */
Tcl_DString dsBuf;
Tcl_DStringInit(&dsBuf);
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index 422c70c..391c119 100644
--- a/win/tclWinFCmd.c
+++ b/win/tclWinFCmd.c
@@ -309,7 +309,8 @@ DoRenameFile(
if (srcAttr & FILE_ATTRIBUTE_DIRECTORY) {
WCHAR *nativeSrcRest, *nativeDstRest;
const char **srcArgv, **dstArgv;
- size_t size, srcArgc, dstArgc;
+ size_t size;
+ Tcl_Size srcArgc, dstArgc;
WCHAR nativeSrcPath[MAX_PATH];
WCHAR nativeDstPath[MAX_PATH];
Tcl_DString srcString, dstString;
@@ -879,7 +880,7 @@ DoCreateDirectory(
*
* Recursively copies a directory. The target directory dst must not
* already exist. Note that this function does not merge two directory
- * hierarchies, even if the target directory is an an empty directory.
+ * hierarchies, even if the target directory is an empty directory.
*
* Results:
* If the directory was successfully copied, returns TCL_OK. Otherwise
@@ -1595,9 +1596,8 @@ ConvertFileNameFormat(
int longShort, /* 0 to short name, 1 to long name. */
Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
- size_t pathc, i;
+ Tcl_Size pathc, i, length;
Tcl_Obj *splitPath;
- size_t length;
splitPath = Tcl_FSSplitPath(fileName, &pathc);
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index b16a707..0410356 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -1660,7 +1660,7 @@ NativeAccess(
}
/*
- * We cannnot verify the access fast, check it below using security
+ * We cannot verify the access fast, check it below using security
* info.
*/
}
@@ -1780,7 +1780,7 @@ NativeAccess(
RevertToSelf();
/*
- * Setup desiredAccess according to the access priveleges we are
+ * Setup desiredAccess according to the access privileges we are
* checking.
*/
@@ -2037,7 +2037,7 @@ NativeStat(
* 'getFileAttributesExProc', and if that isn't available, then on even
* simpler routines.
*
- * Special consideration must be given to Windows hardcoded names like
+ * Special consideration must be given to Windows hard-coded names like
* CON, NULL, COM1, LPT1 etc. For these, we still need to do the
* CreateFile as some may not exist (e.g. there is no CON in wish by
* default). However the subsequent GetFileInformationByHandle will
@@ -2328,7 +2328,7 @@ FromCTime(
* is either the given clientData, if the working directory hasn't
* changed, or a new clientData (owned by our caller), giving the new
* native path, or NULL if the current directory could not be determined.
- * If NULL is returned, the caller can examine the standard posix error
+ * If NULL is returned, the caller can examine the standard Posix error
* codes to determine the cause of the problem.
*
* Side effects:
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index cf74228..ec27837 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -124,7 +124,7 @@ TclpInitPlatform(void)
void
TclpInitLibraryPath(
char **valuePtr,
- size_t *lengthPtr,
+ TCL_HASH_TYPE *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 64
@@ -141,13 +141,13 @@ TclpInitLibraryPath(
* installed DLL.
*/
- sprintf(installLib, "lib/tcl%s", TCL_VERSION);
+ snprintf(installLib, sizeof(installLib), "lib/tcl%s", TCL_VERSION);
/*
* Look for the library relative to the TCL_LIBRARY env variable. If the
* last dirname in the TCL_LIBRARY path does not match the last dirname in
* the installLib variable, use the last dir name of installLib in
- * addition to the orginal TCL_LIBRARY path.
+ * addition to the original TCL_LIBRARY path.
*/
AppendEnvironment(pathPtr, installLib);
@@ -198,7 +198,7 @@ AppendEnvironment(
Tcl_Obj *pathPtr,
const char *lib)
{
- size_t pathc;
+ Tcl_Size pathc;
WCHAR wBuf[MAX_PATH];
char buf[MAX_PATH * 3];
Tcl_Obj *objPtr;
@@ -225,8 +225,8 @@ AppendEnvironment(
}
/*
- * The "L" preceeding the TCL_LIBRARY string is used to tell VC++ that
- * this is a unicode string.
+ * The "L" preceding the TCL_LIBRARY string is used to tell VC++ that
+ * this is a Unicode string.
*/
GetEnvironmentVariableW(L"TCL_LIBRARY", wBuf, MAX_PATH);
@@ -304,7 +304,7 @@ InitializeDefaultLibraryDir(
*end = '\\';
TclWinNoBackslash(name);
- sprintf(end + 1, "lib/tcl%s", TCL_VERSION);
+ snprintf(end + 1, LIBRARY_SIZE, "lib/tcl%s", TCL_VERSION);
*lengthPtr = strlen(name);
*valuePtr = (char *)Tcl_Alloc(*lengthPtr + 1);
*encodingPtr = NULL;
@@ -352,7 +352,7 @@ InitializeSourceLibraryDir(
*end = '\\';
TclWinNoBackslash(name);
- sprintf(end + 1, "../library");
+ snprintf(end + 1, LIBRARY_SIZE, "../library");
*lengthPtr = strlen(name);
*valuePtr = (char *)Tcl_Alloc(*lengthPtr + 1);
*encodingPtr = NULL;
@@ -404,7 +404,7 @@ Tcl_GetEncodingNameFromEnvironment(
Tcl_DStringAppend(bufPtr, "utf-8", 5);
} else {
Tcl_DStringSetLength(bufPtr, 2+TCL_INTEGER_SPACE);
- wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", GetACP());
+ snprintf(Tcl_DStringValue(bufPtr), 2+TCL_INTEGER_SPACE, "cp%d", GetACP());
Tcl_DStringSetLength(bufPtr, strlen(Tcl_DStringValue(bufPtr)));
}
return Tcl_DStringValue(bufPtr);
@@ -488,7 +488,7 @@ TclpSetVariables(
if (osInfo.dwMajorVersion == 10 && osInfo.dwBuildNumber >= 22000) {
osInfo.dwMajorVersion = 11;
}
- wsprintfA(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
+ snprintf(buffer, sizeof(buffer), "%ld.%ld", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
if (sys.oemId.wProcessorArchitecture < NUMPROCESSORS) {
Tcl_SetVar2(interp, "tcl_platform", "machine",
@@ -555,7 +555,7 @@ TclpSetVariables(
*
* Results:
* The return value is the index in environ of an entry with the name
- * "name", or TCL_INDEX_NONE if there is no such entry. The integer
+ * "name", or -1 if there is no such entry. The integer
* at *lengthPtr is filled in with the length of name (if a matching
* entry is found) or the length of the environ array (if no
* matching entry is found).
@@ -569,16 +569,16 @@ TclpSetVariables(
# define tenviron2utfdstr(string, len, dsPtr) \
(char *)Tcl_Char16ToUtfDString((const unsigned short *)(string), ((((len) + 2) >> 1) - 1), (dsPtr))
-size_t
+Tcl_Size
TclpFindVariable(
const char *name, /* Name of desired environment variable
* (UTF-8). */
- size_t *lengthPtr) /* Used to return length of name (for
+ Tcl_Size *lengthPtr) /* Used to return length of name (for
* successful searches) or number of non-NULL
* entries in environ (for unsuccessful
* searches). */
{
- size_t i, length, result = TCL_INDEX_NONE;
+ Tcl_Size i, length, result = -1;
const WCHAR *env;
const char *p1, *p2;
char *envUpper, *nameUpper;
@@ -604,7 +604,7 @@ TclpFindVariable(
*/
Tcl_DStringInit(&envString);
- envUpper = Tcl_WCharToUtfDString(env, TCL_INDEX_NONE, &envString);
+ envUpper = Tcl_WCharToUtfDString(env, -1, &envString);
p1 = strchr(envUpper, '=');
if (p1 == NULL) {
continue;
diff --git a/win/tclWinInt.h b/win/tclWinInt.h
index d3d6680..1267f3f 100644
--- a/win/tclWinInt.h
+++ b/win/tclWinInt.h
@@ -43,8 +43,6 @@ MODULE_SCOPE void TclWinInit(HINSTANCE hInst);
MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle);
MODULE_SCOPE Tcl_Channel TclWinOpenConsoleChannel(HANDLE handle,
char *channelName, int permissions);
-MODULE_SCOPE Tcl_Channel TclWinOpenFileChannel(HANDLE handle, char *channelName,
- int permissions, int appendMode);
MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle,
char *channelName, int permissions);
MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *name,
diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c
index bcb4e08..de4f8f2 100644
--- a/win/tclWinNotify.c
+++ b/win/tclWinNotify.c
@@ -14,7 +14,7 @@
#include "tclInt.h"
/*
- * The follwing static indicates whether this module has been initialized.
+ * The following static indicates whether this module has been initialized.
*/
#define INTERVAL_TIMER 1 /* Handle of interval timer. */
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 84e6ab0..da24306 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -923,12 +923,12 @@ TclpCreateProcess(
* receive no standard input. */
TclFile outputFile, /* If non-NULL, gives the file that receives
* output from the child process. If
- * outputFile file is not writeable or is
+ * outputFile file is not writable or is
* NULL, output from the child will be
* discarded. */
TclFile errorFile, /* If non-NULL, gives the file that receives
* errors from the child process. If errorFile
- * file is not writeable or is NULL, errors
+ * file is not writable or is NULL, errors
* from the child will be discarded. errorFile
* may be the same as outputFile. */
Tcl_Pid *pidPtr) /* If this function is successful, pidPtr is
@@ -1823,7 +1823,7 @@ TclpCreateCommandChannel(
* unique, in case channels share handles (stdin/stdout).
*/
- sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
+ snprintf(channelName, sizeof(channelName), "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
infoPtr->channel = Tcl_CreateChannel(&pipeChannelType, channelName,
infoPtr, infoPtr->validMask);
@@ -2705,7 +2705,7 @@ TclWinAddProcess(
void *hProcess, /* Handle to process */
size_t id) /* Global process identifier */
{
- ProcInfo *procPtr = (ProcInfo*)Tcl_Alloc(sizeof(ProcInfo));
+ ProcInfo *procPtr = (ProcInfo *)Tcl_Alloc(sizeof(ProcInfo));
PipeInit();
@@ -2805,7 +2805,7 @@ WaitForRead(
* or not. */
{
DWORD timeout, count;
- HANDLE *handle = (HANDLE *)((WinFile *) infoPtr->readFile)->handle;
+ HANDLE handle = ((WinFile *) infoPtr->readFile)->handle;
while (1) {
/*
@@ -3138,7 +3138,7 @@ PipeThreadActionProc(
/*
* We do not access firstPipePtr in the thread structures. This is not for
* all pipes managed by the thread, but only those we are watching.
- * Removal of the filevent handlers before transfer thus takes care of
+ * Removal of the fileevent handlers before transfer thus takes care of
* this structure.
*/
@@ -3227,7 +3227,7 @@ TclpOpenTemporaryFile(
do {
char number[TCL_INTEGER_SPACE + 4];
- sprintf(number, "%d.TMP", counter);
+ snprintf(number, sizeof(number), "%d.TMP", counter);
counter = (unsigned short) (counter + 1);
Tcl_DStringInit(&buf);
Tcl_UtfToWCharDString(number, strlen(number), &buf);
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index f9481be..3732550 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -782,7 +782,7 @@ GetValue(
* length to TCL_DSTRING_STATIC_SIZE, but this should be safer if the
* implementation of Dstrings changes.
*
- * This allows short values to be read from the registy in one call.
+ * This allows short values to be read from the registry in one call.
* Longer values need a second call with an expanded DString.
*/
@@ -876,7 +876,7 @@ GetValue(
*
* GetValueNames --
*
- * This function enumerates the values of the a given key. If the
+ * This function enumerates the values of the given key. If the
* optional pattern is supplied, then only value names that match the
* pattern will be returned.
*
@@ -1012,7 +1012,7 @@ OpenKey(
*
* OpenSubKey --
*
- * This function opens a given subkey of a root key on the specified
+ * Opens a given subkey of the given root key on the specified
* host.
*
* Results:
@@ -1097,7 +1097,7 @@ OpenSubKey(
*
* ParseKeyName --
*
- * This function parses a key name into the host, root, and subkey parts.
+ * Parses a key name into the host, root, and subkey parts.
*
* Results:
* The pointers to the start of the host and subkey names are returned in
@@ -1329,7 +1329,7 @@ SetValue(
(DWORD) type, (BYTE *) &value, sizeof(DWORD));
} else if (type == REG_MULTI_SZ) {
Tcl_DString data, buf;
- int objc, i;
+ Tcl_Size objc, i;
Tcl_Obj **objv;
if (Tcl_ListObjGetElements(interp, dataObj, &objc, &objv) != TCL_OK) {
@@ -1476,7 +1476,7 @@ BroadcastValue(
*
* AppendSystemError --
*
- * This routine formats a Windows system error message and places it into
+ * Formats a Windows system error message and places it into
* the interpreter result.
*
* Results:
@@ -1508,7 +1508,7 @@ AppendSystemError(
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) tMsgPtrPtr,
0, NULL);
if (length == 0) {
- sprintf(msgBuf, "unknown error: %ld", error);
+ snprintf(msgBuf, sizeof(msgBuf), "unknown error: %ld", error);
msg = msgBuf;
} else {
char *msgPtr;
@@ -1534,7 +1534,7 @@ AppendSystemError(
msg = msgPtr;
}
- sprintf(id, "%ld", error);
+ snprintf(id, sizeof(id), "%ld", error);
Tcl_SetErrorCode(interp, "WINDOWS", id, msg, NULL);
Tcl_AppendToObj(resultPtr, msg, length);
Tcl_SetObjResult(interp, resultPtr);
@@ -1549,7 +1549,7 @@ AppendSystemError(
*
* ConvertDWORD --
*
- * This function determines whether a DWORD needs to be byte swapped, and
+ * Determines whether a DWORD needs to be byte swapped, and
* returns the appropriately swapped value.
*
* Results:
diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c
index 78b47b9..821fb96 100644
--- a/win/tclWinSerial.c
+++ b/win/tclWinSerial.c
@@ -335,7 +335,7 @@ ProcExitHandler(
*
* SerialBlockTime --
*
- * Wrapper to set Tcl's block time in msec
+ * Wrapper to set Tcl's block time in msec.
*
* Results:
* None.
@@ -904,7 +904,7 @@ SerialInputProc(
}
} else {
/*
- * BLOCKING mode: Tcl trys to read a full buffer of 4 kBytes here.
+ * BLOCKING mode: Tcl tries to read a full buffer of 4 kBytes here.
*/
if (cStat.cbInQue > 0) {
@@ -973,9 +973,9 @@ SerialOutputProc(
*errorCode = 0;
/*
- * At EXIT Tcl trys to flush all open channels in blocking mode. We avoid
+ * At EXIT Tcl tries to flush all open channels in blocking mode. We avoid
* blocking output after ExitProc or CloseHandler(chan) has been called by
- * checking the corrresponding variables.
+ * checking the corresponding variables.
*/
if (!initialized || TclInExit()) {
@@ -1458,7 +1458,7 @@ TclWinOpenSerialChannel(
infoPtr = (SerialInfo *)Tcl_Alloc(sizeof(SerialInfo));
memset(infoPtr, 0, sizeof(SerialInfo));
- infoPtr->validMask = permissions;
+ infoPtr->validMask = permissions & (TCL_READABLE|TCL_WRITABLE);
infoPtr->handle = handle;
infoPtr->channel = (Tcl_Channel) NULL;
infoPtr->readable = 0;
@@ -1476,7 +1476,7 @@ TclWinOpenSerialChannel(
* are shared between multiple channels (stdin/stdout).
*/
- sprintf(channelName, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
+ snprintf(channelName, 16 + TCL_INTEGER_SPACE, "file%" TCL_Z_MODIFIER "x", (size_t) infoPtr);
infoPtr->channel = Tcl_CreateChannel(&serialChannelType, channelName,
infoPtr, permissions);
@@ -1558,7 +1558,7 @@ SerialErrorStr(
if (error & ~((DWORD) (SERIAL_READ_ERRORS | SERIAL_WRITE_ERRORS))) {
char buf[TCL_INTEGER_SPACE + 1];
- wsprintfA(buf, "%d", error);
+ snprintf(buf, sizeof(buf), "%ld", error);
Tcl_DStringAppendElement(dsPtr, buf);
}
}
@@ -1624,7 +1624,7 @@ SerialSetOptionProc(
size_t len, vlen;
Tcl_DString ds;
const WCHAR *native;
- size_t argc;
+ Tcl_Size argc;
const char **argv;
infoPtr = (SerialInfo *) instanceData;
@@ -1820,7 +1820,7 @@ SerialSetOptionProc(
*/
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
- size_t i;
+ Tcl_Size i;
int res = TCL_OK;
if (Tcl_SplitList(interp, value, &argc, &argv) == TCL_ERROR) {
@@ -2105,7 +2105,7 @@ SerialGetOptionProc(
stop = (dcb.StopBits == ONESTOPBIT) ? "1" :
(dcb.StopBits == ONE5STOPBITS) ? "1.5" : "2";
- wsprintfA(buf, "%d,%c,%d,%s", dcb.BaudRate, parity,
+ snprintf(buf, sizeof(buf), "%ld,%c,%d,%s", dcb.BaudRate, parity,
dcb.ByteSize, stop);
Tcl_DStringAppendElement(dsPtr, buf);
}
@@ -2121,7 +2121,7 @@ SerialGetOptionProc(
char buf[TCL_INTEGER_SPACE + 1];
valid = 1;
- wsprintfA(buf, "%d", infoPtr->blockTime);
+ snprintf(buf, sizeof(buf), "%d", infoPtr->blockTime);
Tcl_DStringAppendElement(dsPtr, buf);
}
@@ -2137,9 +2137,9 @@ SerialGetOptionProc(
char buf[TCL_INTEGER_SPACE + 1];
valid = 1;
- wsprintfA(buf, "%d", infoPtr->sysBufRead);
+ snprintf(buf, sizeof(buf), "%ld", infoPtr->sysBufRead);
Tcl_DStringAppendElement(dsPtr, buf);
- wsprintfA(buf, "%d", infoPtr->sysBufWrite);
+ snprintf(buf, sizeof(buf), "%ld", infoPtr->sysBufWrite);
Tcl_DStringAppendElement(dsPtr, buf);
}
if (len == 0) {
@@ -2220,9 +2220,9 @@ SerialGetOptionProc(
count = (int) cStat.cbOutQue + infoPtr->writeQueue;
LeaveCriticalSection(&infoPtr->csWrite);
- wsprintfA(buf, "%d", inBuffered + cStat.cbInQue);
+ snprintf(buf, sizeof(buf), "%ld", inBuffered + cStat.cbInQue);
Tcl_DStringAppendElement(dsPtr, buf);
- wsprintfA(buf, "%d", outBuffered + count);
+ snprintf(buf, sizeof(buf), "%d", outBuffered + count);
Tcl_DStringAppendElement(dsPtr, buf);
}
@@ -2282,7 +2282,7 @@ SerialThreadActionProc(
/*
* We do not access firstSerialPtr in the thread structures. This is not
* for all serials managed by the thread, but only those we are watching.
- * Removal of the filevent handlers before transfer thus takes care of
+ * Removal of the fileevent handlers before transfer thus takes care of
* this structure.
*/
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 4eeeeec..8de4b50 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -105,7 +105,7 @@ typedef union {
#endif
/*
- * This structure describes per-instance state of a tcp based channel.
+ * This structure describes per-instance state of a tcp-based channel.
*/
typedef struct TcpState TcpState;
@@ -161,7 +161,7 @@ struct TcpState {
};
/*
- * These bits may be ORed together into the "flags" field of a TcpState
+ * These bits may be OR'ed together into the "flags" field of a TcpState
* structure.
*/
@@ -549,8 +549,8 @@ TcpBlockModeProc(
* May return two error codes:
* * EWOULDBLOCK: if connect is still in progress
* * ENOTCONN: if connect failed. This would be the error message
- * of a rect or sendto syscall so this is emulated here.
- * * Null: Called by a backround operation. Do not block and don't
+ * of a recv or sendto syscall so this is emulated here.
+ * * Null: Called by a background operation. Do not block and don't
* return any error code.
*
* Results:
@@ -638,7 +638,7 @@ WaitForConnect(
/*
* For blocking sockets and foreground processing, disable async
- * connect as we continue now synchoneously.
+ * connect as we continue now synchronously.
*/
if (errorCodePtr != NULL &&
@@ -653,7 +653,7 @@ WaitForConnect(
SetEvent(tsdPtr->socketListLock);
/*
- * Continue connect. If switched to synchroneous connect, the
+ * Continue connect. If switched to synchronous connect, the
* connect is terminated.
*/
@@ -666,7 +666,7 @@ WaitForConnect(
(void) Tcl_SetServiceMode(oldMode);
/*
- * Check for Succesfull connect or async connect restart
+ * Check for Successful connect or async connect restart
*/
if (result == TCL_OK) {
@@ -826,7 +826,7 @@ TcpInputProc(
/*
* If an RST comes, then ignore the error and report an EOF just like
- * on unix.
+ * on Unix.
*/
if (error == WSAECONNRESET) {
@@ -1223,7 +1223,7 @@ TcpGetOptionProc(
/*
* Go one step in async connect
*
- * If any error is thrown save it as backround error to report eventually
+ * If any error is thrown save it as background error to report eventually
* below.
*/
@@ -1770,7 +1770,7 @@ TcpConnect(
if (async_connect && error == WSAEWOULDBLOCK) {
/*
- * Asynchroneous connect
+ * Asynchronous connect
*
* Remember that we jump back behind this next round
*/
@@ -1839,7 +1839,7 @@ TcpConnect(
if (Tcl_GetErrno() == 0) {
/*
- * Succesfully connected
+ * Successfully connected
*
* Set up the select mask for read/write events.
*/
@@ -1898,7 +1898,7 @@ TcpConnect(
}
/*
- * Error message on synchroneous connect
+ * Error message on synchronous connect
*/
if (interp != NULL) {
@@ -1977,7 +1977,7 @@ Tcl_OpenTcpClient(
return NULL;
}
- sprintf(channelName, SOCK_TEMPLATE, statePtr);
+ snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, (TCL_READABLE | TCL_WRITABLE));
@@ -2036,7 +2036,7 @@ Tcl_MakeTcpClientChannel(
statePtr->selectEvents = FD_READ | FD_CLOSE | FD_WRITE;
SendSelectMessage(tsdPtr, SELECT, statePtr);
- sprintf(channelName, SOCK_TEMPLATE, statePtr);
+ snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, (TCL_READABLE | TCL_WRITABLE));
Tcl_SetChannelOption(NULL, statePtr->channel, "-translation", "auto crlf");
@@ -2208,7 +2208,7 @@ Tcl_OpenTcpServerEx(
statePtr->acceptProc = acceptProc;
statePtr->acceptProcData = acceptProcData;
- sprintf(channelName, SOCK_TEMPLATE, statePtr);
+ snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, statePtr);
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
statePtr, 0);
/*
@@ -2293,7 +2293,7 @@ TcpAccept(
newInfoPtr->selectEvents = (FD_READ | FD_WRITE | FD_CLOSE);
SendSelectMessage(tsdPtr, SELECT, newInfoPtr);
- sprintf(channelName, SOCK_TEMPLATE, newInfoPtr);
+ snprintf(channelName, sizeof(channelName), SOCK_TEMPLATE, newInfoPtr);
newInfoPtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
newInfoPtr, (TCL_READABLE | TCL_WRITABLE));
if (Tcl_SetChannelOption(NULL, newInfoPtr->channel, "-translation",
@@ -2933,7 +2933,7 @@ WaitForSocketEvent(
WaitForSingleObject(tsdPtr->socketListLock, INFINITE);
/*
- * Check if event occured.
+ * Check if event occurred.
*/
event_found = GOT_BITS(statePtr->readyEvents, events);
@@ -2945,7 +2945,7 @@ WaitForSocketEvent(
SetEvent(tsdPtr->socketListLock);
/*
- * Exit loop if event occured.
+ * Exit loop if event occurred.
*/
if (event_found) {
@@ -3050,7 +3050,7 @@ SocketThread(
*
* Side effects:
* The flags for the given socket are updated to reflect the event that
- * occured.
+ * occurred.
*
*----------------------------------------------------------------------
*/
@@ -3200,7 +3200,7 @@ SocketProc(
*
* FindFDInList --
*
- * Return true, if the given file descriptior is contained in the
+ * Return true, if the given file descriptor is contained in the
* file descriptor list.
*
* Results:
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index 0195895..ecc592b 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -777,9 +777,9 @@ Tcl_ConditionWait(
timeout = 0;
} else {
/*
- * When dequeuing, we can leave the tsdPtr->nextPtr and
+ * When dequeueing, we can leave the tsdPtr->nextPtr and
* tsdPtr->prevPtr with dangling pointers because they are
- * reinitialilzed w/out reading them when the thread is enqueued
+ * reinitialized w/out reading them when the thread is enqueued
* later.
*/
diff --git a/win/tclWinTime.c b/win/tclWinTime.c
index 1855c20..a8d4c3f 100644
--- a/win/tclWinTime.c
+++ b/win/tclWinTime.c
@@ -622,7 +622,7 @@ NativeGetMicroseconds(void)
if (curCounter.QuadPart <= perfCounterLastCall) {
/*
- * Calibrated file-time is saved from posix in 100-ns ticks
+ * Calibrated file-time is saved from Posix in 100-ns ticks
*/
return fileTimeLastCall / 10;
@@ -641,7 +641,7 @@ NativeGetMicroseconds(void)
if (curCounter.QuadPart - perfCounterLastCall <
11 * curCounterFreq * timeInfo.calibrationInterv / 10) {
/*
- * Calibrated file-time is saved from posix in 100-ns ticks.
+ * Calibrated file-time is saved from Posix in 100-ns ticks.
*/
return NativeCalc100NsTicks(fileTimeLastCall,
@@ -782,7 +782,7 @@ CalibrationThread(
timeInfo.fileTimeLastCall.HighPart = curFileTime.dwHighDateTime;
/*
- * Calibrated file-time will be saved from posix in 100-ns ticks.
+ * Calibrated file-time will be saved from Posix in 100-ns ticks.
*/
timeInfo.fileTimeLastCall.QuadPart -= timeInfo.posixEpoch.QuadPart;
@@ -857,7 +857,7 @@ UpdateTimeEachSecond(void)
* step over 1 second. */
/*
- * Sample performance counter and system time (from posix epoch).
+ * Sample performance counter and system time (from Posix epoch).
*/
GetSystemTimeAsFileTime(&curSysTime);
@@ -882,7 +882,7 @@ UpdateTimeEachSecond(void)
lastFileTime.QuadPart = curFileTime.QuadPart;
/*
- * We devide by timeInfo.curCounterFreq.QuadPart in several places. That
+ * We divide by timeInfo.curCounterFreq.QuadPart in several places. That
* value should always be positive on a correctly functioning system. But
* it is good to be defensive about such matters. So if something goes
* wrong and the value does goes to zero, we clear the