From 132ddc5e8f61aeb2a04889eb1a6494ec281eef7c Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Fri, 29 Apr 2022 14:28:39 +0000 Subject: [PATCH 1/9] Fix test where it was setting an array element rather than a variable. --- tests/pgtcl.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pgtcl.test b/tests/pgtcl.test index 7a18260..a5e0663 100644 --- a/tests/pgtcl.test +++ b/tests/pgtcl.test @@ -1344,7 +1344,7 @@ test pgtcl-11.3 {using pg_exec with 4-byte unicode positional args} -body { set conn [pg::connect -connlist [array get ::conninfo]] - set paramarray(glyph) "𝔄" + set glyph "𝔄" set res [$conn exec {SELECT relname FROM Pg_class From ae42d504a813fe5988f97562c03f49393a1ad90a Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Fri, 6 May 2022 14:27:42 +0000 Subject: [PATCH 2/9] Remove unused TCL_ARRAY code. --- generic/pgtclCmds.c | 206 +------------------------------------------- 1 file changed, 1 insertion(+), 205 deletions(-) diff --git a/generic/pgtclCmds.c b/generic/pgtclCmds.c index 3ebf995..8a597c3 100644 --- a/generic/pgtclCmds.c +++ b/generic/pgtclCmds.c @@ -41,207 +41,6 @@ static int build_param_array(Tcl_Interp *interp, int nParams, Tcl_Obj *CONST obj static void report_connection_error(Tcl_Interp *interp, PGconn *conn); -#ifdef TCL_ARRAYS - -#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7')) -#define DIGIT(c) ((c) - '0') - - -/* - * translate_escape() - * - * This function performs in-place translation of a single C-style - * escape sequence pointed by p. Curly braces { } and double-quote - * are left escaped if they appear inside an array. - * The value returned is the pointer to the last character (the one - * just before the rest of the buffer). - */ - -static inline char * -translate_escape(char *p, int isArray) -{ - char c, - *q, - *s; - -#ifdef TCL_ARRAYS_DEBUG_ESCAPE - printf(" escape = '%s'\n", p); -#endif - /* Address of the first character after the escape sequence */ - s = p + 2; - switch (c = *(p + 1)) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - c = DIGIT(c); - if (ISOCTAL(*s)) - c = (c << 3) + DIGIT(*s++); - if (ISOCTAL(*s)) - c = (c << 3) + DIGIT(*s++); - *p = c; - break; - case 'b': - *p = '\b'; - break; - case 'f': - *p = '\f'; - break; - case 'n': - *p = '\n'; - break; - case 'r': - *p = '\r'; - break; - case 't': - *p = '\t'; - break; - case 'v': - *p = '\v'; - break; - case '\\': - case '{': - case '}': - case '"': - - /* - * Backslahes, curly braces and double-quotes are left escaped - * if they appear inside an array. They will be unescaped by - * Tcl in Tcl_AppendElement. The buffer position is advanced - * by 1 so that the this character is not processed again by - * the caller. - */ - if (isArray) - return p + 1; - else - *p = c; - break; - case '\0': - - /* - * This means a backslash at the end of the string. It should - * never happen but in that case replace the \ with a \0 but - * don't shift the rest of the buffer so that the caller can - * see the end of the string and terminate. - */ - *p = c; - return p; - break; - default: - - /* - * Default case, store the escaped character over the - * backslash and shift the buffer over itself. - */ - *p = c; - } - /* Shift the rest of the buffer over itself after the current char */ - q = p + 1; - for (; *s;) - *q++ = *s++; - *q = '\0'; -#ifdef TCL_ARRAYS_DEBUG_ESCAPE - printf(" after = '%s'\n", p); -#endif - return p; -} - -/* - * tcl_value() - * - * This function does in-line conversion of a value returned by libpq - * into a tcl string or into a tcl list if the value looks like the - * representation of a postgres array. - */ - -static char * -tcl_value(char *value) -{ - int literal, - last; - char *p; - - if (!value) - return NULL; - - -#ifdef TCL_ARRAYS_DEBUG - printf("pq_value = '%s'\n", value); -#endif - last = strlen(value) - 1; - if ((last >= 1) && (value[0] == '{') && (value[last] == '}')) - { - /* Looks like an array, replace ',' with spaces */ - /* Remove the outer pair of { }, the last first! */ - value[last] = '\0'; - value++; - literal = 0; - for (p = value; *p; p++) - { - if (!literal) - { - /* We are at the list level, look for ',' and '"' */ - switch (*p) - { - case '"': /* beginning of literal */ - literal = 1; - break; - case ',': /* replace the ',' with space */ - *p = ' '; - break; - } - } - else - { - /* We are inside a C string */ - switch (*p) - { - case '"': /* end of literal */ - literal = 0; - break; - case '\\': - - /* - * escape sequence, translate it - */ - p = translate_escape(p, 1); - break; - } - } - if (!*p) - break; - } - } - else - { - /* Looks like a normal scalar value */ - for (p = value; *p; p++) - { - if (*p == '\\') - { - /* - * escape sequence, translate it - */ - p = translate_escape(p, 0); - } - if (!*p) - break; - } - } -#ifdef TCL_ARRAYS_DEBUG - printf("tcl_value = '%s'\n\n", value); -#endif - return value; -} -#else /* TCL_ARRAYS */ -#define tcl_value(x) x -#endif /* TCL_ARRAYS */ - static Tcl_Encoding utf8encoding = NULL; /* @@ -294,9 +93,6 @@ char *utfString(const char *externalString) * the returned field is actually null and, if so, the null string value * associated with the connection is returned. * - * If array-into-list processing has been defined, it is also performed, - * which is probably a bad idea, since it can be tricked by legitimate - * data, but that's tcl_value's fault, if TCL_ARRAYS is defined. */ static char * @@ -323,7 +119,7 @@ PGgetvalue ( PGresult *result, char *nullString, int tupno, int fieldNumber ) } /* string is not empty */ - return tcl_value (string); + return string; } /********************************** From fce8a3045a4ef921f749d9e42fffe5075c6ddedc Mon Sep 17 00:00:00 2001 From: Peter da Silva Date: Thu, 14 Jul 2022 18:46:46 +0000 Subject: [PATCH 3/9] Update version number. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index dfaed0c..0e093fe 100755 --- a/configure.in +++ b/configure.in @@ -19,7 +19,7 @@ dnl to configure the system for the local environment. # so you can encode the package version directly into the source files. #----------------------------------------------------------------------- -AC_INIT([pgtcl], [2.7.7]) +AC_INIT([pgtcl], [3.0.1]) #----- # Version with patch stripped From 2c6fc7fd28fc4b5dad5a73216e88600e758d2f28 Mon Sep 17 00:00:00 2001 From: Petro <2592462+Kazmirchuk@users.noreply.github.com> Date: Fri, 26 Aug 2022 15:30:59 +0200 Subject: [PATCH 4/9] update nmake files according to TIP 477; remove unused Windows-specific code --- generic/libpgtcl.h | 3 + generic/pgtcl.c | 88 ++------- libpgtcl.def | 8 - win/libpgtcl.dsp | 230 ------------------------ win/libpgtcl.dsw | 29 --- win/makefile.vc | 432 +++----------------------------------------- win/nmakehlp.c | 355 ------------------------------------ win/rules-ext.vc | 118 ++++++++++++ win/rules.vc | 436 --------------------------------------------- win32.mak | 201 --------------------- 10 files changed, 166 insertions(+), 1734 deletions(-) delete mode 100644 libpgtcl.def delete mode 100644 win/libpgtcl.dsp delete mode 100644 win/libpgtcl.dsw delete mode 100644 win/nmakehlp.c create mode 100644 win/rules-ext.vc delete mode 100644 win/rules.vc delete mode 100644 win32.mak diff --git a/generic/libpgtcl.h b/generic/libpgtcl.h index e8378b9..acb4166 100644 --- a/generic/libpgtcl.h +++ b/generic/libpgtcl.h @@ -18,6 +18,9 @@ #include +#undef TCL_STORAGE_CLASS +#define TCL_STORAGE_CLASS DLLEXPORT + EXTERN int Pgtcl_Init(Tcl_Interp *interp); extern int Pgtcl_SafeInit(Tcl_Interp *interp); diff --git a/generic/pgtcl.c b/generic/pgtcl.c index f636e61..6f10ba5 100644 --- a/generic/pgtcl.c +++ b/generic/pgtcl.c @@ -24,35 +24,9 @@ #endif #ifdef WIN32 -#include +#include #endif -#ifdef _MSC_VER -/* Only do this when MSVC++ is compiling us. */ -#ifdef USE_TCL_STUBS - /* Mark this .obj as needing tcl's Stubs library. */ -#pragma comment(lib, "tclstub" \ - STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) ".lib") -#if !defined(_MT) || !defined(_DLL) || defined(_DEBUG) - - /* - * This fixes a bug with how the Stubs library was compiled. The - * requirement for msvcrt.lib from tclstubXX.lib should be removed. - */ -#pragma comment(linker, "-nodefaultlib:msvcrt.lib") -#endif -#else - /* Mark this .obj needing the import library */ -#pragma comment(lib, "tcl" \ - STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) ".lib") -#endif -#endif -#undef TCL_STORAGE_CLASS -#define TCL_STORAGE_CLASS DLLEXPORT -/* END STUBS MUMBO JUMBO */ - - - typedef struct { char *name; /* Name of command. */ char *name2; /* Name of command, in ::pg namespace. */ @@ -115,55 +89,31 @@ static PgCmd commands[] = { EXTERN int Pgtcl_Init(Tcl_Interp *interp) { - double tclversion; - Tcl_Obj *tclVersionObj; - PgCmd *cmdPtr; + double tclversion; + Tcl_Obj *tclVersionObj; + PgCmd *cmdPtr; - #ifdef WIN32 - WSADATA wsaData; - #endif +#ifdef WIN32 + WSADATA wsaData; +#endif #ifdef USE_TCL_STUBS if (Tcl_InitStubs(interp, "8.1", 0) == NULL) return TCL_ERROR; #endif - - #ifdef WIN32X - /* - * On Windows, need to explicitly load the libpq library to - * force the call to WSAStartup. - */ - Tcl_Obj *tresult; - - if (LoadLibrary("libpq.dll") == NULL) { - //char buf[32]; - //sprintf(buf, "%d", GetLastError()); - tresult = Tcl_NewStringObj("Cannot load \"libpq.dll\" (or dependant), error was "); - Tcl_AppendToObj(tresult, GetLastError(), -1); - Tcl_SetObjResult(interp, tresult); - -/* - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "Cannot load \"libpq.dll\" (or dependant), error was ", - GetLastError(), NULL); -*/ - - return TCL_ERROR; - } - #endif - #ifdef WIN32 - - if (WSAStartup(MAKEWORD(1, 1), &wsaData)) - { - /* - * No really good way to do error handling here, since we - * don't know how we were loaded - */ - return TCL_ERROR; - } - - #endif +#ifdef WIN32 + + if (WSAStartup(MAKEWORD(1, 1), &wsaData)) + { + /* + * No really good way to do error handling here, since we + * don't know how we were loaded + */ + return TCL_ERROR; + } + +#endif /* diff --git a/libpgtcl.def b/libpgtcl.def deleted file mode 100644 index c4b45f2..0000000 --- a/libpgtcl.def +++ /dev/null @@ -1,8 +0,0 @@ -;libpgtcl.def -; The LIBRARY entry must be same as the name of your DLL, the name of -; our DLL is libpgtcl.dll -LIBRARY libpgtcl -EXPORTS - - Pgtcl_Init - Pgtcl_SafeInit diff --git a/win/libpgtcl.dsp b/win/libpgtcl.dsp deleted file mode 100644 index 188cf19..0000000 --- a/win/libpgtcl.dsp +++ /dev/null @@ -1,230 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libpgtcl3" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=libpgtcl3 - Win32 Debug Dynamic -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libpgtcl3.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libpgtcl3.mak" CFG="libpgtcl3 - Win32 Debug Dynamic" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libpgtcl3 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpgtcl3 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpgtcl3 - Win32 Debug Dynamic" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpgtcl3 - Win32 Release Dynamic" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 1 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libpgtcl3 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /D "USE_TCL_STUBS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib libpq.lib wsock32.lib MSVCRT.lib /nologo /dll /incremental:yes /machine:I386 - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /D "USE_TCL_STUBS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib libpq.lib wsock32.lib MSVCRT.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug Dynamic" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "libpgtcl3___Win32_Debug_Dynamic" -# PROP BASE Intermediate_Dir "libpgtcl3___Win32_Debug_Dynamic" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_Dynamic" -# PROP Intermediate_Dir "Debug_Dynamic" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /D "USE_TCL_STUBS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /D "USE_TCL_STUBS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib libpq.lib wsock32.lib MSVCRT.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib libpqdll.lib wsock32.lib MSVCRT.lib /nologo /dll /debug /machine:I386 /pdbtype:sept - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Release Dynamic" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "libpgtcl3___Win32_Release_Dynamic" -# PROP BASE Intermediate_Dir "libpgtcl3___Win32_Release_Dynamic" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_Dynamic" -# PROP Intermediate_Dir "Release_Dynamic" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /D "USE_TCL_STUBS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBPGTCL3_EXPORTS" /D "USE_TCL_STUBS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib libpq.lib wsock32.lib MSVCRT.lib /nologo /dll /incremental:yes /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib libpqdll.lib wsock32.lib MSVCRT.lib /nologo /dll /incremental:yes /machine:I386 - -!ENDIF - -# Begin Target - -# Name "libpgtcl3 - Win32 Release" -# Name "libpgtcl3 - Win32 Debug" -# Name "libpgtcl3 - Win32 Debug Dynamic" -# Name "libpgtcl3 - Win32 Release Dynamic" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE="..\..\Documents and Settings\bschwarz\My Documents\C\libpgtcl\generic\pgtcl.c" - -!IF "$(CFG)" == "libpgtcl3 - Win32 Release" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug Dynamic" - -# PROP Intermediate_Dir "Debug_Dynamic" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Release Dynamic" - -# PROP Intermediate_Dir "Release_Dynamic" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE="..\..\Documents and Settings\bschwarz\My Documents\C\libpgtcl\generic\pgtclCmds.c" - -!IF "$(CFG)" == "libpgtcl3 - Win32 Release" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug Dynamic" - -# PROP Intermediate_Dir "Debug_Dynamic" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Release Dynamic" - -# PROP Intermediate_Dir "Release_Dynamic" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE="..\..\Documents and Settings\bschwarz\My Documents\C\libpgtcl\generic\pgtclId.c" - -!IF "$(CFG)" == "libpgtcl3 - Win32 Release" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Debug Dynamic" - -# PROP Intermediate_Dir "Debug_Dynamic" - -!ELSEIF "$(CFG)" == "libpgtcl3 - Win32 Release Dynamic" - -# PROP Intermediate_Dir "Release_Dynamic" - -!ENDIF - -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE="..\..\Documents and Settings\bschwarz\My Documents\C\libpgtcl\generic\libpgtcl.h" -# End Source File -# Begin Source File - -SOURCE="..\..\Documents and Settings\bschwarz\My Documents\C\libpgtcl\generic\pgtclCmds.h" -# End Source File -# Begin Source File - -SOURCE="..\..\Documents and Settings\bschwarz\My Documents\C\libpgtcl\generic\pgtclId.h" -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/win/libpgtcl.dsw b/win/libpgtcl.dsw deleted file mode 100644 index e983ae8..0000000 --- a/win/libpgtcl.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "libpgtcl3"=.\libpgtcl3.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/win/makefile.vc b/win/makefile.vc index 3cf51f6..b7c2523 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -1,420 +1,40 @@ -# makefile.vc -- -*- Makefile -*- +#------------------------------------------------------------- -*- makefile -*- # -# Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+) +# Makefile for building Pgtcl # -# This makefile is based upon the Tcl 8.4 Makefile.vc and modified to -# make it suitable as a general package makefile. Look for the word EDIT -# which marks sections that may need modification. As a minumum you will -# need to change the PROJECT, DOTVERSION and DLLOBJS variables to values -# relevant to your package. +# Basic build, test and install +# set PGSQLDIR=c:\Program Files\PostgreSQL\12 (replace with your Postgres installation folder) +# nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl +# nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl test +# nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl install # -# See the file "license.terms" for information on usage and redistribution -# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# For other build options (debug, static etc.) +# see TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for detailed documentation. # -# Copyright (c) 1995-1996 Sun Microsystems, Inc. -# Copyright (c) 1998-2000 Ajuba Solutions. -# Copyright (c) 2001 ActiveState Corporation. -# Copyright (c) 2001-2002 David Gravereaux. -# Copyright (c) 2003 Pat Thoyts -# -#------------------------------------------------------------------------- -# RCS: @(#)$Id$ -#------------------------------------------------------------------------- - -!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCToolkitInstallDir) -MSG = ^ -You will need to run vcvars32.bat from Developer Studio, first, to setup^ -the environment. Jump to this line to read the new instructions. -!error $(MSG) -!endif - #------------------------------------------------------------------------------ -# HOW TO USE this makefile: -# -# 1) It is now necessary to have %MSVCDir% set in the environment. This is -# used as a check to see if vcvars32.bat had been run prior to running -# nmake or during the installation of Microsoft Visual C++, MSVCDir had -# been set globally and the PATH adjusted. Either way is valid. -# -# You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin -# directory to setup the proper environment, if needed, for your current -# setup. This is a needed bootstrap requirement and allows the swapping of -# different environments to be easier. -# -# 2) To use the Platform SDK (not expressly needed), run setenv.bat after -# vcvars32.bat according to the instructions for it. This can also turn on -# the 64-bit compiler, if your SDK has it. -# -# 3) Targets are: -# all -- Builds everything. -# -- Builds the project (eg: nmake sample) -# test -- Builds and runs the test suite. -# install -- Installs the built binaries and libraries to $(INSTALLDIR) -# in an appropriate subdirectory. -# clean/realclean/distclean -- varying levels of cleaning. -# -# 4) Macros usable on the commandline: -# INSTALLDIR= -# Sets where to install Tcl from the built binaries. -# C:\Progra~1\Tcl is assumed when not specified. -# -# OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none -# Sets special options for the core. The default is for none. -# Any combination of the above may be used (comma separated). -# 'none' will over-ride everything to nothing. -# -# static = Builds a static library of the core instead of a -# dll. The shell will be static (and large), as well. -# msvcrt = Effects the static option only to switch it from -# using libcmt(d) as the C runtime [by default] to -# msvcrt(d). This is useful for static embedding -# support. -# staticpkg = Effects the static option only to switch -# tclshXX.exe to have the dde and reg extension linked -# inside it. -# threads = Turns on full multithreading support. -# thrdalloc = Use the thread allocator (shared global free pool). -# symbols = Adds symbols for step debugging. -# profile = Adds profiling hooks. Map file is assumed. -# loimpact = Adds a flag for how NT treats the heap to keep memory -# in use, low. This is said to impact alloc performance. -# -# STATS=memdbg,compdbg,none -# Sets optional memory and bytecode compiler debugging code added -# to the core. The default is for none. Any combination of the -# above may be used (comma separated). 'none' will over-ride -# everything to nothing. -# -# memdbg = Enables the debugging memory allocator. -# compdbg = Enables byte compilation logging. -# -# MACHINE=(IX86|IA64|ALPHA) -# Set the machine type used for the compiler, linker, and -# resource compiler. This hook is needed to tell the tools -# when alternate platforms are requested. IX86 is the default -# when not specified. -# -# TMP_DIR= -# OUT_DIR= -# 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)\ by default. -# -# TESTPAT= -# Reads the tests requested to be run from this file. -# -# CFG_ENCODING=encoding -# name of encoding for configuration information. Defaults -# to cp1252 -# -# 5) Examples: -# -# Basic syntax of calling nmake looks like this: -# nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]] -# -# Standard (no frills) -# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat -# Setting environment for using Microsoft Visual C++ tools. -# c:\tcl_src\win\>nmake -f makefile.vc all -# c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl -# -# Building for Win64 -# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat -# Setting environment for using Microsoft Visual C++ tools. -# c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL -# Targeting Windows pre64 RETAIL -# c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64 -# -#------------------------------------------------------------------------------ -#============================================================================== -############################################################################### -#------------------------------------------------------------------------------ - -!if !exist("makefile.vc") -MSG = ^ -You must run this makefile only from the directory it is in.^ -Please `cd` to its location first. -!error $(MSG) -!endif - -#------------------------------------------------------------------------- -# Project specific information (EDIT) -# -# You should edit this with the name and version of your project. This -# information is used to generate the name of the package library and -# it's install location. -# -# For example, the sample extension is going to build sample04.dll and -# would install it into $(INSTALLDIR)\lib\sample04 -# -# You need to specify the object files that need to be linked into your -# binary here. -# -#------------------------------------------------------------------------- - -PROJECT = sample -!include "rules.vc" - -DOTVERSION = 0.5 -VERSION = $(DOTVERSION:.=) -STUBPREFIX = $(PROJECT)stub - -DLLOBJS = \ - $(TMP_DIR)\tclsample.obj \ - $(TMP_DIR)\sample.obj - -#------------------------------------------------------------------------- -# Target names and paths ( shouldn't need changing ) -#------------------------------------------------------------------------- - -BINROOT = . -ROOT = .. - -PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib -PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT) -PRJLIB = $(OUT_DIR)\$(PRJLIBNAME) -PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib -PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME) - -### Make sure we use backslash only. -PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION) -LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR) -BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR) -DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR) -SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR) -INCLUDE_INSTALL_DIR = $(_TCLDIR)\include - -### The following paths CANNOT have spaces in them. -GENERICDIR = $(ROOT)\generic -WINDIR = $(ROOT)\win -LIBDIR = $(ROOT)\library -DOCDIR = $(ROOT)\doc -TOOLSDIR = $(ROOT)\tools -COMPATDIR = $(ROOT)\compat - -#--------------------------------------------------------------------- -# Compile flags -#--------------------------------------------------------------------- - -!if !$(DEBUG) -!if $(OPTIMIZING) -### This cranks the optimization level to maximize speed -cdebug = -O2 -Op -Gs -!else -cdebug = -!endif -!else if "$(MACHINE)" == "IA64" -### Warnings are too many, can't support warnings into errors. -cdebug = -Z7 -Od -GZ -!else -cdebug = -Z7 -WX -Od -GZ -!endif - -### Declarations common to all compiler options -cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\ - -!if $(PENT_0F_ERRATA) -cflags = $(cflags) -QI0f -!endif - -!if $(ITAN_B_ERRATA) -cflags = $(cflags) -QIA64_Bx -!endif - -!if $(MSVCRT) -!if $(DEBUG) -crt = -MDd -!else -crt = -MD -!endif -!else -!if $(DEBUG) -crt = -MTd -!else -crt = -MT -!endif -!endif - -INCLUDES = $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)" -BASE_CLFAGS = $(cflags) $(cdebug) $(crt) $(INCLUDES) -CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE -TCL_CFLAGS = -DUSE_TCL_STUBS -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \ - $(BASE_CLFAGS) $(OPTDEFINES) - -#--------------------------------------------------------------------- -# Link flags -#--------------------------------------------------------------------- - -!if $(DEBUG) -ldebug = -debug:full -debugtype:cv -!else -ldebug = -release -opt:ref -opt:icf,3 -!endif - -### Declarations common to all linker options -lflags = -nologo -machine:$(MACHINE) $(ldebug) - -!if $(PROFILE) -lflags = $(lflags) -profile -!endif - -!if $(ALIGN98_HACK) && !$(STATIC_BUILD) -### Align sections for PE size savings. -lflags = $(lflags) -opt:nowin98 -!else if !$(ALIGN98_HACK) && $(STATIC_BUILD) -### Align sections for speed in loading by choosing the virtual page size. -lflags = $(lflags) -align:4096 -!endif - -!if $(LOIMPACT) -lflags = $(lflags) -ws:aggressive -!endif - -dlllflags = $(lflags) -dll -conlflags = $(lflags) -subsystem:console -guilflags = $(lflags) -subsystem:windows -baselibs = $(TCLSTUBLIB) - -#--------------------------------------------------------------------- -# TclTest flags -#--------------------------------------------------------------------- - -!IF "$(TESTPAT)" != "" -TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT) -!ENDIF - -#--------------------------------------------------------------------- -# Project specific targets (EDIT) -#--------------------------------------------------------------------- - -all: setup $(PROJECT) -$(PROJECT): setup $(PRJLIB) -install: install-binaries install-libraries install-docs - -# Tests need to ensure we load the right dll file we -# have to handle the output differently on Win9x. -# -!if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE" -test: setup $(PROJECT) - set TCL_LIBRARY=$(ROOT)/library - $(TCLSH) << -load $(PRJLIB:\=/) -cd "$(ROOT)/tests" -set argv "$(TESTFLAGS)" -source all.tcl -<< -!else -test: setup $(PROJECT) - echo Please wait while the test results are collected - set TCL_LIBRARY=$(ROOT)/library - $(TCLSH) << >tests.log -load $(PRJLIB:\=/) -cd "$(ROOT)/tests" -set argv "$(TESTFLAGS)" -source all.tcl -<< - type tests.log | more -!endif - -setup: - @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) - @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) - -$(PRJLIB): $(DLLOBJS) - $(link32) $(dlllflags) -out:$@ $(baselibs) @<< -$** -<< - -@del $*.exp - -$(PRJSTUBLIB): $(PRJSTUBOBJS) - $(lib32) -nologo -out:$@ $(PRJSTUBOBJS) - -#--------------------------------------------------------------------- -# Implicit rules -#--------------------------------------------------------------------- - -{$(WINDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<< -$< -<< - -{$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<< -$< -<< - -{$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: - $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<< -$< -<< - -{$(WINDIR)}.rc{$(TMP_DIR)}.res: - $(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \ -!if $(DEBUG) - -d DEBUG \ -!endif -!if $(TCL_THREADS) - -d TCL_THREADS \ -!endif -!if $(STATIC_BUILD) - -d STATIC_BUILD \ -!endif - $< - -.SUFFIXES: -.SUFFIXES:.c .rc - -#--------------------------------------------------------------------- -# Installation. (EDIT) -# -# You may need to modify this section to reflect the final distribution -# of your files and possibly to generate documentation. -# -#--------------------------------------------------------------------- +# pgtcl is spelled in lowercase to match the package name in configure.in, to extract version number from there +# actual package name 'Pgtcl' is hard-coded in pkgIndex.tcl.in +PROJECT = pgtcl -install-binaries: - @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)' - @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)" - @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL +# NB! LIBDIR must be defined *before* including rules-ext.vc in order to install postgres-helpers.tcl +LIBDIR = .. -### Automatic creation of pkgIndex -#install-libraries: -# @echo Installing library files to '$(SCRIPT_INSTALL_DIR)' -# @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)" -# @echo cd "$(SCRIPT_INSTALL_DIR:\=/)" ; pkg_mkIndex . | $(TCLSH) +!include "rules-ext.vc" -### Manual creation of pkgIndex -### Normally the ifneeded command would be: -### package ifneeded $(PROJECT) $(DOTVERSION) \ -### [list load [file join $$dir $(PROJECT)$(VERSION).$(EXT)]] -### but this project has been named oddly. It has Sample_Init but provides -### the Tclsha1 package. -install-libraries: - @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)' - @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)" - @echo Installing package index in '$(SCRIPT_INSTALL_DIR)' - @type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl" -# Hand-crafted pkgIndex.tcl -package ifneeded Tclsha1 $(DOTVERSION) [list load [file join $$dir $(PROJECT)$(VERSION).$(EXT)] Sample] -<< +PRJ_OBJS = \ + $(TMP_DIR)\pgtclId.obj \ + $(TMP_DIR)\pgtclCmds.obj \ + $(TMP_DIR)\pgtcl.obj \ + $(TMP_DIR)\tokenize.obj -install-docs: - @echo Installing documentation files to '$(DOC_INSTALL_DIR)' - @if exist $(DOCDIR) $(CPY) $(DOCDIR)\*.n "$(DOC_INSTALL_DIR)" +PRJ_INCLUDES = -I"$(PGSQLDIR)\include" +PRJ_LIBS = "$(PGSQLDIR)\lib\libpq.lib" ws2_32.lib -#--------------------------------------------------------------------- -# Clean up -#--------------------------------------------------------------------- +PRJ_DEFINES = -D_CRT_SECURE_NO_WARNINGS -clean: - @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) - @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc +!include "$(_RULESDIR)\targets.vc" -realclean: clean - @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) +pkgindex: default-pkgindex-tea -distclean: realclean - @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe - @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj +# Note: the SQLite bridge option is not supported by this makefile yet diff --git a/win/nmakehlp.c b/win/nmakehlp.c deleted file mode 100644 index 30f81bf..0000000 --- a/win/nmakehlp.c +++ /dev/null @@ -1,355 +0,0 @@ -/* ---------------------------------------------------------------------------- - * nmakehlp.c -- - * - * This is used to fix limitations within nmake and the environment. - * - * Copyright (c) 2002 by David Gravereaux. - * Copyright (c) 2003 by Patrick Thoyts - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * ---------------------------------------------------------------------------- - * RCS: @(#) $Id$ - * ---------------------------------------------------------------------------- - */ -#include -#include -#pragma comment (lib, "user32.lib") -#pragma comment (lib, "kernel32.lib") - -/* 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 GetVersionFromHeader(const char *tclh, const char *tkh); - -/* globals */ -typedef struct { - HANDLE pipe; - char buffer[1000]; -} pipeinfo; - -pipeinfo Out = {INVALID_HANDLE_VALUE, '\0'}; -pipeinfo Err = {INVALID_HANDLE_VALUE, '\0'}; - - - -/* exitcodes: 0 == no, 1 == yes, 2 == error */ -int -main (int argc, char *argv[]) -{ - char msg[300]; - DWORD dwWritten; - int chars; - - if (argc > 1 && *argv[1] == '-') { - switch (*(argv[1]+1)) { - case 'c': - if (argc != 3) { - chars = wsprintf(msg, "usage: %s -c \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); - return 2; - } - return CheckForCompilerFeature(argv[2]); - case 'l': - if (argc != 3) { - chars = wsprintf(msg, "usage: %s -l \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); - return 2; - } - return CheckForLinkerFeature(argv[2]); - case 'f': - if (argc == 2) { - chars = wsprintf(msg, "usage: %s -f \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 */ - return 0; - } else { - return IsIn(argv[2], argv[3]); - } - case 'v': - if (argc != 4) { - chars = wsprintf(msg, "usage: %s -v \n" - "Search for versions from the tcl and tk headers.", - argv[0]); - WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL); - return 0; - } - return GetVersionFromHeader(argv[2], argv[3]); - } - } - chars = wsprintf(msg, "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) -{ - STARTUPINFO si; - PROCESS_INFORMATION pi; - SECURITY_ATTRIBUTES sa; - DWORD threadID; - char msg[300]; - BOOL ok; - HANDLE hProcess, h, pipeThreads[2]; - char cmdline[100]; - - hProcess = GetCurrentProcess(); - - ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - ZeroMemory(&si, sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = INVALID_HANDLE_VALUE; - - ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = FALSE; - - /* 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); - - /* 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); - - /* base command line */ - strcpy(cmdline, "cl.exe -nologo -c -TC -Fdtemp "); - /* append our option for testing */ - strcat(cmdline, option); - /* filename to compile, which exists, but is nothing and empty. */ - strcat(cmdline, " nul"); - - ok = CreateProcess( - NULL, /* Module name. */ - cmdline, /* Command line. */ - NULL, /* Process handle not inheritable. */ - NULL, /* Thread handle not inheritable. */ - TRUE, /* yes, inherit handles. */ - DETACHED_PROCESS, /* No console for you. */ - NULL, /* Use parent's environment block. */ - NULL, /* Use parent's starting directory. */ - &si, /* Pointer to STARTUPINFO structure. */ - &pi); /* Pointer to PROCESS_INFORMATION structure. */ - - if (!ok) { - DWORD err = GetLastError(); - 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], - (300-chars), 0); - WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, strlen(msg), &err, NULL); - return 2; - } - - /* 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. */ - 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. */ - 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. */ - WaitForMultipleObjects(2, pipeThreads, TRUE, 500); - 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); -} - -int -CheckForLinkerFeature (const char *option) -{ - STARTUPINFO si; - PROCESS_INFORMATION pi; - SECURITY_ATTRIBUTES sa; - DWORD threadID; - char msg[300]; - BOOL ok; - HANDLE hProcess, h, pipeThreads[2]; - char cmdline[100]; - - hProcess = GetCurrentProcess(); - - ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - ZeroMemory(&si, sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = INVALID_HANDLE_VALUE; - - ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - /* 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); - - /* 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); - - /* 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"); - - ok = CreateProcess( - NULL, /* Module name. */ - cmdline, /* Command line. */ - NULL, /* Process handle not inheritable. */ - NULL, /* Thread handle not inheritable. */ - TRUE, /* yes, inherit handles. */ - DETACHED_PROCESS, /* No console for you. */ - NULL, /* Use parent's environment block. */ - NULL, /* Use parent's starting directory. */ - &si, /* Pointer to STARTUPINFO structure. */ - &pi); /* Pointer to PROCESS_INFORMATION structure. */ - - if (!ok) { - DWORD err = GetLastError(); - 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], - (300-chars), 0); - WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, strlen(msg), &err, NULL); - return 2; - } - - /* 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. */ - 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. */ - WaitForSingleObject(pi.hProcess, INFINITE); - CloseHandle(pi.hProcess); - - /* 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); -} - -DWORD WINAPI -ReadFromPipe (LPVOID args) -{ - pipeinfo *pi = (pipeinfo *) args; - char *lastBuf = pi->buffer; - DWORD dwRead; - BOOL ok; - -again: - ok = ReadFile(pi->pipe, lastBuf, 25, &dwRead, 0L); - if (!ok || dwRead == 0) { - CloseHandle(pi->pipe); - return 0; - } - lastBuf += dwRead; - goto again; - - return 0; /* makes the compiler happy */ -} - -int -IsIn (const char *string, const char *substring) -{ - return (strstr(string, substring) != NULL); -} - - -static double -ReadVersionFromHeader(const char *file, const char *macro) -{ - double d = 0.0; - CHAR szBuffer[100]; - LPSTR p; - DWORD cbBuffer = 100; - FILE *fp = fopen(file, "r"); - if (fp != NULL) { - while (fgets(szBuffer, cbBuffer, fp) != NULL) { - if ((p = strstr(szBuffer, macro)) != NULL) { - while (*p && !isdigit(*p)) ++p; - d = strtod(p, NULL); - break; - } - } - fclose(fp); - } - return d; -} - -int -GetVersionFromHeader(const char *tclh, const char *tkh) -{ - double dTcl = 0.0, dTk = 0.0; - - if (tclh != NULL) - dTcl = ReadVersionFromHeader(tclh, "TCL_VERSION"); - if (tkh != NULL) - dTk = ReadVersionFromHeader(tkh, "TK_VERSION"); - - if (dTcl > 0 || dTk > 0) { - FILE *ofp = fopen("version.vc", "w"); - if (dTcl > 0) - fprintf(ofp, "TCL_DOTVERSION\t= %0.1f\nTCL_VERSION\t= %u\n", - dTcl, (int)(dTcl * 10.0)); - if (dTk > 0) - fprintf(ofp, "TK_DOTVERSION\t= %0.1f\nTK_VERSION\t= %u\n", - dTk, (int)(dTk * 10.0)); - fclose(ofp); - return 0; - } - return 1; -} diff --git a/win/rules-ext.vc b/win/rules-ext.vc new file mode 100644 index 0000000..17f1bbf --- /dev/null +++ b/win/rules-ext.vc @@ -0,0 +1,118 @@ +# This file should only be included in makefiles for Tcl extensions, +# NOT in the makefile for Tcl itself. + +!ifndef _RULES_EXT_VC + +# We need to run from the directory the parent makefile is located in. +# nmake does not tell us what makefile was used to invoke it so parent +# makefile has to set the MAKEFILEVC macro or we just make a guess and +# warn if we think that is not the case. +!if "$(MAKEFILEVC)" == "" + +!if exist("$(PROJECT).vc") +MAKEFILEVC = $(PROJECT).vc +!elseif exist("makefile.vc") +MAKEFILEVC = makefile.vc +!endif +!endif # "$(MAKEFILEVC)" == "" + +!if !exist("$(MAKEFILEVC)") +MSG = ^ +You must run nmake from the directory containing the project makefile.^ +If you are doing that and getting this message, set the MAKEFILEVC^ +macro to the name of the project makefile. +!message WARNING: $(MSG) +!endif + +!if "$(PROJECT)" == "tcl" +!error The rules-ext.vc file is not intended for Tcl itself. +!endif + +# We extract version numbers using the nmakehlp program. For now use +# the local copy of nmakehlp. Once we locate Tcl, we will use that +# one if it is newer. +!if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul] +!endif + +# First locate the Tcl directory that we are working with. +!if "$(TCLDIR)" != "" + +_RULESDIR = $(TCLDIR:/=\) + +!else + +# If an installation path is specified, that is also the Tcl directory. +# Also Tk never builds against an installed Tcl, it needs Tcl sources +!if defined(INSTALLDIR) && "$(PROJECT)" != "tk" +_RULESDIR=$(INSTALLDIR:/=\) +!else +# Locate Tcl sources +!if [echo _RULESDIR = \> nmakehlp.out] \ + || [nmakehlp -L generic\tcl.h >> nmakehlp.out] +_RULESDIR = ..\..\tcl +!else +!include nmakehlp.out +!endif + +!endif # defined(INSTALLDIR).... + +!endif # ifndef TCLDIR + +# Now look for the targets.vc file under the Tcl root. Note we check this +# file and not rules.vc because the latter also exists on older systems. +!if exist("$(_RULESDIR)\lib\nmake\targets.vc") # Building against installed Tcl +_RULESDIR = $(_RULESDIR)\lib\nmake +!elseif exist("$(_RULESDIR)\win\targets.vc") # Building against Tcl sources +_RULESDIR = $(_RULESDIR)\win +!else +# If we have not located Tcl's targets file, most likely we are compiling +# against an older version of Tcl and so must use our own support files. +_RULESDIR = . +!endif + +!if "$(_RULESDIR)" != "." +# Potentially using Tcl's support files. If this extension has its own +# nmake support files, need to compare the versions and pick newer. + +!if exist("rules.vc") # The extension has its own copy + +!if [echo TCL_RULES_MAJOR = \> versions.vc] \ + && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc] +!endif +!if [echo TCL_RULES_MINOR = \>> versions.vc] \ + && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc] +!endif + +!if [echo OUR_RULES_MAJOR = \>> versions.vc] \ + && [nmakehlp -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc] +!endif +!if [echo OUR_RULES_MINOR = \>> versions.vc] \ + && [nmakehlp -V "rules.vc" RULES_VERSION_MINOR >> versions.vc] +!endif +!include versions.vc +# We have a newer version of the support files, use them +!if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR)) +_RULESDIR = . +!endif + +!endif # if exist("rules.vc") + +!endif # if $(_RULESDIR) != "." + +# Let rules.vc know what copy of nmakehlp.c to use. +NMAKEHLPC = $(_RULESDIR)\nmakehlp.c + +# Get rid of our internal defines before calling rules.vc +!undef TCL_RULES_MAJOR +!undef TCL_RULES_MINOR +!undef OUR_RULES_MAJOR +!undef OUR_RULES_MINOR + +!if exist("$(_RULESDIR)\rules.vc") +!message *** Using $(_RULESDIR)\rules.vc +!include "$(_RULESDIR)\rules.vc" +!else +!error *** Could not locate rules.vc in $(_RULESDIR) +!endif + +!endif # _RULES_EXT_VC \ No newline at end of file diff --git a/win/rules.vc b/win/rules.vc deleted file mode 100644 index ba4b828..0000000 --- a/win/rules.vc +++ /dev/null @@ -1,436 +0,0 @@ -#------------------------------------------------------------------------------ -# rules.vc -- -# -# Microsoft Visual C++ makefile include for decoding the commandline -# macros. This file does not need editing to build Tcl. -# -# This version is modified from the Tcl source version to support -# building extensions using nmake. -# -# 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 -# -#------------------------------------------------------------------------------ -# RCS: @(#) $Id$ -#------------------------------------------------------------------------------ - -!ifndef _RULES_VC -_RULES_VC = 1 - -cc32 = $(CC) # built-in default. -link32 = link -lib32 = lib -rc32 = $(RC) # built-in default. - -!ifndef INSTALLDIR -### Assume the normal default. -_INSTALLDIR = C:\Program Files\Tcl -!else -### Fix the path separators. -_INSTALLDIR = $(INSTALLDIR:/=\) -!endif - -!ifndef MACHINE -MACHINE = IX86 -!endif - -!ifndef CFG_ENCODING -CFG_ENCODING = \"cp1252\" -!endif - -#---------------------------------------------------------- -# Set the proper copy method to avoid overwrite questions -# to the user when copying files and selecting the right -# "delete all" method. -#---------------------------------------------------------- - -!if "$(OS)" == "Windows_NT" -RMDIR = rmdir /S /Q -!if ![ver | find "4.0" > nul] -CPY = echo y | xcopy /i -!else -CPY = xcopy /i /y -!endif -!else -CPY = xcopy /i -RMDIR = deltree /Y -!endif - - -!message =============================================================================== - -#---------------------------------------------------------- -# build the helper app we need to overcome nmake's limiting -# environment. -#---------------------------------------------------------- - -!if !exist(nmakehlp.exe) -!if [$(cc32) -nologo -ML nmakehlp.c -link -subsystem:console > nul] -!endif -!endif - -#---------------------------------------------------------- -# Test for compiler features -#---------------------------------------------------------- - -### test for optimizations -!if [nmakehlp -c -Otip] -!message *** Compiler has 'Optimizations' -OPTIMIZING = 1 -!else -!message *** Compiler doesn't have 'Optimizations' -OPTIMIZING = 0 -!endif - -!if "$(MACHINE)" == "IX86" -### test for pentium errata -!if [nmakehlp -c -QI0f] -!message *** Compiler has 'Pentium 0x0f fix' -PENT_0F_ERRATA = 1 -!else -!message *** Compiler doesn't have 'Pentium 0x0f fix' -PENT_0F_ERRATA = 0 -!endif -### test for -align:4096, when align:512 will do. -!if [nmakehlp -l -opt:nowin98] -!message *** Linker has 'Win98 alignment problem' -ALIGN98_HACK = 1 -!else -!message *** Linker doesn't have 'Win98 alignment problem' -ALIGN98_HACK = 0 -!endif -!else -PENT_0F_ERRATA = 0 -ALIGN98_HACK = 0 -!endif - -!if "$(MACHINE)" == "IA64" -### test for Itanium errata -!if [nmakehlp -c -QIA64_Bx] -!message *** Compiler has 'B-stepping errata workarounds' -ITAN_B_ERRATA = 1 -!else -!message *** Compiler doesn't have 'B-stepping errata workarounds' -ITAN_B_ERRATA = 0 -!endif -!else -ITAN_B_ERRATA = 0 -!endif - -#---------------------------------------------------------- -# Decode the options requested. -#---------------------------------------------------------- - -!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"] -STATIC_BUILD = 0 -TCL_THREADS = 0 -DEBUG = 0 -PROFILE = 0 -MSVCRT = 0 -LOIMPACT = 0 -TCL_USE_STATIC_PACKAGES = 0 -USE_THREAD_ALLOC = 0 -!else -!if [nmakehlp -f $(OPTS) "static"] -!message *** Doing static -STATIC_BUILD = 1 -!else -STATIC_BUILD = 0 -!endif -!if [nmakehlp -f $(OPTS) "msvcrt"] -!message *** Doing msvcrt -MSVCRT = 1 -!else -MSVCRT = 0 -!endif -!if [nmakehlp -f $(OPTS) "staticpkg"] -!message *** Doing staticpkg -TCL_USE_STATIC_PACKAGES = 1 -!else -TCL_USE_STATIC_PACKAGES = 0 -!endif -!if [nmakehlp -f $(OPTS) "threads"] -!message *** Doing threads -TCL_THREADS = 1 -!else -TCL_THREADS = 0 -!endif -!if [nmakehlp -f $(OPTS) "symbols"] -!message *** Doing symbols -DEBUG = 1 -!else -DEBUG = 0 -!endif -!if [nmakehlp -f $(OPTS) "profile"] -!message *** Doing profile -PROFILE = 1 -!else -PROFILE = 0 -!endif -!if [nmakehlp -f $(OPTS) "loimpact"] -!message *** Doing loimpact -LOIMPACT = 1 -!else -LOIMPACT = 0 -!endif -!if [nmakehlp -f $(OPTS) "thrdalloc"] -!message *** Doing thrdalloc -USE_THREAD_ALLOC = 1 -!else -USE_THREAD_ALLOC = 0 -!endif -!endif - - -!if !$(STATIC_BUILD) -# Make sure we don't build overly fat DLLs. -MSVCRT = 1 -# We shouldn't statically put the extensions inside the shell when dynamic. -TCL_USE_STATIC_PACKAGES = 0 -!endif - - -#---------------------------------------------------------- -# Figure-out how to name our intermediate and output directories. -# We wouldn't want different builds to use the same .obj files -# by accident. -#---------------------------------------------------------- - -SUFX = tsgx - -!if $(DEBUG) -BUILDDIRTOP = Debug -DBGX = g -!else -BUILDDIRTOP = Release -DBGX = -SUFX = $(SUFX:g=) -!endif - -TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX - -!if !$(STATIC_BUILD) -TMP_DIRFULL = $(TMP_DIRFULL:Static=) -SUFX = $(SUFX:s=) -EXT = dll -!if $(MSVCRT) -TMP_DIRFULL = $(TMP_DIRFULL:X=) -SUFX = $(SUFX:x=) -!endif -!else -TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=) -EXT = lib -!if !$(MSVCRT) -TMP_DIRFULL = $(TMP_DIRFULL:X=) -SUFX = $(SUFX:x=) -!endif -!endif - -!if !$(TCL_THREADS) -TMP_DIRFULL = $(TMP_DIRFULL:Threaded=) -SUFX = $(SUFX:t=) -!endif - -!ifndef TMP_DIR -TMP_DIR = $(TMP_DIRFULL) -!ifndef OUT_DIR -OUT_DIR = .\$(BUILDDIRTOP) -!endif -!else -!ifndef OUT_DIR -OUT_DIR = $(TMP_DIR) -!endif -!endif - - -#---------------------------------------------------------- -# Decode the statistics requested. -#---------------------------------------------------------- - -!if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"] -TCL_MEM_DEBUG = 0 -TCL_COMPILE_DEBUG = 0 -!else -!if [nmakehlp -f $(STATS) "memdbg"] -!message *** Doing memdbg -TCL_MEM_DEBUG = 1 -!else -TCL_MEM_DEBUG = 0 -!endif -!if [nmakehlp -f $(STATS) "compdbg"] -!message *** Doing compdbg -TCL_COMPILE_DEBUG = 1 -!else -TCL_COMPILE_DEBUG = 0 -!endif -!endif - - -#---------------------------------------------------------- -# Set our defines now armed with our options. -#---------------------------------------------------------- - -OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) - -!if $(TCL_MEM_DEBUG) -OPTDEFINES = -DTCL_MEM_DEBUG -!endif -!if $(TCL_COMPILE_DEBUG) -OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS -!endif -!if $(TCL_THREADS) -OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1 -!if $(USE_THREAD_ALLOC) -OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 -!endif -!endif -!if $(STATIC_BUILD) -OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD -!endif - -!if $(DEBUG) -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DEBUG -!elseif $(OPTIMIZING) -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED -!endif -!if $(PROFILE) -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED -!endif -!if "$(MACHINE)" == "IA64" -OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT -!endif - - -#---------------------------------------------------------- -# Get common info used when building extensions. -#---------------------------------------------------------- - -!if "$(PROJECT)" != "tcl" - -# If INSTALLDIR set to tcl root dir then reset to the lib dir. -!if exist("$(_INSTALLDIR)\include\tcl.h") -_INSTALLDIR=$(_INSTALLDIR)\lib -!endif - -!if !defined(TCLDIR) -!if exist("$(_INSTALLDIR)\..\include\tcl.h") -TCLINSTALL = 1 -_TCLDIR = $(_INSTALLDIR)\.. -_TCL_H = $(_INSTALLDIR)\..\include\tcl.h -TCLDIR = $(_INSTALLDIR)\.. -!else -MSG=^ -Failed to find tcl.h. Set the TCLDIR macro. -!error $(MSG) -!endif -!else -_TCLDIR = $(TCLDIR:/=\) -!if exist("$(_TCLDIR)\include\tcl.h") -TCLINSTALL = 1 -_TCL_H = $(_TCLDIR)\include\tcl.h -!elseif exist("$(_TCLDIR)\generic\tcl.h") -TCLINSTALL = 0 -_TCL_H = $(_TCLDIR)\generic\tcl.h -!else -MSG =^ -Failed to find tcl.h. The TCLDIR macro does not appear correct. -!error $(MSG) -!endif -!endif - -!if [nmakehlp -v $(_TCL_H) ""] == 0 -!include version.vc -!else -TCL_DOTVERSION = 8.5 -TCL_VERSION = $(TCL_DOTVERSION:.=) -!endif - -!if $(TCLINSTALL) -TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe" -TCLSTUBLIB = "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib" -TCLIMPLIB = "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib" -TCL_LIBRARY = $(_TCLDIR)\lib -TCL_INCLUDES = -I"$(_TCLDIR)\include" -!else -TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe" -TCLSTUBLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib" -TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib" -TCL_LIBRARY = $(_TCLDIR)\library -TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" -!endif - -!endif - -#---------------------------------------------------------- -# Get Tk info for building extensions. -#---------------------------------------------------------- - -!if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk" - -!if !defined(TKDIR) -!if exist("$(_INSTALLDIR)\..\include\tk.h") -TKINSTALL = 1 -_TKDIR = $(_INSTALLDIR)\.. -_TK_H = $(_TKDIR)\include\tk.h -TKDIR = $(_TKDIR) -!elseif exist("$(_TCLDIR)\include\tk.h") -TKINSTALL = 1 -_TKDIR = $(_TCLDIR) -_TK_H = $(_TKDIR)\include\tk.h -TKDIR = $(_TKDIR) -!else -MSG =^ -Failed to find tk.h. Set the TKDIR macro. -!error $(MSG) -!endif -!else -_TKDIR = $(TKDIR:/=\) -!if exist("$(_TKDIR)\include\tk.h") -TKINSTALL = 1 -_TK_H = $(_TKDIR)\include\tk.h -!elseif exist("$(_TKDIR)\generic\tk.h") -TKINSTALL = 0 -_TK_H = $(_TKDIR)\generic\tk.h -!else -MSG =^ -Failed to find tk.h. The TKDIR macro does not appear correct. -!error $(MSG) -!endif -!endif - -!if [nmakehlp -v $(_TCL_H) $(_TK_H)] == 0 -!include version.vc -!else -TK_DOTVERSION = 8.5 -TK_VERSION = $(TK_DOTVERSION:.=) -!endif - -!if $(TKINSTALL) -WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe" -TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib" -TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib" -TK_INCLUDES = -I"$(_TKDIR)\include" -!else -WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe" -TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib" -TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib" -TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" -!endif - -!endif - - - -#---------------------------------------------------------- -# Display stats being used. -#---------------------------------------------------------- - -!message *** Intermediate directory will be '$(TMP_DIR)' -!message *** Output directory will be '$(OUT_DIR)' -!message *** Suffix for binaries will be '$(SUFX)' -!message *** Optional defines are '$(OPTDEFINES)' - -!endif diff --git a/win32.mak b/win32.mak deleted file mode 100644 index 3146067..0000000 --- a/win32.mak +++ /dev/null @@ -1,201 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on libpgtcl_REL7_1_STABLE.dsp -!IF "$(CFG)" == "" -CFG=libpgtcl - Win32 Release -!MESSAGE No configuration specified. Defaulting to libpgtcl - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "libpgtcl - Win32 Release" && "$(CFG)" != "libpgtcl - Win32 Debug" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libpgtcl.mak" CFG="libpgtcl - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libpgtcl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libpgtcl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -TCLBASE=\usr\local\tcltk833 -PGINCLUDE=/I ..\..\include /I ..\libpq /I $(TCLBASE)\include - -!IF "$(CFG)" == "libpgtcl - Win32 Release" - -OUTDIR=.\Release -INTDIR=.\Release -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -ALL : "$(OUTDIR)\libpgtcl.dll" "$(OUTDIR)\libpgtcl.bsc" - - -CLEAN : - -@erase "$(INTDIR)\pgtcl.obj" - -@erase "$(INTDIR)\pgtcl.sbr" - -@erase "$(INTDIR)\pgtclCmds.obj" - -@erase "$(INTDIR)\pgtclCmds.sbr" - -@erase "$(INTDIR)\pgtclId.obj" - -@erase "$(INTDIR)\pgtclId.sbr" - -@erase "$(INTDIR)\vc60.idb" - -@erase "$(OUTDIR)\libpgtcl.dll" - -@erase "$(OUTDIR)\libpgtcl.exp" - -@erase "$(OUTDIR)\libpgtcl.lib" - -@erase "$(OUTDIR)\libpgtcl.bsc" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP_PROJ=/nologo /MT /W3 /GX /O2 $(PGINCLUDE) /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\libpgtcl.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libpgtcl.bsc" -BSC32_SBRS= \ - "$(INTDIR)\pgtcl.sbr" \ - "$(INTDIR)\pgtclCmds.sbr" \ - "$(INTDIR)\pgtclId.sbr" - -"$(OUTDIR)\libpgtcl.bsc" : "$(OUTDIR)" $(BSC32_SBRS) - $(BSC32) @<< - $(BSC32_FLAGS) $(BSC32_SBRS) -<< - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tcl83.lib libpq.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\libpgtcl.pdb" /machine:I386 /def:".\libpgtcl.def" /out:"$(OUTDIR)\libpgtcl.dll" /implib:"$(OUTDIR)\libpgtcl.lib" /libpath:"$(TCLBASE)\lib" /libpath:"..\libpq\Release" -DEF_FILE= \ - ".\libpgtcl.def" -LINK32_OBJS= \ - "$(INTDIR)\pgtcl.obj" \ - "$(INTDIR)\pgtclCmds.obj" \ - "$(INTDIR)\pgtclId.obj" - -"$(OUTDIR)\libpgtcl.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ELSEIF "$(CFG)" == "libpgtcl - Win32 Debug" - -OUTDIR=.\Debug -INTDIR=.\Debug -# Begin Custom Macros -OutDir=.\Debug -# End Custom Macros - -ALL : "$(OUTDIR)\libpgtcl.dll" "$(OUTDIR)\libpgtcl.bsc" - - -CLEAN : - -@erase "$(INTDIR)\pgtcl.obj" - -@erase "$(INTDIR)\pgtcl.sbr" - -@erase "$(INTDIR)\pgtclCmds.obj" - -@erase "$(INTDIR)\pgtclCmds.sbr" - -@erase "$(INTDIR)\pgtclId.obj" - -@erase "$(INTDIR)\pgtclId.sbr" - -@erase "$(INTDIR)\vc60.idb" - -@erase "$(INTDIR)\vc60.pdb" - -@erase "$(OUTDIR)\libpgtcl.dll" - -@erase "$(OUTDIR)\libpgtcl.exp" - -@erase "$(OUTDIR)\libpgtcl.ilk" - -@erase "$(OUTDIR)\libpgtcl.lib" - -@erase "$(OUTDIR)\libpgtcl.pdb" - -@erase "$(OUTDIR)\libpgtcl.bsc" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od $(PGINCLUDE) /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\libpgtcl.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c -MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\libpgtcl.bsc" -BSC32_SBRS= \ - "$(INTDIR)\pgtcl.sbr" \ - "$(INTDIR)\pgtclCmds.sbr" \ - "$(INTDIR)\pgtclId.sbr" - -"$(OUTDIR)\libpgtcl.bsc" : "$(OUTDIR)" $(BSC32_SBRS) - $(BSC32) @<< - $(BSC32_FLAGS) $(BSC32_SBRS) -<< - -LINK32=link.exe -LINK32_FLAGS=tcl83.lib libpq.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\libpgtcl.pdb" /debug /machine:I386 /def:".\libpgtcl.def" /out:"$(OUTDIR)\libpgtcl.dll" /implib:"$(OUTDIR)\libpgtcl.lib" /pdbtype:sept /libpath:"$(TCLBASE)\lib" /libpath:"..\libpq\Debug" -DEF_FILE= \ - ".\libpgtcl.def" -LINK32_OBJS= \ - "$(INTDIR)\pgtcl.obj" \ - "$(INTDIR)\pgtclCmds.obj" \ - "$(INTDIR)\pgtclId.obj" - -"$(OUTDIR)\libpgtcl.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - -!ENDIF - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -!IF "$(CFG)" == "libpgtcl - Win32 Release" || "$(CFG)" == "libpgtcl - Win32 Debug" -SOURCE=pgtcl.c - -"$(INTDIR)\pgtcl.obj" "$(INTDIR)\pgtcl.sbr" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=pgtclCmds.c - -"$(INTDIR)\pgtclCmds.obj" "$(INTDIR)\pgtclCmds.sbr" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=pgtclId.c - -"$(INTDIR)\pgtclId.obj" "$(INTDIR)\pgtclId.sbr" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - - -!ENDIF - From eaf5110e6b5ae3ad4f3e8ce70e726879192d4971 Mon Sep 17 00:00:00 2001 From: Petro <2592462+Kazmirchuk@users.noreply.github.com> Date: Fri, 2 Sep 2022 16:39:37 +0200 Subject: [PATCH 5/9] Tclx is not needed in sc_postgres --- postgres-helpers.tcl | 1 - 1 file changed, 1 deletion(-) diff --git a/postgres-helpers.tcl b/postgres-helpers.tcl index be9a5dc..c02706e 100644 --- a/postgres-helpers.tcl +++ b/postgres-helpers.tcl @@ -24,7 +24,6 @@ package provide sc_postgres 1.3 -package require Tclx package require Pgtcl namespace eval sc_pg { From 34b7891cd40e31f6b80e409557d181e9d0a11030 Mon Sep 17 00:00:00 2001 From: MaryRyan Gilmore Date: Tue, 2 Jan 2024 14:48:27 +0000 Subject: [PATCH 6/9] correct handling for big int types --- generic/pgtclSqlite.c | 16 +++++++++------- tests/sqlite3.test | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/generic/pgtclSqlite.c b/generic/pgtclSqlite.c index ad38d73..6753e0c 100644 --- a/generic/pgtclSqlite.c +++ b/generic/pgtclSqlite.c @@ -294,12 +294,13 @@ Pg_sqlite_bindValue(sqlite3 *sqlite_db, sqlite3_stmt *statement, int column, cha break; } case PG_SQLITE_INT: { - int ival = atoi(value); + char* end; + long ival = strtoul(value, &end, 10); if(ival == 0) { // It might be a boolean column mapped to an integer column ival = Pg_sqlite_toBool(value); } - if (sqlite3_bind_int(statement, column+1, ival) == SQLITE_OK) + if (sqlite3_bind_int64(statement, column+1, ival) == SQLITE_OK) return TCL_OK; break; } @@ -509,8 +510,9 @@ Pg_sqlite_executeCheck(Tcl_Interp *interp, sqlite3 *sqlite_db, sqlite3_stmt *sta break; } case PG_SQLITE_INT: { - int ival = sqlite3_column_int(statement, i); - int rval = atoi(row[i]); + char* end; + long ival = sqlite3_column_int64(statement, i); + long rval = strtoul(row[i], &end, 10); if(ival != rval) { status = TCL_OK; goto cleanup_and_exit; @@ -1671,7 +1673,7 @@ Pg_sqlite(ClientData clientdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST ob char *pghandle_name = Tcl_GetString(objv[3]); int nTuples; int tupleIndex; - int maxInt = 0; + long maxInt = 0; double maxFloat = 0.0; char maxString[BUFSIZ]; int maxValid = 0; @@ -1775,7 +1777,8 @@ Pg_sqlite(ClientData clientdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST ob break; } case PG_SQLITE_INT: { - int valInt = atoi(val); + char* end; + long valInt = strtoul(val, &end, 10); if(!maxValid || valInt > maxInt) { maxInt = valInt; maxValid = 1; @@ -1794,7 +1797,6 @@ Pg_sqlite(ClientData clientdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST ob } ckfree((void *)columns); columns = NULL; - if (sqlite3_step(statement) != SQLITE_DONE) { errorMessage = sqlite3_errmsg(sqlite_db); returnCode = TCL_ERROR; diff --git a/tests/sqlite3.test b/tests/sqlite3.test index 54c0325..8257a5c 100644 --- a/tests/sqlite3.test +++ b/tests/sqlite3.test @@ -59,7 +59,7 @@ test pgtcl-sqlite3-1.1 {import postgresql result} -body { set rows [ pg_sqlite sqlite_conn import_postgres_result $res -create pg_class \ -as {relname text relnamespace integer reltype integer relowner integer} \ - -check -pkey {relname} + -check -pkey {relname relnamespace} ] sqlite_conn eval {select count(*) as count from pg_class;} row { From 35ed4adae797647258f95768531ccbc5bcb1771b Mon Sep 17 00:00:00 2001 From: MaryRyan Gilmore Date: Tue, 2 Jan 2024 16:06:25 +0000 Subject: [PATCH 7/9] update to gcc 8 --- .github/workflows/linux-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 8421e40..b6dba9b 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -21,8 +21,8 @@ jobs: run: | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update -qq - sudo apt-get install -y gcc-7 g++-7 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 + sudo apt-get install -y gcc-8 g++-8 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 70 --slave /usr/bin/g++ g++ /usr/bin/g++-8 sudo apt-get install -y tcl8.6-dev - name: configure run: | From 61ceb480d0b51a14bdbbe2d0a5f08a5ca35b4a51 Mon Sep 17 00:00:00 2001 From: MaryRyan Gilmore Date: Tue, 2 Jan 2024 16:12:51 +0000 Subject: [PATCH 8/9] update to gcc 11 --- .github/workflows/linux-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index b6dba9b..18d3015 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -21,8 +21,8 @@ jobs: run: | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update -qq - sudo apt-get install -y gcc-8 g++-8 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 70 --slave /usr/bin/g++ g++ /usr/bin/g++-8 + sudo apt-get install -y gcc-11 g++-11 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 70 --slave /usr/bin/g++ g++ /usr/bin/g++-11 sudo apt-get install -y tcl8.6-dev - name: configure run: | From 6f6e34671eb4924e6bd6b339332a77862f56b5b7 Mon Sep 17 00:00:00 2001 From: Jeff Lawson Date: Thu, 18 Jan 2024 17:10:09 -0600 Subject: [PATCH 9/9] Update CI badges in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ba2f1f..cef798b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -![Linux CI](https://github.com/flightaware/Pgtcl/workflows/Linux%20CI/badge.svg) -![Mac CI](https://github.com/flightaware/Pgtcl/workflows/Mac%20CI/badge.svg) +[![Linux CI](https://github.com/flightaware/Pgtcl/actions/workflows/linux-ci.yml/badge.svg)](https://github.com/flightaware/Pgtcl/actions/workflows/linux-ci.yml) +[![Mac CI](https://github.com/flightaware/Pgtcl/actions/workflows/mac-ci.yml/badge.svg)](https://github.com/flightaware/Pgtcl/actions/workflows/mac-ci.yml) Thank you for downloading Pgtcl, a package that adds PostgreSQL interface extensions to the Tcl programming language... an open source project that's been in existence for nearly twenty years.