bpo-33956: update vendored expat to 2.2.5 (GH-7925)
This commit is contained in:
parent
58ed7307ea
commit
4e21100fa7
|
@ -0,0 +1 @@
|
|||
Update vendored Expat library copy to version 2.2.5.
|
|
@ -1076,7 +1076,7 @@ XML_GetFeatureList(void);
|
|||
*/
|
||||
#define XML_MAJOR_VERSION 2
|
||||
#define XML_MINOR_VERSION 2
|
||||
#define XML_MICRO_VERSION 4
|
||||
#define XML_MICRO_VERSION 5
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
|
||||
/* External API definitions */
|
||||
|
||||
/* Namespace external symbols to allow multiple libexpat version to
|
||||
co-exist. */
|
||||
#include "pyexpatns.h"
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
# define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
@ -125,7 +121,9 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
# ifndef XML_UNICODE
|
||||
# define XML_UNICODE
|
||||
# endif
|
||||
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
|
||||
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
|
||||
# endif
|
||||
|
|
|
@ -116,7 +116,7 @@ extern "C" {
|
|||
|
||||
|
||||
void
|
||||
align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef);
|
||||
_INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -84,7 +84,7 @@ HMODULE _Expat_LoadLibrary(LPCTSTR filename)
|
|||
/* Get a handle to kernel32 so we can access it's functions at runtime */
|
||||
HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32"));
|
||||
if(!hKernel32)
|
||||
return NULL;
|
||||
return NULL; /* LCOV_EXCL_LINE */
|
||||
|
||||
/* Attempt to find LoadLibraryEx() which is only available on Windows 2000
|
||||
and above */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,8 +31,17 @@
|
|||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h> /* 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 <stdbool.h>
|
||||
#include <string.h> // memcpy
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winconfig.h"
|
||||
|
@ -57,7 +66,6 @@
|
|||
{ PREFIX(prologTok), PREFIX(contentTok), \
|
||||
PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \
|
||||
{ PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
|
||||
PREFIX(sameName), \
|
||||
PREFIX(nameMatchesAscii), \
|
||||
PREFIX(nameLength), \
|
||||
PREFIX(skipS), \
|
||||
|
@ -354,7 +362,7 @@ enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
|
|||
};
|
||||
|
||||
void
|
||||
align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef)
|
||||
_INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef)
|
||||
{
|
||||
const char * fromLim = *fromLimRef;
|
||||
size_t walked = 0;
|
||||
|
@ -405,18 +413,22 @@ 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);
|
||||
_INTERNAL_trim_to_complete_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);
|
||||
memcpy(*toP, *fromP, bytesToCopy);
|
||||
*fromP += bytesToCopy;
|
||||
*toP += bytesToCopy;
|
||||
}
|
||||
|
||||
if (output_exhausted) // needs to go first
|
||||
if (output_exhausted) /* needs to go first */
|
||||
return XML_CONVERT_OUTPUT_EXHAUSTED;
|
||||
else if (input_incomplete)
|
||||
return XML_CONVERT_INPUT_INCOMPLETE;
|
||||
|
@ -1452,9 +1464,8 @@ unknown_toUtf8(const ENCODING *enc,
|
|||
return XML_CONVERT_OUTPUT_EXHAUSTED;
|
||||
(*fromP)++;
|
||||
}
|
||||
do {
|
||||
*(*toP)++ = *utf8++;
|
||||
} while (--n != 0);
|
||||
memcpy(*toP, utf8, n);
|
||||
*toP += n;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,9 +167,6 @@ enum XML_Convert_Result {
|
|||
struct encoding {
|
||||
SCANNER scanners[XML_N_STATES];
|
||||
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||
int (PTRCALL *sameName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
|
@ -260,8 +257,6 @@ struct encoding {
|
|||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
|
|
|
@ -1653,79 +1653,6 @@ PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* This function does not appear to be called from anywhere within the
|
||||
* library code. It is used via the macro XmlSameName(), which is
|
||||
* defined but never used. Since it appears in the encoding function
|
||||
* table, removing it is not a thing to be undertaken lightly. For
|
||||
* the moment, we simply exclude it from coverage tests.
|
||||
*
|
||||
* LCOV_EXCL_START
|
||||
*/
|
||||
static int PTRCALL
|
||||
PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
||||
{
|
||||
for (;;) {
|
||||
switch (BYTE_TYPE(enc, ptr1)) {
|
||||
#define LEAD_CASE(n) \
|
||||
case BT_LEAD ## n: \
|
||||
if (*ptr1++ != *ptr2++) \
|
||||
return 0;
|
||||
LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
|
||||
#undef LEAD_CASE
|
||||
/* fall through */
|
||||
if (*ptr1++ != *ptr2++)
|
||||
return 0;
|
||||
break;
|
||||
case BT_NONASCII:
|
||||
case BT_NMSTRT:
|
||||
#ifdef XML_NS
|
||||
case BT_COLON:
|
||||
#endif
|
||||
case BT_HEX:
|
||||
case BT_DIGIT:
|
||||
case BT_NAME:
|
||||
case BT_MINUS:
|
||||
if (*ptr2++ != *ptr1++)
|
||||
return 0;
|
||||
if (MINBPC(enc) > 1) {
|
||||
if (*ptr2++ != *ptr1++)
|
||||
return 0;
|
||||
if (MINBPC(enc) > 2) {
|
||||
if (*ptr2++ != *ptr1++)
|
||||
return 0;
|
||||
if (MINBPC(enc) > 3) {
|
||||
if (*ptr2++ != *ptr1++)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (MINBPC(enc) == 1 && *ptr1 == *ptr2)
|
||||
return 1;
|
||||
switch (BYTE_TYPE(enc, ptr2)) {
|
||||
case BT_LEAD2:
|
||||
case BT_LEAD3:
|
||||
case BT_LEAD4:
|
||||
case BT_NONASCII:
|
||||
case BT_NMSTRT:
|
||||
#ifdef XML_NS
|
||||
case BT_COLON:
|
||||
#endif
|
||||
case BT_HEX:
|
||||
case BT_DIGIT:
|
||||
case BT_NAME:
|
||||
case BT_MINUS:
|
||||
return 0;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* not reached */
|
||||
}
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
static int PTRCALL
|
||||
PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
|
||||
const char *end1, const char *ptr2)
|
||||
|
@ -1733,7 +1660,7 @@ PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
|
|||
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
|
||||
if (end1 - ptr1 < MINBPC(enc)) {
|
||||
/* This line cannot be executed. THe incoming data has already
|
||||
* been tokenized once, so incomplete characters like this have
|
||||
* been tokenized once, so imcomplete characters like this have
|
||||
* already been eliminated from the input. Retaining the
|
||||
* paranoia check is still valuable, however.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue