Attachment "msvc8_3.patch" to
ticket [1096916fff]
added by
patthoyts
2005-11-03 06:11:34.
This patch updates Tcl to support compilation with MSVC++ 8 which is now
shipping with Visual Studio 2005. We have to suppress a lot of warnings as
Microsoft seem to have deprecated the entire standard C library and most
POSIX functions.
Index: generic/regerror.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/regerror.c,v
retrieving revision 1.3
diff -u -r1.3 regerror.c
--- generic/regerror.c 2 Jun 1999 01:53:30 -0000 1.3
+++ generic/regerror.c 2 Nov 2005 13:19:48 -0000
@@ -50,8 +50,8 @@
*/
/* ARGSUSED */
size_t /* actual space needed (including NUL) */
-regerror(errcode, preg, errbuf, errbuf_size)
-int errcode; /* error code, or REG_ATOI or REG_ITOA */
+regerror(code, preg, errbuf, errbuf_size)
+int code; /* error code, or REG_ATOI or REG_ITOA */
CONST regex_t *preg; /* associated regex_t (unused at present) */
char *errbuf; /* result buffer (unless errbuf_size==0) */
size_t errbuf_size; /* available space in errbuf, can be 0 */
@@ -62,7 +62,7 @@
size_t len;
int icode;
- switch (errcode) {
+ switch (code) {
case REG_ATOI: /* convert name to number */
for (r = rerrs; r->code >= 0; r++)
if (strcmp(r->name, errbuf) == 0)
@@ -84,12 +84,12 @@
break;
default: /* a real, normal error code */
for (r = rerrs; r->code >= 0; r++)
- if (r->code == errcode)
+ if (r->code == code)
break;
if (r->code >= 0)
msg = r->explain;
else { /* unknown; say so */
- sprintf(convbuf, unk, errcode);
+ sprintf(convbuf, unk, code);
msg = convbuf;
}
break;
Index: generic/tcl.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
retrieving revision 1.206
diff -u -r1.206 tcl.h
--- generic/tcl.h 14 Oct 2005 17:34:20 -0000 1.206
+++ generic/tcl.h 2 Nov 2005 15:19:51 -0000
@@ -371,7 +371,11 @@
# define TCL_LL_MODIFIER "L"
# define TCL_LL_MODIFIER_SIZE 1
# else /* __BORLANDC__ */
+# if _MSC_VER < 1400
typedef struct _stati64 Tcl_StatBuf;
+# else
+typedef struct _stat64 Tcl_StatBuf;
+# endif /* _MSC_VER < 1400 */
# define TCL_LL_MODIFIER "I64"
# define TCL_LL_MODIFIER_SIZE 3
# endif /* __BORLANDC__ */
Index: generic/tclDate.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclDate.c,v
retrieving revision 1.31
diff -u -r1.31 tclDate.c
--- generic/tclDate.c 2 Nov 2005 14:51:04 -0000 1.31
+++ generic/tclDate.c 2 Nov 2005 19:09:58 -0000
@@ -2359,17 +2359,17 @@
resultElement = Tcl_NewObj();
if ( yyHaveDate ) {
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyYear ) );
+ Tcl_NewIntObj( (int) yyYear ) );
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyMonth ) );
+ Tcl_NewIntObj( (int) yyMonth ) );
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyDay ) );
+ Tcl_NewIntObj( (int) yyDay ) );
}
Tcl_ListObjAppendElement( interp, result, resultElement );
if ( yyHaveTime ) {
Tcl_ListObjAppendElement( interp, result,
- Tcl_NewIntObj( ToSeconds( yyHour,
+ Tcl_NewIntObj( (int) ToSeconds( yyHour,
yyMinutes,
yySeconds,
yyMeridian ) ) );
@@ -2380,7 +2380,7 @@
resultElement = Tcl_NewObj();
if ( yyHaveZone ) {
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( -yyTimezone ) );
+ Tcl_NewIntObj( (int) -yyTimezone ) );
Tcl_ListObjAppendElement( interp, resultElement,
Tcl_NewIntObj( 1-yyDSTmode ) );
}
@@ -2389,29 +2389,29 @@
resultElement = Tcl_NewObj();
if ( yyHaveRel ) {
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyRelMonth ) );
+ Tcl_NewIntObj( (int) yyRelMonth ) );
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyRelDay ) );
+ Tcl_NewIntObj( (int) yyRelDay ) );
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyRelSeconds ) );
+ Tcl_NewIntObj( (int) yyRelSeconds ) );
}
Tcl_ListObjAppendElement( interp, result, resultElement );
resultElement = Tcl_NewObj();
if ( yyHaveDay && !yyHaveDate ) {
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyDayOrdinal ) );
+ Tcl_NewIntObj( (int) yyDayOrdinal ) );
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyDayNumber ) );
+ Tcl_NewIntObj( (int) yyDayNumber ) );
}
Tcl_ListObjAppendElement( interp, result, resultElement );
resultElement = Tcl_NewObj();
if ( yyHaveOrdinalMonth ) {
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyMonthOrdinal ) );
+ Tcl_NewIntObj( (int) yyMonthOrdinal ) );
Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( yyMonth ) );
+ Tcl_NewIntObj( (int) yyMonth ) );
}
Tcl_ListObjAppendElement( interp, result, resultElement );
Index: tests/env.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/env.test,v
retrieving revision 1.22
diff -u -r1.22 env.test
--- tests/env.test 5 Oct 2005 08:03:35 -0000 1.22
+++ tests/env.test 2 Nov 2005 22:17:11 -0000
@@ -76,7 +76,11 @@
lrem names ComSpec
lrem names ""
}
- foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH __CF_USER_TEXT_ENCODING } {
+ foreach name {
+ TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY
+ SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
+ __CF_USER_TEXT_ENCODING SYSTEMDRIVE SYSTEMROOT
+ } {
lrem names $name
}
foreach p $names {
@@ -99,19 +103,24 @@
# Save the current environment variables at the start of the test.
foreach name [array names env] {
- set env2($name) $env($name)
+ set env2([string toupper $name]) $env($name)
unset env($name)
}
# Added the following lines so that child tcltest can actually find its
# library if the initial tcltest is run from a non-standard place.
# ('saved' env vars)
-foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH} {
+foreach name {
+ TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH
+ DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH SYSTEMDRIVE SYSTEMROOT
+} {
if {[info exists env2($name)]} {
set env($name) $env2($name);
}
}
+#array set env [array get env2 S*]
+
test env-2.1 {adding environment variables} {exec} {
getenv
} {}
Index: win/makefile.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/makefile.vc,v
retrieving revision 1.140
diff -u -r1.140 makefile.vc
--- win/makefile.vc 8 Oct 2005 14:42:54 -0000 1.140
+++ win/makefile.vc 2 Nov 2005 18:05:15 -0000
@@ -16,8 +16,9 @@
#------------------------------------------------------------------------------
# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
-# or with the MS Platform SDK (MSSDK)
-!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK)
+# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
+# VCINSTALLDIR instead.
+!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR)
MSG = ^
You need to run vcvars32.bat from Developer Studio or setenv.bat from the^
Platform SDK first to setup the environment. Jump to this line to read^
@@ -415,22 +416,28 @@
# Compile flags
#---------------------------------------------------------------------
+# MSVC 2005 changes:
+# -Op gone, use /fp:precise ?
+# /QI0f has been removed.
+# /YX removed - use /Yc or /Yu or better nothing.
+# /GS and /GR are on by default
+
!if !$(DEBUG)
!if $(OPTIMIZING)
### This cranks the optimization level to maximize speed
-cdebug = -O2 -Op -Gs
+cdebug = -O2 $(OPTIMIZATIONS)
!else
cdebug =
!endif
!else if "$(MACHINE)" == "IA64"
### Warnings are too many, can't support warnings into errors.
-cdebug = -Z7 -Od -GZ
+cdebug = -Z7 -Od $(DEBUGFLAGS)
!else
-cdebug = -Z7 -WX -Od -GZ
+cdebug = -Z7 -Od $(DEBUGFLAGS)
!endif
### Declarations common to all compiler options
-cflags = -nologo -c -YX -Fp$(TMP_DIR)^\
+cflags = -nologo -c -Fp$(TMP_DIR)^\
!if $(FULLWARNINGS)
cflags = $(cflags) -W4
Index: win/nmakehlp.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/nmakehlp.c,v
retrieving revision 1.7
diff -u -r1.7 nmakehlp.c
--- win/nmakehlp.c 10 Feb 2004 22:04:04 -0000 1.7
+++ win/nmakehlp.c 2 Nov 2005 13:19:48 -0000
@@ -192,8 +192,13 @@
CloseHandle(pipeThreads[0]);
CloseHandle(pipeThreads[1]);
- /* look for the commandline warning code in both streams. */
- return !(strstr(Out.buffer, "D4002") != NULL || strstr(Err.buffer, "D4002") != NULL);
+ /* 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
Index: win/rules.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/rules.vc,v
retrieving revision 1.21
diff -u -r1.21 rules.vc
--- win/rules.vc 11 Aug 2005 22:06:47 -0000 1.21
+++ win/rules.vc 2 Nov 2005 18:08:34 -0000
@@ -64,7 +64,7 @@
#----------------------------------------------------------
!if !exist(nmakehlp.exe)
-!if [$(cc32) -nologo -ML nmakehlp.c -link -subsystem:console > nul]
+!if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul]
!endif
!endif
@@ -73,7 +73,7 @@
#----------------------------------------------------------
### test for optimizations
-!if [nmakehlp -c -Otip]
+!if [nmakehlp -c -Oti]
!message *** Compiler has 'Optimizations'
OPTIMIZING = 1
!else
@@ -81,6 +81,32 @@
OPTIMIZING = 0
!endif
+OPTIMIZATIONS =
+
+!if [nmakehlp -c -Op]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -Op
+!endif
+
+!if [nmakehlp -c -fp:strict]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict
+!endif
+
+!if [nmakehlp -c -Gs]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs
+!endif
+
+!if [nmakehlp -c -GS]
+OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
+!endif
+
+DEBUGFLAGS =
+
+!if [nmakehlp -c -RTC1]
+DEBUGFLAGS = $(DEBUGFLAGS) -RTC1
+!elseif [nmakehlp -c -GZ]
+DEBUGFLAGS = $(DEBUGFLAGS) -GZ
+!endif
+
!if "$(MACHINE)" == "IX86"
### test for pentium errata
!if [nmakehlp -c -QI0f]
Index: win/tclWinPort.h
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinPort.h,v
retrieving revision 1.45
diff -u -r1.45 tclWinPort.h
--- win/tclWinPort.h 5 Oct 2005 08:03:35 -0000 1.45
+++ win/tclWinPort.h 2 Nov 2005 14:47:51 -0000
@@ -413,6 +413,17 @@
# endif
#endif
+
+/*
+ * MSVC 8.0 started to mark many standard C library functions depreciated
+ * including the *printf family and others. Tell it to shut up.
+ * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0)
+ */
+#if _MSC_VER >= 1400
+#pragma warning(disable:4996)
+#endif
+
+
/*
* There is no platform-specific panic routine for Windows in the Tcl internals.
*/
Index: win/tclWinSock.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinSock.c,v
retrieving revision 1.48
diff -u -r1.48 tclWinSock.c
--- win/tclWinSock.c 24 Jul 2005 22:56:50 -0000 1.48
+++ win/tclWinSock.c 2 Nov 2005 20:19:52 -0000
@@ -1079,7 +1079,7 @@
* progress. */
SOCKADDR_IN sockaddr; /* Socket address */
SOCKADDR_IN mysockaddr; /* Socket address for client */
- SOCKET sock;
+ SOCKET sock = INVALID_SOCKET;
SocketInfo *infoPtr; /* The returned value. */
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
TclThreadDataKeyGet(&dataKey);
Index: win/tclWinTime.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinTime.c,v
retrieving revision 1.31
diff -u -r1.31 tclWinTime.c
--- win/tclWinTime.c 24 Jul 2005 22:56:51 -0000 1.31
+++ win/tclWinTime.c 2 Nov 2005 16:25:34 -0000
@@ -464,7 +464,7 @@
timeInfo.fileTimeLastCall.QuadPart = curFileTime;
timeInfo.perfCounterLastCall.QuadPart = curCounter.QuadPart;
usecSincePosixEpoch = (curFileTime - posixEpoch.QuadPart) / 10;
- timePtr->sec = (time_t) (usecSincePosixEpoch / 1000000);
+ timePtr->sec = (long) (usecSincePosixEpoch / 1000000);
timePtr->usec = (unsigned long) (usecSincePosixEpoch % 1000000);
useFtime = 0;
}
@@ -478,7 +478,7 @@
*/
ftime(&t);
- timePtr->sec = t.time;
+ timePtr->sec = (long)t.time;
timePtr->usec = t.millitm * 1000;
}
}
@@ -701,9 +701,9 @@
}
time /= 24;
- tmPtr->tm_mday += time;
- tmPtr->tm_yday += time;
- tmPtr->tm_wday = (tmPtr->tm_wday + time) % 7;
+ tmPtr->tm_mday += (int)time;
+ tmPtr->tm_yday += (int)time;
+ tmPtr->tm_wday = (tmPtr->tm_wday + (int)time) % 7;
}
} else {
tmPtr = ComputeGMT(t);
@@ -744,8 +744,8 @@
* Compute the 4 year span containing the specified time.
*/
- tmp = *tp / SECSPER4YEAR;
- rem = *tp % SECSPER4YEAR;
+ tmp = (long)(*tp / SECSPER4YEAR);
+ rem = (long)(*tp % SECSPER4YEAR);
/*
* Correct for weird mod semantics so the remainder is always positive.
@@ -812,7 +812,7 @@
* Compute day of week. Epoch started on a Thursday.
*/
- tmPtr->tm_wday = (*tp / SECSPERDAY) + 4;
+ tmPtr->tm_wday = (long)(*tp / SECSPERDAY) + 4;
if ((*tp % SECSPERDAY) < 0) {
tmPtr->tm_wday--;
}