From 2ac3a08a98a293de62ed6ae01aa7a7d139660207 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Thu, 3 Nov 2005 00:17:30 +0000 Subject: Applied patch #1096916 to support building with MSVC 8. * generic/regerror.c: Avoid use of reserved word. * generic/tcl.h: Select the right Tcl_Stat structure * generic/tclDate.c: Casts to handle 64 bit time_t case. * tests/env.test: Include essential envvar on Win32 * win/nmakehlp.c: Handle new return codes. * win/makefile.vc: Use the selected options. * win/rules.vc: Check options are applicable * win/tclWinPort.h: Disable deprecated function warnings * win/tclWinSock.c: Provide default value to avoid warning. * win/tclWinTime.c: Add casts to handle 64bit time_t type. --- ChangeLog | 14 ++++++++++++++ generic/regerror.c | 10 +++++----- generic/tcl.h | 6 +++++- generic/tclDate.c | 24 ++++++++++++------------ tests/env.test | 17 +++++++++++++---- win/makefile.vc | 21 ++++++++++++++------- win/nmakehlp.c | 11 ++++++++--- win/rules.vc | 32 +++++++++++++++++++++++++++++--- win/tclWinPort.h | 13 ++++++++++++- win/tclWinSock.c | 4 ++-- win/tclWinTime.c | 18 +++++++++--------- 11 files changed, 123 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index d474bf4..9da7ba3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-11-02 Pat Thoyts + + Applied patch #1096916 to support building with MSVC 8. + * generic/regerror.c: Avoid use of reserved word. + * generic/tcl.h: Select the right Tcl_Stat structure + * generic/tclDate.c: Casts to handle 64 bit time_t case. + * tests/env.test: Include essential envvar on Win32 + * win/nmakehlp.c: Handle new return codes. + * win/makefile.vc: Use the selected options. + * win/rules.vc: Check options are applicable + * win/tclWinPort.h: Disable deprecated function warnings + * win/tclWinSock.c: Provide default value to avoid warning. + * win/tclWinTime.c: Add casts to handle 64bit time_t type. + 2005-11-01 Don Porter * generic/tclTrace.c (TclCheckExecutionTraces): Corrected mistaken diff --git a/generic/regerror.c b/generic/regerror.c index aca13aa..182830d 100644 --- a/generic/regerror.c +++ b/generic/regerror.c @@ -50,8 +50,8 @@ static struct rerr { */ /* 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 errbuf_size; /* available space in errbuf, can be 0 */ 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 @@ size_t errbuf_size; /* available space in errbuf, can be 0 */ 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; diff --git a/generic/tcl.h b/generic/tcl.h index 05e913f..5f6b7dd 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.206 2005/10/14 17:34:20 vasiljevic Exp $ + * RCS: @(#) $Id: tcl.h,v 1.207 2005/11/03 00:17:30 patthoyts Exp $ */ #ifndef _TCL @@ -371,7 +371,11 @@ typedef struct stati64 Tcl_StatBuf; # 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__ */ diff --git a/generic/tclDate.c b/generic/tclDate.c index 7761fa2..2020335 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -2359,17 +2359,17 @@ TclClockOldscanObjCmd( clientData, interp, objc, objv ) 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 @@ TclClockOldscanObjCmd( clientData, interp, objc, objv ) 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 @@ TclClockOldscanObjCmd( clientData, interp, objc, objv ) 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 ); diff --git a/tests/env.test b/tests/env.test index c2bad61..a1e50d9 100644 --- a/tests/env.test +++ b/tests/env.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: env.test,v 1.22 2005/10/05 08:03:35 hobbs Exp $ +# RCS: @(#) $Id: env.test,v 1.23 2005/11/03 00:17:31 patthoyts Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -76,7 +76,11 @@ set printenvScript [makeFile { 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 @@ proc getenv {} { # 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 } {} diff --git a/win/makefile.vc b/win/makefile.vc index da38877..d74f505 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -12,12 +12,13 @@ # Copyright (c) 2001-2004 David Gravereaux. # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: makefile.vc,v 1.140 2005/10/08 14:42:54 dgp Exp $ +# RCS: @(#) $Id: makefile.vc,v 1.141 2005/11/03 00:17:31 patthoyts Exp $ #------------------------------------------------------------------------------ # 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 @@ WINDIR = $(ROOT)\win # 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 diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 4599315..d1fb6b4 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -9,7 +9,7 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * ---------------------------------------------------------------------------- - * RCS: @(#) $Id: nmakehlp.c,v 1.7 2004/02/10 22:04:04 davygrvy Exp $ + * RCS: @(#) $Id: nmakehlp.c,v 1.8 2005/11/03 00:17:31 patthoyts Exp $ * ---------------------------------------------------------------------------- */ #include @@ -192,8 +192,13 @@ CheckForCompilerFeature (const char *option) 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 diff --git a/win/rules.vc b/win/rules.vc index cfa4baa..6c595bc 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -10,7 +10,7 @@ # Copyright (c) 2001-2003 David Gravereaux. # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: rules.vc,v 1.21 2005/08/11 22:06:47 kennykb Exp $ +# RCS: @(#) $Id: rules.vc,v 1.22 2005/11/03 00:17:31 patthoyts Exp $ #------------------------------------------------------------------------------ !ifndef _RULES_VC @@ -64,7 +64,7 @@ RMDIR = deltree /Y #---------------------------------------------------------- !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 @@ RMDIR = deltree /Y #---------------------------------------------------------- ### test for optimizations -!if [nmakehlp -c -Otip] +!if [nmakehlp -c -Oti] !message *** Compiler has 'Optimizations' OPTIMIZING = 1 !else @@ -81,6 +81,32 @@ OPTIMIZING = 1 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] diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 4c11208..984682f 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPort.h,v 1.45 2005/10/05 08:03:35 hobbs Exp $ + * RCS: @(#) $Id: tclWinPort.h,v 1.46 2005/11/03 00:17:31 patthoyts Exp $ */ #ifndef _TCLWINPORT @@ -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. */ diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 10c24bd..030518a 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.48 2005/07/24 22:56:50 dkf Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.49 2005/11/03 00:17:31 patthoyts Exp $ */ #include "tclWinInt.h" @@ -1079,7 +1079,7 @@ CreateSocket(interp, port, host, server, myaddr, myport, async) * 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); diff --git a/win/tclWinTime.c b/win/tclWinTime.c index fc91e2b..0b8ebfa 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.31 2005/07/24 22:56:51 dkf Exp $ + * RCS: @(#) $Id: tclWinTime.c,v 1.32 2005/11/03 00:17:31 patthoyts Exp $ */ #include "tclInt.h" @@ -464,7 +464,7 @@ NativeGetTime(timePtr, clientData) 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 @@ NativeGetTime(timePtr, clientData) */ ftime(&t); - timePtr->sec = t.time; + timePtr->sec = (long)t.time; timePtr->usec = t.millitm * 1000; } } @@ -701,9 +701,9 @@ TclpGetDate(t, useGMT) } 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 @@ ComputeGMT(tp) * 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 @@ ComputeGMT(tp) * 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--; } -- cgit v0.12