6 #if defined(__clang__) || defined(__GNUC__)
7 #pragma GCC diagnostic ignored "-Wshadow"
8 #pragma GCC diagnostic ignored "-Wunused-parameter"
17 #define XML_BUILDING_EXPAT 1
19 #ifdef COMPILED_FROM_DSP
21 #elif defined(MACOS_CLASSIC)
23 #elif defined(__amigaos__)
25 #elif defined(__WATCOMC__)
26 #include "watcomconfig.h"
27 #elif defined(HAVE_EXPAT_CONFIG_H)
35 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
36 #define XmlConvert XmlUtf16Convert
37 #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
38 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
39 #define XmlEncode XmlUtf16Encode
41 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
42 typedef unsigned short ICHAR;
44 #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
45 #define XmlConvert XmlUtf8Convert
46 #define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
47 #define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
48 #define XmlEncode XmlUtf8Encode
49 #define MUST_CONVERT(enc, s) (!(enc)->isUtf8)
56 #define XmlInitEncodingNS XmlInitEncoding
57 #define XmlInitUnknownEncodingNS XmlInitUnknownEncoding
58 #undef XmlGetInternalEncodingNS
59 #define XmlGetInternalEncodingNS XmlGetInternalEncoding
60 #define XmlParseXmlDeclNS XmlParseXmlDecl
66 #ifdef XML_UNICODE_WCHAR_T
67 #define XML_T(x) (const wchar_t)x
68 #define XML_L(x) L ## x
70 #define XML_T(x) (const unsigned short)x
82 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
87 #define memmove(d,s,l) bcopy((s),(d),(l))
89 #error memmove does not exist on this platform, nor is a substitute available
116 #define CHAR_HASH(h, c) \
117 (((h) * 0xF4243) ^ (unsigned short)(c))
119 #define CHAR_HASH(h, c) \
120 (((h) * 0xF4243) ^ (unsigned char)(c))
131 #define SECOND_HASH(hash, mask, power) \
132 ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2))
133 #define PROBE_STEP(hash, mask, power) \
134 ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1))
141 #define INIT_TAG_BUF_SIZE 32
142 #define INIT_DATA_BUF_SIZE 1024
143 #define INIT_ATTS_SIZE 16
144 #define INIT_ATTS_VERSION 0xFFFFFFFF
145 #define INIT_BLOCK_SIZE 1024
146 #define INIT_BUFFER_SIZE 1024
148 #define EXPAND_SPARE 24
221 #define INIT_SCAFFOLD_ELEMENTS 32
309 const char **endPtr);
317 static Processor externalParEntProcessor;
318 static Processor externalParEntInitProcessor;
320 static Processor entityValueInitProcessor;
334 const char *
s,
const char *
next);
339 const char *end,
int tok,
const char *
next,
const char **nextPtr,
346 const char *
start,
const char *end,
const char **endPtr,
350 const char *end,
const char **nextPtr,
XML_Bool haveMore);
354 const char *end,
const char **nextPtr,
XML_Bool haveMore);
382 const char *
start,
const char *end);
423 const char *ptr,
const char *end);
426 const char *ptr,
const char *end);
439 const char *ptr,
const char *end);
453 #define poolStart(pool) ((pool)->start)
454 #define poolEnd(pool) ((pool)->ptr)
455 #define poolLength(pool) ((pool)->ptr - (pool)->start)
456 #define poolChop(pool) ((void)--(pool->ptr))
457 #define poolLastChar(pool) (((pool)->ptr)[-1])
458 #define poolDiscard(pool) ((pool)->ptr = (pool)->start)
459 #define poolFinish(pool) ((pool)->start = (pool)->ptr)
460 #define poolAppendChar(pool, c) \
461 (((pool)->ptr == (pool)->end && !poolGrow(pool)) \
463 : ((*((pool)->ptr)++ = c), 1))
550 XML_AttrInfo *m_attInfo;
568 #define MALLOC(s) (parser->m_mem.malloc_fcn((s)))
569 #define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s)))
570 #define FREE(p) (parser->m_mem.free_fcn((p)))
572 #define userData (parser->m_userData)
573 #define handlerArg (parser->m_handlerArg)
574 #define startElementHandler (parser->m_startElementHandler)
575 #define endElementHandler (parser->m_endElementHandler)
576 #define characterDataHandler (parser->m_characterDataHandler)
577 #define processingInstructionHandler \
578 (parser->m_processingInstructionHandler)
579 #define commentHandler (parser->m_commentHandler)
580 #define startCdataSectionHandler \
581 (parser->m_startCdataSectionHandler)
582 #define endCdataSectionHandler (parser->m_endCdataSectionHandler)
583 #define defaultHandler (parser->m_defaultHandler)
584 #define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler)
585 #define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler)
586 #define unparsedEntityDeclHandler \
587 (parser->m_unparsedEntityDeclHandler)
588 #define notationDeclHandler (parser->m_notationDeclHandler)
589 #define startNamespaceDeclHandler \
590 (parser->m_startNamespaceDeclHandler)
591 #define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler)
592 #define notStandaloneHandler (parser->m_notStandaloneHandler)
593 #define externalEntityRefHandler \
594 (parser->m_externalEntityRefHandler)
595 #define externalEntityRefHandlerArg \
596 (parser->m_externalEntityRefHandlerArg)
597 #define internalEntityRefHandler \
598 (parser->m_internalEntityRefHandler)
599 #define skippedEntityHandler (parser->m_skippedEntityHandler)
600 #define unknownEncodingHandler (parser->m_unknownEncodingHandler)
601 #define elementDeclHandler (parser->m_elementDeclHandler)
602 #define attlistDeclHandler (parser->m_attlistDeclHandler)
603 #define entityDeclHandler (parser->m_entityDeclHandler)
604 #define xmlDeclHandler (parser->m_xmlDeclHandler)
605 #define encoding (parser->m_encoding)
606 #define initEncoding (parser->m_initEncoding)
607 #define internalEncoding (parser->m_internalEncoding)
608 #define unknownEncodingMem (parser->m_unknownEncodingMem)
609 #define unknownEncodingData (parser->m_unknownEncodingData)
610 #define unknownEncodingHandlerData \
611 (parser->m_unknownEncodingHandlerData)
612 #define unknownEncodingRelease (parser->m_unknownEncodingRelease)
613 #define protocolEncodingName (parser->m_protocolEncodingName)
614 #define ns (parser->m_ns)
615 #define ns_triplets (parser->m_ns_triplets)
616 #define prologState (parser->m_prologState)
617 #define processor (parser->m_processor)
618 #define errorCode (parser->m_errorCode)
619 #define eventPtr (parser->m_eventPtr)
620 #define eventEndPtr (parser->m_eventEndPtr)
621 #define positionPtr (parser->m_positionPtr)
622 #define position (parser->m_position)
623 #define openInternalEntities (parser->m_openInternalEntities)
624 #define freeInternalEntities (parser->m_freeInternalEntities)
625 #define defaultExpandInternalEntities \
626 (parser->m_defaultExpandInternalEntities)
627 #define tagLevel (parser->m_tagLevel)
628 #define buffer (parser->m_buffer)
629 #define bufferPtr (parser->m_bufferPtr)
630 #define bufferEnd (parser->m_bufferEnd)
631 #define parseEndByteIndex (parser->m_parseEndByteIndex)
632 #define parseEndPtr (parser->m_parseEndPtr)
633 #define bufferLim (parser->m_bufferLim)
634 #define dataBuf (parser->m_dataBuf)
635 #define dataBufEnd (parser->m_dataBufEnd)
636 #define _dtd (parser->m_dtd)
637 #define curBase (parser->m_curBase)
638 #define declEntity (parser->m_declEntity)
639 #define doctypeName (parser->m_doctypeName)
640 #define doctypeSysid (parser->m_doctypeSysid)
641 #define doctypePubid (parser->m_doctypePubid)
642 #define declAttributeType (parser->m_declAttributeType)
643 #define declNotationName (parser->m_declNotationName)
644 #define declNotationPublicId (parser->m_declNotationPublicId)
645 #define declElementType (parser->m_declElementType)
646 #define declAttributeId (parser->m_declAttributeId)
647 #define declAttributeIsCdata (parser->m_declAttributeIsCdata)
648 #define declAttributeIsId (parser->m_declAttributeIsId)
649 #define freeTagList (parser->m_freeTagList)
650 #define freeBindingList (parser->m_freeBindingList)
651 #define inheritedBindings (parser->m_inheritedBindings)
652 #define tagStack (parser->m_tagStack)
653 #define atts (parser->m_atts)
654 #define attsSize (parser->m_attsSize)
655 #define nSpecifiedAtts (parser->m_nSpecifiedAtts)
656 #define idAttIndex (parser->m_idAttIndex)
657 #define nsAtts (parser->m_nsAtts)
658 #define nsAttsVersion (parser->m_nsAttsVersion)
659 #define nsAttsPower (parser->m_nsAttsPower)
660 #define attInfo (parser->m_attInfo)
661 #define tempPool (parser->m_tempPool)
662 #define temp2Pool (parser->m_temp2Pool)
663 #define groupConnector (parser->m_groupConnector)
664 #define groupSize (parser->m_groupSize)
665 #define namespaceSeparator (parser->m_namespaceSeparator)
666 #define parentParser (parser->m_parentParser)
667 #define ps_parsing (parser->m_parsingStatus.parsing)
668 #define ps_finalBuffer (parser->m_parsingStatus.finalBuffer)
670 #define isParamEntity (parser->m_isParamEntity)
671 #define useForeignDTD (parser->m_useForeignDTD)
672 #define paramEntityParsing (parser->m_paramEntityParsing)
674 #define hash_secret_salt (parser->m_hash_secret_salt)
702 unsigned int seed =
time(NULL) % UINT_MAX;
727 return parserCreate(encodingName, memsuite, nameSep, NULL);
742 if (parser != NULL) {
752 if (parser != NULL) {
949 while (openEntityList) {
951 openEntityList = openEntity->
next;
975 if (encodingName == NULL)
996 XML_ProcessingInstructionHandler oldProcessingInstructionHandler
999 XML_StartCdataSectionHandler oldStartCdataSectionHandler
1001 XML_EndCdataSectionHandler oldEndCdataSectionHandler
1004 XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler
1007 XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler
1009 XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler
1012 XML_ExternalEntityRefHandler oldExternalEntityRefHandler
1015 XML_UnknownEncodingHandler oldUnknownEncodingHandler
1083 if (oldUserData == oldHandlerArg)
1087 if (oldExternalEntityRefHandlerArg != oldParser)
1094 paramEntityParsing = oldParamEntityParsing;
1116 processor = externalParEntInitProcessor;
1146 if (tagList == NULL) {
1153 tagList = tagList->
parent;
1162 if (entityList == NULL) {
1168 openEntity = entityList;
1169 entityList = entityList->
next;
1181 if (!isParamEntity &&
_dtd)
1187 #ifdef XML_ATTR_INFO
1213 useForeignDTD = useDTD;
1270 #ifdef XML_ATTR_INFO
1280 XML_StartElementHandler
start,
1281 XML_EndElementHandler end)
1289 XML_StartElementHandler
start) {
1295 XML_EndElementHandler end) {
1301 XML_CharacterDataHandler handler)
1308 XML_ProcessingInstructionHandler handler)
1315 XML_CommentHandler handler)
1322 XML_StartCdataSectionHandler
start,
1323 XML_EndCdataSectionHandler end)
1331 XML_StartCdataSectionHandler
start) {
1337 XML_EndCdataSectionHandler end) {
1343 XML_DefaultHandler handler)
1351 XML_DefaultHandler handler)
1359 XML_StartDoctypeDeclHandler
start,
1368 XML_StartDoctypeDeclHandler
start) {
1380 XML_UnparsedEntityDeclHandler handler)
1387 XML_NotationDeclHandler handler)
1394 XML_StartNamespaceDeclHandler
start,
1395 XML_EndNamespaceDeclHandler end)
1403 XML_StartNamespaceDeclHandler
start) {
1409 XML_EndNamespaceDeclHandler end) {
1415 XML_NotStandaloneHandler handler)
1422 XML_ExternalEntityRefHandler handler)
1438 XML_SkippedEntityHandler handler)
1445 XML_UnknownEncodingHandler handler,
1454 XML_ElementDeclHandler eldecl)
1461 XML_AttlistDeclHandler attdecl)
1468 XML_EntityDeclHandler handler)
1475 XML_XmlDeclHandler handler) {
1487 paramEntityParsing = peParsing;
1496 unsigned long hash_salt)
1555 #ifndef XML_CONTEXT_BYTES
1589 nLeftOver = s + len - end;
1595 ? (
char *)
MALLOC(len * 2)
1606 memcpy(
buffer, end, nLeftOver);
1622 memcpy(buff, s, len);
1700 #ifdef XML_CONTEXT_BYTES
1708 #ifdef XML_CONTEXT_BYTES
1724 if (bufferSize == 0)
1728 }
while (bufferSize < neededSize);
1729 newBuf = (
char *)
MALLOC(bufferSize);
1735 #ifdef XML_CONTEXT_BYTES
1782 if (isParamEntity) {
1836 assert(status != NULL);
1865 #ifdef XML_CONTEXT_BYTES
1938 XML_L(
"out of memory"),
1939 XML_L(
"syntax error"),
1940 XML_L(
"no element found"),
1941 XML_L(
"not well-formed (invalid token)"),
1942 XML_L(
"unclosed token"),
1943 XML_L(
"partial character"),
1944 XML_L(
"mismatched tag"),
1945 XML_L(
"duplicate attribute"),
1946 XML_L(
"junk after document element"),
1947 XML_L(
"illegal parameter entity reference"),
1948 XML_L(
"undefined entity"),
1949 XML_L(
"recursive entity reference"),
1950 XML_L(
"asynchronous entity"),
1951 XML_L(
"reference to invalid character number"),
1952 XML_L(
"reference to binary entity"),
1953 XML_L(
"reference to external entity in attribute"),
1954 XML_L(
"XML or text declaration not at start of entity"),
1955 XML_L(
"unknown encoding"),
1956 XML_L(
"encoding specified in XML declaration is incorrect"),
1957 XML_L(
"unclosed CDATA section"),
1958 XML_L(
"error in processing external entity reference"),
1959 XML_L(
"document is not standalone"),
1960 XML_L(
"unexpected parser state - please send a bug report"),
1961 XML_L(
"entity declared in parameter entity"),
1962 XML_L(
"requested feature requires XML_DTD support in Expat"),
1963 XML_L(
"cannot change setting once parsing has begun"),
1964 XML_L(
"unbound prefix"),
1965 XML_L(
"must not undeclare prefix"),
1966 XML_L(
"incomplete markup in parameter entity"),
1967 XML_L(
"XML declaration not well-formed"),
1968 XML_L(
"text declaration not well-formed"),
1969 XML_L(
"illegal character(s) in public id"),
1970 XML_L(
"parser suspended"),
1971 XML_L(
"parser not suspended"),
1972 XML_L(
"parsing aborted"),
1973 XML_L(
"parsing finished"),
1974 XML_L(
"cannot suspend in external parameter entity"),
1975 XML_L(
"reserved prefix (xml) must not be undeclared or bound to another namespace name"),
1976 XML_L(
"reserved prefix (xmlns) must not be declared or undeclared"),
1977 XML_L(
"prefix must not be bound to one of the reserved namespace names")
1979 if (code > 0 && code <
sizeof(message)/
sizeof(message[0]))
1980 return message[code];
1995 #define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c)
1996 #define V2(a,b,c) XML_L("expat_")V1(a,b,c)
2027 #ifdef XML_UNICODE_WCHAR_T
2033 #ifdef XML_CONTEXT_BYTES
2043 #ifdef XML_LARGE_SIZE
2046 #ifdef XML_ATTR_INFO
2067 char *rawNameBuf = tag->
buf + nameLen;
2073 if (tag->
rawName == rawNameBuf)
2080 char *temp = (
char *)
REALLOC(tag->
buf, bufSize);
2095 tag->
bufEnd = temp + bufSize;
2096 rawNameBuf = temp + nameLen;
2109 const char **endPtr)
2124 const char **endPtr)
2137 const char **endPtr)
2139 const char *next =
start;
2177 const char **endPtr)
2180 const char *next =
start;
2225 const char **endPtr)
2242 const char **nextPtr,
2248 const char **eventPP;
2249 const char **eventEndPP;
2261 const char *next =
s;
2280 if (startTagLevel == 0)
2291 if (startTagLevel > 0) {
2419 const char *fromPtr = tag->
rawName;
2425 &fromPtr, rawNameEnd,
2428 if (fromPtr == rawNameEnd) {
2434 char *temp = (
char *)
REALLOC(tag->
buf, bufSize);
2438 tag->
bufEnd = temp + bufSize;
2439 toPtr = (
XML_Char *)temp + convLen;
2444 *toPtr =
XML_T(
'\0');
2470 result =
storeAtts(parser, enc, s, &name, &bindings);
2480 *eventPP = *eventEndPP;
2505 const char *rawName;
2513 || memcmp(tag->
rawName, rawName, len) != 0) {
2523 if (
ns && localPart) {
2530 while (*localPart) *uri++ = *localPart++;
2534 while (*prefix) *uri++ = *prefix++;
2601 result =
doCdataSection(parser, enc, &next, end, nextPtr, haveMore);
2632 if (startTagLevel == 0) {
2645 if (charDataHandler) {
2680 *eventPP = s = next;
2705 const char *attStr,
TAG_NAME *tagNamePtr,
2741 #ifdef XML_ATTR_INFO
2742 XML_AttrInfo *
temp2;
2749 #ifdef XML_ATTR_INFO
2755 if (n > oldAttsSize)
2760 for (i = 0; i <
n; i++) {
2762 #ifdef XML_ATTR_INFO
2763 XML_AttrInfo *currAttInfo = &
attInfo[i];
2771 #ifdef XML_ATTR_INFO
2773 currAttInfo->nameEnd = currAttInfo->nameStart +
2783 if ((attId->
name)[-1]) {
2788 (attId->
name)[-1] = 1;
2789 appAtts[attIndex++] = attId->
name;
2790 if (!
atts[i].normalized) {
2797 for (j = 0; j < nDefaultAtts; j++) {
2807 atts[i].valuePtr,
atts[i].valueEnd,
2818 if (appAtts[attIndex] == 0)
2827 appAtts[attIndex], bindingsPtr);
2836 (attId->
name)[-1] = 2;
2846 for (i = 0; i < attIndex; i += 2)
2847 if (appAtts[i] == elementType->
idAtt->
name) {
2856 for (i = 0; i < nDefaultAtts; i++) {
2862 da->
value, bindingsPtr);
2869 appAtts[attIndex++] = da->
id->
name;
2870 appAtts[attIndex++] = da->
value;
2875 appAtts[attIndex++] = da->
id->
name;
2876 appAtts[attIndex++] = da->
value;
2880 appAtts[attIndex] = 0;
2906 for (j = nsAttsSize; j != 0; )
2907 nsAtts[--j].version = version;
2912 for (; i < attIndex; i += 2) {
2925 for (j = 0; j < b->
uriLen; j++) {
2943 unsigned char step = 0;
2944 unsigned long mask = nsAttsSize - 1;
2946 while (
nsAtts[j].version == version) {
2952 for (; *s1 == *s2 && *s1 != 0; s1++, s2++);
2958 j < step ? (j += nsAttsSize -
step) : (j -= step);
2978 nsAtts[j].hash = uriHash;
2991 for (; i < attIndex; i += 2)
2992 ((
XML_Char *)(appAtts[i]))[-1] = 0;
2993 for (binding = *bindingsPtr; binding; binding = binding->
nextTagBinding)
3000 if (elementType->
prefix) {
3004 localPart = tagNamePtr->
str;
3010 localPart = tagNamePtr->
str;
3023 for (i = 0; localPart[i++];)
3025 n = i + binding->
uriLen + prefixLen;
3041 memcpy(uri, localPart, i *
sizeof(
XML_Char));
3048 tagNamePtr->
str = binding->
uri;
3059 static const XML_Char xmlNamespace[] = {
3067 static const int xmlLen =
3069 static const XML_Char xmlnsNamespace[] = {
3076 static const int xmlnsLen =
3087 if (*uri ==
XML_T(
'\0') && prefix->
name)
3105 for (len = 0; uri[
len]; len++) {
3106 if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len]))
3109 if (!mustBeXML && isXMLNS
3110 && (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
3113 isXML = isXML && len == xmlLen;
3114 isXMLNS = isXMLNS && len == xmlnsLen;
3116 if (mustBeXML != isXML)
3156 if (*uri ==
XML_T(
'\0') && prefix == &
_dtd->defaultPrefix)
3176 const char **endPtr)
3201 const char **startPtr,
3203 const char **nextPtr,
3206 const char *
s = *startPtr;
3207 const char **eventPP;
3208 const char **eventEndPP;
3253 if (charDataHandler) {
3296 *eventPP = s = next;
3318 const char **endPtr)
3337 const char **startPtr,
3339 const char **nextPtr,
3344 const char *
s = *startPtr;
3345 const char **eventPP;
3346 const char **eventEndPP;
3358 tok = XmlIgnoreSectionTok(enc, s, end, &next);
3361 case XML_TOK_IGNORE_SECT:
3400 char encodingBuf[128];
3406 if (i ==
sizeof(encodingBuf) - 1
3408 encodingBuf[0] =
'\0';
3413 encodingBuf[i] =
'\0';
3426 const char *s,
const char *next)
3428 const char *encodingName = NULL;
3429 const XML_Char *storedEncName = NULL;
3430 const ENCODING *newEncoding = NULL;
3432 const char *versionend;
3433 const XML_Char *storedversion = NULL;
3447 if (isGeneralTextEntity)
3452 if (!isGeneralTextEntity && standalone == 1) {
3460 if (encodingName != NULL) {
3490 else if (encodingName) {
3492 if (!storedEncName) {
3507 if (storedEncName || storedversion)
3519 for (i = 0; i < 256; i++)
3521 info.convert = NULL;
3523 info.release = NULL;
3530 info.release(info.
data);
3546 if (info.release != NULL)
3547 info.release(info.
data);
3556 const char **nextPtr)
3568 externalParEntInitProcessor(
XML_Parser parser,
3571 const char **nextPtr)
3583 return entityValueInitProcessor(parser, s, end, nextPtr);
3587 return externalParEntProcessor(parser, s, end, nextPtr);
3595 const char **nextPtr)
3598 const char *start =
s;
3599 const char *next =
start;
3640 return entityValueProcessor(parser, next, end, nextPtr);
3662 const char **nextPtr)
3664 const char *next =
s;
3703 const char **nextPtr)
3705 const char *start =
s;
3706 const char *next =
s;
3741 const char **nextPtr)
3743 const char *next =
s;
3756 const char **nextPtr,
3762 static const XML_Char atypeCDATA[] =
3765 static const XML_Char atypeIDREF[] =
3767 static const XML_Char atypeIDREFS[] =
3769 static const XML_Char atypeENTITY[] =
3773 static const XML_Char atypeNMTOKEN[] = {
3785 const char **eventPP;
3786 const char **eventEndPP;
3830 if (isParamEntity || enc !=
encoding) {
3877 case XML_ROLE_TEXT_DECL:
3891 &dtd->paramEntities,
3911 goto alreadyChecked;
3949 &dtd->paramEntities,
3963 if (dtd->paramEntityRead) {
3989 if (useForeignDTD) {
4006 if (dtd->paramEntityRead) {
4027 goto checkAttListDeclHandler;
4035 goto checkAttListDeclHandler;
4039 goto checkAttListDeclHandler;
4043 goto checkAttListDeclHandler;
4046 goto checkAttListDeclHandler;
4049 goto checkAttListDeclHandler;
4052 goto checkAttListDeclHandler;
4055 goto checkAttListDeclHandler;
4058 goto checkAttListDeclHandler;
4061 checkAttListDeclHandler:
4070 prefix = enumValueSep;
4198 && !paramEntityParsing
4208 &dtd->paramEntities,
4412 case XML_ROLE_IGNORE_SECT:
4418 result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore);
4485 case XML_ROLE_INNER_PARAM_ENTITY_REF:
4487 if (!paramEntityParsing)
4497 entity = (
ENTITY *)
lookup(parser, &dtd->paramEntities, name, 0);
4546 if (!dtd->paramEntityRead) {
4585 content->
name = NULL;
4610 goto elementContent;
4613 goto elementContent;
4616 goto elementContent;
4638 for (; name[nameLen++]; );
4663 if (!handleDefault) {
4737 const char **nextPtr)
4742 const char *next = NULL;
4804 const char *textStart, *textEnd;
4822 openEntity->
entity = entity;
4827 textStart = (
char *)entity->
textPtr;
4861 const char **nextPtr)
4864 const char *textStart, *textEnd;
4871 entity = openEntity->
entity;
4922 const char **nextPtr)
4929 const char *ptr,
const char *end,
4945 const char *ptr,
const char *end,
4983 for (i = 0; i <
n; i++) {
5007 char checkEntityDecl;
5026 if (pool == &dtd->
pool)
5036 if (checkEntityDecl) {
5076 (
char *)textEnd, pool);
5096 const char *entityTextPtr,
5097 const char *entityTextEnd)
5120 if (isParamEntity || enc !=
encoding) {
5128 goto endEntityValue;
5130 entity = (
ENTITY *)
lookup(parser, &dtd->paramEntities, name, 0);
5140 goto endEntityValue;
5146 goto endEntityValue;
5159 goto endEntityValue;
5162 if (!dtd->paramEntityRead)
5177 goto endEntityValue;
5186 goto endEntityValue;
5189 goto endEntityValue;
5192 if (!
poolAppend(pool, enc, entityTextPtr, next)) {
5194 goto endEntityValue;
5203 goto endEntityValue;
5205 *(pool->
ptr)++ = 0xA;
5216 goto endEntityValue;
5223 goto endEntityValue;
5225 for (i = 0; i <
n; i++) {
5228 goto endEntityValue;
5230 *(pool->
ptr)++ = buf[i];
5238 goto endEntityValue;
5243 goto endEntityValue;
5248 goto endEntityValue;
5250 entityTextPtr = next;
5264 if (*s ==
XML_T(
'\0'))
5284 const char *start,
const char *end)
5313 const char *start,
const char *end)
5335 const char *s,
const char *end)
5338 const char **eventPP;
5339 const char **eventEndPP;
5366 if (value || isId) {
5374 type->
idAtt = attId;
5410 for (name = elementType->
name; *name; name++) {
5414 for (s = elementType->
name; s != name; s++) {
5437 const char *start,
const char *end)
5452 if (id->
name != name)
5464 if (name[5] ==
XML_T(
'\0'))
5472 for (i = 0; name[i]; i++) {
5476 for (j = 0; j < i; j++) {
5496 #define CONTEXT_SEP XML_T(ASCII_FF)
5513 for (i = 0; i <
len; i++)
5531 for (s = prefix->
name; *s; s++)
5539 for (i = 0; i <
len; i++)
5556 for (s = e->
name; *s; s++)
5573 while (*context !=
XML_T(
'\0')) {
5581 if (*s !=
XML_T(
'\0'))
5604 for (context = s + 1;
5615 if (*context !=
XML_T(
'\0'))
5633 for (s = publicId; *
s; s++) {
5638 if (p != publicId && p[-1] != 0x20)
5645 if (p != publicId && p[-1] == 0x20)
5866 &(newDtd->paramEntities),
5868 &(oldDtd->paramEntities)))
5870 newDtd->paramEntityRead = oldDtd->paramEntityRead;
5895 const XML_Char *cachedOldBase = NULL;
5896 const XML_Char *cachedNewBase = NULL;
5918 if (oldE->
base == cachedOldBase)
5919 newE->
base = cachedNewBase;
5921 cachedOldBase = oldE->
base;
5925 cachedNewBase = newE->
base = tem;
5955 #define INIT_POWER 6
5960 for (; *s1 == *s2; s1++, s2++)
5979 if (table->
size == 0) {
5992 memset(table->
v, 0, tsize);
5993 i =
hash(parser, name) & ((
unsigned long)table->
size - 1);
5996 unsigned long h =
hash(parser, name);
5997 unsigned long mask = (
unsigned long)table->
size - 1;
5998 unsigned char step = 0;
6011 if (table->
used >> (table->
power - 1)) {
6012 unsigned char newPower = table->
power + 1;
6013 size_t newSize = (size_t)1 << newPower;
6014 unsigned long newMask = (
unsigned long)newSize - 1;
6015 size_t tsize = newSize *
sizeof(
NAMED *);
6019 memset(newV, 0, tsize);
6020 for (i = 0; i < table->
size; i++)
6022 unsigned long newHash =
hash(parser, table->
v[i]->
name);
6023 size_t j = newHash & newMask;
6030 newV[j] = table->
v[i];
6034 table->
power = newPower;
6035 table->
size = newSize;
6038 while (table->
v[i]) {
6048 memset(table->
v[i], 0, createSize);
6058 for (i = 0; i < table->
size; i++) {
6069 for (i = 0; i < table->
size; i++)
6094 while (iter->
p != iter->
end) {
6095 NAMED *tem = *(iter->
p)++;
6152 const char *ptr,
const char *end)
6183 for (; n > 0; --
n, s++) {
6205 const char *ptr,
const char *end)
6219 if (pool->
start == 0) {
6253 pool->
end = pool->
start + blockSize;
6266 tem->
size = blockSize;
6270 memcpy(tem->
s, pool->
start,
6274 pool->
end = tem->
s + blockSize;
6339 dest->
name = *strpos;
6342 *(*strpos)++ = *src;
6357 i < dest->numchildren;
6401 if (ret->
name != name)