Python improvements to expat
Michael Gilbert <[email protected]> Mon, 18 Jan 2010 11:54:28 -0500
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <[email protected]> |
Hi, Python has made some minor improvements to expat. Would it make sense to merge any of their changes? See the attached diff. Note that a lot of the differences (i.e. using characters instead of defines and losing support for large files) are because they have version 2.0.0 of expat. I'm not sure if any of the other changes would be useful. Best wishes, Mike _______________________________________________ Expat-discuss mailing list [email protected] http://mail.libexpat.org/mailman/listinfo/expat-discuss
python-expat.diff
(text/x-diff, 26.1 KB)
diff -ur expat-2.0.1/lib/amigaconfig.h python2.6-2.6.4/Modules/expat/amigaconfig.h --- expat-2.0.1/lib/amigaconfig.h 2007-06-03 10:57:04.000000000 -0400 +++ python2.6-2.6.4/Modules/expat/amigaconfig.h 2006-06-19 19:21:25.000000000 -0400 @@ -10,12 +10,66 @@ /* Define to 1 if you have the <check.h> header file. */ #undef HAVE_CHECK_H +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + /* Define to 1 if you have the `memmove' function. */ #define HAVE_MEMMOVE 1 +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "[email protected]" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "expat" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "expat 1.95.8" + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.95.8" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + /* whether byteorder is bigendian */ #define WORDS_BIGENDIAN @@ -29,4 +83,14 @@ /* Define to make XML Namespaces functionality available. */ #define XML_NS +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `long' if <sys/types.h> does not define. */ +#undef off_t + +/* Define to `unsigned' if <sys/types.h> does not define. */ +#undef size_t + + #endif /* AMIGACONFIG_H */ diff -ur expat-2.0.1/lib/ascii.h python2.6-2.6.4/Modules/expat/ascii.h --- expat-2.0.1/lib/ascii.h 2007-05-07 22:25:35.000000000 -0400 +++ python2.6-2.6.4/Modules/expat/ascii.h 2003-01-25 17:41:29.000000000 -0500 @@ -83,10 +83,3 @@ #define ASCII_LSQB 0x5B #define ASCII_RSQB 0x5D #define ASCII_UNDERSCORE 0x5F -#define ASCII_LPAREN 0x28 -#define ASCII_RPAREN 0x29 -#define ASCII_FF 0x0C -#define ASCII_SLASH 0x2F -#define ASCII_HASH 0x23 -#define ASCII_PIPE 0x7C -#define ASCII_COMMA 0x2C Only in python2.6-2.6.4/Modules/expat/: expat_config.h Only in expat-2.0.1/lib/: expat.dsp diff -ur expat-2.0.1/lib/expat_external.h python2.6-2.6.4/Modules/expat/expat_external.h --- expat-2.0.1/lib/expat_external.h 2006-06-02 08:17:36.000000000 -0400 +++ python2.6-2.6.4/Modules/expat/expat_external.h 2006-06-19 19:57:41.000000000 -0400 @@ -7,6 +7,10 @@ /* 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 @@ -34,9 +38,9 @@ system headers may assume the cdecl convention. */ #ifndef XMLCALL -#if defined(_MSC_VER) +#if defined(XML_USE_MSC_EXTENSIONS) #define XMLCALL __cdecl -#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) +#elif defined(__GNUC__) && defined(__i386) #define XMLCALL __attribute__((cdecl)) #else /* For any platform which uses this definition and supports more than diff -ur expat-2.0.1/lib/expat.h python2.6-2.6.4/Modules/expat/expat.h --- expat-2.0.1/lib/expat.h 2006-11-26 21:51:58.000000000 -0500 +++ python2.6-2.6.4/Modules/expat/expat.h 2006-06-19 19:21:25.000000000 -0400 @@ -983,8 +983,7 @@ XML_FEATURE_MIN_SIZE, XML_FEATURE_SIZEOF_XML_CHAR, XML_FEATURE_SIZEOF_XML_LCHAR, - XML_FEATURE_NS, - XML_FEATURE_LARGE_SIZE + XML_FEATURE_NS /* Additional features must be added to the end of this enum. */ }; @@ -1005,7 +1004,7 @@ */ #define XML_MAJOR_VERSION 2 #define XML_MINOR_VERSION 0 -#define XML_MICRO_VERSION 1 +#define XML_MICRO_VERSION 0 #ifdef __cplusplus } Only in expat-2.0.1/lib/: expat_static.dsp Only in expat-2.0.1/lib/: expatw.dsp Only in expat-2.0.1/lib/: expatw_static.dsp diff -ur expat-2.0.1/lib/internal.h python2.6-2.6.4/Modules/expat/internal.h --- expat-2.0.1/lib/internal.h 2006-11-26 12:35:37.000000000 -0500 +++ python2.6-2.6.4/Modules/expat/internal.h 2003-10-21 11:38:55.000000000 -0400 @@ -20,7 +20,7 @@ and therefore subject to change. */ -#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) +#if defined(__GNUC__) && defined(__i386__) /* We'll use this version by default only where we know it helps. regparm() generates warnings on Solaris boxes. See SF bug #692878. Only in expat-2.0.1/lib/: libexpat.def Only in expat-2.0.1/lib/: libexpatw.def Only in expat-2.0.1/lib/: Makefile.MPW Only in python2.6-2.6.4/Modules/expat/: pyexpatns.h diff -ur expat-2.0.1/lib/xmlparse.c python2.6-2.6.4/Modules/expat/xmlparse.c --- expat-2.0.1/lib/xmlparse.c 2007-05-07 22:25:35.000000000 -0400 +++ python2.6-2.6.4/Modules/expat/xmlparse.c 2006-08-13 14:12:26.000000000 -0400 @@ -2,10 +2,6 @@ See the file COPYING for copying permission. */ -#include <stddef.h> -#include <string.h> /* memset(), memcpy() */ -#include <assert.h> - #define XML_BUILDING_EXPAT 1 #ifdef COMPILED_FROM_DSP @@ -14,13 +10,14 @@ #include "macconfig.h" #elif defined(__amigaos4__) #include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" #elif defined(HAVE_EXPAT_CONFIG_H) #include <expat_config.h> #endif /* ndef COMPILED_FROM_DSP */ -#include "ascii.h" +#include <stddef.h> +#include <string.h> /* memset(), memcpy() */ +#include <assert.h> + #include "expat.h" #ifdef XML_UNICODE @@ -29,8 +26,7 @@ #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS #define XmlEncode XmlUtf16Encode -/* Using pointer subtraction to convert to integer type. */ -#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) +#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) typedef unsigned short ICHAR; #else #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX @@ -669,12 +665,10 @@ } static const XML_Char implicitContext[] = { - ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p, - ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, - ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, - ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, - ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, - ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0' + 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' }; XML_Parser XMLCALL @@ -767,7 +761,7 @@ unknownEncodingHandler = NULL; unknownEncodingHandlerData = NULL; - namespaceSeparator = ASCII_EXCL; + namespaceSeparator = '!'; ns = XML_FALSE; ns_triplets = XML_FALSE; @@ -1954,9 +1948,6 @@ #ifdef XML_NS {XML_FEATURE_NS, XML_L("XML_NS"), 0}, #endif -#ifdef XML_LARGE_SIZE - {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, -#endif {XML_FEATURE_END, NULL, 0} }; @@ -2550,30 +2541,27 @@ } *nextPtr = end; return XML_ERROR_NONE; - case XML_TOK_DATA_CHARS: - { - XML_CharacterDataHandler charDataHandler = characterDataHandler; - if (charDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - charDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; - } + case XML_TOK_DATA_CHARS: + if (characterDataHandler) { + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; + XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = s; + characterDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); + if (s == next) + break; + *eventPP = s; } - else - charDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); } - else if (defaultHandler) - reportDefault(parser, enc, s, next); + else + characterDataHandler(handlerArg, + (XML_Char *)s, + (int)((XML_Char *)next - (XML_Char *)s)); } + else if (defaultHandler) + reportDefault(parser, enc, s, next); break; case XML_TOK_PI: if (!reportProcessingInstruction(parser, enc, s, next)) @@ -2807,6 +2795,8 @@ unsigned long uriHash = 0; ((XML_Char *)s)[-1] = 0; /* clear flag */ id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); + if (!id) + return XML_ERROR_NO_MEMORY; b = id->prefix->binding; if (!b) return XML_ERROR_UNBOUND_PREFIX; @@ -2818,7 +2808,7 @@ return XML_ERROR_NO_MEMORY; uriHash = CHAR_HASH(uriHash, c); } - while (*s++ != XML_T(ASCII_COLON)) + while (*s++ != XML_T(':')) ; do { /* copies null terminator */ const XML_Char c = *s; @@ -2892,7 +2882,7 @@ if (!binding) return XML_ERROR_UNBOUND_PREFIX; localPart = tagNamePtr->str; - while (*localPart++ != XML_T(ASCII_COLON)) + while (*localPart++ != XML_T(':')) ; } else if (dtd->defaultPrefix.binding) { @@ -2947,21 +2937,17 @@ const XML_Char *uri, BINDING **bindingsPtr) { static const XML_Char xmlNamespace[] = { - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, - ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH, - ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, - ASCII_e, '\0' + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' }; static const int xmlLen = (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; static const XML_Char xmlnsNamespace[] = { - ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, - ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, - ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, - ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, - ASCII_SLASH, '\0' + 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' }; static const int xmlnsLen = (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; @@ -2978,13 +2964,13 @@ return XML_ERROR_UNDECLARING_PREFIX; if (prefix->name - && prefix->name[0] == XML_T(ASCII_x) - && prefix->name[1] == XML_T(ASCII_m) - && prefix->name[2] == XML_T(ASCII_l)) { + && prefix->name[0] == XML_T('x') + && prefix->name[1] == XML_T('m') + && prefix->name[2] == XML_T('l')) { /* Not allowed to bind xmlns */ - if (prefix->name[3] == XML_T(ASCII_n) - && prefix->name[4] == XML_T(ASCII_s) + if (prefix->name[3] == XML_T('n') + && prefix->name[4] == XML_T('s') && prefix->name[5] == XML_T('\0')) return XML_ERROR_RESERVED_PREFIX_XMLNS; @@ -3138,29 +3124,26 @@ reportDefault(parser, enc, s, next); break; case XML_TOK_DATA_CHARS: - { - XML_CharacterDataHandler charDataHandler = characterDataHandler; - if (charDataHandler) { - if (MUST_CONVERT(enc, s)) { - for (;;) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = next; - charDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; - } + if (characterDataHandler) { + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; + XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = next; + characterDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); + if (s == next) + break; + *eventPP = s; } - else - charDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); } - else if (defaultHandler) - reportDefault(parser, enc, s, next); + else + characterDataHandler(handlerArg, + (XML_Char *)s, + (int)((XML_Char *)next - (XML_Char *)s)); } + else if (defaultHandler) + reportDefault(parser, enc, s, next); break; case XML_TOK_INVALID: *eventPP = next; @@ -3647,27 +3630,23 @@ XML_Bool haveMore) { #ifdef XML_DTD - static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' }; + static const XML_Char externalSubsetName[] = { '#' , '\0' }; #endif /* XML_DTD */ - static const XML_Char atypeCDATA[] = - { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; - static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' }; - static const XML_Char atypeIDREF[] = - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; - static const XML_Char atypeIDREFS[] = - { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; - static const XML_Char atypeENTITY[] = - { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; - static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N, - ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; + static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' }; + static const XML_Char atypeID[] = { 'I', 'D', '\0' }; + static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; + static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; + static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; + static const XML_Char atypeENTITIES[] = + { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; static const XML_Char atypeNMTOKEN[] = { - ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; - static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, - ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; - static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T, - ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' }; - static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' }; - static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; + 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; + static const XML_Char atypeNMTOKENS[] = { + 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; + static const XML_Char notationPrefix[] = { + 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; + static const XML_Char enumValueSep[] = { '|', '\0' }; + static const XML_Char enumValueStart[] = { '(', '\0' }; /* save one level of indirection */ DTD * const dtd = _dtd; @@ -3973,11 +3952,11 @@ 0, parser)) return XML_ERROR_NO_MEMORY; if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T(ASCII_LPAREN) - || (*declAttributeType == XML_T(ASCII_N) - && declAttributeType[1] == XML_T(ASCII_O))) { + if (*declAttributeType == XML_T('(') + || (*declAttributeType == XML_T('N') + && declAttributeType[1] == XML_T('O'))) { /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) + if (!poolAppendChar(&tempPool, XML_T(')')) || !poolAppendChar(&tempPool, XML_T('\0'))) return XML_ERROR_NO_MEMORY; declAttributeType = tempPool.start; @@ -4010,11 +3989,11 @@ declAttributeIsCdata, XML_FALSE, attVal, parser)) return XML_ERROR_NO_MEMORY; if (attlistDeclHandler && declAttributeType) { - if (*declAttributeType == XML_T(ASCII_LPAREN) - || (*declAttributeType == XML_T(ASCII_N) - && declAttributeType[1] == XML_T(ASCII_O))) { + if (*declAttributeType == XML_T('(') + || (*declAttributeType == XML_T('N') + && declAttributeType[1] == XML_T('O'))) { /* Enumerated or Notation type */ - if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) + if (!poolAppendChar(&tempPool, XML_T(')')) || !poolAppendChar(&tempPool, XML_T('\0'))) return XML_ERROR_NO_MEMORY; declAttributeType = tempPool.start; @@ -4341,14 +4320,14 @@ } break; case XML_ROLE_GROUP_SEQUENCE: - if (groupConnector[prologState.level] == ASCII_PIPE) + if (groupConnector[prologState.level] == '|') return XML_ERROR_SYNTAX; - groupConnector[prologState.level] = ASCII_COMMA; + groupConnector[prologState.level] = ','; if (dtd->in_eldecl && elementDeclHandler) handleDefault = XML_FALSE; break; case XML_ROLE_GROUP_CHOICE: - if (groupConnector[prologState.level] == ASCII_COMMA) + if (groupConnector[prologState.level] == ',') return XML_ERROR_SYNTAX; if (dtd->in_eldecl && !groupConnector[prologState.level] @@ -4360,7 +4339,7 @@ if (elementDeclHandler) handleDefault = XML_FALSE; } - groupConnector[prologState.level] = ASCII_PIPE; + groupConnector[prologState.level] = '|'; break; case XML_ROLE_PARAM_ENTITY_REF: #ifdef XML_DTD @@ -5290,7 +5269,7 @@ DTD * const dtd = _dtd; /* save one level of indirection */ const XML_Char *name; for (name = elementType->name; *name; name++) { - if (*name == XML_T(ASCII_COLON)) { + if (*name == XML_T(':')) { PREFIX *prefix; const XML_Char *s; for (s = elementType->name; s != name; s++) { @@ -5337,12 +5316,12 @@ poolFinish(&dtd->pool); if (!ns) ; - else if (name[0] == XML_T(ASCII_x) - && name[1] == XML_T(ASCII_m) - && name[2] == XML_T(ASCII_l) - && name[3] == XML_T(ASCII_n) - && name[4] == XML_T(ASCII_s) - && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { + else if (name[0] == XML_T('x') + && name[1] == XML_T('m') + && name[2] == XML_T('l') + && name[3] == XML_T('n') + && name[4] == XML_T('s') + && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { if (name[5] == XML_T('\0')) id->prefix = &dtd->defaultPrefix; else @@ -5353,7 +5332,7 @@ int i; for (i = 0; name[i]; i++) { /* attributes without prefix are *not* in the default namespace */ - if (name[i] == XML_T(ASCII_COLON)) { + if (name[i] == XML_T(':')) { int j; for (j = 0; j < i; j++) { if (!poolAppendChar(&dtd->pool, name[j])) @@ -5363,6 +5342,8 @@ return NULL; id->prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), sizeof(PREFIX)); + if (!id->prefix) + return NULL; if (id->prefix->name == poolStart(&dtd->pool)) poolFinish(&dtd->pool); else @@ -5375,7 +5356,7 @@ return id; } -#define CONTEXT_SEP XML_T(ASCII_FF) +#define CONTEXT_SEP XML_T('\f') static const XML_Char * getContext(XML_Parser parser) @@ -5387,7 +5368,7 @@ if (dtd->defaultPrefix.binding) { int i; int len; - if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) + if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; len = dtd->defaultPrefix.binding->uriLen; if (namespaceSeparator) @@ -5413,7 +5394,7 @@ for (s = prefix->name; *s; s++) if (!poolAppendChar(&tempPool, *s)) return NULL; - if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) + if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; len = prefix->binding->uriLen; if (namespaceSeparator) @@ -5465,7 +5446,7 @@ context = s; poolDiscard(&tempPool); } - else if (*s == XML_T(ASCII_EQUALS)) { + else if (*s == XML_T('=')) { PREFIX *prefix; if (poolLength(&tempPool) == 0) prefix = &dtd->defaultPrefix; diff -ur expat-2.0.1/lib/xmlrole.c python2.6-2.6.4/Modules/expat/xmlrole.c --- expat-2.0.1/lib/xmlrole.c 2006-08-05 13:00:31.000000000 -0400 +++ python2.6-2.6.4/Modules/expat/xmlrole.c 2006-06-19 19:21:25.000000000 -0400 @@ -2,22 +2,20 @@ See the file COPYING for copying permission. */ -#include <stddef.h> - #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" #elif defined(__amigaos4__) #include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" #else #ifdef HAVE_EXPAT_CONFIG_H #include <expat_config.h> #endif #endif /* ndef COMPILED_FROM_DSP */ +#include <stddef.h> + #include "expat_external.h" #include "internal.h" #include "xmlrole.h" @@ -55,16 +53,12 @@ ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; -#ifdef XML_DTD static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; -#endif static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; -#ifdef XML_DTD static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; -#endif static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; static const char KW_NMTOKEN[] = { diff -ur expat-2.0.1/lib/xmltok.c python2.6-2.6.4/Modules/expat/xmltok.c --- expat-2.0.1/lib/xmltok.c 2006-11-26 12:34:46.000000000 -0500 +++ python2.6-2.6.4/Modules/expat/xmltok.c 2006-06-19 19:21:25.000000000 -0400 @@ -2,22 +2,20 @@ See the file COPYING for copying permission. */ -#include <stddef.h> - #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" #elif defined(__amigaos4__) #include "amigaconfig.h" -#elif defined(__WATCOMC__) -#include "watcomconfig.h" #else #ifdef HAVE_EXPAT_CONFIG_H #include <expat_config.h> #endif #endif /* ndef COMPILED_FROM_DSP */ +#include <stddef.h> + #include "expat_external.h" #include "internal.h" #include "xmltok.h" @@ -297,9 +295,7 @@ #endif #define PREFIX(ident) normal_ ## ident -#define XML_TOK_IMPL_C #include "xmltok_impl.c" -#undef XML_TOK_IMPL_C #undef MINBPC #undef BYTE_TYPE @@ -696,9 +692,7 @@ #define IS_NMSTRT_CHAR(enc, p, n) (0) #define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) -#define XML_TOK_IMPL_C #include "xmltok_impl.c" -#undef XML_TOK_IMPL_C #undef MINBPC #undef BYTE_TYPE @@ -837,9 +831,7 @@ #define IS_NMSTRT_CHAR(enc, p, n) (0) #define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) -#define XML_TOK_IMPL_C #include "xmltok_impl.c" -#undef XML_TOK_IMPL_C #undef MINBPC #undef BYTE_TYPE @@ -1618,9 +1610,7 @@ #define NS(x) x #define ns(x) x -#define XML_TOK_NS_C #include "xmltok_ns.c" -#undef XML_TOK_NS_C #undef NS #undef ns @@ -1629,9 +1619,7 @@ #define NS(x) x ## NS #define ns(x) x ## _ns -#define XML_TOK_NS_C #include "xmltok_ns.c" -#undef XML_TOK_NS_C #undef NS #undef ns diff -ur expat-2.0.1/lib/xmltok_impl.c python2.6-2.6.4/Modules/expat/xmltok_impl.c --- expat-2.0.1/lib/xmltok_impl.c 2006-11-26 12:34:46.000000000 -0500 +++ python2.6-2.6.4/Modules/expat/xmltok_impl.c 2009-08-13 15:45:44.000000000 -0400 @@ -2,9 +2,6 @@ See the file COPYING for copying permission. */ -/* This file is included! */ -#ifdef XML_TOK_IMPL_C - #ifndef IS_INVALID_CHAR #define IS_INVALID_CHAR(enc, ptr, n) (0) #endif @@ -1744,7 +1741,7 @@ const char *end, POSITION *pos) { - while (ptr != end) { + while (ptr < end) { switch (BYTE_TYPE(enc, ptr)) { #define LEAD_CASE(n) \ case BT_LEAD ## n: \ @@ -1780,4 +1777,3 @@ #undef CHECK_NMSTRT_CASE #undef CHECK_NMSTRT_CASES -#endif /* XML_TOK_IMPL_C */ diff -ur expat-2.0.1/lib/xmltok_ns.c python2.6-2.6.4/Modules/expat/xmltok_ns.c --- expat-2.0.1/lib/xmltok_ns.c 2006-11-26 12:34:46.000000000 -0500 +++ python2.6-2.6.4/Modules/expat/xmltok_ns.c 2006-06-19 19:21:25.000000000 -0400 @@ -1,10 +1,3 @@ -/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd - See the file COPYING for copying permission. -*/ - -/* This file is included! */ -#ifdef XML_TOK_NS_C - const ENCODING * NS(XmlGetUtf8InternalEncoding)(void) { @@ -111,5 +104,3 @@ encoding, standalone); } - -#endif /* XML_TOK_NS_C */