Changeset 388 for python/vendor/current/Modules/expat
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- Location:
- python/vendor/current/Modules/expat
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Modules/expat/amigaconfig.h
r2 r388 11 11 #undef HAVE_CHECK_H 12 12 13 /* Define to 1 if you have the <dlfcn.h> header file. */14 #undef HAVE_DLFCN_H15 16 /* Define to 1 if you have the <fcntl.h> header file. */17 #define HAVE_FCNTL_H 118 19 /* Define to 1 if you have the `getpagesize' function. */20 #undef HAVE_GETPAGESIZE21 22 /* Define to 1 if you have the <inttypes.h> header file. */23 #define HAVE_INTTYPES_H 124 25 13 /* Define to 1 if you have the `memmove' function. */ 26 14 #define HAVE_MEMMOVE 1 27 15 28 /* Define to 1 if you have the <memory.h> header file. */29 #undef HAVE_MEMORY_H30 31 /* Define to 1 if you have a working `mmap' system call. */32 #undef HAVE_MMAP33 34 /* Define to 1 if you have the <stdint.h> header file. */35 #define HAVE_STDINT_H 136 37 /* Define to 1 if you have the <stdlib.h> header file. */38 #define HAVE_STDLIB_H 139 40 /* Define to 1 if you have the <strings.h> header file. */41 #define HAVE_STRINGS_H 142 43 /* Define to 1 if you have the <string.h> header file. */44 #define HAVE_STRING_H 145 46 /* Define to 1 if you have the <sys/stat.h> header file. */47 #define HAVE_SYS_STAT_H 148 49 /* Define to 1 if you have the <sys/types.h> header file. */50 #define HAVE_SYS_TYPES_H 151 52 16 /* Define to 1 if you have the <unistd.h> header file. */ 53 17 #define HAVE_UNISTD_H 1 54 55 /* Define to the address where bug reports for this package should be sent. */56 #define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org"57 58 /* Define to the full name of this package. */59 #define PACKAGE_NAME "expat"60 61 /* Define to the full name and version of this package. */62 #define PACKAGE_STRING "expat 1.95.8"63 64 /* Define to the one symbol short name of this package. */65 #undef PACKAGE_TARNAME66 67 /* Define to the version of this package. */68 #define PACKAGE_VERSION "1.95.8"69 70 /* Define to 1 if you have the ANSI C header files. */71 #define STDC_HEADERS 172 18 73 19 /* whether byteorder is bigendian */ … … 84 30 #define XML_NS 85 31 86 /* Define to empty if `const' does not conform to ANSI C. */87 #undef const88 89 /* Define to `long' if <sys/types.h> does not define. */90 #undef off_t91 92 /* Define to `unsigned' if <sys/types.h> does not define. */93 #undef size_t94 95 96 32 #endif /* AMIGACONFIG_H */ -
python/vendor/current/Modules/expat/ascii.h
r2 r388 84 84 #define ASCII_RSQB 0x5D 85 85 #define ASCII_UNDERSCORE 0x5F 86 #define ASCII_LPAREN 0x28 87 #define ASCII_RPAREN 0x29 88 #define ASCII_FF 0x0C 89 #define ASCII_SLASH 0x2F 90 #define ASCII_HASH 0x23 91 #define ASCII_PIPE 0x7C 92 #define ASCII_COMMA 0x2C -
python/vendor/current/Modules/expat/expat.h
r2 r388 743 743 XML_GetIdAttributeIndex(XML_Parser parser); 744 744 745 #ifdef XML_ATTR_INFO 746 /* Source file byte offsets for the start and end of attribute names and values. 747 The value indices are exclusive of surrounding quotes; thus in a UTF-8 source 748 file an attribute value of "blah" will yield: 749 info->valueEnd - info->valueStart = 4 bytes. 750 */ 751 typedef struct { 752 XML_Index nameStart; /* Offset to beginning of the attribute name. */ 753 XML_Index nameEnd; /* Offset after the attribute name's last byte. */ 754 XML_Index valueStart; /* Offset to beginning of the attribute value. */ 755 XML_Index valueEnd; /* Offset after the attribute value's last byte. */ 756 } XML_AttrInfo; 757 758 /* Returns an array of XML_AttrInfo structures for the attribute/value pairs 759 passed in last call to the XML_StartElementHandler that were specified 760 in the start-tag rather than defaulted. Each attribute/value pair counts 761 as 1; thus the number of entries in the array is 762 XML_GetSpecifiedAttributeCount(parser) / 2. 763 */ 764 XMLPARSEAPI(const XML_AttrInfo *) 765 XML_GetAttributeInfo(XML_Parser parser); 766 #endif 767 745 768 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is 746 769 detected. The last call to XML_Parse must have isFinal true; len … … 884 907 enum XML_ParamEntityParsing parsing); 885 908 909 /* Sets the hash salt to use for internal hash calculations. 910 Helps in preventing DoS attacks based on predicting hash 911 function behavior. This must be called before parsing is started. 912 Returns 1 if successful, 0 when called after parsing has started. 913 */ 914 XMLPARSEAPI(int) 915 XML_SetHashSalt(XML_Parser parser, 916 unsigned long hash_salt); 917 918 #define XML_HAS_SET_HASH_SALT /* Python Only: Defined for pyexpat.c. */ 919 886 920 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then 887 921 XML_GetErrorCode returns information about the error. … … 984 1018 XML_FEATURE_SIZEOF_XML_CHAR, 985 1019 XML_FEATURE_SIZEOF_XML_LCHAR, 986 XML_FEATURE_NS 1020 XML_FEATURE_NS, 1021 XML_FEATURE_LARGE_SIZE, 1022 XML_FEATURE_ATTR_INFO 987 1023 /* Additional features must be added to the end of this enum. */ 988 1024 }; … … 1004 1040 */ 1005 1041 #define XML_MAJOR_VERSION 2 1006 #define XML_MINOR_VERSION 01042 #define XML_MINOR_VERSION 1 1007 1043 #define XML_MICRO_VERSION 0 1008 1044 -
python/vendor/current/Modules/expat/expat_external.h
r2 r388 39 39 */ 40 40 #ifndef XMLCALL 41 #if defined( XML_USE_MSC_EXTENSIONS)41 #if defined(_MSC_VER) 42 42 #define XMLCALL __cdecl 43 #elif defined(__GNUC__) && defined(__i386) 43 #elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) 44 44 #define XMLCALL __attribute__((cdecl)) 45 45 #else -
python/vendor/current/Modules/expat/internal.h
r2 r388 21 21 */ 22 22 23 #if defined(__GNUC__) && defined(__i386__) 23 #if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) 24 24 /* We'll use this version by default only where we know it helps. 25 25 -
python/vendor/current/Modules/expat/pyexpatns.h
r2 r388 98 98 #define XML_SetExternalEntityRefHandler PyExpat_XML_SetExternalEntityRefHandler 99 99 #define XML_SetExternalEntityRefHandlerArg PyExpat_XML_SetExternalEntityRefHandlerArg 100 #define XML_SetHashSalt PyExpat_XML_SetHashSalt 100 101 #define XML_SetNamespaceDeclHandler PyExpat_XML_SetNamespaceDeclHandler 101 102 #define XML_SetNotationDeclHandler PyExpat_XML_SetNotationDeclHandler -
python/vendor/current/Modules/expat/xmlparse.c
r2 r388 2 2 See the file COPYING for copying permission. 3 3 */ 4 5 #include <stddef.h> 6 #include <string.h> /* memset(), memcpy() */ 7 #include <assert.h> 8 #include <limits.h> /* UINT_MAX */ 9 #include <time.h> /* time() */ 4 10 5 11 #define XML_BUILDING_EXPAT 1 … … 9 15 #elif defined(MACOS_CLASSIC) 10 16 #include "macconfig.h" 11 #elif defined(__amigaos 4__)17 #elif defined(__amigaos__) 12 18 #include "amigaconfig.h" 19 #elif defined(__WATCOMC__) 20 #include "watcomconfig.h" 13 21 #elif defined(HAVE_EXPAT_CONFIG_H) 14 22 #include <expat_config.h> 15 23 #endif /* ndef COMPILED_FROM_DSP */ 16 24 17 #include <stddef.h> 18 #include <string.h> /* memset(), memcpy() */ 19 #include <assert.h> 20 25 #include "ascii.h" 21 26 #include "expat.h" 22 27 … … 27 32 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS 28 33 #define XmlEncode XmlUtf16Encode 29 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) 34 /* Using pointer subtraction to convert to integer type. */ 35 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) 30 36 typedef unsigned short ICHAR; 31 37 #else … … 324 330 initializeEncoding(XML_Parser parser); 325 331 static enum XML_Error 326 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, 327 const char *end, int tok, const char *next, const char **nextPtr, 332 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, 333 const char *end, int tok, const char *next, const char **nextPtr, 328 334 XML_Bool haveMore); 329 335 static enum XML_Error 330 processInternalEntity(XML_Parser parser, ENTITY *entity, 336 processInternalEntity(XML_Parser parser, ENTITY *entity, 331 337 XML_Bool betweenDecl); 332 338 static enum XML_Error 333 339 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, 334 const char *start, const char *end, const char **endPtr, 340 const char *start, const char *end, const char **endPtr, 335 341 XML_Bool haveMore); 336 342 static enum XML_Error … … 350 356 const XML_Char *uri, BINDING **bindingsPtr); 351 357 static int 352 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, 358 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, 353 359 XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); 354 360 static enum XML_Error … … 388 394 dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); 389 395 static int 390 dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); 396 dtdCopy(XML_Parser oldParser, 397 DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); 391 398 static int 392 copyEntityTable( HASH_TABLE *, STRING_POOL *, const HASH_TABLE *);393 399 copyEntityTable(XML_Parser oldParser, 400 HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); 394 401 static NAMED * 395 lookup( HASH_TABLE *table, KEY name, size_t createSize);402 lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize); 396 403 static void FASTCALL 397 404 hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); … … 426 433 const char *ptr, const char *end); 427 434 435 static unsigned long generate_hash_secret_salt(void); 436 static XML_Bool startParsing(XML_Parser parser); 437 428 438 static XML_Parser 429 439 parserCreate(const XML_Char *encodingName, … … 431 441 const XML_Char *nameSep, 432 442 DTD *dtd); 443 433 444 static void 434 445 parserInit(XML_Parser parser, const XML_Char *encodingName); … … 530 541 unsigned long m_nsAttsVersion; 531 542 unsigned char m_nsAttsPower; 543 #ifdef XML_ATTR_INFO 544 XML_AttrInfo *m_attInfo; 545 #endif 532 546 POSITION m_position; 533 547 STRING_POOL m_tempPool; … … 543 557 enum XML_ParamEntityParsing m_paramEntityParsing; 544 558 #endif 559 unsigned long m_hash_secret_salt; 545 560 }; 546 561 … … 637 652 #define nsAttsVersion (parser->m_nsAttsVersion) 638 653 #define nsAttsPower (parser->m_nsAttsPower) 654 #define attInfo (parser->m_attInfo) 639 655 #define tempPool (parser->m_tempPool) 640 656 #define temp2Pool (parser->m_temp2Pool) … … 650 666 #define paramEntityParsing (parser->m_paramEntityParsing) 651 667 #endif /* XML_DTD */ 668 #define hash_secret_salt (parser->m_hash_secret_salt) 652 669 653 670 XML_Parser XMLCALL … … 666 683 667 684 static const XML_Char implicitContext[] = { 668 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', 669 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', 670 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', 671 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' 685 ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p, 686 ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, 687 ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, 688 ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, 689 ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, 690 ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0' 672 691 }; 692 693 static unsigned long 694 generate_hash_secret_salt(void) 695 { 696 unsigned int seed = time(NULL) % UINT_MAX; 697 srand(seed); 698 return rand(); 699 } 700 701 static XML_Bool /* only valid for root parser */ 702 startParsing(XML_Parser parser) 703 { 704 /* hash functions must be initialized before setContext() is called */ 705 if (hash_secret_salt == 0) 706 hash_secret_salt = generate_hash_secret_salt(); 707 if (ns) { 708 /* implicit context only set for root parser, since child 709 parsers (i.e. external entity parsers) will inherit it 710 */ 711 return setContext(parser, implicitContext); 712 } 713 return XML_TRUE; 714 } 673 715 674 716 XML_Parser XMLCALL … … 677 719 const XML_Char *nameSep) 678 720 { 679 XML_Parser parser = parserCreate(encodingName, memsuite, nameSep, NULL); 680 if (parser != NULL && ns) { 681 /* implicit context only set for root parser, since child 682 parsers (i.e. external entity parsers) will inherit it 683 */ 684 if (!setContext(parser, implicitContext)) { 685 XML_ParserFree(parser); 686 return NULL; 687 } 688 } 689 return parser; 721 return parserCreate(encodingName, memsuite, nameSep, NULL); 690 722 } 691 723 … … 732 764 return NULL; 733 765 } 766 #ifdef XML_ATTR_INFO 767 attInfo = (XML_AttrInfo*)MALLOC(attsSize * sizeof(XML_AttrInfo)); 768 if (attInfo == NULL) { 769 FREE(atts); 770 FREE(parser); 771 return NULL; 772 } 773 #endif 734 774 dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); 735 775 if (dataBuf == NULL) { 736 776 FREE(atts); 777 #ifdef XML_ATTR_INFO 778 FREE(attInfo); 779 #endif 737 780 FREE(parser); 738 781 return NULL; … … 747 790 FREE(dataBuf); 748 791 FREE(atts); 792 #ifdef XML_ATTR_INFO 793 FREE(attInfo); 794 #endif 749 795 FREE(parser); 750 796 return NULL; … … 762 808 unknownEncodingHandlerData = NULL; 763 809 764 namespaceSeparator = '!';810 namespaceSeparator = ASCII_EXCL; 765 811 ns = XML_FALSE; 766 812 ns_triplets = XML_FALSE; … … 861 907 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; 862 908 #endif 909 hash_secret_salt = 0; 863 910 } 864 911 … … 908 955 parserInit(parser, encodingName); 909 956 dtdReset(_dtd, &parser->m_mem); 910 return setContext(parser, implicitContext);957 return XML_TRUE; 911 958 } 912 959 … … 977 1024 #endif 978 1025 XML_Bool oldns_triplets = ns_triplets; 1026 /* Note that the new parser shares the same hash secret as the old 1027 parser, so that dtdCopy and copyEntityTable can lookup values 1028 from hash tables associated with either parser without us having 1029 to worry which hash secrets each table has. 1030 */ 1031 unsigned long oldhash_secret_salt = hash_secret_salt; 979 1032 980 1033 #ifdef XML_DTD … … 1030 1083 defaultExpandInternalEntities = oldDefaultExpandInternalEntities; 1031 1084 ns_triplets = oldns_triplets; 1085 hash_secret_salt = oldhash_secret_salt; 1032 1086 parentParser = oldParser; 1033 1087 #ifdef XML_DTD … … 1036 1090 if (context) { 1037 1091 #endif /* XML_DTD */ 1038 if (!dtdCopy( _dtd, oldDtd, &parser->m_mem)1092 if (!dtdCopy(oldParser, _dtd, oldDtd, &parser->m_mem) 1039 1093 || !setContext(parser, context)) { 1040 1094 XML_ParserFree(parser); … … 1125 1179 dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); 1126 1180 FREE((void *)atts); 1181 #ifdef XML_ATTR_INFO 1182 FREE((void *)attInfo); 1183 #endif 1127 1184 FREE(groupConnector); 1128 1185 FREE(buffer); … … 1205 1262 } 1206 1263 1264 #ifdef XML_ATTR_INFO 1265 const XML_AttrInfo * XMLCALL 1266 XML_GetAttributeInfo(XML_Parser parser) 1267 { 1268 return attInfo; 1269 } 1270 #endif 1271 1207 1272 void XMLCALL 1208 1273 XML_SetElementHandler(XML_Parser parser, … … 1421 1486 } 1422 1487 1488 int XMLCALL 1489 XML_SetHashSalt(XML_Parser parser, 1490 unsigned long hash_salt) 1491 { 1492 /* block after XML_Parse()/XML_ParseBuffer() has been called */ 1493 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) 1494 return 0; 1495 hash_secret_salt = hash_salt; 1496 return 1; 1497 } 1498 1423 1499 enum XML_Status XMLCALL 1424 1500 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) … … 1431 1507 errorCode = XML_ERROR_FINISHED; 1432 1508 return XML_STATUS_ERROR; 1509 case XML_INITIALIZED: 1510 if (parentParser == NULL && !startParsing(parser)) { 1511 errorCode = XML_ERROR_NO_MEMORY; 1512 return XML_STATUS_ERROR; 1513 } 1433 1514 default: 1434 1515 ps_parsing = XML_PARSING; … … 1454 1535 positionPtr = bufferPtr; 1455 1536 return XML_STATUS_SUSPENDED; 1456 case XML_INITIALIZED: 1537 case XML_INITIALIZED: 1457 1538 case XML_PARSING: 1458 1539 ps_parsing = XML_FINISHED; … … 1489 1570 case XML_INITIALIZED: 1490 1571 case XML_PARSING: 1491 result = XML_STATUS_OK;1492 1572 if (isFinal) { 1493 1573 ps_parsing = XML_FINISHED; 1494 return result; 1495 } 1574 return XML_STATUS_OK; 1575 } 1576 /* fall through */ 1577 default: 1578 result = XML_STATUS_OK; 1496 1579 } 1497 1580 } … … 1508 1591 if (temp == NULL) { 1509 1592 errorCode = XML_ERROR_NO_MEMORY; 1510 return XML_STATUS_ERROR;1511 }1512 buffer = temp;1513 if (!buffer) {1514 errorCode = XML_ERROR_NO_MEMORY;1515 1593 eventPtr = eventEndPtr = NULL; 1516 1594 processor = errorProcessor; 1517 1595 return XML_STATUS_ERROR; 1518 1596 } 1597 buffer = temp; 1519 1598 bufferLim = buffer + len * 2; 1520 1599 } … … 1554 1633 errorCode = XML_ERROR_FINISHED; 1555 1634 return XML_STATUS_ERROR; 1635 case XML_INITIALIZED: 1636 if (parentParser == NULL && !startParsing(parser)) { 1637 errorCode = XML_ERROR_NO_MEMORY; 1638 return XML_STATUS_ERROR; 1639 } 1556 1640 default: 1557 1641 ps_parsing = XML_PARSING; … … 1577 1661 result = XML_STATUS_SUSPENDED; 1578 1662 break; 1579 case XML_INITIALIZED: 1663 case XML_INITIALIZED: 1580 1664 case XML_PARSING: 1581 1665 if (isFinal) { … … 1667 1751 #endif /* not defined XML_CONTEXT_BYTES */ 1668 1752 } 1753 eventPtr = eventEndPtr = NULL; 1754 positionPtr = NULL; 1669 1755 } 1670 1756 return bufferEnd; … … 1724 1810 result = XML_STATUS_SUSPENDED; 1725 1811 break; 1726 case XML_INITIALIZED: 1812 case XML_INITIALIZED: 1727 1813 case XML_PARSING: 1728 1814 if (ps_finalBuffer) { … … 1949 2035 {XML_FEATURE_NS, XML_L("XML_NS"), 0}, 1950 2036 #endif 2037 #ifdef XML_LARGE_SIZE 2038 {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, 2039 #endif 2040 #ifdef XML_ATTR_INFO 2041 {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0}, 2042 #endif 1951 2043 {XML_FEATURE_END, NULL, 0} 1952 2044 }; … … 2011 2103 const char **endPtr) 2012 2104 { 2013 enum XML_Error result = doContent(parser, 0, encoding, start, end, 2105 enum XML_Error result = doContent(parser, 0, encoding, start, end, 2014 2106 endPtr, (XML_Bool)!ps_finalBuffer); 2015 2107 if (result == XML_ERROR_NONE) { … … 2093 2185 return result; 2094 2186 switch (ps_parsing) { 2095 case XML_SUSPENDED: 2187 case XML_SUSPENDED: 2096 2188 *endPtr = next; 2097 2189 return XML_ERROR_NONE; … … 2127 2219 const char **endPtr) 2128 2220 { 2129 enum XML_Error result = doContent(parser, 1, encoding, start, end, 2221 enum XML_Error result = doContent(parser, 1, encoding, start, end, 2130 2222 endPtr, (XML_Bool)!ps_finalBuffer); 2131 2223 if (result == XML_ERROR_NONE) { … … 2146 2238 { 2147 2239 /* save one level of indirection */ 2148 DTD * const dtd = _dtd; 2240 DTD * const dtd = _dtd; 2149 2241 2150 2242 const char **eventPP; … … 2177 2269 else if (defaultHandler) 2178 2270 reportDefault(parser, enc, s, end); 2179 /* We are at the end of the final buffer, should we check for 2180 XML_SUSPENDED, XML_FINISHED? 2271 /* We are at the end of the final buffer, should we check for 2272 XML_SUSPENDED, XML_FINISHED? 2181 2273 */ 2182 2274 if (startTagLevel == 0) … … 2232 2324 if (!name) 2233 2325 return XML_ERROR_NO_MEMORY; 2234 entity = (ENTITY *)lookup( &dtd->generalEntities, name, 0);2326 entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); 2235 2327 poolDiscard(&dtd->pool); 2236 2328 /* First, determine if a check for an existing declaration is needed; … … 2529 2621 else if (defaultHandler) 2530 2622 reportDefault(parser, enc, s, end); 2531 /* We are at the end of the final buffer, should we check for 2532 XML_SUSPENDED, XML_FINISHED? 2623 /* We are at the end of the final buffer, should we check for 2624 XML_SUSPENDED, XML_FINISHED? 2533 2625 */ 2534 2626 if (startTagLevel == 0) { … … 2543 2635 return XML_ERROR_NONE; 2544 2636 case XML_TOK_DATA_CHARS: 2545 if (characterDataHandler) { 2546 if (MUST_CONVERT(enc, s)) { 2547 for (;;) { 2548 ICHAR *dataPtr = (ICHAR *)dataBuf; 2549 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); 2550 *eventEndPP = s; 2551 characterDataHandler(handlerArg, dataBuf, 2552 (int)(dataPtr - (ICHAR *)dataBuf)); 2553 if (s == next) 2554 break; 2555 *eventPP = s; 2637 { 2638 XML_CharacterDataHandler charDataHandler = characterDataHandler; 2639 if (charDataHandler) { 2640 if (MUST_CONVERT(enc, s)) { 2641 for (;;) { 2642 ICHAR *dataPtr = (ICHAR *)dataBuf; 2643 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); 2644 *eventEndPP = s; 2645 charDataHandler(handlerArg, dataBuf, 2646 (int)(dataPtr - (ICHAR *)dataBuf)); 2647 if (s == next) 2648 break; 2649 *eventPP = s; 2650 } 2556 2651 } 2557 }2558 else2559 characterDataHandler(handlerArg,2560 (XML_Char *)s,2561 (int)((XML_Char *)next - (XML_Char *)s));2562 }2563 else if (defaultHandler)2564 reportDefault(parser, enc, s, next);2652 else 2653 charDataHandler(handlerArg, 2654 (XML_Char *)s, 2655 (int)((XML_Char *)next - (XML_Char *)s)); 2656 } 2657 else if (defaultHandler) 2658 reportDefault(parser, enc, s, next); 2659 } 2565 2660 break; 2566 2661 case XML_TOK_PI: … … 2579 2674 *eventPP = s = next; 2580 2675 switch (ps_parsing) { 2581 case XML_SUSPENDED: 2676 case XML_SUSPENDED: 2582 2677 *nextPtr = next; 2583 2678 return XML_ERROR_NONE; … … 2619 2714 2620 2715 /* lookup the element type name */ 2621 elementType = (ELEMENT_TYPE *)lookup( &dtd->elementTypes, tagNamePtr->str,0);2716 elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str,0); 2622 2717 if (!elementType) { 2623 2718 const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); 2624 2719 if (!name) 2625 2720 return XML_ERROR_NO_MEMORY; 2626 elementType = (ELEMENT_TYPE *)lookup( &dtd->elementTypes, name,2721 elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name, 2627 2722 sizeof(ELEMENT_TYPE)); 2628 2723 if (!elementType) … … 2638 2733 int oldAttsSize = attsSize; 2639 2734 ATTRIBUTE *temp; 2735 #ifdef XML_ATTR_INFO 2736 XML_AttrInfo *temp2; 2737 #endif 2640 2738 attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; 2641 2739 temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); … … 2643 2741 return XML_ERROR_NO_MEMORY; 2644 2742 atts = temp; 2743 #ifdef XML_ATTR_INFO 2744 temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo)); 2745 if (temp2 == NULL) 2746 return XML_ERROR_NO_MEMORY; 2747 attInfo = temp2; 2748 #endif 2645 2749 if (n > oldAttsSize) 2646 2750 XmlGetAttributes(enc, attStr, n, atts); … … 2649 2753 appAtts = (const XML_Char **)atts; 2650 2754 for (i = 0; i < n; i++) { 2755 ATTRIBUTE *currAtt = &atts[i]; 2756 #ifdef XML_ATTR_INFO 2757 XML_AttrInfo *currAttInfo = &attInfo[i]; 2758 #endif 2651 2759 /* add the name and value to the attribute list */ 2652 ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name,2653 atts[i].name2654 + XmlNameLength(enc, atts[i].name));2760 ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, 2761 currAtt->name 2762 + XmlNameLength(enc, currAtt->name)); 2655 2763 if (!attId) 2656 2764 return XML_ERROR_NO_MEMORY; 2765 #ifdef XML_ATTR_INFO 2766 currAttInfo->nameStart = parseEndByteIndex - (parseEndPtr - currAtt->name); 2767 currAttInfo->nameEnd = currAttInfo->nameStart + 2768 XmlNameLength(enc, currAtt->name); 2769 currAttInfo->valueStart = parseEndByteIndex - 2770 (parseEndPtr - currAtt->valuePtr); 2771 currAttInfo->valueEnd = parseEndByteIndex - (parseEndPtr - currAtt->valueEnd); 2772 #endif 2657 2773 /* Detect duplicate attributes by their QNames. This does not work when 2658 2774 namespace processing is turned on and different prefixes for the same … … 2793 2909 ATTRIBUTE_ID *id; 2794 2910 const BINDING *b; 2795 unsigned long uriHash = 0;2911 unsigned long uriHash = hash_secret_salt; 2796 2912 ((XML_Char *)s)[-1] = 0; /* clear flag */ 2797 id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); 2798 if (!id) 2799 return XML_ERROR_NO_MEMORY; 2913 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); 2800 2914 b = id->prefix->binding; 2801 2915 if (!b) … … 2809 2923 uriHash = CHAR_HASH(uriHash, c); 2810 2924 } 2811 while (*s++ != XML_T( ':'))2925 while (*s++ != XML_T(ASCII_COLON)) 2812 2926 ; 2813 2927 do { /* copies null terminator */ … … 2819 2933 2820 2934 { /* Check hash table for duplicate of expanded name (uriName). 2821 Derived from code in lookup( HASH_TABLE *table, ...).2935 Derived from code in lookup(parser, HASH_TABLE *table, ...). 2822 2936 */ 2823 2937 unsigned char step = 0; … … 2883 2997 return XML_ERROR_UNBOUND_PREFIX; 2884 2998 localPart = tagNamePtr->str; 2885 while (*localPart++ != XML_T( ':'))2999 while (*localPart++ != XML_T(ASCII_COLON)) 2886 3000 ; 2887 3001 } … … 2938 3052 { 2939 3053 static const XML_Char xmlNamespace[] = { 2940 'h', 't', 't', 'p', ':', '/', '/', 2941 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', 2942 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', 2943 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' 3054 ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, 3055 ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, 3056 ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, 3057 ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH, 3058 ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, 3059 ASCII_e, '\0' 2944 3060 }; 2945 static const int xmlLen = 3061 static const int xmlLen = 2946 3062 (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; 2947 3063 static const XML_Char xmlnsNamespace[] = { 2948 'h', 't', 't', 'p', ':', '/', '/', 2949 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', 2950 '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' 3064 ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, 3065 ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, 3066 ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, 3067 ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, 3068 ASCII_SLASH, '\0' 2951 3069 }; 2952 static const int xmlnsLen = 3070 static const int xmlnsLen = 2953 3071 (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; 2954 3072 … … 2956 3074 XML_Bool isXML = XML_TRUE; 2957 3075 XML_Bool isXMLNS = XML_TRUE; 2958 3076 2959 3077 BINDING *b; 2960 3078 int len; … … 2965 3083 2966 3084 if (prefix->name 2967 && prefix->name[0] == XML_T( 'x')2968 && prefix->name[1] == XML_T( 'm')2969 && prefix->name[2] == XML_T( 'l')) {3085 && prefix->name[0] == XML_T(ASCII_x) 3086 && prefix->name[1] == XML_T(ASCII_m) 3087 && prefix->name[2] == XML_T(ASCII_l)) { 2970 3088 2971 3089 /* Not allowed to bind xmlns */ 2972 if (prefix->name[3] == XML_T( 'n')2973 && prefix->name[4] == XML_T( 's')3090 if (prefix->name[3] == XML_T(ASCII_n) 3091 && prefix->name[4] == XML_T(ASCII_s) 2974 3092 && prefix->name[5] == XML_T('\0')) 2975 3093 return XML_ERROR_RESERVED_PREFIX_XMLNS; … … 2983 3101 isXML = XML_FALSE; 2984 3102 2985 if (!mustBeXML && isXMLNS 3103 if (!mustBeXML && isXMLNS 2986 3104 && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) 2987 3105 isXMLNS = XML_FALSE; … … 3125 3243 break; 3126 3244 case XML_TOK_DATA_CHARS: 3127 if (characterDataHandler) { 3128 if (MUST_CONVERT(enc, s)) { 3129 for (;;) { 3130 ICHAR *dataPtr = (ICHAR *)dataBuf; 3131 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); 3132 *eventEndPP = next; 3133 characterDataHandler(handlerArg, dataBuf, 3134 (int)(dataPtr - (ICHAR *)dataBuf)); 3135 if (s == next) 3136 break; 3137 *eventPP = s; 3245 { 3246 XML_CharacterDataHandler charDataHandler = characterDataHandler; 3247 if (charDataHandler) { 3248 if (MUST_CONVERT(enc, s)) { 3249 for (;;) { 3250 ICHAR *dataPtr = (ICHAR *)dataBuf; 3251 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); 3252 *eventEndPP = next; 3253 charDataHandler(handlerArg, dataBuf, 3254 (int)(dataPtr - (ICHAR *)dataBuf)); 3255 if (s == next) 3256 break; 3257 *eventPP = s; 3258 } 3138 3259 } 3139 }3140 else3141 characterDataHandler(handlerArg,3142 (XML_Char *)s,3143 (int)((XML_Char *)next - (XML_Char *)s));3144 }3145 else if (defaultHandler)3146 reportDefault(parser, enc, s, next);3260 else 3261 charDataHandler(handlerArg, 3262 (XML_Char *)s, 3263 (int)((XML_Char *)next - (XML_Char *)s)); 3264 } 3265 else if (defaultHandler) 3266 reportDefault(parser, enc, s, next); 3267 } 3147 3268 break; 3148 3269 case XML_TOK_INVALID: … … 3191 3312 const char **endPtr) 3192 3313 { 3193 enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, 3314 enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, 3194 3315 endPtr, (XML_Bool)!ps_finalBuffer); 3195 3316 if (result != XML_ERROR_NONE) … … 3473 3594 eventPtr = start; 3474 3595 3475 for (;;) { 3596 for (;;) { 3476 3597 tok = XmlPrologTok(encoding, start, end, &next); 3477 3598 eventEndPtr = next; … … 3501 3622 return result; 3502 3623 switch (ps_parsing) { 3503 case XML_SUSPENDED: 3624 case XML_SUSPENDED: 3504 3625 *nextPtr = next; 3505 3626 return XML_ERROR_NONE; … … 3566 3687 3567 3688 processor = prologProcessor; 3568 return doProlog(parser, encoding, s, end, tok, next, 3689 return doProlog(parser, encoding, s, end, tok, next, 3569 3690 nextPtr, (XML_Bool)!ps_finalBuffer); 3570 3691 } … … 3616 3737 const char *next = s; 3617 3738 int tok = XmlPrologTok(encoding, s, end, &next); 3618 return doProlog(parser, encoding, s, end, tok, next, 3739 return doProlog(parser, encoding, s, end, tok, next, 3619 3740 nextPtr, (XML_Bool)!ps_finalBuffer); 3620 3741 } … … 3631 3752 { 3632 3753 #ifdef XML_DTD 3633 static const XML_Char externalSubsetName[] = { '#', '\0' };3754 static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' }; 3634 3755 #endif /* XML_DTD */ 3635 static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' }; 3636 static const XML_Char atypeID[] = { 'I', 'D', '\0' }; 3637 static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; 3638 static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; 3639 static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; 3640 static const XML_Char atypeENTITIES[] = 3641 { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; 3756 static const XML_Char atypeCDATA[] = 3757 { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; 3758 static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' }; 3759 static const XML_Char atypeIDREF[] = 3760 { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; 3761 static const XML_Char atypeIDREFS[] = 3762 { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; 3763 static const XML_Char atypeENTITY[] = 3764 { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; 3765 static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N, 3766 ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; 3642 3767 static const XML_Char atypeNMTOKEN[] = { 3643 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' };3644 static const XML_Char atypeNMTOKENS[] = { 3645 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' };3646 static const XML_Char notationPrefix[] = { 3647 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' };3648 static const XML_Char enumValueSep[] = { '|', '\0' };3649 static const XML_Char enumValueStart[] = { '(', '\0' };3768 ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; 3769 static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, 3770 ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; 3771 static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T, 3772 ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' }; 3773 static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' }; 3774 static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; 3650 3775 3651 3776 /* save one level of indirection */ 3652 DTD * const dtd = _dtd; 3777 DTD * const dtd = _dtd; 3653 3778 3654 3779 const char **eventPP; … … 3757 3882 #ifdef XML_DTD 3758 3883 useForeignDTD = XML_FALSE; 3759 declEntity = (ENTITY *)lookup(&dtd->paramEntities, 3884 declEntity = (ENTITY *)lookup(parser, 3885 &dtd->paramEntities, 3760 3886 externalSubsetName, 3761 3887 sizeof(ENTITY)); … … 3765 3891 dtd->hasParamEntityRefs = XML_TRUE; 3766 3892 if (startDoctypeDeclHandler) { 3893 XML_Char *pubId; 3767 3894 if (!XmlIsPublicId(enc, s, next, eventPP)) 3768 3895 return XML_ERROR_PUBLICID; 3769 doctypePubid = poolStoreString(&tempPool, enc,3770 3771 3772 if (! doctypePubid)3896 pubId = poolStoreString(&tempPool, enc, 3897 s + enc->minBytesPerChar, 3898 next - enc->minBytesPerChar); 3899 if (!pubId) 3773 3900 return XML_ERROR_NO_MEMORY; 3774 normalizePublicId( (XML_Char *)doctypePubid);3901 normalizePublicId(pubId); 3775 3902 poolFinish(&tempPool); 3903 doctypePubid = pubId; 3776 3904 handleDefault = XML_FALSE; 3777 3905 goto alreadyChecked; … … 3812 3940 dtd->hasParamEntityRefs = XML_TRUE; 3813 3941 if (paramEntityParsing && externalEntityRefHandler) { 3814 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, 3942 ENTITY *entity = (ENTITY *)lookup(parser, 3943 &dtd->paramEntities, 3815 3944 externalSubsetName, 3816 3945 sizeof(ENTITY)); … … 3827 3956 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; 3828 3957 if (dtd->paramEntityRead) { 3829 if (!dtd->standalone && 3830 notStandaloneHandler && 3958 if (!dtd->standalone && 3959 notStandaloneHandler && 3831 3960 !notStandaloneHandler(handlerArg)) 3832 3961 return XML_ERROR_NOT_STANDALONE; … … 3856 3985 dtd->hasParamEntityRefs = XML_TRUE; 3857 3986 if (paramEntityParsing && externalEntityRefHandler) { 3858 ENTITY *entity = (ENTITY *)lookup( &dtd->paramEntities,3987 ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, 3859 3988 externalSubsetName, 3860 3989 sizeof(ENTITY)); … … 3956 4085 return XML_ERROR_NO_MEMORY; 3957 4086 if (attlistDeclHandler && declAttributeType) { 3958 if (*declAttributeType == XML_T( '(')3959 || (*declAttributeType == XML_T( 'N')3960 && declAttributeType[1] == XML_T( 'O'))) {4087 if (*declAttributeType == XML_T(ASCII_LPAREN) 4088 || (*declAttributeType == XML_T(ASCII_N) 4089 && declAttributeType[1] == XML_T(ASCII_O))) { 3961 4090 /* Enumerated or Notation type */ 3962 if (!poolAppendChar(&tempPool, XML_T( ')'))4091 if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) 3963 4092 || !poolAppendChar(&tempPool, XML_T('\0'))) 3964 4093 return XML_ERROR_NO_MEMORY; … … 3993 4122 return XML_ERROR_NO_MEMORY; 3994 4123 if (attlistDeclHandler && declAttributeType) { 3995 if (*declAttributeType == XML_T( '(')3996 || (*declAttributeType == XML_T( 'N')3997 && declAttributeType[1] == XML_T( 'O'))) {4124 if (*declAttributeType == XML_T(ASCII_LPAREN) 4125 || (*declAttributeType == XML_T(ASCII_N) 4126 && declAttributeType[1] == XML_T(ASCII_O))) { 3998 4127 /* Enumerated or Notation type */ 3999 if (!poolAppendChar(&tempPool, XML_T( ')'))4128 if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) 4000 4129 || !poolAppendChar(&tempPool, XML_T('\0'))) 4001 4130 return XML_ERROR_NO_MEMORY; … … 4070 4199 #else /* XML_DTD */ 4071 4200 if (!declEntity) { 4072 declEntity = (ENTITY *)lookup(&dtd->paramEntities, 4201 declEntity = (ENTITY *)lookup(parser, 4202 &dtd->paramEntities, 4073 4203 externalSubsetName, 4074 4204 sizeof(ENTITY)); … … 4145 4275 if (!name) 4146 4276 return XML_ERROR_NO_MEMORY; 4147 declEntity = (ENTITY *)lookup( &dtd->generalEntities, name,4277 declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 4148 4278 sizeof(ENTITY)); 4149 4279 if (!declEntity) … … 4177 4307 if (!name) 4178 4308 return XML_ERROR_NO_MEMORY; 4179 declEntity = (ENTITY *)lookup( &dtd->paramEntities,4309 declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities, 4180 4310 name, sizeof(ENTITY)); 4181 4311 if (!declEntity) … … 4266 4396 case XML_TOK_PARAM_ENTITY_REF: 4267 4397 /* PE references in internal subset are 4268 not allowed within declarations. */ 4398 not allowed within declarations. */ 4269 4399 return XML_ERROR_PARAM_ENTITY_REF; 4270 4400 case XML_TOK_XML_DECL: … … 4324 4454 break; 4325 4455 case XML_ROLE_GROUP_SEQUENCE: 4326 if (groupConnector[prologState.level] == '|')4456 if (groupConnector[prologState.level] == ASCII_PIPE) 4327 4457 return XML_ERROR_SYNTAX; 4328 groupConnector[prologState.level] = ',';4458 groupConnector[prologState.level] = ASCII_COMMA; 4329 4459 if (dtd->in_eldecl && elementDeclHandler) 4330 4460 handleDefault = XML_FALSE; 4331 4461 break; 4332 4462 case XML_ROLE_GROUP_CHOICE: 4333 if (groupConnector[prologState.level] == ',')4463 if (groupConnector[prologState.level] == ASCII_COMMA) 4334 4464 return XML_ERROR_SYNTAX; 4335 4465 if (dtd->in_eldecl … … 4343 4473 handleDefault = XML_FALSE; 4344 4474 } 4345 groupConnector[prologState.level] = '|';4475 groupConnector[prologState.level] = ASCII_PIPE; 4346 4476 break; 4347 4477 case XML_ROLE_PARAM_ENTITY_REF: … … 4359 4489 if (!name) 4360 4490 return XML_ERROR_NO_MEMORY; 4361 entity = (ENTITY *)lookup( &dtd->paramEntities, name, 0);4491 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); 4362 4492 poolDiscard(&dtd->pool); 4363 4493 /* first, determine if a check for an existing declaration is needed; … … 4387 4517 if (entity->textPtr) { 4388 4518 enum XML_Error result; 4389 XML_Bool betweenDecl = 4519 XML_Bool betweenDecl = 4390 4520 (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); 4391 4521 result = processInternalEntity(parser, entity, betweenDecl); … … 4582 4712 4583 4713 switch (ps_parsing) { 4584 case XML_SUSPENDED: 4714 case XML_SUSPENDED: 4585 4715 *nextPtr = next; 4586 4716 return XML_ERROR_NONE; … … 4652 4782 eventPtr = s = next; 4653 4783 switch (ps_parsing) { 4654 case XML_SUSPENDED: 4784 case XML_SUSPENDED: 4655 4785 *nextPtr = next; 4656 4786 return XML_ERROR_NONE; … … 4695 4825 if (entity->is_param) { 4696 4826 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); 4697 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, 4827 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, 4698 4828 next, &next, XML_FALSE); 4699 4829 } 4700 else 4830 else 4701 4831 #endif /* XML_DTD */ 4702 result = doContent(parser, tagLevel, internalEncoding, textStart, 4832 result = doContent(parser, tagLevel, internalEncoding, textStart, 4703 4833 textEnd, &next, XML_FALSE); 4704 4834 … … 4740 4870 if (entity->is_param) { 4741 4871 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); 4742 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, 4872 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, 4743 4873 next, &next, XML_FALSE); 4744 4874 } 4745 4875 else 4746 4876 #endif /* XML_DTD */ 4747 result = doContent(parser, openEntity->startTagLevel, internalEncoding, 4748 textStart, textEnd, &next, XML_FALSE); 4877 result = doContent(parser, openEntity->startTagLevel, internalEncoding, 4878 textStart, textEnd, &next, XML_FALSE); 4749 4879 4750 4880 if (result != XML_ERROR_NONE) … … 4767 4897 processor = prologProcessor; 4768 4898 tok = XmlPrologTok(encoding, s, end, &next); 4769 return doProlog(parser, encoding, s, end, tok, next, nextPtr, 4899 return doProlog(parser, encoding, s, end, tok, next, nextPtr, 4770 4900 (XML_Bool)!ps_finalBuffer); 4771 4901 } … … 4776 4906 /* see externalEntityContentProcessor vs contentProcessor */ 4777 4907 return doContent(parser, parentParser ? 1 : 0, encoding, s, end, 4778 nextPtr, (XML_Bool)!ps_finalBuffer); 4779 } 4908 nextPtr, (XML_Bool)!ps_finalBuffer); 4909 } 4780 4910 } 4781 4911 … … 4883 5013 if (!name) 4884 5014 return XML_ERROR_NO_MEMORY; 4885 entity = (ENTITY *)lookup( &dtd->generalEntities, name, 0);5015 entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); 4886 5016 poolDiscard(&temp2Pool); 4887 5017 /* First, determine if a check for an existing declaration is needed; … … 4930 5060 if (enc == encoding) 4931 5061 eventPtr = ptr; 4932 5062 return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; 4933 5063 } 4934 5064 else { … … 4992 5122 goto endEntityValue; 4993 5123 } 4994 entity = (ENTITY *)lookup( &dtd->paramEntities, name, 0);5124 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); 4995 5125 poolDiscard(&tempPool); 4996 5126 if (!entity) { … … 5273 5403 const XML_Char *name; 5274 5404 for (name = elementType->name; *name; name++) { 5275 if (*name == XML_T( ':')) {5405 if (*name == XML_T(ASCII_COLON)) { 5276 5406 PREFIX *prefix; 5277 5407 const XML_Char *s; … … 5282 5412 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) 5283 5413 return 0; 5284 prefix = (PREFIX *)lookup( &dtd->prefixes, poolStart(&dtd->pool),5414 prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), 5285 5415 sizeof(PREFIX)); 5286 5416 if (!prefix) … … 5311 5441 /* skip quotation mark - its storage will be re-used (like in name[-1]) */ 5312 5442 ++name; 5313 id = (ATTRIBUTE_ID *)lookup( &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID));5443 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); 5314 5444 if (!id) 5315 5445 return NULL; … … 5320 5450 if (!ns) 5321 5451 ; 5322 else if (name[0] == XML_T( 'x')5323 && name[1] == XML_T( 'm')5324 && name[2] == XML_T( 'l')5325 && name[3] == XML_T( 'n')5326 && name[4] == XML_T( 's')5327 && (name[5] == XML_T('\0') || name[5] == XML_T( ':'))) {5452 else if (name[0] == XML_T(ASCII_x) 5453 && name[1] == XML_T(ASCII_m) 5454 && name[2] == XML_T(ASCII_l) 5455 && name[3] == XML_T(ASCII_n) 5456 && name[4] == XML_T(ASCII_s) 5457 && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { 5328 5458 if (name[5] == XML_T('\0')) 5329 5459 id->prefix = &dtd->defaultPrefix; 5330 5460 else 5331 id->prefix = (PREFIX *)lookup( &dtd->prefixes, name + 6, sizeof(PREFIX));5461 id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX)); 5332 5462 id->xmlns = XML_TRUE; 5333 5463 } … … 5336 5466 for (i = 0; name[i]; i++) { 5337 5467 /* attributes without prefix are *not* in the default namespace */ 5338 if (name[i] == XML_T( ':')) {5468 if (name[i] == XML_T(ASCII_COLON)) { 5339 5469 int j; 5340 5470 for (j = 0; j < i; j++) { … … 5344 5474 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) 5345 5475 return NULL; 5346 id->prefix = (PREFIX *)lookup( &dtd->prefixes, poolStart(&dtd->pool),5476 id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), 5347 5477 sizeof(PREFIX)); 5348 if (!id->prefix)5349 return NULL;5350 5478 if (id->prefix->name == poolStart(&dtd->pool)) 5351 5479 poolFinish(&dtd->pool); … … 5360 5488 } 5361 5489 5362 #define CONTEXT_SEP XML_T( '\f')5490 #define CONTEXT_SEP XML_T(ASCII_FF) 5363 5491 5364 5492 static const XML_Char * … … 5372 5500 int i; 5373 5501 int len; 5374 if (!poolAppendChar(&tempPool, XML_T( '=')))5502 if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) 5375 5503 return NULL; 5376 5504 len = dtd->defaultPrefix.binding->uriLen; … … 5398 5526 if (!poolAppendChar(&tempPool, *s)) 5399 5527 return NULL; 5400 if (!poolAppendChar(&tempPool, XML_T( '=')))5528 if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) 5401 5529 return NULL; 5402 5530 len = prefix->binding->uriLen; … … 5442 5570 if (!poolAppendChar(&tempPool, XML_T('\0'))) 5443 5571 return XML_FALSE; 5444 e = (ENTITY *)lookup( &dtd->generalEntities, poolStart(&tempPool), 0);5572 e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0); 5445 5573 if (e) 5446 5574 e->open = XML_TRUE; … … 5450 5578 poolDiscard(&tempPool); 5451 5579 } 5452 else if (*s == XML_T( '=')) {5580 else if (*s == XML_T(ASCII_EQUALS)) { 5453 5581 PREFIX *prefix; 5454 5582 if (poolLength(&tempPool) == 0) … … 5457 5585 if (!poolAppendChar(&tempPool, XML_T('\0'))) 5458 5586 return XML_FALSE; 5459 prefix = (PREFIX *)lookup( &dtd->prefixes, poolStart(&tempPool),5587 prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&tempPool), 5460 5588 sizeof(PREFIX)); 5461 5589 if (!prefix) … … 5621 5749 */ 5622 5750 static int 5623 dtdCopy( DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms)5751 dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) 5624 5752 { 5625 5753 HASH_TABLE_ITER iter; … … 5636 5764 if (!name) 5637 5765 return 0; 5638 if (!lookup( &(newDtd->prefixes), name, sizeof(PREFIX)))5766 if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX))) 5639 5767 return 0; 5640 5768 } … … 5658 5786 return 0; 5659 5787 ++name; 5660 newA = (ATTRIBUTE_ID *)lookup( &(newDtd->attributeIds), name,5788 newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name, 5661 5789 sizeof(ATTRIBUTE_ID)); 5662 5790 if (!newA) … … 5668 5796 newA->prefix = &newDtd->defaultPrefix; 5669 5797 else 5670 newA->prefix = (PREFIX *)lookup( &(newDtd->prefixes),5798 newA->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), 5671 5799 oldA->prefix->name, 0); 5672 5800 } … … 5687 5815 if (!name) 5688 5816 return 0; 5689 newE = (ELEMENT_TYPE *)lookup( &(newDtd->elementTypes), name,5817 newE = (ELEMENT_TYPE *)lookup(oldParser, &(newDtd->elementTypes), name, 5690 5818 sizeof(ELEMENT_TYPE)); 5691 5819 if (!newE) … … 5701 5829 if (oldE->idAtt) 5702 5830 newE->idAtt = (ATTRIBUTE_ID *) 5703 lookup( &(newDtd->attributeIds), oldE->idAtt->name, 0);5831 lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0); 5704 5832 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; 5705 5833 if (oldE->prefix) 5706 newE->prefix = (PREFIX *)lookup( &(newDtd->prefixes),5834 newE->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), 5707 5835 oldE->prefix->name, 0); 5708 5836 for (i = 0; i < newE->nDefaultAtts; i++) { 5709 5837 newE->defaultAtts[i].id = (ATTRIBUTE_ID *) 5710 lookup( &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0);5838 lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); 5711 5839 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; 5712 5840 if (oldE->defaultAtts[i].value) { … … 5722 5850 5723 5851 /* Copy the entity tables. */ 5724 if (!copyEntityTable(&(newDtd->generalEntities), 5852 if (!copyEntityTable(oldParser, 5853 &(newDtd->generalEntities), 5725 5854 &(newDtd->pool), 5726 5855 &(oldDtd->generalEntities))) … … 5728 5857 5729 5858 #ifdef XML_DTD 5730 if (!copyEntityTable(&(newDtd->paramEntities), 5859 if (!copyEntityTable(oldParser, 5860 &(newDtd->paramEntities), 5731 5861 &(newDtd->pool), 5732 5862 &(oldDtd->paramEntities))) … … 5751 5881 5752 5882 static int 5753 copyEntityTable(HASH_TABLE *newTable, 5883 copyEntityTable(XML_Parser oldParser, 5884 HASH_TABLE *newTable, 5754 5885 STRING_POOL *newPool, 5755 5886 const HASH_TABLE *oldTable) … … 5770 5901 if (!name) 5771 5902 return 0; 5772 newE = (ENTITY *)lookup( newTable, name, sizeof(ENTITY));5903 newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY)); 5773 5904 if (!newE) 5774 5905 return 0; … … 5828 5959 5829 5960 static unsigned long FASTCALL 5830 hash( KEY s)5831 { 5832 unsigned long h = 0;5961 hash(XML_Parser parser, KEY s) 5962 { 5963 unsigned long h = hash_secret_salt; 5833 5964 while (*s) 5834 5965 h = CHAR_HASH(h, *s++); … … 5837 5968 5838 5969 static NAMED * 5839 lookup( HASH_TABLE *table, KEY name, size_t createSize)5970 lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) 5840 5971 { 5841 5972 size_t i; … … 5854 5985 } 5855 5986 memset(table->v, 0, tsize); 5856 i = hash( name) & ((unsigned long)table->size - 1);5987 i = hash(parser, name) & ((unsigned long)table->size - 1); 5857 5988 } 5858 5989 else { 5859 unsigned long h = hash( name);5990 unsigned long h = hash(parser, name); 5860 5991 unsigned long mask = (unsigned long)table->size - 1; 5861 5992 unsigned char step = 0; … … 5883 6014 for (i = 0; i < table->size; i++) 5884 6015 if (table->v[i]) { 5885 unsigned long newHash = hash( table->v[i]->name);6016 unsigned long newHash = hash(parser, table->v[i]->name); 5886 6017 size_t j = newHash & newMask; 5887 6018 step = 0; … … 6104 6235 if (pool->blocks && pool->start == pool->blocks->s) { 6105 6236 int blockSize = (int)(pool->end - pool->start)*2; 6106 pool->blocks= (BLOCK *)6237 BLOCK *temp = (BLOCK *) 6107 6238 pool->mem->realloc_fcn(pool->blocks, 6108 6239 (offsetof(BLOCK, s) 6109 6240 + blockSize * sizeof(XML_Char))); 6110 if ( pool->blocks== NULL)6241 if (temp == NULL) 6111 6242 return XML_FALSE; 6243 pool->blocks = temp; 6112 6244 pool->blocks->size = blockSize; 6113 6245 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); … … 6258 6390 if (!name) 6259 6391 return NULL; 6260 ret = (ELEMENT_TYPE *) lookup( &dtd->elementTypes, name, sizeof(ELEMENT_TYPE));6392 ret = (ELEMENT_TYPE *) lookup(parser, &dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); 6261 6393 if (!ret) 6262 6394 return NULL; -
python/vendor/current/Modules/expat/xmlrole.c
r2 r388 2 2 See the file COPYING for copying permission. 3 3 */ 4 5 #include <stddef.h> 4 6 5 7 #ifdef COMPILED_FROM_DSP … … 7 9 #elif defined(MACOS_CLASSIC) 8 10 #include "macconfig.h" 9 #elif defined(__amigaos 4__)11 #elif defined(__amigaos__) 10 12 #include "amigaconfig.h" 13 #elif defined(__WATCOMC__) 14 #include "watcomconfig.h" 11 15 #else 12 16 #ifdef HAVE_EXPAT_CONFIG_H … … 14 18 #endif 15 19 #endif /* ndef COMPILED_FROM_DSP */ 16 17 #include <stddef.h>18 20 19 21 #include "expat_external.h" … … 54 56 static const char KW_IDREFS[] = { 55 57 ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; 58 #ifdef XML_DTD 56 59 static const char KW_IGNORE[] = { 57 60 ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; 61 #endif 58 62 static const char KW_IMPLIED[] = { 59 63 ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; 64 #ifdef XML_DTD 60 65 static const char KW_INCLUDE[] = { 61 66 ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; 67 #endif 62 68 static const char KW_NDATA[] = { 63 69 ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -
python/vendor/current/Modules/expat/xmltok.c
r2 r388 2 2 See the file COPYING for copying permission. 3 3 */ 4 5 #include <stddef.h> 4 6 5 7 #ifdef COMPILED_FROM_DSP … … 7 9 #elif defined(MACOS_CLASSIC) 8 10 #include "macconfig.h" 9 #elif defined(__amigaos 4__)11 #elif defined(__amigaos__) 10 12 #include "amigaconfig.h" 13 #elif defined(__WATCOMC__) 14 #include "watcomconfig.h" 11 15 #else 12 16 #ifdef HAVE_EXPAT_CONFIG_H … … 14 18 #endif 15 19 #endif /* ndef COMPILED_FROM_DSP */ 16 17 #include <stddef.h>18 20 19 21 #include "expat_external.h" … … 296 298 297 299 #define PREFIX(ident) normal_ ## ident 300 #define XML_TOK_IMPL_C 298 301 #include "xmltok_impl.c" 302 #undef XML_TOK_IMPL_C 299 303 300 304 #undef MINBPC … … 693 697 #define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) 694 698 699 #define XML_TOK_IMPL_C 695 700 #include "xmltok_impl.c" 701 #undef XML_TOK_IMPL_C 696 702 697 703 #undef MINBPC … … 832 838 #define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) 833 839 840 #define XML_TOK_IMPL_C 834 841 #include "xmltok_impl.c" 842 #undef XML_TOK_IMPL_C 835 843 836 844 #undef MINBPC … … 1338 1346 XmlInitUnknownEncoding(void *mem, 1339 1347 int *table, 1340 CONVERTER convert, 1348 CONVERTER convert, 1341 1349 void *userData) 1342 1350 { … … 1577 1585 /* 0 isn't a legal data character. Furthermore a document 1578 1586 entity can only start with ASCII characters. So the only 1579 way this can fail to be big-endian UTF-16 i f it it's an1587 way this can fail to be big-endian UTF-16 is if it is an 1580 1588 external parsed general entity that's labelled as 1581 1589 UTF-16LE. … … 1611 1619 #define NS(x) x 1612 1620 #define ns(x) x 1621 #define XML_TOK_NS_C 1613 1622 #include "xmltok_ns.c" 1623 #undef XML_TOK_NS_C 1614 1624 #undef NS 1615 1625 #undef ns … … 1620 1630 #define ns(x) x ## _ns 1621 1631 1632 #define XML_TOK_NS_C 1622 1633 #include "xmltok_ns.c" 1634 #undef XML_TOK_NS_C 1623 1635 1624 1636 #undef NS … … 1628 1640 XmlInitUnknownEncodingNS(void *mem, 1629 1641 int *table, 1630 CONVERTER convert, 1642 CONVERTER convert, 1631 1643 void *userData) 1632 1644 { -
python/vendor/current/Modules/expat/xmltok_impl.c
r2 r388 2 2 See the file COPYING for copying permission. 3 3 */ 4 5 /* This file is included! */ 6 #ifdef XML_TOK_IMPL_C 4 7 5 8 #ifndef IS_INVALID_CHAR … … 883 886 { 884 887 if (ptr == end) 885 return -XML_TOK_PERCENT;888 return XML_TOK_PARTIAL; 886 889 switch (BYTE_TYPE(enc, ptr)) { 887 890 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) … … 1778 1781 #undef CHECK_NMSTRT_CASES 1779 1782 1783 #endif /* XML_TOK_IMPL_C */ -
python/vendor/current/Modules/expat/xmltok_ns.c
r2 r388 1 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 2 See the file COPYING for copying permission. 3 */ 4 5 /* This file is included! */ 6 #ifdef XML_TOK_NS_C 7 1 8 const ENCODING * 2 9 NS(XmlGetUtf8InternalEncoding)(void) … … 105 112 standalone); 106 113 } 114 115 #endif /* XML_TOK_NS_C */
Note:
See TracChangeset
for help on using the changeset viewer.