mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
bpo-33956: update vendored expat to 2.2.5 (GH-7925)
This commit is contained in:
parent
58ed7307ea
commit
4e21100fa7
9 changed files with 1350 additions and 1461 deletions
|
@ -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_MAJOR_VERSION 2
|
||||||
#define XML_MINOR_VERSION 2
|
#define XML_MINOR_VERSION 2
|
||||||
#define XML_MICRO_VERSION 4
|
#define XML_MICRO_VERSION 5
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
|
|
||||||
/* External API definitions */
|
/* 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__)
|
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||||
# define XML_USE_MSC_EXTENSIONS 1
|
# define XML_USE_MSC_EXTENSIONS 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -125,7 +121,9 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XML_UNICODE_WCHAR_T
|
#ifdef XML_UNICODE_WCHAR_T
|
||||||
|
# ifndef XML_UNICODE
|
||||||
# define XML_UNICODE
|
# define XML_UNICODE
|
||||||
|
# endif
|
||||||
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
|
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
|
||||||
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
|
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -116,7 +116,7 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
void
|
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
|
#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 */
|
/* Get a handle to kernel32 so we can access it's functions at runtime */
|
||||||
HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32"));
|
HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32"));
|
||||||
if(!hKernel32)
|
if(!hKernel32)
|
||||||
return NULL;
|
return NULL; /* LCOV_EXCL_LINE */
|
||||||
|
|
||||||
/* Attempt to find LoadLibraryEx() which is only available on Windows 2000
|
/* Attempt to find LoadLibraryEx() which is only available on Windows 2000
|
||||||
and above */
|
and above */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -31,8 +31,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#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 <stdbool.h>
|
||||||
#include <string.h> // memcpy
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "winconfig.h"
|
#include "winconfig.h"
|
||||||
|
@ -57,7 +66,6 @@
|
||||||
{ PREFIX(prologTok), PREFIX(contentTok), \
|
{ PREFIX(prologTok), PREFIX(contentTok), \
|
||||||
PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \
|
PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \
|
||||||
{ PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
|
{ PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
|
||||||
PREFIX(sameName), \
|
|
||||||
PREFIX(nameMatchesAscii), \
|
PREFIX(nameMatchesAscii), \
|
||||||
PREFIX(nameLength), \
|
PREFIX(nameLength), \
|
||||||
PREFIX(skipS), \
|
PREFIX(skipS), \
|
||||||
|
@ -354,7 +362,7 @@ enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
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;
|
const char * fromLim = *fromLimRef;
|
||||||
size_t walked = 0;
|
size_t walked = 0;
|
||||||
|
@ -405,18 +413,22 @@ utf8_toUtf8(const ENCODING *UNUSED_P(enc),
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid copying partial characters (from incomplete input). */
|
/* Avoid copying partial characters (from incomplete input). */
|
||||||
|
{
|
||||||
const char * const fromLimBefore = fromLim;
|
const char * const fromLimBefore = fromLim;
|
||||||
align_limit_to_full_utf8_characters(*fromP, &fromLim);
|
_INTERNAL_trim_to_complete_utf8_characters(*fromP, &fromLim);
|
||||||
if (fromLim < fromLimBefore) {
|
if (fromLim < fromLimBefore) {
|
||||||
input_incomplete = true;
|
input_incomplete = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
const ptrdiff_t bytesToCopy = fromLim - *fromP;
|
const ptrdiff_t bytesToCopy = fromLim - *fromP;
|
||||||
memcpy((void *)*toP, (const void *)*fromP, (size_t)bytesToCopy);
|
memcpy(*toP, *fromP, bytesToCopy);
|
||||||
*fromP += bytesToCopy;
|
*fromP += bytesToCopy;
|
||||||
*toP += bytesToCopy;
|
*toP += bytesToCopy;
|
||||||
|
}
|
||||||
|
|
||||||
if (output_exhausted) // needs to go first
|
if (output_exhausted) /* needs to go first */
|
||||||
return XML_CONVERT_OUTPUT_EXHAUSTED;
|
return XML_CONVERT_OUTPUT_EXHAUSTED;
|
||||||
else if (input_incomplete)
|
else if (input_incomplete)
|
||||||
return XML_CONVERT_INPUT_INCOMPLETE;
|
return XML_CONVERT_INPUT_INCOMPLETE;
|
||||||
|
@ -1452,9 +1464,8 @@ unknown_toUtf8(const ENCODING *enc,
|
||||||
return XML_CONVERT_OUTPUT_EXHAUSTED;
|
return XML_CONVERT_OUTPUT_EXHAUSTED;
|
||||||
(*fromP)++;
|
(*fromP)++;
|
||||||
}
|
}
|
||||||
do {
|
memcpy(*toP, utf8, n);
|
||||||
*(*toP)++ = *utf8++;
|
*toP += n;
|
||||||
} while (--n != 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,9 +167,6 @@ enum XML_Convert_Result {
|
||||||
struct encoding {
|
struct encoding {
|
||||||
SCANNER scanners[XML_N_STATES];
|
SCANNER scanners[XML_N_STATES];
|
||||||
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||||
int (PTRCALL *sameName)(const ENCODING *,
|
|
||||||
const char *,
|
|
||||||
const char *);
|
|
||||||
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
||||||
const char *,
|
const char *,
|
||||||
const char *,
|
const char *,
|
||||||
|
@ -260,8 +257,6 @@ struct encoding {
|
||||||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, 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) \
|
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||||
(((enc)->nameMatchesAscii)(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;
|
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
|
static int PTRCALL
|
||||||
PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
|
PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
|
||||||
const char *end1, const char *ptr2)
|
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++) {
|
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
|
||||||
if (end1 - ptr1 < MINBPC(enc)) {
|
if (end1 - ptr1 < MINBPC(enc)) {
|
||||||
/* This line cannot be executed. THe incoming data has already
|
/* 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
|
* already been eliminated from the input. Retaining the
|
||||||
* paranoia check is still valuable, however.
|
* paranoia check is still valuable, however.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue