From d54d6fffba57bd417e31ab33230cbc490142bf03 Mon Sep 17 00:00:00 2001 From: Chris Liddell Date: Tue, 11 Oct 2022 16:50:30 +0100 Subject: Tweaks for expat 2.4.9 to build on Windows. --- expat/expat_config.h | 22 ++++++++++++++++++---- expat/lib/siphash.h | 2 ++ expat/lib/xmlparse.c | 7 +++++-- expat/lib/xmltok.c | 5 +++++ 4 files changed, 30 insertions(+), 6 deletions(-) (limited to 'expat') diff --git a/expat/expat_config.h b/expat/expat_config.h index 7842c262c..f64037ac6 100644 --- a/expat/expat_config.h +++ b/expat/expat_config.h @@ -23,7 +23,7 @@ #define HAVE_GETPAGESIZE 1 /* Define to 1 if you have the `getrandom' function. */ -#define HAVE_GETRANDOM 1 +/*#define HAVE_GETRANDOM 1*/ /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 @@ -35,7 +35,21 @@ #define HAVE_MMAP 1 /* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 +/*#define HAVE_STDINT_H 1*/ +# if defined(__WIN32__) /* MSVC currently doesn't provide C99 headers */ + typedef signed char int8_t; + typedef short int int16_t; + typedef int int32_t; + typedef __int64 int64_t; + typedef unsigned char uint8_t; + typedef unsigned short int uint16_t; + typedef unsigned int uint32_t; + typedef unsigned __int64 uint64_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + typedef unsigned long long uint64_t; +#endif /* Define to 1 if you have the header file. */ #define HAVE_STDIO_H 1 @@ -50,7 +64,7 @@ #define HAVE_STRING_H 1 /* Define to 1 if you have `syscall' and `SYS_getrandom'. */ -#define HAVE_SYSCALL_GETRANDOM 1 +/*#define HAVE_SYSCALL_GETRANDOM 1*/ /* Define to 1 if you have the header file. */ #define HAVE_SYS_PARAM_H 1 @@ -117,7 +131,7 @@ #define XML_CONTEXT_BYTES 1024 /* Define to include code reading entropy from `/dev/urandom'. */ -#define XML_DEV_URANDOM 1 +/*#define XML_DEV_URANDOM 1*/ /* Define to make parameter entity parsing functionality available. */ #define XML_DTD 1 diff --git a/expat/lib/siphash.h b/expat/lib/siphash.h index 303283ad2..b1cff17eb 100644 --- a/expat/lib/siphash.h +++ b/expat/lib/siphash.h @@ -99,7 +99,9 @@ #define SIPHASH_H #include /* size_t */ +#ifdef HAVE_STDINT_H #include /* uint64_t uint32_t uint8_t */ +#endif /* * Workaround to not require a C++11 compiler for using ULL suffix diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index b89d7ed22..db1f26083 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -78,7 +78,9 @@ #include /* UINT_MAX */ #include /* fprintf */ #include /* getenv, rand_s */ +#ifdef HAVE_STDINT_H #include /* uintptr_t */ +#endif #include /* isnan */ #ifdef _WIN32 @@ -2533,7 +2535,7 @@ XML_Bool XMLCALL XML_SetBillionLaughsAttackProtectionMaximumAmplification( XML_Parser parser, float maximumAmplificationFactor) { if ((parser == NULL) || (parser->m_parentParser != NULL) - || isnan(maximumAmplificationFactor) +/* || isnan(maximumAmplificationFactor) */ || (maximumAmplificationFactor < 1.0f)) { return XML_FALSE; } @@ -5283,6 +5285,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, case XML_ROLE_GROUP_OPEN: if (parser->m_prologState.level >= parser->m_groupSize) { char *new_connector; + int *new_scaff_index; if (parser->m_groupSize) { { /* Detect and prevent integer overflow */ @@ -5310,7 +5313,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, } #endif - int *const new_scaff_index = (int *)REALLOC( + new_scaff_index = (int *)REALLOC( parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int)); if (new_scaff_index == NULL) return XML_ERROR_NO_MEMORY; diff --git a/expat/lib/xmltok.c b/expat/lib/xmltok.c index 2b7012a58..9f857b3d0 100644 --- a/expat/lib/xmltok.c +++ b/expat/lib/xmltok.c @@ -48,7 +48,12 @@ #include #include /* memcpy */ +#if 0 #include +#endif +typedef int bool; +#define true 1 +#define false 0 #ifdef _WIN32 # include "winconfig.h" -- cgit v1.2.1