From fa855c9a00c58a96cd844631521fb7b72e969ce1 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 27 Sep 2017 10:49:18 +0200 Subject: [PATCH 1/4] bpo-31170: Fix inclusion of expat in Windows build projects Co-Authored-By: Steve Dower --- PCbuild/_elementtree.vcxproj | 1 + PCbuild/_elementtree.vcxproj.filters | 8 +++++++- PCbuild/pyexpat.vcxproj | 3 ++- PCbuild/pyexpat.vcxproj.filters | 8 +++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/PCbuild/_elementtree.vcxproj b/PCbuild/_elementtree.vcxproj index 3bd513ffddbf15..040536f6b27d89 100644 --- a/PCbuild/_elementtree.vcxproj +++ b/PCbuild/_elementtree.vcxproj @@ -253,6 +253,7 @@ + diff --git a/PCbuild/_elementtree.vcxproj.filters b/PCbuild/_elementtree.vcxproj.filters index ee78295fa9494d..b17626afc2af79 100644 --- a/PCbuild/_elementtree.vcxproj.filters +++ b/PCbuild/_elementtree.vcxproj.filters @@ -33,6 +33,9 @@ Header Files + + Source Files + Header Files @@ -69,4 +72,7 @@ Source Files - \ No newline at end of file + + + + diff --git a/PCbuild/pyexpat.vcxproj b/PCbuild/pyexpat.vcxproj index 974fd3d6cbc4b7..fa4e843f8ad863 100644 --- a/PCbuild/pyexpat.vcxproj +++ b/PCbuild/pyexpat.vcxproj @@ -220,6 +220,7 @@ + @@ -234,4 +235,4 @@ - \ No newline at end of file + diff --git a/PCbuild/pyexpat.vcxproj.filters b/PCbuild/pyexpat.vcxproj.filters index abf362fb0bfa8a..3d60e6c6b525a1 100644 --- a/PCbuild/pyexpat.vcxproj.filters +++ b/PCbuild/pyexpat.vcxproj.filters @@ -17,6 +17,9 @@ + + Source Files + Source Files @@ -30,4 +33,7 @@ Source Files - \ No newline at end of file + + + + From a69f3da3fcaefd531263f75d2eeb21befd6d3cd8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 27 Sep 2017 15:06:31 +0200 Subject: [PATCH 2/4] expat: Fix compilation on Visual Studio 2010 The standard header stdbool.h is not available with old Visual Studio compilers Cherry-picked from libexpat commit b4b89c2ab0cc5325a41360c25ef9d2ccbe617e5c. expat: Add artificial scopes in xmltok.c utf8_toUtf8() to fix c89 compilation. Cherry-picked from libexpat commit e0b290eb3d8f4c4b45137a7d7f4f8db812145bd2 --- Modules/expat/xmltok.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Modules/expat/xmltok.c b/Modules/expat/xmltok.c index 007aed0640a2ef..482df75b204b70 100644 --- a/Modules/expat/xmltok.c +++ b/Modules/expat/xmltok.c @@ -31,9 +31,18 @@ */ #include -#include #include // memcpy +#if defined(_MSC_VER) && (_MSC_VER <= 1700) + /* for vs2012/11.0/1700 and earlier Visual Studio compilers */ +# define bool int +# define false 0 +# define true 1 +#else +# include +#endif + + #ifdef _WIN32 #include "winconfig.h" #else @@ -405,16 +414,20 @@ utf8_toUtf8(const ENCODING *UNUSED_P(enc), } /* Avoid copying partial characters (from incomplete input). */ - const char * const fromLimBefore = fromLim; - align_limit_to_full_utf8_characters(*fromP, &fromLim); - if (fromLim < fromLimBefore) { - input_incomplete = true; + { + const char * const fromLimBefore = fromLim; + align_limit_to_full_utf8_characters(*fromP, &fromLim); + if (fromLim < fromLimBefore) { + input_incomplete = true; + } } - const ptrdiff_t bytesToCopy = fromLim - *fromP; - memcpy((void *)*toP, (const void *)*fromP, (size_t)bytesToCopy); - *fromP += bytesToCopy; - *toP += bytesToCopy; + { + const ptrdiff_t bytesToCopy = fromLim - *fromP; + memcpy((void *)*toP, (const void *)*fromP, (size_t)bytesToCopy); + *fromP += bytesToCopy; + *toP += bytesToCopy; + } if (output_exhausted) // needs to go first return XML_CONVERT_OUTPUT_EXHAUSTED; From cec5e9b5b09d5834057a7117b7db60632ccaacc7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 27 Sep 2017 15:18:12 +0200 Subject: [PATCH 3/4] Expat: fix preprocessor defines in VS projects Remove the following defines: * BYTEORDER=1234 * HAVE_MEMMOVE * USE_PYEXPAT_CAPI * XML_CONTEXT_BYTES=1024 * XML_DTD * XML_NS * XML_STATIC --- PC/VS9.0/_elementtree.vcproj | 16 ++++++++-------- PC/VS9.0/pyexpat.vcproj | 16 ++++++++-------- PCbuild/_elementtree.vcxproj | 14 +++++++------- PCbuild/pyexpat.vcxproj | 16 ++++++++-------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/PC/VS9.0/_elementtree.vcproj b/PC/VS9.0/_elementtree.vcproj index f9d7375c0c1fb2..d24510757ab278 100644 --- a/PC/VS9.0/_elementtree.vcproj +++ b/PC/VS9.0/_elementtree.vcproj @@ -43,7 +43,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 @@ -173,7 +173,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 @@ -185,7 +185,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 @@ -194,7 +194,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 @@ -206,7 +206,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 @@ -216,7 +216,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 @@ -228,7 +228,7 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) - XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) 0x1D100000 diff --git a/PCbuild/pyexpat.vcxproj b/PCbuild/pyexpat.vcxproj index fa4e843f8ad863..36f9c6cb08a5e8 100644 --- a/PCbuild/pyexpat.vcxproj +++ b/PCbuild/pyexpat.vcxproj @@ -152,7 +152,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -161,13 +161,13 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -176,13 +176,13 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -191,7 +191,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) MachineX64 @@ -200,7 +200,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -209,7 +209,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE;%(PreprocessorDefinitions) + PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) MachineX64 From 0e9ea68a5b74d225a5272e19cefc7a49e255e8ea Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 27 Sep 2017 15:23:02 +0200 Subject: [PATCH 4/4] PCbuild/pyexpat.vcxproj: define _CRT_SECURE_NO_WARNINGS --- PC/VS9.0/pyexpat.vcproj | 16 ++++++++-------- PCbuild/pyexpat.vcxproj | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/PC/VS9.0/pyexpat.vcproj b/PC/VS9.0/pyexpat.vcproj index fb77ccb4865a8f..fbab7a8d7f666f 100644 --- a/PC/VS9.0/pyexpat.vcproj +++ b/PC/VS9.0/pyexpat.vcproj @@ -43,7 +43,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -161,13 +161,13 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -176,13 +176,13 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -191,7 +191,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) MachineX64 @@ -200,7 +200,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) @@ -209,7 +209,7 @@ .\..\Modules\expat;%(AdditionalIncludeDirectories) - PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions) MachineX64