summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2006-09-26 21:40:35 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2006-09-26 21:40:35 (GMT)
commitce214ead30c417294e6701b0b07d0b6cc8f455c2 (patch)
tree31f99b53eebeaa5a255e51509f28407c43ff23f8 /win
parentc211c9903b52974bb4397841b10bcdefeb0329c1 (diff)
downloadtcl-ce214ead30c417294e6701b0b07d0b6cc8f455c2.zip
tcl-ce214ead30c417294e6701b0b07d0b6cc8f455c2.tar.gz
tcl-ce214ead30c417294e6701b0b07d0b6cc8f455c2.tar.bz2
* win/makefile.vc: Updated MSVC build to properly deal with
* win/nmakehlp.c: MSVC8 and AMD64 target. Backport from 8.5 * win/rules.vc: * generic/tcl.h: Fixed stat definition for MSVC8 AMD64. * win/tclWinSock.c: Casting type police. * win/tclWinTime.c:
Diffstat (limited to 'win')
-rw-r--r--win/makefile.vc30
-rw-r--r--win/nmakehlp.c347
-rw-r--r--win/rules.vc78
-rw-r--r--win/tclWinSock.c4
-rw-r--r--win/tclWinTime.c6
5 files changed, 341 insertions, 124 deletions
diff --git a/win/makefile.vc b/win/makefile.vc
index 417b13f..e3625b9 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -12,7 +12,7 @@
# Copyright (c) 2001-2002 David Gravereaux.
#
#------------------------------------------------------------------------------
-# RCS: @(#) $Id: makefile.vc,v 1.100.2.8 2006/06/14 15:21:14 patthoyts Exp $
+# RCS: @(#) $Id: makefile.vc,v 1.100.2.9 2006/09/26 21:40:36 patthoyts Exp $
#------------------------------------------------------------------------------
# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
@@ -338,6 +338,12 @@ cdebug = -Z7 -WX $(DEBUGFLAGS)
cwarn = -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\
+!if $(FULLWARNINGS)
+cflags = $(cflags) -W4
+!else
+cflags = $(cflags) -W3
+!endif
+
!if $(MSVCRT)
!if "$(DBGX)" == ""
crt = -MD
@@ -353,10 +359,10 @@ crt = -MTd
!endif
TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
-BASE_CLFAGS = $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) \
+BASE_CFLAGS = $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) \
-DTCL_PIPE_DLL=\"$(TCLPIPEDLLNAME)\"
CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE
-TCL_CFLAGS = $(BASE_CLFAGS) $(OPTDEFINES)
+TCL_CFLAGS = $(BASE_CFLAGS) $(OPTDEFINES)
#---------------------------------------------------------------------
@@ -370,7 +376,11 @@ ldebug = -release -opt:ref -opt:icf,3
!endif
### Declarations common to all linker options
-lflags = -nologo -machine:$(MACHINE) $(ldebug)
+lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
+
+!if $(FULLWARNINGS)
+lflags = $(lflags) -warn:3
+!endif
!if $(PROFILE)
lflags = $(lflags) -profile
@@ -392,7 +402,7 @@ dlllflags = $(lflags) -dll
conlflags = $(lflags) -subsystem:console
guilflags = $(lflags) -subsystem:windows
-baselibs = kernel32.lib advapi32.lib user32.lib
+baselibs = kernel32.lib advapi32.lib user32.lib
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
@@ -628,23 +638,23 @@ $(TMP_DIR)\tclAppInit.obj: $(WINDIR)\tclAppInit.c
$(TMP_DIR)\tclWinReg.obj: $(WINDIR)\tclWinReg.c
!if $(STATIC_BUILD)
- $(cc32) $(BASE_CLFAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $?
+ $(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $?
!else
- $(cc32) $(BASE_CLFAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $?
+ $(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $?
!endif
$(TMP_DIR)\tclWinDde.obj: $(WINDIR)\tclWinDde.c
!if $(STATIC_BUILD)
- $(cc32) $(BASE_CLFAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $?
+ $(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $?
!else
- $(cc32) $(BASE_CLFAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $?
+ $(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $?
!endif
### The following objects are part of the stub library and should not
### be built as DLL objects. -Zl is used to avoid a dependancy on any
-### specific c-runtime.
+### specific C run-time.
$(TMP_DIR)\tclStubLib.obj: $(GENERICDIR)\tclStubLib.c
$(cc32) $(cdebug) $(cflags) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $?
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 48b82c4..9d5df8e 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -1,4 +1,5 @@
-/* ----------------------------------------------------------------------------
+/*
+ * ----------------------------------------------------------------------------
* nmakehlp.c --
*
* This is used to fix limitations within nmake and the environment.
@@ -9,35 +10,51 @@
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* ----------------------------------------------------------------------------
- * RCS: @(#) $Id: nmakehlp.c,v 1.1.4.1 2006/06/14 15:21:15 patthoyts Exp $
+ * RCS: @(#) $Id: nmakehlp.c,v 1.1.4.2 2006/09/26 21:40:37 patthoyts Exp $
* ----------------------------------------------------------------------------
*/
#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
+#include <shlwapi.h>
#pragma comment (lib, "user32.lib")
#pragma comment (lib, "kernel32.lib")
+#pragma comment (lib, "shlwapi.lib")
+#include <stdio.h>
+#include <math.h>
+#if defined(_M_IA64) || defined(_M_AMD64)
+#pragma comment(lib, "bufferoverflowU")
+#endif
+
/* protos */
-int CheckForCompilerFeature (const char *option);
-int CheckForLinkerFeature (const char *option);
-int IsIn (const char *string, const char *substring);
-DWORD WINAPI ReadFromPipe (LPVOID args);
+
+int CheckForCompilerFeature(const char *option);
+int CheckForLinkerFeature(const char *option);
+int IsIn(const char *string, const char *substring);
+int GrepForDefine(const char *file, const char *string);
+DWORD WINAPI ReadFromPipe(LPVOID args);
/* globals */
+
+#define CHUNK 25
+#define STATICBUFFERSIZE 1000
typedef struct {
HANDLE pipe;
- char buffer[1000];
+ char buffer[STATICBUFFERSIZE];
} pipeinfo;
pipeinfo Out = {INVALID_HANDLE_VALUE, '\0'};
pipeinfo Err = {INVALID_HANDLE_VALUE, '\0'};
+
+/*
+ * exitcodes: 0 == no, 1 == yes, 2 == error
+ */
-
-
-/* exitcodes: 0 == no, 1 == yes, 2 == error */
int
-main (int argc, char *argv[])
+main(
+ int argc,
+ char *argv[])
{
char msg[300];
DWORD dwWritten;
@@ -50,7 +67,7 @@ main (int argc, char *argv[])
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
/*
- * Make sure the compiler and linker aren't affected by the outside world.
+ * Make sure the compiler and linker aren't effected by the outside world.
*/
SetEnvironmentVariable("CL", "");
@@ -60,56 +77,79 @@ main (int argc, char *argv[])
switch (*(argv[1]+1)) {
case 'c':
if (argc != 3) {
- chars = wsprintf(msg, "usage: %s -c <compiler option>\n"
+ chars = wnsprintf(msg, sizeof(msg)-1,
+ "usage: %s -c <compiler option>\n"
"Tests for whether cl.exe supports an option\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
+ &dwWritten, NULL);
return 2;
}
return CheckForCompilerFeature(argv[2]);
case 'l':
if (argc != 3) {
- chars = wsprintf(msg, "usage: %s -l <linker option>\n"
+ chars = wnsprintf(msg, sizeof(msg) - 1,
+ "usage: %s -l <linker option>\n"
"Tests for whether link.exe supports an option\n"
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
+ &dwWritten, NULL);
return 2;
}
return CheckForLinkerFeature(argv[2]);
case 'f':
if (argc == 2) {
- chars = wsprintf(msg, "usage: %s -f <string> <substring>\n"
- "Find a substring within another\n"
- "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
+ chars = wnsprintf(msg, sizeof(msg) - 1,
+ "usage: %s -f <string> <substring>\n"
+ "Find a substring within another\n"
+ "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
+ &dwWritten, NULL);
return 2;
} else if (argc == 3) {
- /* if the string is blank, there is no match */
+ /*
+ * If the string is blank, there is no match.
+ */
+
return 0;
} else {
return IsIn(argv[2], argv[3]);
}
+ case 'g':
+ if (argc == 2) {
+ chars = wnsprintf(msg, sizeof(msg) - 1,
+ "usage: %s -g <file> <string>\n"
+ "grep for a #define\n"
+ "exitcodes: integer of the found string (no decimals)\n",
+ argv[0]);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
+ &dwWritten, NULL);
+ return 2;
+ }
+ return GrepForDefine(argv[2], argv[3]);
}
}
- chars = wsprintf(msg, "usage: %s -c|-l|-f ...\n"
+ chars = wnsprintf(msg, sizeof(msg) - 1,
+ "usage: %s -c|-l|-f ...\n"
"This is a little helper app to equalize shell differences between WinNT and\n"
"Win9x and get nmake.exe to accomplish its job.\n",
argv[0]);
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
return 2;
}
-
+
int
-CheckForCompilerFeature (const char *option)
+CheckForCompilerFeature(
+ const char *option)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES sa;
- DWORD threadID, n;
+ DWORD threadID;
char msg[300];
BOOL ok;
HANDLE hProcess, h, pipeThreads[2];
- char cmdline[256];
+ char cmdline[100];
hProcess = GetCurrentProcess();
@@ -124,29 +164,44 @@ CheckForCompilerFeature (const char *option)
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = FALSE;
- /* create a non-inheritible pipe. */
+ /*
+ * Create a non-inheritible pipe.
+ */
+
CreatePipe(&Out.pipe, &h, &sa, 0);
- /* dupe the write side, make it inheritible, and close the original. */
- DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput,
- 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+ /*
+ * Dupe the write side, make it inheritible, and close the original.
+ */
+
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+
+ /*
+ * Same as above, but for the error side.
+ */
- /* Same as above, but for the error side. */
CreatePipe(&Err.pipe, &h, &sa, 0);
- DuplicateHandle(hProcess, h, hProcess, &si.hStdError,
- 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE,
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
- /* base command line */
- n = GetEnvironmentVariable("CC", cmdline, 255);
- cmdline[n] = 0;
- if (n == 0)
- strcpy(cmdline, "cl.exe");
- strncat(cmdline, " -nologo -c -TC -Zs -X ", 255);
+ /*
+ * Base command line.
+ */
- /* append our option for testing */
- strcat(cmdline, option);
- /* filename to compile, which exists, but is nothing and empty. */
- strcat(cmdline, " .\\nul");
+ lstrcpy(cmdline, "cl.exe -nologo -c -TC -Zs -X ");
+
+ /*
+ * Append our option for testing
+ */
+
+ lstrcat(cmdline, option);
+
+ /*
+ * Filename to compile, which exists, but is nothing and empty.
+ */
+
+ lstrcat(cmdline, " .\\nul");
ok = CreateProcess(
NULL, /* Module name. */
@@ -162,65 +217,62 @@ CheckForCompilerFeature (const char *option)
if (!ok) {
DWORD err = GetLastError();
- int chars = wsprintf(msg, "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
+ int chars = wsprintf(msg,
+ "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
- FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID) &msg[chars],
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
(300-chars), 0);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, strlen(msg), &err, NULL);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
return 2;
}
- /* close our references to the write handles that have now been inherited. */
+ /*
+ * Close our references to the write handles that have now been inherited.
+ */
+
CloseHandle(si.hStdOutput);
CloseHandle(si.hStdError);
WaitForInputIdle(pi.hProcess, 5000);
CloseHandle(pi.hThread);
- /* start the pipe reader threads. */
+ /*
+ * Start the pipe reader threads.
+ */
+
pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
- /* block waiting for the process to end. */
+ /*
+ * Block waiting for the process to end.
+ */
+
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
- /* clean up temporary files before returning */
- DeleteFile("temp.idb");
- DeleteFile("temp.pdb");
+ /*
+ * Wait for our pipe to get done reading, should it be a little slow.
+ */
- /* wait for our pipe to get done reading, should it be a little slow. */
WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
CloseHandle(pipeThreads[0]);
CloseHandle(pipeThreads[1]);
-#ifdef _DEBUG
- {
- DWORD err = 0;
- strcat(cmdline, "\n");
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), cmdline,
- strlen(cmdline), &err, NULL);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), Out.buffer,
- strlen(Out.buffer), &err,NULL);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), Err.buffer,
- strlen(Err.buffer), &err,NULL);
- }
-#endif
-
/*
* Look for the commandline warning code in both streams.
* - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002.
*/
-
+
return !(strstr(Out.buffer, "D4002") != NULL
|| strstr(Err.buffer, "D4002") != NULL
|| strstr(Out.buffer, "D9002") != NULL
|| strstr(Err.buffer, "D9002") != NULL);
}
-
+
int
-CheckForLinkerFeature (const char *option)
+CheckForLinkerFeature(
+ const char *option)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
@@ -244,24 +296,38 @@ CheckForLinkerFeature (const char *option)
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
- /* create a non-inheritible pipe. */
+ /*
+ * Create a non-inheritible pipe.
+ */
+
CreatePipe(&Out.pipe, &h, &sa, 0);
- /* dupe the write side, make it inheritible, and close the original. */
- DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput,
- 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+ /*
+ * Dupe the write side, make it inheritible, and close the original.
+ */
+
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+
+ /*
+ * Same as above, but for the error side.
+ */
- /* Same as above, but for the error side. */
CreatePipe(&Err.pipe, &h, &sa, 0);
- DuplicateHandle(hProcess, h, hProcess, &si.hStdError,
- 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE,
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+
+ /*
+ * Base command line.
+ */
+
+ lstrcpy(cmdline, "link.exe -nologo ");
+
+ /*
+ * Append our option for testing.
+ */
- /* base command line */
- strcpy(cmdline, "link.exe -nologo ");
- /* append our option for testing */
- strcat(cmdline, option);
- /* filename to compile, which exists, but is nothing and empty. */
-// strcat(cmdline, " nul");
+ lstrcat(cmdline, option);
ok = CreateProcess(
NULL, /* Module name. */
@@ -277,49 +343,73 @@ CheckForLinkerFeature (const char *option)
if (!ok) {
DWORD err = GetLastError();
- int chars = wsprintf(msg, "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
+ int chars = wnsprintf(msg, sizeof(msg) - 1,
+ "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
- FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID) &msg[chars],
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
(300-chars), 0);
- WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, strlen(msg), &err, NULL);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
return 2;
}
- /* close our references to the write handles that have now been inherited. */
+ /*
+ * Close our references to the write handles that have now been inherited.
+ */
+
CloseHandle(si.hStdOutput);
CloseHandle(si.hStdError);
WaitForInputIdle(pi.hProcess, 5000);
CloseHandle(pi.hThread);
- /* start the pipe reader threads. */
+ /*
+ * Start the pipe reader threads.
+ */
+
pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
- /* block waiting for the process to end. */
+ /*
+ * Block waiting for the process to end.
+ */
+
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
- /* wait for our pipe to get done reading, should it be a little slow. */
+ /*
+ * Wait for our pipe to get done reading, should it be a little slow.
+ */
+
WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
CloseHandle(pipeThreads[0]);
CloseHandle(pipeThreads[1]);
- /* look for the commandline warning code in the stderr stream. */
- return !(strstr(Out.buffer, "LNK1117") != NULL || strstr(Err.buffer, "LNK1117") != NULL);
-}
+ /*
+ * Look for the commandline warning code in the stderr stream.
+ */
+ return !(strstr(Out.buffer, "LNK1117") != NULL ||
+ strstr(Err.buffer, "LNK1117") != NULL ||
+ strstr(Out.buffer, "LNK4044") != NULL ||
+ strstr(Err.buffer, "LNK4044") != NULL);
+}
+
DWORD WINAPI
-ReadFromPipe (LPVOID args)
+ReadFromPipe(
+ LPVOID args)
{
pipeinfo *pi = (pipeinfo *) args;
char *lastBuf = pi->buffer;
DWORD dwRead;
BOOL ok;
-again:
- ok = ReadFile(pi->pipe, lastBuf, 25, &dwRead, 0L);
+ again:
+ if (lastBuf - pi->buffer + CHUNK > STATICBUFFERSIZE) {
+ CloseHandle(pi->pipe);
+ return -1;
+ }
+ ok = ReadFile(pi->pipe, lastBuf, CHUNK, &dwRead, 0L);
if (!ok || dwRead == 0) {
CloseHandle(pi->pipe);
return 0;
@@ -329,9 +419,68 @@ again:
return 0; /* makes the compiler happy */
}
-
+
int
-IsIn (const char *string, const char *substring)
+IsIn(
+ const char *string,
+ const char *substring)
{
return (strstr(string, substring) != NULL);
}
+
+/*
+ * Find a specified #define by name.
+ *
+ * If the line is '#define TCL_VERSION "8.5"', it returns 85 as the result.
+ */
+
+int
+GrepForDefine(
+ const char *file,
+ const char *string)
+{
+ FILE *f;
+ char s1[51], s2[51], s3[51];
+ int r = 0;
+ double d1;
+
+ f = fopen(file, "rt");
+ if (f == NULL) {
+ return 0;
+ }
+
+ do {
+ r = fscanf(f, "%50s", s1);
+ if (r == 1 && !strcmp(s1, "#define")) {
+ /*
+ * Get next two words.
+ */
+
+ r = fscanf(f, "%50s %50s", s2, s3);
+ if (r != 2) {
+ continue;
+ }
+
+ /*
+ * Is the first word what we're looking for?
+ */
+
+ if (!strcmp(s2, string)) {
+ fclose(f);
+
+ /*
+ * Add 1 past first double quote char. "8.5"
+ */
+
+ d1 = atof(s3 + 1); /* 8.5 */
+ while (floor(d1) != d1) {
+ d1 *= 10.0;
+ }
+ return ((int) d1); /* 85 */
+ }
+ }
+ } while (!feof(f));
+
+ fclose(f);
+ return 0;
+}
diff --git a/win/rules.vc b/win/rules.vc
index 9b7a6c4..1210997 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -7,11 +7,11 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# Copyright (c) 2001-2002 David Gravereaux.
-# Copyright (c) 2003 Patrick Thoyts
+# Copyright (c) 2001-2003 David Gravereaux.
+# Copyright (c) 2003-2006 Patrick Thoyts
#
#------------------------------------------------------------------------------
-# RCS: @(#) $Id: rules.vc,v 1.11.2.2 2006/06/14 15:24:19 patthoyts Exp $
+# RCS: @(#) $Id: rules.vc,v 1.11.2.3 2006/09/26 21:40:37 patthoyts Exp $
#------------------------------------------------------------------------------
!ifndef _RULES_VC
@@ -34,6 +34,9 @@ _INSTALLDIR = $(INSTALLDIR:/=\)
MACHINE = IX86
!endif
+!ifndef CFG_ENCODING
+CFG_ENCODING = \"cp1252\"
+!endif
#----------------------------------------------------------
# Set the proper copy method to avoid overwrite questions
@@ -46,13 +49,14 @@ RMDIR = rmdir /S /Q
!if ![ver | find "4.0" > nul]
CPY = echo y | xcopy /i
!else
-CPY = xcopy /i /y
+CPY = xcopy /i /y >NUL
!endif
!else
CPY = xcopy /i
RMDIR = deltree /Y
!endif
-
+MKDIR = mkdir
+COPY = copy /y >NUL
!message ===============================================================================
@@ -105,6 +109,10 @@ OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs
OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
!endif
+!if [nmakehlp -c -GL]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -GL
+!endif
+
DEBUGFLAGS =
!if [nmakehlp -c -RTC1]
@@ -113,6 +121,10 @@ DEBUGFLAGS = $(DEBUGFLAGS) -RTC1
DEBUGFLAGS = $(DEBUGFLAGS) -GZ
!endif
+!if [nmakehlp -c -RTCc]
+DEBUGFLAGS = $(DEBUGFLAGS) -RTCc
+!endif
+
COMPILERFLAGS =-W3
!if [nmakehlp -c -YX]
@@ -152,6 +164,12 @@ ALIGN98_HACK = 0
ALIGN98_HACK = 0
!endif
+LINKERFLAGS =
+
+!if [nmakehlp -l -ltcg]
+LINKERFLAGS =-ltcg
+!endif
+
#----------------------------------------------------------
# MSVC8 (ships with Visual Studio 2005) generates a manifest
# file that we should link into the binaries. This is how.
@@ -257,6 +275,16 @@ TCL_USE_STATIC_PACKAGES = 0
# by accident.
#----------------------------------------------------------
+#----------------------------------------
+# Naming convention:
+# t = full thread support.
+# s = static library (as opposed to an
+# import library)
+# g = linked to the debug enabled C
+# run-time.
+# x = special static build when it
+# links to the dynamic C run-time.
+#----------------------------------------
SUFX = tsgx
!if $(DEBUG)
@@ -268,9 +296,12 @@ DBGX =
SUFX = $(SUFX:g=)
!endif
-#!if $(VCVER) > 6
-#BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
-#!endif
+!if "$(MACHINE)" != "IX86"
+BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE)
+!endif
+!if $(VCVER) > 6
+BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
+!endif
TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
@@ -330,6 +361,28 @@ TCL_COMPILE_DEBUG = 0
!endif
!endif
+#----------------------------------------------------------
+# Decode the checks requested.
+#----------------------------------------------------------
+
+!if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"]
+TCL_NO_DEPRECATED = 0
+FULLWARNINGS = 0
+!else
+!if [nmakehlp -f $(CHECKS) "nodep"]
+!message *** Doing nodep check
+TCL_NO_DEPRECATED = 1
+!else
+TCL_NO_DEPRECATED = 0
+!endif
+!if [nmakehlp -f $(CHECKS) "fullwarn"]
+!message *** Doing full warnings check
+FULLWARNINGS = 1
+!else
+FULLWARNINGS = 0
+!endif
+!endif
+
#----------------------------------------------------------
# Set our defines now armed with our options.
@@ -337,7 +390,7 @@ TCL_COMPILE_DEBUG = 0
OPTDEFINES =
!if $(TCL_MEM_DEBUG)
-OPTDEFINES = -DTCL_MEM_DEBUG
+OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG
!endif
!if $(TCL_COMPILE_DEBUG)
OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
@@ -373,6 +426,7 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
!if !defined(TCLDIR)
!if exist("$(_INSTALLDIR)\include\tcl.h")
+TCLH = "$(_INSTALLDIR)\include\tcl.h"
TCLINSTALL = 1
_TCLDIR = $(_INSTALLDIR)
!else
@@ -383,8 +437,10 @@ Failed to find tcl.h. Set the TCLDIR macro.
!else
_TCLDIR = $(TCLDIR:/=\)
!if exist("$(_TCLDIR)\include\tcl.h")
+TCLH = "$(_TCLDIR)\include\tcl.h"
TCLINSTALL = 1
!elseif exist("$(_TCLDIR)\generic\tcl.h")
+TCLH = "$(_TCLDIR)\generic\tcl.h"
TCLINSTALL = 0
!else
MSG =^
@@ -437,6 +493,8 @@ TCLTOOLSDIR = $(_TCLDIR)\tools
!message *** Output directory will be '$(OUT_DIR)'
!message *** Suffix for binaries will be '$(SUFX)'
!message *** Optional defines are '$(OPTDEFINES)'
-!message *** Compiler version $(VCVER) options are '$(OPTIMIZATIONS) $(DEBUGFLAGS)'
+!message *** Compiler version $(VCVER)
+!message *** Compiler options '$(OPTIMIZATIONS) $(DEBUGFLAGS)'
+!message *** Link options '$(LINKERFLAGS)'
!endif
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 99913ea..feeb374 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinSock.c,v 1.36.2.5 2006/03/10 14:27:41 vasiljevic Exp $
+ * RCS: @(#) $Id: tclWinSock.c,v 1.36.2.6 2006/09/26 21:40:37 patthoyts Exp $
*/
#include "tclWinInt.h"
@@ -2356,7 +2356,7 @@ SocketThread(LPVOID arg)
SetEvent(tsdPtr->readyEvent);
- return msg.wParam;
+ return (DWORD)msg.wParam;
}
diff --git a/win/tclWinTime.c b/win/tclWinTime.c
index 842d114..f1c9d6a 100644
--- a/win/tclWinTime.c
+++ b/win/tclWinTime.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinTime.c,v 1.14.2.9 2006/06/14 15:21:15 patthoyts Exp $
+ * RCS: @(#) $Id: tclWinTime.c,v 1.14.2.10 2006/09/26 21:40:37 patthoyts Exp $
*/
#include "tclWinInt.h"
@@ -486,7 +486,7 @@ StopCalibration( ClientData unused )
char *
TclpGetTZName(int dst)
{
- int len;
+ size_t len;
char *zone, *p;
TIME_ZONE_INFORMATION tz;
Tcl_Encoding encoding;
@@ -533,7 +533,7 @@ TclpGetTZName(int dst)
}
}
}
- Tcl_ExternalToUtf(NULL, NULL, zone, len, 0, NULL, name,
+ Tcl_ExternalToUtf(NULL, NULL, zone, (int)len, 0, NULL, name,
sizeof(tsdPtr->tzName), NULL, NULL, NULL);
}
if (name[0] == '\0') {