Mercurial > cpython-lru_cache-weakref
annotate Modules/expat/xmlparse.c @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | 764df2fdc9c6 |
| children | 6248dd5d192a |
| rev | line source |
|---|---|
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1 /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2 See the file COPYING for copying permission. |
| 21930 | 3 */ |
| 4 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5 #include <stddef.h> |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6 #include <string.h> /* memset(), memcpy() */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
7 |
| 21930 | 8 #ifdef COMPILED_FROM_DSP |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
9 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
10 #include "winconfig.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
11 #define XMLPARSEAPI(type) type __cdecl |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
12 #include "expat.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
13 #undef XMLPARSEAPI |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
14 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
15 #elif defined(MACOS_CLASSIC) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
16 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
17 #include "macconfig.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
18 #include "expat.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
19 |
| 21930 | 20 #else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
21 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
22 /* Unused - MvL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
23 #include <expat_config.h> |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
24 */ |
| 21930 | 25 |
| 26 #ifdef __declspec | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
27 #define XMLPARSEAPI(type) type __cdecl |
| 21930 | 28 #endif |
| 29 | |
| 30 #include "expat.h" | |
| 31 | |
| 32 #ifdef __declspec | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
33 #undef XMLPARSEAPI |
| 21930 | 34 #endif |
| 35 #endif /* ndef COMPILED_FROM_DSP */ | |
| 36 | |
| 37 #ifdef XML_UNICODE | |
| 38 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX | |
| 39 #define XmlConvert XmlUtf16Convert | |
| 40 #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding | |
| 41 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS | |
| 42 #define XmlEncode XmlUtf16Encode | |
| 43 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) | |
| 44 typedef unsigned short ICHAR; | |
| 45 #else | |
| 46 #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX | |
| 47 #define XmlConvert XmlUtf8Convert | |
| 48 #define XmlGetInternalEncoding XmlGetUtf8InternalEncoding | |
| 49 #define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS | |
| 50 #define XmlEncode XmlUtf8Encode | |
| 51 #define MUST_CONVERT(enc, s) (!(enc)->isUtf8) | |
| 52 typedef char ICHAR; | |
| 53 #endif | |
| 54 | |
| 55 | |
| 56 #ifndef XML_NS | |
| 57 | |
| 58 #define XmlInitEncodingNS XmlInitEncoding | |
| 59 #define XmlInitUnknownEncodingNS XmlInitUnknownEncoding | |
| 60 #undef XmlGetInternalEncodingNS | |
| 61 #define XmlGetInternalEncodingNS XmlGetInternalEncoding | |
| 62 #define XmlParseXmlDeclNS XmlParseXmlDecl | |
| 63 | |
| 64 #endif | |
| 65 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
66 #ifdef XML_UNICODE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
67 |
| 21930 | 68 #ifdef XML_UNICODE_WCHAR_T |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
69 #define XML_T(x) (const wchar_t)x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
70 #define XML_L(x) L ## x |
| 21930 | 71 #else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
72 #define XML_T(x) (const unsigned short)x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
73 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
74 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
75 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
76 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
77 |
| 21930 | 78 #define XML_T(x) x |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
79 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
80 |
| 21930 | 81 #endif |
| 82 | |
| 83 /* Round up n to be a multiple of sz, where sz is a power of 2. */ | |
| 84 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) | |
| 85 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
86 #include "internal.h" |
| 21930 | 87 #include "xmltok.h" |
| 88 #include "xmlrole.h" | |
| 89 | |
| 90 typedef const XML_Char *KEY; | |
| 91 | |
| 92 typedef struct { | |
| 93 KEY name; | |
| 94 } NAMED; | |
| 95 | |
| 96 typedef struct { | |
| 97 NAMED **v; | |
| 98 size_t size; | |
| 99 size_t used; | |
| 100 size_t usedLim; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
101 const XML_Memory_Handling_Suite *mem; |
| 21930 | 102 } HASH_TABLE; |
| 103 | |
| 104 typedef struct { | |
| 105 NAMED **p; | |
| 106 NAMED **end; | |
| 107 } HASH_TABLE_ITER; | |
| 108 | |
| 109 #define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ | |
| 110 #define INIT_DATA_BUF_SIZE 1024 | |
| 111 #define INIT_ATTS_SIZE 16 | |
| 112 #define INIT_BLOCK_SIZE 1024 | |
| 113 #define INIT_BUFFER_SIZE 1024 | |
| 114 | |
| 115 #define EXPAND_SPARE 24 | |
| 116 | |
| 117 typedef struct binding { | |
| 118 struct prefix *prefix; | |
| 119 struct binding *nextTagBinding; | |
| 120 struct binding *prevPrefixBinding; | |
| 121 const struct attribute_id *attId; | |
| 122 XML_Char *uri; | |
| 123 int uriLen; | |
| 124 int uriAlloc; | |
| 125 } BINDING; | |
| 126 | |
| 127 typedef struct prefix { | |
| 128 const XML_Char *name; | |
| 129 BINDING *binding; | |
| 130 } PREFIX; | |
| 131 | |
| 132 typedef struct { | |
| 133 const XML_Char *str; | |
| 134 const XML_Char *localPart; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
135 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
136 int strLen; |
| 21930 | 137 int uriLen; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
138 int prefixLen; |
| 21930 | 139 } TAG_NAME; |
| 140 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
141 /* TAG represents an open element. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
142 The name of the element is stored in both the document and API |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
143 encodings. The memory buffer 'buf' is a separately-allocated |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
144 memory area which stores the name. During the XML_Parse()/ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
145 XMLParseBuffer() when the element is open, the memory for the 'raw' |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
146 version of the name (in the document encoding) is shared with the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
147 document buffer. If the element is open across calls to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
148 XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
149 contain the 'raw' name as well. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
150 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
151 A parser re-uses these structures, maintaining a list of allocated |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
152 TAG objects in a free list. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
153 */ |
| 21930 | 154 typedef struct tag { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
155 struct tag *parent; /* parent of this element */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
156 const char *rawName; /* tagName in the original encoding */ |
| 21930 | 157 int rawNameLength; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
158 TAG_NAME name; /* tagName in the API encoding */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
159 char *buf; /* buffer for name components */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
160 char *bufEnd; /* end of the buffer */ |
| 21930 | 161 BINDING *bindings; |
| 162 } TAG; | |
| 163 | |
| 164 typedef struct { | |
| 165 const XML_Char *name; | |
| 166 const XML_Char *textPtr; | |
| 167 int textLen; | |
| 168 const XML_Char *systemId; | |
| 169 const XML_Char *base; | |
| 170 const XML_Char *publicId; | |
| 171 const XML_Char *notation; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
172 XML_Bool open; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
173 XML_Bool is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
174 XML_Bool is_internal; /* true if declared in internal subset outside PE */ |
| 21930 | 175 } ENTITY; |
| 176 | |
| 177 typedef struct { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
178 enum XML_Content_Type type; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
179 enum XML_Content_Quant quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
180 const XML_Char * name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
181 int firstchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
182 int lastchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
183 int childcnt; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
184 int nextsib; |
| 21930 | 185 } CONTENT_SCAFFOLD; |
| 186 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
187 #define INIT_SCAFFOLD_ELEMENTS 32 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
188 |
| 21930 | 189 typedef struct block { |
| 190 struct block *next; | |
| 191 int size; | |
| 192 XML_Char s[1]; | |
| 193 } BLOCK; | |
| 194 | |
| 195 typedef struct { | |
| 196 BLOCK *blocks; | |
| 197 BLOCK *freeBlocks; | |
| 198 const XML_Char *end; | |
| 199 XML_Char *ptr; | |
| 200 XML_Char *start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
201 const XML_Memory_Handling_Suite *mem; |
| 21930 | 202 } STRING_POOL; |
| 203 | |
| 204 /* The XML_Char before the name is used to determine whether | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
205 an attribute has been specified. */ |
| 21930 | 206 typedef struct attribute_id { |
| 207 XML_Char *name; | |
| 208 PREFIX *prefix; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
209 XML_Bool maybeTokenized; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
210 XML_Bool xmlns; |
| 21930 | 211 } ATTRIBUTE_ID; |
| 212 | |
| 213 typedef struct { | |
| 214 const ATTRIBUTE_ID *id; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
215 XML_Bool isCdata; |
| 21930 | 216 const XML_Char *value; |
| 217 } DEFAULT_ATTRIBUTE; | |
| 218 | |
| 219 typedef struct { | |
| 220 const XML_Char *name; | |
| 221 PREFIX *prefix; | |
| 222 const ATTRIBUTE_ID *idAtt; | |
| 223 int nDefaultAtts; | |
| 224 int allocDefaultAtts; | |
| 225 DEFAULT_ATTRIBUTE *defaultAtts; | |
| 226 } ELEMENT_TYPE; | |
| 227 | |
| 228 typedef struct { | |
| 229 HASH_TABLE generalEntities; | |
| 230 HASH_TABLE elementTypes; | |
| 231 HASH_TABLE attributeIds; | |
| 232 HASH_TABLE prefixes; | |
| 233 STRING_POOL pool; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
234 STRING_POOL entityValuePool; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
235 /* false once a parameter entity reference has been skipped */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
236 XML_Bool keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
237 /* true once an internal or external PE reference has been encountered; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
238 this includes the reference to an external subset */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
239 XML_Bool hasParamEntityRefs; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
240 XML_Bool standalone; |
| 21930 | 241 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
242 /* indicates if external PE has been read */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
243 XML_Bool paramEntityRead; |
| 21930 | 244 HASH_TABLE paramEntities; |
| 245 #endif /* XML_DTD */ | |
| 246 PREFIX defaultPrefix; | |
| 247 /* === scaffolding for building content model === */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
248 XML_Bool in_eldecl; |
| 21930 | 249 CONTENT_SCAFFOLD *scaffold; |
| 250 unsigned contentStringLen; | |
| 251 unsigned scaffSize; | |
| 252 unsigned scaffCount; | |
| 253 int scaffLevel; | |
| 254 int *scaffIndex; | |
| 255 } DTD; | |
| 256 | |
| 257 typedef struct open_internal_entity { | |
| 258 const char *internalEventPtr; | |
| 259 const char *internalEventEndPtr; | |
| 260 struct open_internal_entity *next; | |
| 261 ENTITY *entity; | |
| 262 } OPEN_INTERNAL_ENTITY; | |
| 263 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
264 typedef enum XML_Error PTRCALL Processor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
265 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
266 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
267 const char **endPtr); |
| 21930 | 268 |
| 269 static Processor prologProcessor; | |
| 270 static Processor prologInitProcessor; | |
| 271 static Processor contentProcessor; | |
| 272 static Processor cdataSectionProcessor; | |
| 273 #ifdef XML_DTD | |
| 274 static Processor ignoreSectionProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
275 static Processor externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
276 static Processor externalParEntInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
277 static Processor entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
278 static Processor entityValueInitProcessor; |
| 21930 | 279 #endif /* XML_DTD */ |
| 280 static Processor epilogProcessor; | |
| 281 static Processor errorProcessor; | |
| 282 static Processor externalEntityInitProcessor; | |
| 283 static Processor externalEntityInitProcessor2; | |
| 284 static Processor externalEntityInitProcessor3; | |
| 285 static Processor externalEntityContentProcessor; | |
| 286 | |
| 287 static enum XML_Error | |
| 288 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); | |
| 289 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
290 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
291 const char *, const char *); |
| 21930 | 292 static enum XML_Error |
| 293 initializeEncoding(XML_Parser parser); | |
| 294 static enum XML_Error | |
| 295 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
296 const char *end, int tok, const char *next, const char **nextPtr); |
| 21930 | 297 static enum XML_Error |
| 298 processInternalParamEntity(XML_Parser parser, ENTITY *entity); | |
| 299 static enum XML_Error | |
| 300 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
301 const char *start, const char *end, const char **endPtr); |
| 21930 | 302 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
303 doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
304 const char *end, const char **nextPtr); |
| 21930 | 305 #ifdef XML_DTD |
| 306 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
307 doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
308 const char *end, const char **nextPtr); |
| 21930 | 309 #endif /* XML_DTD */ |
| 310 | |
| 311 static enum XML_Error | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
312 storeAtts(XML_Parser parser, const ENCODING *, const char *s, |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
313 TAG_NAME *tagNamePtr, BINDING **bindingsPtr); |
| 21930 | 314 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
315 addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
316 const XML_Char *uri, BINDING **bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
317 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
318 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
319 XML_Bool isCdata, XML_Bool isId, const XML_Char *dfltValue, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
320 XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
321 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
322 storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
323 const char *, const char *, STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
324 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
325 appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
326 const char *, const char *, STRING_POOL *); |
| 21930 | 327 static ATTRIBUTE_ID * |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
328 getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
329 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
330 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
331 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); |
| 21930 | 332 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
333 storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
334 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
335 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
336 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
337 const char *start, const char *end); |
| 21930 | 338 static int |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
339 reportComment(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
340 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
341 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
342 reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
343 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
344 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
345 static const XML_Char * getContext(XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
346 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
347 setContext(XML_Parser parser, const XML_Char *context); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
348 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
349 static void FASTCALL normalizePublicId(XML_Char *s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
350 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
351 static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
352 /* do not call if parentParser != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
353 static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); |
| 21930 | 354 static void |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
355 dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
356 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
357 dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
358 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
359 copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
360 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
361 static NAMED * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
362 lookup(HASH_TABLE *table, KEY name, size_t createSize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
363 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
364 hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
365 static void FASTCALL hashTableClear(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
366 static void FASTCALL hashTableDestroy(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
367 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
368 hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
369 static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
370 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
371 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
372 poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
373 static void FASTCALL poolClear(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
374 static void FASTCALL poolDestroy(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
375 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
376 poolAppend(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
377 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
378 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
379 poolStoreString(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
380 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
381 static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
382 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
383 poolCopyString(STRING_POOL *pool, const XML_Char *s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
384 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
385 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
386 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
387 poolAppendString(STRING_POOL *pool, const XML_Char *s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
388 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
389 static int FASTCALL nextScaffoldPart(XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
390 static XML_Content * build_model(XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
391 static ELEMENT_TYPE * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
392 getElementType(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
393 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
394 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
395 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
396 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
397 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
398 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
399 DTD *dtd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
400 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
401 parserInit(XML_Parser parser, const XML_Char *encodingName); |
| 21930 | 402 |
| 403 #define poolStart(pool) ((pool)->start) | |
| 404 #define poolEnd(pool) ((pool)->ptr) | |
| 405 #define poolLength(pool) ((pool)->ptr - (pool)->start) | |
| 406 #define poolChop(pool) ((void)--(pool->ptr)) | |
| 407 #define poolLastChar(pool) (((pool)->ptr)[-1]) | |
| 408 #define poolDiscard(pool) ((pool)->ptr = (pool)->start) | |
| 409 #define poolFinish(pool) ((pool)->start = (pool)->ptr) | |
| 410 #define poolAppendChar(pool, c) \ | |
| 411 (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ | |
| 412 ? 0 \ | |
| 413 : ((*((pool)->ptr)++ = c), 1)) | |
| 414 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
415 struct XML_ParserStruct { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
416 /* The first member must be userData so that the XML_GetUserData |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
417 macro works. */ |
| 21930 | 418 void *m_userData; |
| 419 void *m_handlerArg; | |
| 420 char *m_buffer; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
421 const XML_Memory_Handling_Suite m_mem; |
| 21930 | 422 /* first character to be parsed */ |
| 423 const char *m_bufferPtr; | |
| 424 /* past last character to be parsed */ | |
| 425 char *m_bufferEnd; | |
| 426 /* allocated end of buffer */ | |
| 427 const char *m_bufferLim; | |
| 428 long m_parseEndByteIndex; | |
| 429 const char *m_parseEndPtr; | |
| 430 XML_Char *m_dataBuf; | |
| 431 XML_Char *m_dataBufEnd; | |
| 432 XML_StartElementHandler m_startElementHandler; | |
| 433 XML_EndElementHandler m_endElementHandler; | |
| 434 XML_CharacterDataHandler m_characterDataHandler; | |
| 435 XML_ProcessingInstructionHandler m_processingInstructionHandler; | |
| 436 XML_CommentHandler m_commentHandler; | |
| 437 XML_StartCdataSectionHandler m_startCdataSectionHandler; | |
| 438 XML_EndCdataSectionHandler m_endCdataSectionHandler; | |
| 439 XML_DefaultHandler m_defaultHandler; | |
| 440 XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; | |
| 441 XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; | |
| 442 XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; | |
| 443 XML_NotationDeclHandler m_notationDeclHandler; | |
| 444 XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; | |
| 445 XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; | |
| 446 XML_NotStandaloneHandler m_notStandaloneHandler; | |
| 447 XML_ExternalEntityRefHandler m_externalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
448 XML_Parser m_externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
449 XML_SkippedEntityHandler m_skippedEntityHandler; |
| 21930 | 450 XML_UnknownEncodingHandler m_unknownEncodingHandler; |
| 451 XML_ElementDeclHandler m_elementDeclHandler; | |
| 452 XML_AttlistDeclHandler m_attlistDeclHandler; | |
| 453 XML_EntityDeclHandler m_entityDeclHandler; | |
| 454 XML_XmlDeclHandler m_xmlDeclHandler; | |
| 455 const ENCODING *m_encoding; | |
| 456 INIT_ENCODING m_initEncoding; | |
| 457 const ENCODING *m_internalEncoding; | |
| 458 const XML_Char *m_protocolEncodingName; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
459 XML_Bool m_ns; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
460 XML_Bool m_ns_triplets; |
| 21930 | 461 void *m_unknownEncodingMem; |
| 462 void *m_unknownEncodingData; | |
| 463 void *m_unknownEncodingHandlerData; | |
| 464 void (*m_unknownEncodingRelease)(void *); | |
| 465 PROLOG_STATE m_prologState; | |
| 466 Processor *m_processor; | |
| 467 enum XML_Error m_errorCode; | |
| 468 const char *m_eventPtr; | |
| 469 const char *m_eventEndPtr; | |
| 470 const char *m_positionPtr; | |
| 471 OPEN_INTERNAL_ENTITY *m_openInternalEntities; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
472 XML_Bool m_defaultExpandInternalEntities; |
| 21930 | 473 int m_tagLevel; |
| 474 ENTITY *m_declEntity; | |
| 475 const XML_Char *m_doctypeName; | |
| 476 const XML_Char *m_doctypeSysid; | |
| 477 const XML_Char *m_doctypePubid; | |
| 478 const XML_Char *m_declAttributeType; | |
| 479 const XML_Char *m_declNotationName; | |
| 480 const XML_Char *m_declNotationPublicId; | |
| 481 ELEMENT_TYPE *m_declElementType; | |
| 482 ATTRIBUTE_ID *m_declAttributeId; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
483 XML_Bool m_declAttributeIsCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
484 XML_Bool m_declAttributeIsId; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
485 DTD *m_dtd; |
| 21930 | 486 const XML_Char *m_curBase; |
| 487 TAG *m_tagStack; | |
| 488 TAG *m_freeTagList; | |
| 489 BINDING *m_inheritedBindings; | |
| 490 BINDING *m_freeBindingList; | |
| 491 int m_attsSize; | |
| 492 int m_nSpecifiedAtts; | |
| 493 int m_idAttIndex; | |
| 494 ATTRIBUTE *m_atts; | |
| 495 POSITION m_position; | |
| 496 STRING_POOL m_tempPool; | |
| 497 STRING_POOL m_temp2Pool; | |
| 498 char *m_groupConnector; | |
| 499 unsigned m_groupSize; | |
| 500 XML_Char m_namespaceSeparator; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
501 XML_Parser m_parentParser; |
| 21930 | 502 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
503 XML_Bool m_isParamEntity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
504 XML_Bool m_useForeignDTD; |
| 21930 | 505 enum XML_ParamEntityParsing m_paramEntityParsing; |
| 506 #endif | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
507 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
508 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
509 #define MALLOC(s) (parser->m_mem.malloc_fcn((s))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
510 #define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
511 #define FREE(p) (parser->m_mem.free_fcn((p))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
512 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
513 #define userData (parser->m_userData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
514 #define handlerArg (parser->m_handlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
515 #define startElementHandler (parser->m_startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
516 #define endElementHandler (parser->m_endElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
517 #define characterDataHandler (parser->m_characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
518 #define processingInstructionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
519 (parser->m_processingInstructionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
520 #define commentHandler (parser->m_commentHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
521 #define startCdataSectionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
522 (parser->m_startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
523 #define endCdataSectionHandler (parser->m_endCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
524 #define defaultHandler (parser->m_defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
525 #define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
526 #define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
527 #define unparsedEntityDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
528 (parser->m_unparsedEntityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
529 #define notationDeclHandler (parser->m_notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
530 #define startNamespaceDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
531 (parser->m_startNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
532 #define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
533 #define notStandaloneHandler (parser->m_notStandaloneHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
534 #define externalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
535 (parser->m_externalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
536 #define externalEntityRefHandlerArg \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
537 (parser->m_externalEntityRefHandlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
538 #define internalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
539 (parser->m_internalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
540 #define skippedEntityHandler (parser->m_skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
541 #define unknownEncodingHandler (parser->m_unknownEncodingHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
542 #define elementDeclHandler (parser->m_elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
543 #define attlistDeclHandler (parser->m_attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
544 #define entityDeclHandler (parser->m_entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
545 #define xmlDeclHandler (parser->m_xmlDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
546 #define encoding (parser->m_encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
547 #define initEncoding (parser->m_initEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
548 #define internalEncoding (parser->m_internalEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
549 #define unknownEncodingMem (parser->m_unknownEncodingMem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
550 #define unknownEncodingData (parser->m_unknownEncodingData) |
| 21930 | 551 #define unknownEncodingHandlerData \ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
552 (parser->m_unknownEncodingHandlerData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
553 #define unknownEncodingRelease (parser->m_unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
554 #define protocolEncodingName (parser->m_protocolEncodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
555 #define ns (parser->m_ns) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
556 #define ns_triplets (parser->m_ns_triplets) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
557 #define prologState (parser->m_prologState) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
558 #define processor (parser->m_processor) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
559 #define errorCode (parser->m_errorCode) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
560 #define eventPtr (parser->m_eventPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
561 #define eventEndPtr (parser->m_eventEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
562 #define positionPtr (parser->m_positionPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
563 #define position (parser->m_position) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
564 #define openInternalEntities (parser->m_openInternalEntities) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
565 #define defaultExpandInternalEntities \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
566 (parser->m_defaultExpandInternalEntities) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
567 #define tagLevel (parser->m_tagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
568 #define buffer (parser->m_buffer) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
569 #define bufferPtr (parser->m_bufferPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
570 #define bufferEnd (parser->m_bufferEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
571 #define parseEndByteIndex (parser->m_parseEndByteIndex) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
572 #define parseEndPtr (parser->m_parseEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
573 #define bufferLim (parser->m_bufferLim) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
574 #define dataBuf (parser->m_dataBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
575 #define dataBufEnd (parser->m_dataBufEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
576 #define _dtd (parser->m_dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
577 #define curBase (parser->m_curBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
578 #define declEntity (parser->m_declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
579 #define doctypeName (parser->m_doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
580 #define doctypeSysid (parser->m_doctypeSysid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
581 #define doctypePubid (parser->m_doctypePubid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
582 #define declAttributeType (parser->m_declAttributeType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
583 #define declNotationName (parser->m_declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
584 #define declNotationPublicId (parser->m_declNotationPublicId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
585 #define declElementType (parser->m_declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
586 #define declAttributeId (parser->m_declAttributeId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
587 #define declAttributeIsCdata (parser->m_declAttributeIsCdata) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
588 #define declAttributeIsId (parser->m_declAttributeIsId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
589 #define freeTagList (parser->m_freeTagList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
590 #define freeBindingList (parser->m_freeBindingList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
591 #define inheritedBindings (parser->m_inheritedBindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
592 #define tagStack (parser->m_tagStack) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
593 #define atts (parser->m_atts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
594 #define attsSize (parser->m_attsSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
595 #define nSpecifiedAtts (parser->m_nSpecifiedAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
596 #define idAttIndex (parser->m_idAttIndex) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
597 #define tempPool (parser->m_tempPool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
598 #define temp2Pool (parser->m_temp2Pool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
599 #define groupConnector (parser->m_groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
600 #define groupSize (parser->m_groupSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
601 #define namespaceSeparator (parser->m_namespaceSeparator) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
602 #define parentParser (parser->m_parentParser) |
| 21930 | 603 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
604 #define isParamEntity (parser->m_isParamEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
605 #define useForeignDTD (parser->m_useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
606 #define paramEntityParsing (parser->m_paramEntityParsing) |
| 21930 | 607 #endif /* XML_DTD */ |
| 608 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
609 #define parsing \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
610 (parentParser \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
611 ? \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
612 (isParamEntity \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
613 ? \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
614 (processor != externalParEntInitProcessor) \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
615 : \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
616 (processor != externalEntityInitProcessor)) \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
617 : \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
618 (processor != prologInitProcessor)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
619 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
620 XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
621 XML_ParserCreate(const XML_Char *encodingName) |
| 21930 | 622 { |
| 623 return XML_ParserCreate_MM(encodingName, NULL, NULL); | |
| 624 } | |
| 625 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
626 XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
627 XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) |
| 21930 | 628 { |
| 629 XML_Char tmp[2]; | |
| 630 *tmp = nsSep; | |
| 631 return XML_ParserCreate_MM(encodingName, NULL, tmp); | |
| 632 } | |
| 633 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
634 static const XML_Char implicitContext[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
635 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
636 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
637 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
638 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
639 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
640 |
| 21930 | 641 XML_Parser |
| 642 XML_ParserCreate_MM(const XML_Char *encodingName, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
643 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
644 const XML_Char *nameSep) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
645 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
646 XML_Parser parser = parserCreate(encodingName, memsuite, nameSep, NULL); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
647 if (parser != NULL && ns) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
648 /* implicit context only set for root parser, since child |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
649 parsers (i.e. external entity parsers) will inherit it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
650 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
651 if (!setContext(parser, implicitContext)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
652 XML_ParserFree(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
653 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
654 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
655 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
656 return parser; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
657 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
658 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
659 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
660 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
661 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
662 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
663 DTD *dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
664 { |
| 21930 | 665 XML_Parser parser; |
| 666 | |
| 667 if (memsuite) { | |
| 668 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
669 parser = (XML_Parser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
670 memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
671 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
672 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
673 mtemp->malloc_fcn = memsuite->malloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
674 mtemp->realloc_fcn = memsuite->realloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
675 mtemp->free_fcn = memsuite->free_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
676 } |
| 21930 | 677 } |
| 678 else { | |
| 679 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
680 parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
681 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
682 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
683 mtemp->malloc_fcn = malloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
684 mtemp->realloc_fcn = realloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
685 mtemp->free_fcn = free; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
686 } |
| 21930 | 687 } |
| 688 | |
| 689 if (!parser) | |
| 690 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
691 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
692 buffer = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
693 bufferLim = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
694 |
| 21930 | 695 attsSize = INIT_ATTS_SIZE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
696 atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
697 if (atts == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
698 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
699 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
700 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
701 dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
702 if (dataBuf == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
703 FREE(atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
704 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
705 return NULL; |
| 21930 | 706 } |
| 707 dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; | |
| 708 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
709 if (dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
710 _dtd = dtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
711 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
712 _dtd = dtdCreate(&parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
713 if (_dtd == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
714 FREE(dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
715 FREE(atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
716 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
717 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
718 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
719 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
720 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
721 freeBindingList = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
722 freeTagList = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
723 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
724 groupSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
725 groupConnector = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
726 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
727 unknownEncodingHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
728 unknownEncodingHandlerData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
729 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
730 namespaceSeparator = '!'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
731 ns = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
732 ns_triplets = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
733 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
734 poolInit(&tempPool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
735 poolInit(&temp2Pool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
736 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
737 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
738 if (encodingName && !protocolEncodingName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
739 XML_ParserFree(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
740 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
741 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
742 |
| 21930 | 743 if (nameSep) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
744 ns = XML_TRUE; |
| 21930 | 745 internalEncoding = XmlGetInternalEncodingNS(); |
| 746 namespaceSeparator = *nameSep; | |
| 747 } | |
| 748 else { | |
| 749 internalEncoding = XmlGetInternalEncoding(); | |
| 750 } | |
| 751 | |
| 752 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
753 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
754 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
755 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
756 parserInit(XML_Parser parser, const XML_Char *encodingName) |
| 21930 | 757 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
758 processor = prologInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
759 XmlPrologStateInit(&prologState); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
760 protocolEncodingName = (encodingName != NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
761 ? poolCopyString(&tempPool, encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
762 : NULL); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
763 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
764 XmlInitEncoding(&initEncoding, &encoding, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
765 userData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
766 handlerArg = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
767 startElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
768 endElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
769 characterDataHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
770 processingInstructionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
771 commentHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
772 startCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
773 endCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
774 defaultHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
775 startDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
776 endDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
777 unparsedEntityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
778 notationDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
779 startNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
780 endNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
781 notStandaloneHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
782 externalEntityRefHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
783 externalEntityRefHandlerArg = parser; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
784 skippedEntityHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
785 elementDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
786 attlistDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
787 entityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
788 xmlDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
789 bufferPtr = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
790 bufferEnd = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
791 parseEndByteIndex = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
792 parseEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
793 declElementType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
794 declAttributeId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
795 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
796 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
797 doctypeSysid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
798 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
799 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
800 declNotationName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
801 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
802 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
803 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
804 memset(&position, 0, sizeof(POSITION)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
805 errorCode = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
806 eventPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
807 eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
808 positionPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
809 openInternalEntities = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
810 defaultExpandInternalEntities = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
811 tagLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
812 tagStack = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
813 inheritedBindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
814 nSpecifiedAtts = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
815 unknownEncodingMem = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
816 unknownEncodingRelease = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
817 unknownEncodingData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
818 parentParser = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
819 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
820 isParamEntity = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
821 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
822 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
823 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
824 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
825 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
826 /* moves list of bindings to freeBindingList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
827 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
828 moveToFreeBindingList(XML_Parser parser, BINDING *bindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
829 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
830 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
831 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
832 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
833 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
834 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
835 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
836 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
837 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
838 XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
839 XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
840 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
841 TAG *tStk; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
842 if (parentParser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
843 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
844 /* move tagStack to freeTagList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
845 tStk = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
846 while (tStk) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
847 TAG *tag = tStk; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
848 tStk = tStk->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
849 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
850 moveToFreeBindingList(parser, tag->bindings); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
851 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
852 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
853 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
854 moveToFreeBindingList(parser, inheritedBindings); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
855 if (unknownEncodingMem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
856 FREE(unknownEncodingMem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
857 if (unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
858 unknownEncodingRelease(unknownEncodingData); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
859 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
860 poolClear(&temp2Pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
861 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
862 dtdReset(_dtd, &parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
863 return setContext(parser, implicitContext); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
864 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
865 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
866 enum XML_Status |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
867 XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
868 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
869 /* Block after XML_Parse()/XML_ParseBuffer() has been called. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
870 XXX There's no way for the caller to determine which of the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
871 XXX possible error cases caused the XML_STATUS_ERROR return. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
872 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
873 if (parsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
874 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
875 if (encodingName == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
876 protocolEncodingName = NULL; |
| 21930 | 877 else { |
| 878 protocolEncodingName = poolCopyString(&tempPool, encodingName); | |
| 879 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
880 return XML_STATUS_ERROR; |
| 21930 | 881 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
882 return XML_STATUS_OK; |
| 21930 | 883 } |
| 884 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
885 XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
886 XML_ExternalEntityParserCreate(XML_Parser oldParser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
887 const XML_Char *context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
888 const XML_Char *encodingName) |
| 21930 | 889 { |
| 890 XML_Parser parser = oldParser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
891 DTD *newDtd = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
892 DTD *oldDtd = _dtd; |
| 21930 | 893 XML_StartElementHandler oldStartElementHandler = startElementHandler; |
| 894 XML_EndElementHandler oldEndElementHandler = endElementHandler; | |
| 895 XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
896 XML_ProcessingInstructionHandler oldProcessingInstructionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
897 = processingInstructionHandler; |
| 21930 | 898 XML_CommentHandler oldCommentHandler = commentHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
899 XML_StartCdataSectionHandler oldStartCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
900 = startCdataSectionHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
901 XML_EndCdataSectionHandler oldEndCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
902 = endCdataSectionHandler; |
| 21930 | 903 XML_DefaultHandler oldDefaultHandler = defaultHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
904 XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
905 = unparsedEntityDeclHandler; |
| 21930 | 906 XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
907 XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
908 = startNamespaceDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
909 XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
910 = endNamespaceDeclHandler; |
| 21930 | 911 XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
912 XML_ExternalEntityRefHandler oldExternalEntityRefHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
913 = externalEntityRefHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
914 XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
915 XML_UnknownEncodingHandler oldUnknownEncodingHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
916 = unknownEncodingHandler; |
| 21930 | 917 XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; |
| 918 XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; | |
| 919 XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; | |
| 920 XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; | |
| 921 ELEMENT_TYPE * oldDeclElementType = declElementType; | |
| 922 | |
| 923 void *oldUserData = userData; | |
| 924 void *oldHandlerArg = handlerArg; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
925 XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
926 XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
927 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
928 enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
929 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
930 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
931 XML_Bool oldns_triplets = ns_triplets; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
932 |
| 21930 | 933 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
934 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
935 newDtd = oldDtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
936 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
937 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
938 /* Note that the magical uses of the pre-processor to make field |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
939 access look more like C++ require that `parser' be overwritten |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
940 here. This makes this function more painful to follow than it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
941 would be otherwise. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
942 */ |
| 21930 | 943 if (ns) { |
| 944 XML_Char tmp[2]; | |
| 945 *tmp = namespaceSeparator; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
946 parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); |
| 21930 | 947 } |
| 948 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
949 parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); |
| 21930 | 950 } |
| 951 | |
| 952 if (!parser) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
953 return NULL; |
| 21930 | 954 |
| 955 startElementHandler = oldStartElementHandler; | |
| 956 endElementHandler = oldEndElementHandler; | |
| 957 characterDataHandler = oldCharacterDataHandler; | |
| 958 processingInstructionHandler = oldProcessingInstructionHandler; | |
| 959 commentHandler = oldCommentHandler; | |
| 960 startCdataSectionHandler = oldStartCdataSectionHandler; | |
| 961 endCdataSectionHandler = oldEndCdataSectionHandler; | |
| 962 defaultHandler = oldDefaultHandler; | |
| 963 unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; | |
| 964 notationDeclHandler = oldNotationDeclHandler; | |
| 965 startNamespaceDeclHandler = oldStartNamespaceDeclHandler; | |
| 966 endNamespaceDeclHandler = oldEndNamespaceDeclHandler; | |
| 967 notStandaloneHandler = oldNotStandaloneHandler; | |
| 968 externalEntityRefHandler = oldExternalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
969 skippedEntityHandler = oldSkippedEntityHandler; |
| 21930 | 970 unknownEncodingHandler = oldUnknownEncodingHandler; |
| 971 elementDeclHandler = oldElementDeclHandler; | |
| 972 attlistDeclHandler = oldAttlistDeclHandler; | |
| 973 entityDeclHandler = oldEntityDeclHandler; | |
| 974 xmlDeclHandler = oldXmlDeclHandler; | |
| 975 declElementType = oldDeclElementType; | |
| 976 userData = oldUserData; | |
| 977 if (oldUserData == oldHandlerArg) | |
| 978 handlerArg = userData; | |
| 979 else | |
| 980 handlerArg = parser; | |
| 981 if (oldExternalEntityRefHandlerArg != oldParser) | |
| 982 externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; | |
| 983 defaultExpandInternalEntities = oldDefaultExpandInternalEntities; | |
| 984 ns_triplets = oldns_triplets; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
985 parentParser = oldParser; |
| 21930 | 986 #ifdef XML_DTD |
| 987 paramEntityParsing = oldParamEntityParsing; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
988 prologState.inEntityValue = oldInEntityValue; |
| 21930 | 989 if (context) { |
| 990 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
991 if (!dtdCopy(_dtd, oldDtd, &parser->m_mem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
992 || !setContext(parser, context)) { |
| 21930 | 993 XML_ParserFree(parser); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
994 return NULL; |
| 21930 | 995 } |
| 996 processor = externalEntityInitProcessor; | |
| 997 #ifdef XML_DTD | |
| 998 } | |
| 999 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1000 /* The DTD instance referenced by _dtd is shared between the document's |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1001 root parser and external PE parsers, therefore one does not need to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1002 call setContext. In addition, one also *must* not call setContext, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1003 because this would overwrite existing prefix->binding pointers in |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1004 _dtd with ones that get destroyed with the external PE parser. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1005 This would leave those prefixes with dangling pointers. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1006 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1007 isParamEntity = XML_TRUE; |
| 21930 | 1008 XmlPrologStateInitExternalEntity(&prologState); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1009 processor = externalParEntInitProcessor; |
| 21930 | 1010 } |
| 1011 #endif /* XML_DTD */ | |
| 1012 return parser; | |
| 1013 } | |
| 1014 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1015 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1016 destroyBindings(BINDING *bindings, XML_Parser parser) |
| 21930 | 1017 { |
| 1018 for (;;) { | |
| 1019 BINDING *b = bindings; | |
| 1020 if (!b) | |
| 1021 break; | |
| 1022 bindings = b->nextTagBinding; | |
| 1023 FREE(b->uri); | |
| 1024 FREE(b); | |
| 1025 } | |
| 1026 } | |
| 1027 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1028 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1029 XML_ParserFree(XML_Parser parser) |
| 21930 | 1030 { |
| 1031 for (;;) { | |
| 1032 TAG *p; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1033 if (tagStack == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1034 if (freeTagList == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1035 break; |
| 21930 | 1036 tagStack = freeTagList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1037 freeTagList = NULL; |
| 21930 | 1038 } |
| 1039 p = tagStack; | |
| 1040 tagStack = tagStack->parent; | |
| 1041 FREE(p->buf); | |
| 1042 destroyBindings(p->bindings, parser); | |
| 1043 FREE(p); | |
| 1044 } | |
| 1045 destroyBindings(freeBindingList, parser); | |
| 1046 destroyBindings(inheritedBindings, parser); | |
| 1047 poolDestroy(&tempPool); | |
| 1048 poolDestroy(&temp2Pool); | |
| 1049 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1050 /* external parameter entity parsers share the DTD structure |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1051 parser->m_dtd with the root parser, so we must not destroy it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1052 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1053 if (!isParamEntity && _dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1054 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1055 if (_dtd) |
| 21930 | 1056 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1057 dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); |
| 21930 | 1058 FREE((void *)atts); |
| 1059 if (groupConnector) | |
| 1060 FREE(groupConnector); | |
| 1061 if (buffer) | |
| 1062 FREE(buffer); | |
| 1063 FREE(dataBuf); | |
| 1064 if (unknownEncodingMem) | |
| 1065 FREE(unknownEncodingMem); | |
| 1066 if (unknownEncodingRelease) | |
| 1067 unknownEncodingRelease(unknownEncodingData); | |
| 1068 FREE(parser); | |
| 1069 } | |
| 1070 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1071 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1072 XML_UseParserAsHandlerArg(XML_Parser parser) |
| 21930 | 1073 { |
| 1074 handlerArg = parser; | |
| 1075 } | |
| 1076 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1077 enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1078 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1079 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1080 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1081 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1082 if (parsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1083 return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1084 useForeignDTD = useDTD; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1085 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1086 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1087 return XML_ERROR_FEATURE_REQUIRES_XML_DTD; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1088 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1089 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1090 |
| 21930 | 1091 void |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1092 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1093 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1094 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1095 if (parsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1096 return; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1097 ns_triplets = do_nst ? XML_TRUE : XML_FALSE; |
| 21930 | 1098 } |
| 1099 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1100 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1101 XML_SetUserData(XML_Parser parser, void *p) |
| 21930 | 1102 { |
| 1103 if (handlerArg == userData) | |
| 1104 handlerArg = userData = p; | |
| 1105 else | |
| 1106 userData = p; | |
| 1107 } | |
| 1108 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1109 enum XML_Status |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1110 XML_SetBase(XML_Parser parser, const XML_Char *p) |
| 21930 | 1111 { |
| 1112 if (p) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1113 p = poolCopyString(&_dtd->pool, p); |
| 21930 | 1114 if (!p) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1115 return XML_STATUS_ERROR; |
| 21930 | 1116 curBase = p; |
| 1117 } | |
| 1118 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1119 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1120 return XML_STATUS_OK; |
| 21930 | 1121 } |
| 1122 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1123 const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1124 XML_GetBase(XML_Parser parser) |
| 21930 | 1125 { |
| 1126 return curBase; | |
| 1127 } | |
| 1128 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1129 int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1130 XML_GetSpecifiedAttributeCount(XML_Parser parser) |
| 21930 | 1131 { |
| 1132 return nSpecifiedAtts; | |
| 1133 } | |
| 1134 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1135 int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1136 XML_GetIdAttributeIndex(XML_Parser parser) |
| 21930 | 1137 { |
| 1138 return idAttIndex; | |
| 1139 } | |
| 1140 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1141 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1142 XML_SetElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1143 XML_StartElementHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1144 XML_EndElementHandler end) |
| 21930 | 1145 { |
| 1146 startElementHandler = start; | |
| 1147 endElementHandler = end; | |
| 1148 } | |
| 1149 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1150 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1151 XML_SetStartElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1152 XML_StartElementHandler start) { |
| 21930 | 1153 startElementHandler = start; |
| 1154 } | |
| 1155 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1156 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1157 XML_SetEndElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1158 XML_EndElementHandler end) { |
| 21930 | 1159 endElementHandler = end; |
| 1160 } | |
| 1161 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1162 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1163 XML_SetCharacterDataHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1164 XML_CharacterDataHandler handler) |
| 21930 | 1165 { |
| 1166 characterDataHandler = handler; | |
| 1167 } | |
| 1168 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1169 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1170 XML_SetProcessingInstructionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1171 XML_ProcessingInstructionHandler handler) |
| 21930 | 1172 { |
| 1173 processingInstructionHandler = handler; | |
| 1174 } | |
| 1175 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1176 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1177 XML_SetCommentHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1178 XML_CommentHandler handler) |
| 21930 | 1179 { |
| 1180 commentHandler = handler; | |
| 1181 } | |
| 1182 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1183 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1184 XML_SetCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1185 XML_StartCdataSectionHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1186 XML_EndCdataSectionHandler end) |
| 21930 | 1187 { |
| 1188 startCdataSectionHandler = start; | |
| 1189 endCdataSectionHandler = end; | |
| 1190 } | |
| 1191 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1192 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1193 XML_SetStartCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1194 XML_StartCdataSectionHandler start) { |
| 21930 | 1195 startCdataSectionHandler = start; |
| 1196 } | |
| 1197 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1198 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1199 XML_SetEndCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1200 XML_EndCdataSectionHandler end) { |
| 21930 | 1201 endCdataSectionHandler = end; |
| 1202 } | |
| 1203 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1204 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1205 XML_SetDefaultHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1206 XML_DefaultHandler handler) |
| 21930 | 1207 { |
| 1208 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1209 defaultExpandInternalEntities = XML_FALSE; |
| 21930 | 1210 } |
| 1211 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1212 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1213 XML_SetDefaultHandlerExpand(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1214 XML_DefaultHandler handler) |
| 21930 | 1215 { |
| 1216 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1217 defaultExpandInternalEntities = XML_TRUE; |
| 21930 | 1218 } |
| 1219 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1220 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1221 XML_SetDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1222 XML_StartDoctypeDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1223 XML_EndDoctypeDeclHandler end) |
| 21930 | 1224 { |
| 1225 startDoctypeDeclHandler = start; | |
| 1226 endDoctypeDeclHandler = end; | |
| 1227 } | |
| 1228 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1229 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1230 XML_SetStartDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1231 XML_StartDoctypeDeclHandler start) { |
| 21930 | 1232 startDoctypeDeclHandler = start; |
| 1233 } | |
| 1234 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1235 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1236 XML_SetEndDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1237 XML_EndDoctypeDeclHandler end) { |
| 21930 | 1238 endDoctypeDeclHandler = end; |
| 1239 } | |
| 1240 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1241 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1242 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1243 XML_UnparsedEntityDeclHandler handler) |
| 21930 | 1244 { |
| 1245 unparsedEntityDeclHandler = handler; | |
| 1246 } | |
| 1247 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1248 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1249 XML_SetNotationDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1250 XML_NotationDeclHandler handler) |
| 21930 | 1251 { |
| 1252 notationDeclHandler = handler; | |
| 1253 } | |
| 1254 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1255 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1256 XML_SetNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1257 XML_StartNamespaceDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1258 XML_EndNamespaceDeclHandler end) |
| 21930 | 1259 { |
| 1260 startNamespaceDeclHandler = start; | |
| 1261 endNamespaceDeclHandler = end; | |
| 1262 } | |
| 1263 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1264 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1265 XML_SetStartNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1266 XML_StartNamespaceDeclHandler start) { |
| 21930 | 1267 startNamespaceDeclHandler = start; |
| 1268 } | |
| 1269 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1270 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1271 XML_SetEndNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1272 XML_EndNamespaceDeclHandler end) { |
| 21930 | 1273 endNamespaceDeclHandler = end; |
| 1274 } | |
| 1275 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1276 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1277 XML_SetNotStandaloneHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1278 XML_NotStandaloneHandler handler) |
| 21930 | 1279 { |
| 1280 notStandaloneHandler = handler; | |
| 1281 } | |
| 1282 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1283 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1284 XML_SetExternalEntityRefHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1285 XML_ExternalEntityRefHandler handler) |
| 21930 | 1286 { |
| 1287 externalEntityRefHandler = handler; | |
| 1288 } | |
| 1289 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1290 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1291 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) |
| 21930 | 1292 { |
| 1293 if (arg) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1294 externalEntityRefHandlerArg = (XML_Parser)arg; |
| 21930 | 1295 else |
| 1296 externalEntityRefHandlerArg = parser; | |
| 1297 } | |
| 1298 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1299 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1300 XML_SetSkippedEntityHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1301 XML_SkippedEntityHandler handler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1302 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1303 skippedEntityHandler = handler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1304 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1305 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1306 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1307 XML_SetUnknownEncodingHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1308 XML_UnknownEncodingHandler handler, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1309 void *data) |
| 21930 | 1310 { |
| 1311 unknownEncodingHandler = handler; | |
| 1312 unknownEncodingHandlerData = data; | |
| 1313 } | |
| 1314 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1315 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1316 XML_SetElementDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1317 XML_ElementDeclHandler eldecl) |
| 21930 | 1318 { |
| 1319 elementDeclHandler = eldecl; | |
| 1320 } | |
| 1321 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1322 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1323 XML_SetAttlistDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1324 XML_AttlistDeclHandler attdecl) |
| 21930 | 1325 { |
| 1326 attlistDeclHandler = attdecl; | |
| 1327 } | |
| 1328 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1329 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1330 XML_SetEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1331 XML_EntityDeclHandler handler) |
| 21930 | 1332 { |
| 1333 entityDeclHandler = handler; | |
| 1334 } | |
| 1335 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1336 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1337 XML_SetXmlDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1338 XML_XmlDeclHandler handler) { |
| 21930 | 1339 xmlDeclHandler = handler; |
| 1340 } | |
| 1341 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1342 int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1343 XML_SetParamEntityParsing(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1344 enum XML_ParamEntityParsing peParsing) |
| 21930 | 1345 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1346 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1347 if (parsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1348 return 0; |
| 21930 | 1349 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1350 paramEntityParsing = peParsing; |
| 21930 | 1351 return 1; |
| 1352 #else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1353 return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; |
| 21930 | 1354 #endif |
| 1355 } | |
| 1356 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1357 enum XML_Status |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1358 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) |
| 21930 | 1359 { |
| 1360 if (len == 0) { | |
| 1361 if (!isFinal) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1362 return XML_STATUS_OK; |
| 21930 | 1363 positionPtr = bufferPtr; |
| 1364 errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0); | |
| 1365 if (errorCode == XML_ERROR_NONE) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1366 return XML_STATUS_OK; |
| 21930 | 1367 eventEndPtr = eventPtr; |
| 1368 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1369 return XML_STATUS_ERROR; |
| 21930 | 1370 } |
| 1371 #ifndef XML_CONTEXT_BYTES | |
| 1372 else if (bufferPtr == bufferEnd) { | |
| 1373 const char *end; | |
| 1374 int nLeftOver; | |
| 1375 parseEndByteIndex += len; | |
| 1376 positionPtr = s; | |
| 1377 if (isFinal) { | |
| 1378 errorCode = processor(parser, s, parseEndPtr = s + len, 0); | |
| 1379 if (errorCode == XML_ERROR_NONE) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1380 return XML_STATUS_OK; |
| 21930 | 1381 eventEndPtr = eventPtr; |
| 1382 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1383 return XML_STATUS_ERROR; |
| 21930 | 1384 } |
| 1385 errorCode = processor(parser, s, parseEndPtr = s + len, &end); | |
| 1386 if (errorCode != XML_ERROR_NONE) { | |
| 1387 eventEndPtr = eventPtr; | |
| 1388 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1389 return XML_STATUS_ERROR; |
| 21930 | 1390 } |
| 1391 XmlUpdatePosition(encoding, positionPtr, end, &position); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1392 positionPtr = end; |
| 21930 | 1393 nLeftOver = s + len - end; |
| 1394 if (nLeftOver) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1395 if (buffer == NULL || nLeftOver > bufferLim - buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1396 /* FIXME avoid integer overflow */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1397 char *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1398 temp = (buffer == NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1399 ? (char *)MALLOC(len * 2) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1400 : (char *)REALLOC(buffer, len * 2)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1401 if (temp == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1402 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1403 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1404 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1405 buffer = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1406 if (!buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1407 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1408 eventPtr = eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1409 processor = errorProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1410 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1411 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1412 bufferLim = buffer + len * 2; |
| 21930 | 1413 } |
| 1414 memcpy(buffer, end, nLeftOver); | |
| 1415 bufferPtr = buffer; | |
| 1416 bufferEnd = buffer + nLeftOver; | |
| 1417 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1418 return XML_STATUS_OK; |
| 21930 | 1419 } |
| 1420 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1421 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1422 void *buff = XML_GetBuffer(parser, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1423 if (buff == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1424 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1425 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1426 memcpy(buff, s, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1427 return XML_ParseBuffer(parser, len, isFinal); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1428 } |
| 21930 | 1429 } |
| 1430 } | |
| 1431 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1432 enum XML_Status |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1433 XML_ParseBuffer(XML_Parser parser, int len, int isFinal) |
| 21930 | 1434 { |
| 1435 const char *start = bufferPtr; | |
| 1436 positionPtr = start; | |
| 1437 bufferEnd += len; | |
| 1438 parseEndByteIndex += len; | |
| 1439 errorCode = processor(parser, start, parseEndPtr = bufferEnd, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1440 isFinal ? (const char **)NULL : &bufferPtr); |
| 21930 | 1441 if (errorCode == XML_ERROR_NONE) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1442 if (!isFinal) { |
| 21930 | 1443 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1444 positionPtr = bufferPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1445 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1446 return XML_STATUS_OK; |
| 21930 | 1447 } |
| 1448 else { | |
| 1449 eventEndPtr = eventPtr; | |
| 1450 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1451 return XML_STATUS_ERROR; |
| 21930 | 1452 } |
| 1453 } | |
| 1454 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1455 void * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1456 XML_GetBuffer(XML_Parser parser, int len) |
| 21930 | 1457 { |
| 1458 if (len > bufferLim - bufferEnd) { | |
| 1459 /* FIXME avoid integer overflow */ | |
| 1460 int neededSize = len + (bufferEnd - bufferPtr); | |
| 1461 #ifdef XML_CONTEXT_BYTES | |
| 1462 int keep = bufferPtr - buffer; | |
| 1463 | |
| 1464 if (keep > XML_CONTEXT_BYTES) | |
| 1465 keep = XML_CONTEXT_BYTES; | |
| 1466 neededSize += keep; | |
| 1467 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1468 if (neededSize <= bufferLim - buffer) { | |
| 1469 #ifdef XML_CONTEXT_BYTES | |
| 1470 if (keep < bufferPtr - buffer) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1471 int offset = (bufferPtr - buffer) - keep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1472 memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1473 bufferEnd -= offset; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1474 bufferPtr -= offset; |
| 21930 | 1475 } |
| 1476 #else | |
| 1477 memmove(buffer, bufferPtr, bufferEnd - bufferPtr); | |
| 1478 bufferEnd = buffer + (bufferEnd - bufferPtr); | |
| 1479 bufferPtr = buffer; | |
| 1480 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1481 } | |
| 1482 else { | |
| 1483 char *newBuf; | |
| 1484 int bufferSize = bufferLim - bufferPtr; | |
| 1485 if (bufferSize == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1486 bufferSize = INIT_BUFFER_SIZE; |
| 21930 | 1487 do { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1488 bufferSize *= 2; |
| 21930 | 1489 } while (bufferSize < neededSize); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1490 newBuf = (char *)MALLOC(bufferSize); |
| 21930 | 1491 if (newBuf == 0) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1492 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1493 return NULL; |
| 21930 | 1494 } |
| 1495 bufferLim = newBuf + bufferSize; | |
| 1496 #ifdef XML_CONTEXT_BYTES | |
| 1497 if (bufferPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1498 int keep = bufferPtr - buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1499 if (keep > XML_CONTEXT_BYTES) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1500 keep = XML_CONTEXT_BYTES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1501 memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1502 FREE(buffer); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1503 buffer = newBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1504 bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1505 bufferPtr = buffer + keep; |
| 21930 | 1506 } |
| 1507 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1508 bufferEnd = newBuf + (bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1509 bufferPtr = buffer = newBuf; |
| 21930 | 1510 } |
| 1511 #else | |
| 1512 if (bufferPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1513 memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1514 FREE(buffer); |
| 21930 | 1515 } |
| 1516 bufferEnd = newBuf + (bufferEnd - bufferPtr); | |
| 1517 bufferPtr = buffer = newBuf; | |
| 1518 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1519 } | |
| 1520 } | |
| 1521 return bufferEnd; | |
| 1522 } | |
| 1523 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1524 enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1525 XML_GetErrorCode(XML_Parser parser) |
| 21930 | 1526 { |
| 1527 return errorCode; | |
| 1528 } | |
| 1529 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1530 long |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1531 XML_GetCurrentByteIndex(XML_Parser parser) |
| 21930 | 1532 { |
| 1533 if (eventPtr) | |
| 1534 return parseEndByteIndex - (parseEndPtr - eventPtr); | |
| 1535 return -1; | |
| 1536 } | |
| 1537 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1538 int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1539 XML_GetCurrentByteCount(XML_Parser parser) |
| 21930 | 1540 { |
| 1541 if (eventEndPtr && eventPtr) | |
| 1542 return eventEndPtr - eventPtr; | |
| 1543 return 0; | |
| 1544 } | |
| 1545 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1546 const char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1547 XML_GetInputContext(XML_Parser parser, int *offset, int *size) |
| 21930 | 1548 { |
| 1549 #ifdef XML_CONTEXT_BYTES | |
| 1550 if (eventPtr && buffer) { | |
| 1551 *offset = eventPtr - buffer; | |
| 1552 *size = bufferEnd - buffer; | |
| 1553 return buffer; | |
| 1554 } | |
| 1555 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1556 return (char *) 0; | |
| 1557 } | |
| 1558 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1559 int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1560 XML_GetCurrentLineNumber(XML_Parser parser) |
| 21930 | 1561 { |
| 1562 if (eventPtr) { | |
| 1563 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); | |
| 1564 positionPtr = eventPtr; | |
| 1565 } | |
| 1566 return position.lineNumber + 1; | |
| 1567 } | |
| 1568 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1569 int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1570 XML_GetCurrentColumnNumber(XML_Parser parser) |
| 21930 | 1571 { |
| 1572 if (eventPtr) { | |
| 1573 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); | |
| 1574 positionPtr = eventPtr; | |
| 1575 } | |
| 1576 return position.columnNumber; | |
| 1577 } | |
| 1578 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1579 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1580 XML_FreeContentModel(XML_Parser parser, XML_Content *model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1581 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1582 FREE(model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1583 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1584 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1585 void * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1586 XML_MemMalloc(XML_Parser parser, size_t size) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1587 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1588 return MALLOC(size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1589 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1590 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1591 void * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1592 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1593 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1594 return REALLOC(ptr, size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1595 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1596 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1597 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1598 XML_MemFree(XML_Parser parser, void *ptr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1599 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1600 FREE(ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1601 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1602 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1603 void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1604 XML_DefaultCurrent(XML_Parser parser) |
| 21930 | 1605 { |
| 1606 if (defaultHandler) { | |
| 1607 if (openInternalEntities) | |
| 1608 reportDefault(parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1609 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1610 openInternalEntities->internalEventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1611 openInternalEntities->internalEventEndPtr); |
| 21930 | 1612 else |
| 1613 reportDefault(parser, encoding, eventPtr, eventEndPtr); | |
| 1614 } | |
| 1615 } | |
| 1616 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1617 const XML_LChar * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1618 XML_ErrorString(enum XML_Error code) |
| 21930 | 1619 { |
| 1620 static const XML_LChar *message[] = { | |
| 1621 0, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1622 XML_L("out of memory"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1623 XML_L("syntax error"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1624 XML_L("no element found"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1625 XML_L("not well-formed (invalid token)"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1626 XML_L("unclosed token"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1627 XML_L("partial character"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1628 XML_L("mismatched tag"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1629 XML_L("duplicate attribute"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1630 XML_L("junk after document element"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1631 XML_L("illegal parameter entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1632 XML_L("undefined entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1633 XML_L("recursive entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1634 XML_L("asynchronous entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1635 XML_L("reference to invalid character number"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1636 XML_L("reference to binary entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1637 XML_L("reference to external entity in attribute"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1638 XML_L("xml declaration not at start of external entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1639 XML_L("unknown encoding"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1640 XML_L("encoding specified in XML declaration is incorrect"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1641 XML_L("unclosed CDATA section"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1642 XML_L("error in processing external entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1643 XML_L("document is not standalone"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1644 XML_L("unexpected parser state - please send a bug report"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1645 XML_L("entity declared in parameter entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1646 XML_L("requested feature requires XML_DTD support in Expat"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1647 XML_L("cannot change setting once parsing has begun") |
| 21930 | 1648 }; |
| 1649 if (code > 0 && code < sizeof(message)/sizeof(message[0])) | |
| 1650 return message[code]; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1651 return NULL; |
| 21930 | 1652 } |
| 1653 | |
| 1654 const XML_LChar * | |
| 1655 XML_ExpatVersion(void) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1656 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1657 /* V1 is used to string-ize the version number. However, it would |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1658 string-ize the actual version macro *names* unless we get them |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1659 substituted before being passed to V1. CPP is defined to expand |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1660 a macro, then rescan for more expansions. Thus, we use V2 to expand |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1661 the version macros, then CPP will expand the resulting V1() macro |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1662 with the correct numerals. */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1663 /* ### I'm assuming cpp is portable in this respect... */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1664 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1665 #define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1666 #define V2(a,b,c) XML_L("expat_")V1(a,b,c) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1667 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1668 return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1669 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1670 #undef V1 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1671 #undef V2 |
| 21930 | 1672 } |
| 1673 | |
| 1674 XML_Expat_Version | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1675 XML_ExpatVersionInfo(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1676 { |
| 21930 | 1677 XML_Expat_Version version; |
| 1678 | |
| 1679 version.major = XML_MAJOR_VERSION; | |
| 1680 version.minor = XML_MINOR_VERSION; | |
| 1681 version.micro = XML_MICRO_VERSION; | |
| 1682 | |
| 1683 return version; | |
| 1684 } | |
| 1685 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1686 const XML_Feature * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1687 XML_GetFeatureList(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1688 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1689 static XML_Feature features[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1690 {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)")}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1691 {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)")}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1692 #ifdef XML_UNICODE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1693 {XML_FEATURE_UNICODE, XML_L("XML_UNICODE")}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1694 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1695 #ifdef XML_UNICODE_WCHAR_T |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1696 {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T")}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1697 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1698 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1699 {XML_FEATURE_DTD, XML_L("XML_DTD")}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1700 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1701 #ifdef XML_CONTEXT_BYTES |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1702 {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1703 XML_CONTEXT_BYTES}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1704 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1705 #ifdef XML_MIN_SIZE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1706 {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE")}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1707 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1708 {XML_FEATURE_END, NULL} |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1709 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1710 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1711 features[0].value = sizeof(XML_Char); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1712 features[1].value = sizeof(XML_LChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1713 return features; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1714 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1715 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1716 /* Initially tag->rawName always points into the parse buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1717 for those TAG instances opened while the current parse buffer was |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1718 processed, and not yet closed, we need to store tag->rawName in a more |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1719 permanent location, since the parse buffer is about to be discarded. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1720 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1721 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1722 storeRawNames(XML_Parser parser) |
| 21930 | 1723 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1724 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1725 while (tag) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1726 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1727 int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1728 char *rawNameBuf = tag->buf + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1729 /* Stop if already stored. Since tagStack is a stack, we can stop |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1730 at the first entry that has already been copied; everything |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1731 below it in the stack is already been accounted for in a |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1732 previous call to this function. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1733 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1734 if (tag->rawName == rawNameBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1735 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1736 /* For re-use purposes we need to ensure that the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1737 size of tag->buf is a multiple of sizeof(XML_Char). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1738 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1739 bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1740 if (bufSize > tag->bufEnd - tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1741 char *temp = (char *)REALLOC(tag->buf, bufSize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1742 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1743 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1744 /* if tag->name.str points to tag->buf (only when namespace |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1745 processing is off) then we have to update it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1746 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1747 if (tag->name.str == (XML_Char *)tag->buf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1748 tag->name.str = (XML_Char *)temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1749 /* if tag->name.localPart is set (when namespace processing is on) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1750 then update it as well, since it will always point into tag->buf |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1751 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1752 if (tag->name.localPart) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1753 tag->name.localPart = (XML_Char *)temp + (tag->name.localPart - |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1754 (XML_Char *)tag->buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1755 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1756 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1757 rawNameBuf = temp + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1758 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1759 memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1760 tag->rawName = rawNameBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1761 tag = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1762 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1763 return XML_TRUE; |
| 21930 | 1764 } |
| 1765 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1766 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1767 contentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1768 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1769 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1770 const char **endPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1771 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1772 enum XML_Error result = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1773 doContent(parser, 0, encoding, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1774 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1775 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1776 if (!storeRawNames(parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1777 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1778 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1779 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1780 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1781 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1782 externalEntityInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1783 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1784 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1785 const char **endPtr) |
| 21930 | 1786 { |
| 1787 enum XML_Error result = initializeEncoding(parser); | |
| 1788 if (result != XML_ERROR_NONE) | |
| 1789 return result; | |
| 1790 processor = externalEntityInitProcessor2; | |
| 1791 return externalEntityInitProcessor2(parser, start, end, endPtr); | |
| 1792 } | |
| 1793 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1794 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1795 externalEntityInitProcessor2(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1796 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1797 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1798 const char **endPtr) |
| 21930 | 1799 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1800 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 21930 | 1801 int tok = XmlContentTok(encoding, start, end, &next); |
| 1802 switch (tok) { | |
| 1803 case XML_TOK_BOM: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1804 /* If we are at the end of the buffer, this would cause the next stage, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1805 i.e. externalEntityInitProcessor3, to pass control directly to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1806 doContent (by detecting XML_TOK_NONE) without processing any xml text |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1807 declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1808 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1809 if (next == end && endPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1810 *endPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1811 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1812 } |
| 21930 | 1813 start = next; |
| 1814 break; | |
| 1815 case XML_TOK_PARTIAL: | |
| 1816 if (endPtr) { | |
| 1817 *endPtr = start; | |
| 1818 return XML_ERROR_NONE; | |
| 1819 } | |
| 1820 eventPtr = start; | |
| 1821 return XML_ERROR_UNCLOSED_TOKEN; | |
| 1822 case XML_TOK_PARTIAL_CHAR: | |
| 1823 if (endPtr) { | |
| 1824 *endPtr = start; | |
| 1825 return XML_ERROR_NONE; | |
| 1826 } | |
| 1827 eventPtr = start; | |
| 1828 return XML_ERROR_PARTIAL_CHAR; | |
| 1829 } | |
| 1830 processor = externalEntityInitProcessor3; | |
| 1831 return externalEntityInitProcessor3(parser, start, end, endPtr); | |
| 1832 } | |
| 1833 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1834 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1835 externalEntityInitProcessor3(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1836 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1837 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1838 const char **endPtr) |
| 21930 | 1839 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1840 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 21930 | 1841 int tok = XmlContentTok(encoding, start, end, &next); |
| 1842 switch (tok) { | |
| 1843 case XML_TOK_XML_DECL: | |
| 1844 { | |
| 1845 enum XML_Error result = processXmlDecl(parser, 1, start, next); | |
| 1846 if (result != XML_ERROR_NONE) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1847 return result; |
| 21930 | 1848 start = next; |
| 1849 } | |
| 1850 break; | |
| 1851 case XML_TOK_PARTIAL: | |
| 1852 if (endPtr) { | |
| 1853 *endPtr = start; | |
| 1854 return XML_ERROR_NONE; | |
| 1855 } | |
| 1856 eventPtr = start; | |
| 1857 return XML_ERROR_UNCLOSED_TOKEN; | |
| 1858 case XML_TOK_PARTIAL_CHAR: | |
| 1859 if (endPtr) { | |
| 1860 *endPtr = start; | |
| 1861 return XML_ERROR_NONE; | |
| 1862 } | |
| 1863 eventPtr = start; | |
| 1864 return XML_ERROR_PARTIAL_CHAR; | |
| 1865 } | |
| 1866 processor = externalEntityContentProcessor; | |
| 1867 tagLevel = 1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1868 return externalEntityContentProcessor(parser, start, end, endPtr); |
| 21930 | 1869 } |
| 1870 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1871 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1872 externalEntityContentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1873 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1874 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1875 const char **endPtr) |
| 21930 | 1876 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1877 enum XML_Error result = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1878 doContent(parser, 1, encoding, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1879 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1880 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1881 if (!storeRawNames(parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1882 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1883 return result; |
| 21930 | 1884 } |
| 1885 | |
| 1886 static enum XML_Error | |
| 1887 doContent(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1888 int startTagLevel, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1889 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1890 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1891 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1892 const char **nextPtr) |
| 21930 | 1893 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1894 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 1895 const char **eventPP; |
| 1896 const char **eventEndPP; | |
| 1897 if (enc == encoding) { | |
| 1898 eventPP = &eventPtr; | |
| 1899 eventEndPP = &eventEndPtr; | |
| 1900 } | |
| 1901 else { | |
| 1902 eventPP = &(openInternalEntities->internalEventPtr); | |
| 1903 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 1904 } | |
| 1905 *eventPP = s; | |
| 1906 for (;;) { | |
| 1907 const char *next = s; /* XmlContentTok doesn't always set the last arg */ | |
| 1908 int tok = XmlContentTok(enc, s, end, &next); | |
| 1909 *eventEndPP = next; | |
| 1910 switch (tok) { | |
| 1911 case XML_TOK_TRAILING_CR: | |
| 1912 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1913 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1914 return XML_ERROR_NONE; |
| 21930 | 1915 } |
| 1916 *eventEndPP = end; | |
| 1917 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1918 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1919 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 1920 } |
| 1921 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1922 reportDefault(parser, enc, s, end); |
| 21930 | 1923 if (startTagLevel == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1924 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 1925 if (tagLevel != startTagLevel) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1926 return XML_ERROR_ASYNC_ENTITY; |
| 21930 | 1927 return XML_ERROR_NONE; |
| 1928 case XML_TOK_NONE: | |
| 1929 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1930 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1931 return XML_ERROR_NONE; |
| 21930 | 1932 } |
| 1933 if (startTagLevel > 0) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1934 if (tagLevel != startTagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1935 return XML_ERROR_ASYNC_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1936 return XML_ERROR_NONE; |
| 21930 | 1937 } |
| 1938 return XML_ERROR_NO_ELEMENTS; | |
| 1939 case XML_TOK_INVALID: | |
| 1940 *eventPP = next; | |
| 1941 return XML_ERROR_INVALID_TOKEN; | |
| 1942 case XML_TOK_PARTIAL: | |
| 1943 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1944 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1945 return XML_ERROR_NONE; |
| 21930 | 1946 } |
| 1947 return XML_ERROR_UNCLOSED_TOKEN; | |
| 1948 case XML_TOK_PARTIAL_CHAR: | |
| 1949 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1950 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1951 return XML_ERROR_NONE; |
| 21930 | 1952 } |
| 1953 return XML_ERROR_PARTIAL_CHAR; | |
| 1954 case XML_TOK_ENTITY_REF: | |
| 1955 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1956 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1957 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1958 XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1959 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1960 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1961 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1962 if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1963 characterDataHandler(handlerArg, &ch, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1964 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1965 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1966 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1967 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1968 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1969 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1970 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1971 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1972 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1973 entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1974 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1975 /* First, determine if a check for an existing declaration is needed; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1976 if yes, check that the entity exists, and that it is internal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1977 otherwise call the skipped entity or default handler. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1978 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1979 if (!dtd->hasParamEntityRefs || dtd->standalone) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1980 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1981 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1982 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1983 return XML_ERROR_ENTITY_DECLARED_IN_PE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1984 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1985 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1986 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1987 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1988 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1989 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1990 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1991 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1992 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1993 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1994 if (entity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1995 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1996 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1997 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1998 OPEN_INTERNAL_ENTITY openEntity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1999 if (!defaultExpandInternalEntities) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2000 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2001 skippedEntityHandler(handlerArg, entity->name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2002 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2003 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2004 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2005 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2006 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2007 openEntity.next = openInternalEntities; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2008 openInternalEntities = &openEntity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2009 openEntity.entity = entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2010 openEntity.internalEventPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2011 openEntity.internalEventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2012 result = doContent(parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2013 tagLevel, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2014 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2015 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2016 (char *)(entity->textPtr + entity->textLen), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2017 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2018 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2019 openInternalEntities = openEntity.next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2020 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2021 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2022 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2023 else if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2024 const XML_Char *context; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2025 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2026 context = getContext(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2027 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2028 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2029 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2030 if (!externalEntityRefHandler((XML_Parser)externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2031 context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2032 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2033 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2034 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2035 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2036 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2037 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2038 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2039 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2040 break; |
| 21930 | 2041 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2042 case XML_TOK_START_TAG_NO_ATTS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2043 /* fall through */ |
| 21930 | 2044 case XML_TOK_START_TAG_WITH_ATTS: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2045 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2046 TAG *tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2047 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2048 XML_Char *toPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2049 if (freeTagList) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2050 tag = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2051 freeTagList = freeTagList->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2052 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2053 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2054 tag = (TAG *)MALLOC(sizeof(TAG)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2055 if (!tag) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2056 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2057 tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2058 if (!tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2059 FREE(tag); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2060 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2061 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2062 tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2063 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2064 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2065 tag->parent = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2066 tagStack = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2067 tag->name.localPart = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2068 tag->name.prefix = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2069 tag->rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2070 tag->rawNameLength = XmlNameLength(enc, tag->rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2071 ++tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2072 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2073 const char *rawNameEnd = tag->rawName + tag->rawNameLength; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2074 const char *fromPtr = tag->rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2075 toPtr = (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2076 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2077 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2078 int convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2079 XmlConvert(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2080 &fromPtr, rawNameEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2081 (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2082 convLen = toPtr - (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2083 if (fromPtr == rawNameEnd) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2084 tag->name.strLen = convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2085 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2086 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2087 bufSize = (tag->bufEnd - tag->buf) << 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2088 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2089 char *temp = (char *)REALLOC(tag->buf, bufSize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2090 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2091 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2092 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2093 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2094 toPtr = (XML_Char *)temp + convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2095 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2096 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2097 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2098 tag->name.str = (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2099 *toPtr = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2100 result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2101 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2102 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2103 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2104 startElementHandler(handlerArg, tag->name.str, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2105 (const XML_Char **)atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2106 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2107 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2108 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2109 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2110 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2111 case XML_TOK_EMPTY_ELEMENT_NO_ATTS: |
| 21930 | 2112 /* fall through */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2113 case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: |
| 21930 | 2114 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2115 const char *rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2116 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2117 BINDING *bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2118 XML_Bool noElmHandlers = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2119 TAG_NAME name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2120 name.str = poolStoreString(&tempPool, enc, rawName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2121 rawName + XmlNameLength(enc, rawName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2122 if (!name.str) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2123 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2124 poolFinish(&tempPool); |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2125 result = storeAtts(parser, enc, s, &name, &bindings); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2126 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2127 return result; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2128 poolFinish(&tempPool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2129 if (startElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2130 startElementHandler(handlerArg, name.str, (const XML_Char **)atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2131 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2132 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2133 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2134 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2135 *eventPP = *eventEndPP; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2136 endElementHandler(handlerArg, name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2137 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2138 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2139 if (noElmHandlers && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2140 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2141 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2142 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2143 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2144 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2145 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2146 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2147 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2148 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2149 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2150 } |
| 21930 | 2151 } |
| 2152 if (tagLevel == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2153 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2154 break; |
| 2155 case XML_TOK_END_TAG: | |
| 2156 if (tagLevel == startTagLevel) | |
| 2157 return XML_ERROR_ASYNC_ENTITY; | |
| 2158 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2159 int len; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2160 const char *rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2161 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2162 tagStack = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2163 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2164 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2165 rawName = s + enc->minBytesPerChar*2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2166 len = XmlNameLength(enc, rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2167 if (len != tag->rawNameLength |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2168 || memcmp(tag->rawName, rawName, len) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2169 *eventPP = rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2170 return XML_ERROR_TAG_MISMATCH; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2171 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2172 --tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2173 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2174 const XML_Char *localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2175 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2176 XML_Char *uri; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2177 localPart = tag->name.localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2178 if (ns && localPart) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2179 /* localPart and prefix may have been overwritten in |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2180 tag->name.str, since this points to the binding->uri |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2181 buffer which gets re-used; so we have to add them again |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2182 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2183 uri = (XML_Char *)tag->name.str + tag->name.uriLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2184 /* don't need to check for space - already done in storeAtts() */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2185 while (*localPart) *uri++ = *localPart++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2186 prefix = (XML_Char *)tag->name.prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2187 if (ns_triplets && prefix) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2188 *uri++ = namespaceSeparator; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2189 while (*prefix) *uri++ = *prefix++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2190 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2191 *uri = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2192 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2193 endElementHandler(handlerArg, tag->name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2194 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2195 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2196 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2197 while (tag->bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2198 BINDING *b = tag->bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2199 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2200 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2201 tag->bindings = tag->bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2202 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2203 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2204 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2205 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2206 if (tagLevel == 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2207 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2208 } |
| 2209 break; | |
| 2210 case XML_TOK_CHAR_REF: | |
| 2211 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2212 int n = XmlCharRefNumber(enc, s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2213 if (n < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2214 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2215 if (characterDataHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2216 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2217 characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2218 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2219 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2220 reportDefault(parser, enc, s, next); |
| 21930 | 2221 } |
| 2222 break; | |
| 2223 case XML_TOK_XML_DECL: | |
| 2224 return XML_ERROR_MISPLACED_XML_PI; | |
| 2225 case XML_TOK_DATA_NEWLINE: | |
| 2226 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2227 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2228 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2229 } |
| 2230 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2231 reportDefault(parser, enc, s, next); |
| 21930 | 2232 break; |
| 2233 case XML_TOK_CDATA_SECT_OPEN: | |
| 2234 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2235 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2236 if (startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2237 startCdataSectionHandler(handlerArg); |
| 21930 | 2238 #if 0 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2239 /* Suppose you doing a transformation on a document that involves |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2240 changing only the character data. You set up a defaultHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2241 and a characterDataHandler. The defaultHandler simply copies |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2242 characters through. The characterDataHandler does the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2243 transformation and writes the characters out escaping them as |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2244 necessary. This case will fail to work if we leave out the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2245 following two lines (because & and < inside CDATA sections will |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2246 be incorrectly escaped). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2247 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2248 However, now we have a start/endCdataSectionHandler, so it seems |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2249 easier to let the user deal with this. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2250 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2251 else if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2252 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 2253 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2254 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2255 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2256 result = doCdataSection(parser, enc, &next, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2257 if (!next) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2258 processor = cdataSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2259 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2260 } |
| 21930 | 2261 } |
| 2262 break; | |
| 2263 case XML_TOK_TRAILING_RSQB: | |
| 2264 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2265 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2266 return XML_ERROR_NONE; |
| 21930 | 2267 } |
| 2268 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2269 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2270 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2271 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2272 characterDataHandler(handlerArg, dataBuf, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2273 dataPtr - (ICHAR *)dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2274 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2275 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2276 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2277 (XML_Char *)s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2278 (XML_Char *)end - (XML_Char *)s); |
| 21930 | 2279 } |
| 2280 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2281 reportDefault(parser, enc, s, end); |
| 21930 | 2282 if (startTagLevel == 0) { |
| 2283 *eventPP = end; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2284 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2285 } |
| 2286 if (tagLevel != startTagLevel) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2287 *eventPP = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2288 return XML_ERROR_ASYNC_ENTITY; |
| 21930 | 2289 } |
| 2290 return XML_ERROR_NONE; | |
| 2291 case XML_TOK_DATA_CHARS: | |
| 2292 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2293 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2294 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2295 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2296 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2297 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2298 characterDataHandler(handlerArg, dataBuf, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2299 dataPtr - (ICHAR *)dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2300 if (s == next) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2301 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2302 *eventPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2303 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2304 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2305 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2306 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2307 (XML_Char *)s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2308 (XML_Char *)next - (XML_Char *)s); |
| 21930 | 2309 } |
| 2310 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2311 reportDefault(parser, enc, s, next); |
| 21930 | 2312 break; |
| 2313 case XML_TOK_PI: | |
| 2314 if (!reportProcessingInstruction(parser, enc, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2315 return XML_ERROR_NO_MEMORY; |
| 21930 | 2316 break; |
| 2317 case XML_TOK_COMMENT: | |
| 2318 if (!reportComment(parser, enc, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2319 return XML_ERROR_NO_MEMORY; |
| 21930 | 2320 break; |
| 2321 default: | |
| 2322 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2323 reportDefault(parser, enc, s, next); |
| 21930 | 2324 break; |
| 2325 } | |
| 2326 *eventPP = s = next; | |
| 2327 } | |
| 2328 /* not reached */ | |
| 2329 } | |
| 2330 | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2331 /* Precondition: all arguments must be non-NULL; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2332 Purpose: |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2333 - normalize attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2334 - check attributes for well-formedness |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2335 - generate namespace aware attribute names (URI, prefix) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2336 - build list of attributes for startElementHandler |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2337 - default attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2338 - process namespace declarations (check and report them) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2339 - generate namespace aware element name (URI, prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2340 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2341 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2342 storeAtts(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2343 const char *attStr, TAG_NAME *tagNamePtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2344 BINDING **bindingsPtr) |
| 21930 | 2345 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2346 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2347 ELEMENT_TYPE *elementType = NULL; |
| 21930 | 2348 int nDefaultAtts = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2349 const XML_Char **appAtts; /* the attribute list for the application */ |
| 21930 | 2350 int attIndex = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2351 int prefixLen; |
| 21930 | 2352 int i; |
| 2353 int n; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2354 XML_Char *uri; |
| 21930 | 2355 int nPrefixes = 0; |
| 2356 BINDING *binding; | |
| 2357 const XML_Char *localPart; | |
| 2358 | |
| 2359 /* lookup the element type name */ | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2360 elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2361 if (!elementType) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2362 const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2363 if (!name) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2364 return XML_ERROR_NO_MEMORY; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2365 elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name, |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2366 sizeof(ELEMENT_TYPE)); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2367 if (!elementType) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2368 return XML_ERROR_NO_MEMORY; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2369 if (ns && !setElementTypePrefix(parser, elementType)) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2370 return XML_ERROR_NO_MEMORY; |
| 21930 | 2371 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2372 nDefaultAtts = elementType->nDefaultAtts; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2373 |
| 21930 | 2374 /* get the attributes from the tokenizer */ |
| 2375 n = XmlGetAttributes(enc, attStr, attsSize, atts); | |
| 2376 if (n + nDefaultAtts > attsSize) { | |
| 2377 int oldAttsSize = attsSize; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2378 ATTRIBUTE *temp; |
| 21930 | 2379 attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2380 temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2381 if (temp == NULL) |
| 21930 | 2382 return XML_ERROR_NO_MEMORY; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2383 atts = temp; |
| 21930 | 2384 if (n > oldAttsSize) |
| 2385 XmlGetAttributes(enc, attStr, n, atts); | |
| 2386 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2387 |
| 21930 | 2388 appAtts = (const XML_Char **)atts; |
| 2389 for (i = 0; i < n; i++) { | |
| 2390 /* add the name and value to the attribute list */ | |
| 2391 ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2392 atts[i].name |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2393 + XmlNameLength(enc, atts[i].name)); |
| 21930 | 2394 if (!attId) |
| 2395 return XML_ERROR_NO_MEMORY; | |
| 2396 /* detect duplicate attributes */ | |
| 2397 if ((attId->name)[-1]) { | |
| 2398 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2399 eventPtr = atts[i].name; |
| 21930 | 2400 return XML_ERROR_DUPLICATE_ATTRIBUTE; |
| 2401 } | |
| 2402 (attId->name)[-1] = 1; | |
| 2403 appAtts[attIndex++] = attId->name; | |
| 2404 if (!atts[i].normalized) { | |
| 2405 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2406 XML_Bool isCdata = XML_TRUE; |
| 21930 | 2407 |
| 2408 /* figure out whether declared as other than CDATA */ | |
| 2409 if (attId->maybeTokenized) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2410 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2411 for (j = 0; j < nDefaultAtts; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2412 if (attId == elementType->defaultAtts[j].id) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2413 isCdata = elementType->defaultAtts[j].isCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2414 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2415 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2416 } |
| 21930 | 2417 } |
| 2418 | |
| 2419 /* normalize the attribute value */ | |
| 2420 result = storeAttributeValue(parser, enc, isCdata, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2421 atts[i].valuePtr, atts[i].valueEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2422 &tempPool); |
| 21930 | 2423 if (result) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2424 return result; |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2425 appAtts[attIndex] = poolStart(&tempPool); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2426 poolFinish(&tempPool); |
| 21930 | 2427 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2428 else { |
| 21930 | 2429 /* the value did not need normalizing */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2430 appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2431 atts[i].valueEnd); |
| 21930 | 2432 if (appAtts[attIndex] == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2433 return XML_ERROR_NO_MEMORY; |
| 21930 | 2434 poolFinish(&tempPool); |
| 2435 } | |
| 2436 /* handle prefixed attribute names */ | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2437 if (attId->prefix) { |
| 21930 | 2438 if (attId->xmlns) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2439 /* deal with namespace declarations here */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2440 enum XML_Error result = addBinding(parser, attId->prefix, attId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2441 appAtts[attIndex], bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2442 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2443 return result; |
| 21930 | 2444 --attIndex; |
| 2445 } | |
| 2446 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2447 /* deal with other prefixed names later */ |
| 21930 | 2448 attIndex++; |
| 2449 nPrefixes++; | |
| 2450 (attId->name)[-1] = 2; | |
| 2451 } | |
| 2452 } | |
| 2453 else | |
| 2454 attIndex++; | |
| 2455 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2456 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2457 /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2458 nSpecifiedAtts = attIndex; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2459 if (elementType->idAtt && (elementType->idAtt->name)[-1]) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2460 for (i = 0; i < attIndex; i += 2) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2461 if (appAtts[i] == elementType->idAtt->name) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2462 idAttIndex = i; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2463 break; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2464 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2465 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2466 else |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2467 idAttIndex = -1; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2468 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2469 /* do attribute defaulting */ |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2470 for (i = 0; i < nDefaultAtts; i++) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2471 const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2472 if (!(da->id->name)[-1] && da->value) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2473 if (da->id->prefix) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2474 if (da->id->xmlns) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2475 enum XML_Error result = addBinding(parser, da->id->prefix, da->id, |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2476 da->value, bindingsPtr); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2477 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2478 return result; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2479 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2480 else { |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2481 (da->id->name)[-1] = 2; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2482 nPrefixes++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2483 appAtts[attIndex++] = da->id->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2484 appAtts[attIndex++] = da->value; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2485 } |
| 21930 | 2486 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2487 else { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2488 (da->id->name)[-1] = 1; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2489 appAtts[attIndex++] = da->id->name; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2490 appAtts[attIndex++] = da->value; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2491 } |
| 21930 | 2492 } |
| 2493 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2494 appAtts[attIndex] = 0; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2495 |
| 21930 | 2496 i = 0; |
| 2497 if (nPrefixes) { | |
| 2498 /* expand prefixed attribute names */ | |
| 2499 for (; i < attIndex; i += 2) { | |
| 2500 if (appAtts[i][-1] == 2) { | |
| 2501 ATTRIBUTE_ID *id; | |
| 2502 ((XML_Char *)(appAtts[i]))[-1] = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2503 id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, appAtts[i], 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2504 if (id->prefix->binding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2505 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2506 const BINDING *b = id->prefix->binding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2507 const XML_Char *s = appAtts[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2508 for (j = 0; j < b->uriLen; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2509 if (!poolAppendChar(&tempPool, b->uri[j])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2510 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2511 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2512 while (*s++ != XML_T(':')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2513 ; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2514 do { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2515 if (!poolAppendChar(&tempPool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2516 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2517 } while (*s++); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2518 if (ns_triplets) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2519 tempPool.ptr[-1] = namespaceSeparator; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2520 s = b->prefix->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2521 do { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2522 if (!poolAppendChar(&tempPool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2523 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2524 } while (*s++); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2525 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2526 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2527 appAtts[i] = poolStart(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2528 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2529 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2530 if (!--nPrefixes) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2531 break; |
| 21930 | 2532 } |
| 2533 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2534 ((XML_Char *)(appAtts[i]))[-1] = 0; |
| 21930 | 2535 } |
| 2536 } | |
| 2537 /* clear the flags that say whether attributes were specified */ | |
| 2538 for (; i < attIndex; i += 2) | |
| 2539 ((XML_Char *)(appAtts[i]))[-1] = 0; | |
| 2540 for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) | |
| 2541 binding->attId->name[-1] = 0; | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2542 |
| 21930 | 2543 /* expand the element type name */ |
| 2544 if (elementType->prefix) { | |
| 2545 binding = elementType->prefix->binding; | |
| 2546 if (!binding) | |
| 2547 return XML_ERROR_NONE; | |
| 2548 localPart = tagNamePtr->str; | |
| 2549 while (*localPart++ != XML_T(':')) | |
| 2550 ; | |
| 2551 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2552 else if (dtd->defaultPrefix.binding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2553 binding = dtd->defaultPrefix.binding; |
| 21930 | 2554 localPart = tagNamePtr->str; |
| 2555 } | |
| 2556 else | |
| 2557 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2558 prefixLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2559 if (ns && ns_triplets && binding->prefix->name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2560 for (; binding->prefix->name[prefixLen++];) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2561 ; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2562 } |
| 21930 | 2563 tagNamePtr->localPart = localPart; |
| 2564 tagNamePtr->uriLen = binding->uriLen; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2565 tagNamePtr->prefix = binding->prefix->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2566 tagNamePtr->prefixLen = prefixLen; |
| 21930 | 2567 for (i = 0; localPart[i++];) |
| 2568 ; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2569 n = i + binding->uriLen + prefixLen; |
| 21930 | 2570 if (n > binding->uriAlloc) { |
| 2571 TAG *p; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2572 uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); |
| 21930 | 2573 if (!uri) |
| 2574 return XML_ERROR_NO_MEMORY; | |
| 2575 binding->uriAlloc = n + EXPAND_SPARE; | |
| 2576 memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); | |
| 2577 for (p = tagStack; p; p = p->parent) | |
| 2578 if (p->name.str == binding->uri) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2579 p->name.str = uri; |
| 21930 | 2580 FREE(binding->uri); |
| 2581 binding->uri = uri; | |
| 2582 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2583 uri = binding->uri + binding->uriLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2584 memcpy(uri, localPart, i * sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2585 if (prefixLen) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2586 uri = uri + (i - 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2587 if (namespaceSeparator) { *(uri) = namespaceSeparator; } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2588 memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2589 } |
| 21930 | 2590 tagNamePtr->str = binding->uri; |
| 2591 return XML_ERROR_NONE; | |
| 2592 } | |
| 2593 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2594 /* addBinding() overwrites the value of prefix->binding without checking. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2595 Therefore one must keep track of the old value outside of addBinding(). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2596 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2597 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2598 addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2599 const XML_Char *uri, BINDING **bindingsPtr) |
| 21930 | 2600 { |
| 2601 BINDING *b; | |
| 2602 int len; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2603 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2604 /* empty string is only valid when there is no prefix per XML NS 1.0 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2605 if (*uri == XML_T('\0') && prefix->name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2606 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2607 |
| 21930 | 2608 for (len = 0; uri[len]; len++) |
| 2609 ; | |
| 2610 if (namespaceSeparator) | |
| 2611 len++; | |
| 2612 if (freeBindingList) { | |
| 2613 b = freeBindingList; | |
| 2614 if (len > b->uriAlloc) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2615 XML_Char *temp = (XML_Char *)REALLOC(b->uri, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2616 sizeof(XML_Char) * (len + EXPAND_SPARE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2617 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2618 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2619 b->uri = temp; |
| 21930 | 2620 b->uriAlloc = len + EXPAND_SPARE; |
| 2621 } | |
| 2622 freeBindingList = b->nextTagBinding; | |
| 2623 } | |
| 2624 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2625 b = (BINDING *)MALLOC(sizeof(BINDING)); |
| 21930 | 2626 if (!b) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2627 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2628 b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); |
| 21930 | 2629 if (!b->uri) { |
| 2630 FREE(b); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2631 return XML_ERROR_NO_MEMORY; |
| 21930 | 2632 } |
| 2633 b->uriAlloc = len + EXPAND_SPARE; | |
| 2634 } | |
| 2635 b->uriLen = len; | |
| 2636 memcpy(b->uri, uri, len * sizeof(XML_Char)); | |
| 2637 if (namespaceSeparator) | |
| 2638 b->uri[len - 1] = namespaceSeparator; | |
| 2639 b->prefix = prefix; | |
| 2640 b->attId = attId; | |
| 2641 b->prevPrefixBinding = prefix->binding; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2642 if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2643 prefix->binding = NULL; |
| 21930 | 2644 else |
| 2645 prefix->binding = b; | |
| 2646 b->nextTagBinding = *bindingsPtr; | |
| 2647 *bindingsPtr = b; | |
| 2648 if (startNamespaceDeclHandler) | |
| 2649 startNamespaceDeclHandler(handlerArg, prefix->name, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2650 prefix->binding ? uri : 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2651 return XML_ERROR_NONE; |
| 21930 | 2652 } |
| 2653 | |
| 2654 /* The idea here is to avoid using stack for each CDATA section when | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2655 the whole file is parsed with one call. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2656 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2657 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2658 cdataSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2659 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2660 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2661 const char **endPtr) |
| 21930 | 2662 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2663 enum XML_Error result = doCdataSection(parser, encoding, &start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2664 end, endPtr); |
| 21930 | 2665 if (start) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2666 if (parentParser) { /* we are parsing an external entity */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2667 processor = externalEntityContentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2668 return externalEntityContentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2669 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2670 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2671 processor = contentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2672 return contentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2673 } |
| 21930 | 2674 } |
| 2675 return result; | |
| 2676 } | |
| 2677 | |
| 2678 /* startPtr gets set to non-null is the section is closed, and to null if | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2679 the section is not yet closed. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2680 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2681 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2682 doCdataSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2683 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2684 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2685 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2686 const char **nextPtr) |
| 21930 | 2687 { |
| 2688 const char *s = *startPtr; | |
| 2689 const char **eventPP; | |
| 2690 const char **eventEndPP; | |
| 2691 if (enc == encoding) { | |
| 2692 eventPP = &eventPtr; | |
| 2693 *eventPP = s; | |
| 2694 eventEndPP = &eventEndPtr; | |
| 2695 } | |
| 2696 else { | |
| 2697 eventPP = &(openInternalEntities->internalEventPtr); | |
| 2698 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 2699 } | |
| 2700 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2701 *startPtr = NULL; |
| 21930 | 2702 for (;;) { |
| 2703 const char *next; | |
| 2704 int tok = XmlCdataSectionTok(enc, s, end, &next); | |
| 2705 *eventEndPP = next; | |
| 2706 switch (tok) { | |
| 2707 case XML_TOK_CDATA_SECT_CLOSE: | |
| 2708 if (endCdataSectionHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2709 endCdataSectionHandler(handlerArg); |
| 21930 | 2710 #if 0 |
| 2711 /* see comment under XML_TOK_CDATA_SECT_OPEN */ | |
| 2712 else if (characterDataHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2713 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 2714 #endif |
| 2715 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2716 reportDefault(parser, enc, s, next); |
| 21930 | 2717 *startPtr = next; |
| 2718 return XML_ERROR_NONE; | |
| 2719 case XML_TOK_DATA_NEWLINE: | |
| 2720 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2721 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2722 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2723 } |
| 2724 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2725 reportDefault(parser, enc, s, next); |
| 21930 | 2726 break; |
| 2727 case XML_TOK_DATA_CHARS: | |
| 2728 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2729 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2730 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2731 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2732 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2733 *eventEndPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2734 characterDataHandler(handlerArg, dataBuf, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2735 dataPtr - (ICHAR *)dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2736 if (s == next) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2737 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2738 *eventPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2739 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2740 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2741 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2742 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2743 (XML_Char *)s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2744 (XML_Char *)next - (XML_Char *)s); |
| 21930 | 2745 } |
| 2746 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2747 reportDefault(parser, enc, s, next); |
| 21930 | 2748 break; |
| 2749 case XML_TOK_INVALID: | |
| 2750 *eventPP = next; | |
| 2751 return XML_ERROR_INVALID_TOKEN; | |
| 2752 case XML_TOK_PARTIAL_CHAR: | |
| 2753 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2754 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2755 return XML_ERROR_NONE; |
| 21930 | 2756 } |
| 2757 return XML_ERROR_PARTIAL_CHAR; | |
| 2758 case XML_TOK_PARTIAL: | |
| 2759 case XML_TOK_NONE: | |
| 2760 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2761 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2762 return XML_ERROR_NONE; |
| 21930 | 2763 } |
| 2764 return XML_ERROR_UNCLOSED_CDATA_SECTION; | |
| 2765 default: | |
| 2766 *eventPP = next; | |
| 2767 return XML_ERROR_UNEXPECTED_STATE; | |
| 2768 } | |
| 2769 *eventPP = s = next; | |
| 2770 } | |
| 2771 /* not reached */ | |
| 2772 } | |
| 2773 | |
| 2774 #ifdef XML_DTD | |
| 2775 | |
| 2776 /* The idea here is to avoid using stack for each IGNORE section when | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2777 the whole file is parsed with one call. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2778 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2779 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2780 ignoreSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2781 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2782 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2783 const char **endPtr) |
| 21930 | 2784 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2785 enum XML_Error result = doIgnoreSection(parser, encoding, &start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2786 end, endPtr); |
| 21930 | 2787 if (start) { |
| 2788 processor = prologProcessor; | |
| 2789 return prologProcessor(parser, start, end, endPtr); | |
| 2790 } | |
| 2791 return result; | |
| 2792 } | |
| 2793 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2794 /* startPtr gets set to non-null is the section is closed, and to null |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2795 if the section is not yet closed. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2796 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2797 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2798 doIgnoreSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2799 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2800 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2801 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2802 const char **nextPtr) |
| 21930 | 2803 { |
| 2804 const char *next; | |
| 2805 int tok; | |
| 2806 const char *s = *startPtr; | |
| 2807 const char **eventPP; | |
| 2808 const char **eventEndPP; | |
| 2809 if (enc == encoding) { | |
| 2810 eventPP = &eventPtr; | |
| 2811 *eventPP = s; | |
| 2812 eventEndPP = &eventEndPtr; | |
| 2813 } | |
| 2814 else { | |
| 2815 eventPP = &(openInternalEntities->internalEventPtr); | |
| 2816 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 2817 } | |
| 2818 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2819 *startPtr = NULL; |
| 21930 | 2820 tok = XmlIgnoreSectionTok(enc, s, end, &next); |
| 2821 *eventEndPP = next; | |
| 2822 switch (tok) { | |
| 2823 case XML_TOK_IGNORE_SECT: | |
| 2824 if (defaultHandler) | |
| 2825 reportDefault(parser, enc, s, next); | |
| 2826 *startPtr = next; | |
| 2827 return XML_ERROR_NONE; | |
| 2828 case XML_TOK_INVALID: | |
| 2829 *eventPP = next; | |
| 2830 return XML_ERROR_INVALID_TOKEN; | |
| 2831 case XML_TOK_PARTIAL_CHAR: | |
| 2832 if (nextPtr) { | |
| 2833 *nextPtr = s; | |
| 2834 return XML_ERROR_NONE; | |
| 2835 } | |
| 2836 return XML_ERROR_PARTIAL_CHAR; | |
| 2837 case XML_TOK_PARTIAL: | |
| 2838 case XML_TOK_NONE: | |
| 2839 if (nextPtr) { | |
| 2840 *nextPtr = s; | |
| 2841 return XML_ERROR_NONE; | |
| 2842 } | |
| 2843 return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ | |
| 2844 default: | |
| 2845 *eventPP = next; | |
| 2846 return XML_ERROR_UNEXPECTED_STATE; | |
| 2847 } | |
| 2848 /* not reached */ | |
| 2849 } | |
| 2850 | |
| 2851 #endif /* XML_DTD */ | |
| 2852 | |
| 2853 static enum XML_Error | |
| 2854 initializeEncoding(XML_Parser parser) | |
| 2855 { | |
| 2856 const char *s; | |
| 2857 #ifdef XML_UNICODE | |
| 2858 char encodingBuf[128]; | |
| 2859 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2860 s = NULL; |
| 21930 | 2861 else { |
| 2862 int i; | |
| 2863 for (i = 0; protocolEncodingName[i]; i++) { | |
| 2864 if (i == sizeof(encodingBuf) - 1 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2865 || (protocolEncodingName[i] & ~0x7f) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2866 encodingBuf[0] = '\0'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2867 break; |
| 21930 | 2868 } |
| 2869 encodingBuf[i] = (char)protocolEncodingName[i]; | |
| 2870 } | |
| 2871 encodingBuf[i] = '\0'; | |
| 2872 s = encodingBuf; | |
| 2873 } | |
| 2874 #else | |
| 2875 s = protocolEncodingName; | |
| 2876 #endif | |
| 2877 if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) | |
| 2878 return XML_ERROR_NONE; | |
| 2879 return handleUnknownEncoding(parser, protocolEncodingName); | |
| 2880 } | |
| 2881 | |
| 2882 static enum XML_Error | |
| 2883 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2884 const char *s, const char *next) |
| 21930 | 2885 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2886 const char *encodingName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2887 const XML_Char *storedEncName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2888 const ENCODING *newEncoding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2889 const char *version = NULL; |
| 21930 | 2890 const char *versionend; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2891 const XML_Char *storedversion = NULL; |
| 21930 | 2892 int standalone = -1; |
| 2893 if (!(ns | |
| 2894 ? XmlParseXmlDeclNS | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2895 : XmlParseXmlDecl)(isGeneralTextEntity, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2896 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2897 s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2898 next, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2899 &eventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2900 &version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2901 &versionend, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2902 &encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2903 &newEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2904 &standalone)) |
| 21930 | 2905 return XML_ERROR_SYNTAX; |
| 2906 if (!isGeneralTextEntity && standalone == 1) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2907 _dtd->standalone = XML_TRUE; |
| 21930 | 2908 #ifdef XML_DTD |
| 2909 if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) | |
| 2910 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; | |
| 2911 #endif /* XML_DTD */ | |
| 2912 } | |
| 2913 if (xmlDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2914 if (encodingName != NULL) { |
| 21930 | 2915 storedEncName = poolStoreString(&temp2Pool, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2916 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2917 encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2918 encodingName |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2919 + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2920 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2921 return XML_ERROR_NO_MEMORY; |
| 21930 | 2922 poolFinish(&temp2Pool); |
| 2923 } | |
| 2924 if (version) { | |
| 2925 storedversion = poolStoreString(&temp2Pool, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2926 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2927 version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2928 versionend - encoding->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2929 if (!storedversion) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2930 return XML_ERROR_NO_MEMORY; |
| 21930 | 2931 } |
| 2932 xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); | |
| 2933 } | |
| 2934 else if (defaultHandler) | |
| 2935 reportDefault(parser, encoding, s, next); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2936 if (protocolEncodingName == NULL) { |
| 21930 | 2937 if (newEncoding) { |
| 2938 if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2939 eventPtr = encodingName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2940 return XML_ERROR_INCORRECT_ENCODING; |
| 21930 | 2941 } |
| 2942 encoding = newEncoding; | |
| 2943 } | |
| 2944 else if (encodingName) { | |
| 2945 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2946 if (!storedEncName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2947 storedEncName = poolStoreString( |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2948 &temp2Pool, encoding, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2949 encodingName + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2950 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2951 return XML_ERROR_NO_MEMORY; |
| 21930 | 2952 } |
| 2953 result = handleUnknownEncoding(parser, storedEncName); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2954 poolClear(&temp2Pool); |
| 21930 | 2955 if (result == XML_ERROR_UNKNOWN_ENCODING) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2956 eventPtr = encodingName; |
| 21930 | 2957 return result; |
| 2958 } | |
| 2959 } | |
| 2960 | |
| 2961 if (storedEncName || storedversion) | |
| 2962 poolClear(&temp2Pool); | |
| 2963 | |
| 2964 return XML_ERROR_NONE; | |
| 2965 } | |
| 2966 | |
| 2967 static enum XML_Error | |
| 2968 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) | |
| 2969 { | |
| 2970 if (unknownEncodingHandler) { | |
| 2971 XML_Encoding info; | |
| 2972 int i; | |
| 2973 for (i = 0; i < 256; i++) | |
| 2974 info.map[i] = -1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2975 info.convert = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2976 info.data = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2977 info.release = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2978 if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2979 &info)) { |
| 21930 | 2980 ENCODING *enc; |
| 2981 unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); | |
| 2982 if (!unknownEncodingMem) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2983 if (info.release) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2984 info.release(info.data); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2985 return XML_ERROR_NO_MEMORY; |
| 21930 | 2986 } |
| 2987 enc = (ns | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2988 ? XmlInitUnknownEncodingNS |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2989 : XmlInitUnknownEncoding)(unknownEncodingMem, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2990 info.map, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2991 info.convert, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2992 info.data); |
| 21930 | 2993 if (enc) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2994 unknownEncodingData = info.data; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2995 unknownEncodingRelease = info.release; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2996 encoding = enc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2997 return XML_ERROR_NONE; |
| 21930 | 2998 } |
| 2999 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3000 if (info.release != NULL) |
| 21930 | 3001 info.release(info.data); |
| 3002 } | |
| 3003 return XML_ERROR_UNKNOWN_ENCODING; | |
| 3004 } | |
| 3005 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3006 static enum XML_Error PTRCALL |
| 21930 | 3007 prologInitProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3008 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3009 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3010 const char **nextPtr) |
| 21930 | 3011 { |
| 3012 enum XML_Error result = initializeEncoding(parser); | |
| 3013 if (result != XML_ERROR_NONE) | |
| 3014 return result; | |
| 3015 processor = prologProcessor; | |
| 3016 return prologProcessor(parser, s, end, nextPtr); | |
| 3017 } | |
| 3018 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3019 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3020 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3021 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3022 externalParEntInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3023 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3024 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3025 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3026 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3027 enum XML_Error result = initializeEncoding(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3028 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3029 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3030 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3031 /* we know now that XML_Parse(Buffer) has been called, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3032 so we consider the external parameter entity read */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3033 _dtd->paramEntityRead = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3034 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3035 if (prologState.inEntityValue) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3036 processor = entityValueInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3037 return entityValueInitProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3038 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3039 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3040 processor = externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3041 return externalParEntProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3042 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3043 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3044 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3045 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3046 entityValueInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3047 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3048 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3049 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3050 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3051 const char *start = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3052 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3053 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3054 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3055 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3056 tok = XmlPrologTok(encoding, start, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3057 if (tok <= 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3058 if (nextPtr != 0 && tok != XML_TOK_INVALID) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3059 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3060 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3061 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3062 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3063 case XML_TOK_INVALID: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3064 return XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3065 case XML_TOK_PARTIAL: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3066 return XML_ERROR_UNCLOSED_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3067 case XML_TOK_PARTIAL_CHAR: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3068 return XML_ERROR_PARTIAL_CHAR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3069 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3070 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3071 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3072 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3073 return storeEntityValue(parser, encoding, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3074 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3075 else if (tok == XML_TOK_XML_DECL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3076 enum XML_Error result = processXmlDecl(parser, 0, start, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3077 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3078 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3079 if (nextPtr) *nextPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3080 /* stop scanning for text declaration - we found one */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3081 processor = entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3082 return entityValueProcessor(parser, next, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3083 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3084 /* If we are at the end of the buffer, this would cause XmlPrologTok to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3085 return XML_TOK_NONE on the next call, which would then cause the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3086 function to exit with *nextPtr set to s - that is what we want for other |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3087 tokens, but not for the BOM - we would rather like to skip it; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3088 then, when this routine is entered the next time, XmlPrologTok will |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3089 return XML_TOK_INVALID, since the BOM is still in the buffer |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3090 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3091 else if (tok == XML_TOK_BOM && next == end && nextPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3092 *nextPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3093 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3094 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3095 start = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3096 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3097 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3098 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3099 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3100 externalParEntProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3101 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3102 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3103 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3104 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3105 const char *start = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3106 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3107 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3108 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3109 tok = XmlPrologTok(encoding, start, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3110 if (tok <= 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3111 if (nextPtr != 0 && tok != XML_TOK_INVALID) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3112 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3113 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3114 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3115 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3116 case XML_TOK_INVALID: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3117 return XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3118 case XML_TOK_PARTIAL: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3119 return XML_ERROR_UNCLOSED_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3120 case XML_TOK_PARTIAL_CHAR: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3121 return XML_ERROR_PARTIAL_CHAR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3122 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3123 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3124 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3125 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3126 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3127 /* This would cause the next stage, i.e. doProlog to be passed XML_TOK_BOM. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3128 However, when parsing an external subset, doProlog will not accept a BOM |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3129 as valid, and report a syntax error, so we have to skip the BOM |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3130 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3131 else if (tok == XML_TOK_BOM) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3132 s = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3133 tok = XmlPrologTok(encoding, s, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3134 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3135 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3136 processor = prologProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3137 return doProlog(parser, encoding, s, end, tok, next, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3138 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3139 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3140 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3141 entityValueProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3142 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3143 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3144 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3145 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3146 const char *start = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3147 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3148 const ENCODING *enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3149 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3150 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3151 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3152 tok = XmlPrologTok(enc, start, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3153 if (tok <= 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3154 if (nextPtr != 0 && tok != XML_TOK_INVALID) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3155 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3156 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3157 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3158 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3159 case XML_TOK_INVALID: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3160 return XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3161 case XML_TOK_PARTIAL: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3162 return XML_ERROR_UNCLOSED_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3163 case XML_TOK_PARTIAL_CHAR: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3164 return XML_ERROR_PARTIAL_CHAR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3165 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3166 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3167 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3168 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3169 return storeEntityValue(parser, enc, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3170 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3171 start = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3172 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3173 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3174 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3175 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3176 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3177 static enum XML_Error PTRCALL |
| 21930 | 3178 prologProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3179 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3180 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3181 const char **nextPtr) |
| 21930 | 3182 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3183 const char *next = s; |
| 21930 | 3184 int tok = XmlPrologTok(encoding, s, end, &next); |
| 3185 return doProlog(parser, encoding, s, end, tok, next, nextPtr); | |
| 3186 } | |
| 3187 | |
| 3188 static enum XML_Error | |
| 3189 doProlog(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3190 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3191 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3192 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3193 int tok, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3194 const char *next, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3195 const char **nextPtr) |
| 21930 | 3196 { |
| 3197 #ifdef XML_DTD | |
| 3198 static const XML_Char externalSubsetName[] = { '#' , '\0' }; | |
| 3199 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3200 static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3201 static const XML_Char atypeID[] = { 'I', 'D', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3202 static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3203 static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3204 static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3205 static const XML_Char atypeENTITIES[] = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3206 { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3207 static const XML_Char atypeNMTOKEN[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3208 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3209 static const XML_Char atypeNMTOKENS[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3210 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3211 static const XML_Char notationPrefix[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3212 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3213 static const XML_Char enumValueSep[] = { '|', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3214 static const XML_Char enumValueStart[] = { '(', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3215 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3216 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 3217 |
| 3218 const char **eventPP; | |
| 3219 const char **eventEndPP; | |
| 3220 enum XML_Content_Quant quant; | |
| 3221 | |
| 3222 if (enc == encoding) { | |
| 3223 eventPP = &eventPtr; | |
| 3224 eventEndPP = &eventEndPtr; | |
| 3225 } | |
| 3226 else { | |
| 3227 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3228 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3229 } | |
| 3230 for (;;) { | |
| 3231 int role; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3232 XML_Bool handleDefault = XML_TRUE; |
| 21930 | 3233 *eventPP = s; |
| 3234 *eventEndPP = next; | |
| 3235 if (tok <= 0) { | |
| 3236 if (nextPtr != 0 && tok != XML_TOK_INVALID) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3237 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3238 return XML_ERROR_NONE; |
| 21930 | 3239 } |
| 3240 switch (tok) { | |
| 3241 case XML_TOK_INVALID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3242 *eventPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3243 return XML_ERROR_INVALID_TOKEN; |
| 21930 | 3244 case XML_TOK_PARTIAL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3245 return XML_ERROR_UNCLOSED_TOKEN; |
| 21930 | 3246 case XML_TOK_PARTIAL_CHAR: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3247 return XML_ERROR_PARTIAL_CHAR; |
| 21930 | 3248 case XML_TOK_NONE: |
| 3249 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3250 if (enc != encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3251 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3252 if (isParamEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3253 if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3254 == XML_ROLE_ERROR) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3255 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3256 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3257 } |
| 21930 | 3258 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3259 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 3260 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3261 tok = -tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3262 next = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3263 break; |
| 21930 | 3264 } |
| 3265 } | |
| 3266 role = XmlTokenRole(&prologState, tok, s, next, enc); | |
| 3267 switch (role) { | |
| 3268 case XML_ROLE_XML_DECL: | |
| 3269 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3270 enum XML_Error result = processXmlDecl(parser, 0, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3271 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3272 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3273 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3274 handleDefault = XML_FALSE; |
| 21930 | 3275 } |
| 3276 break; | |
| 3277 case XML_ROLE_DOCTYPE_NAME: | |
| 3278 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3279 doctypeName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3280 if (!doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3281 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3282 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3283 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3284 handleDefault = XML_FALSE; |
| 21930 | 3285 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3286 doctypeSysid = NULL; /* always initialize to NULL */ |
| 21930 | 3287 break; |
| 3288 case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: | |
| 3289 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3290 startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3291 doctypePubid, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3292 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3293 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3294 handleDefault = XML_FALSE; |
| 21930 | 3295 } |
| 3296 break; | |
| 3297 #ifdef XML_DTD | |
| 3298 case XML_ROLE_TEXT_DECL: | |
| 3299 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3300 enum XML_Error result = processXmlDecl(parser, 1, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3301 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3302 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3303 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3304 handleDefault = XML_FALSE; |
| 21930 | 3305 } |
| 3306 break; | |
| 3307 #endif /* XML_DTD */ | |
| 3308 case XML_ROLE_DOCTYPE_PUBLIC_ID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3309 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3310 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3311 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3312 dtd->hasParamEntityRefs = XML_TRUE; |
| 21930 | 3313 if (startDoctypeDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3314 doctypePubid = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3315 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3316 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3317 if (!doctypePubid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3318 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3319 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3320 handleDefault = XML_FALSE; |
| 21930 | 3321 } |
| 3322 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3323 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3324 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3325 sizeof(ENTITY)); |
| 21930 | 3326 if (!declEntity) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3327 return XML_ERROR_NO_MEMORY; |
| 21930 | 3328 #endif /* XML_DTD */ |
| 3329 /* fall through */ | |
| 3330 case XML_ROLE_ENTITY_PUBLIC_ID: | |
| 3331 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3332 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3333 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3334 XML_Char *tem = poolStoreString(&dtd->pool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3335 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3336 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3337 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3338 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3339 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3340 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3341 declEntity->publicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3342 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3343 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3344 handleDefault = XML_FALSE; |
| 21930 | 3345 } |
| 3346 break; | |
| 3347 case XML_ROLE_DOCTYPE_CLOSE: | |
| 3348 if (doctypeName) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3349 startDoctypeDeclHandler(handlerArg, doctypeName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3350 doctypeSysid, doctypePubid, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3351 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3352 handleDefault = XML_FALSE; |
| 21930 | 3353 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3354 /* doctypeSysid will be non-NULL in the case of a previous |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3355 XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3356 was not set, indicating an external subset |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3357 */ |
| 21930 | 3358 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3359 if (doctypeSysid || useForeignDTD) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3360 dtd->hasParamEntityRefs = XML_TRUE; /* when docTypeSysid == NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3361 if (paramEntityParsing && externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3362 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3363 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3364 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3365 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3366 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3367 if (useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3368 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3369 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3370 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3371 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3372 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3373 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3374 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3375 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3376 if (dtd->paramEntityRead && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3377 !dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3378 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3379 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3380 return XML_ERROR_NOT_STANDALONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3381 /* end of DTD - no need to update dtd->keepProcessing */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3382 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3383 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3384 } |
| 21930 | 3385 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3386 if (endDoctypeDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3387 endDoctypeDeclHandler(handlerArg); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3388 handleDefault = XML_FALSE; |
| 21930 | 3389 } |
| 3390 break; | |
| 3391 case XML_ROLE_INSTANCE_START: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3392 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3393 /* if there is no DOCTYPE declaration then now is the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3394 last chance to read the foreign DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3395 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3396 if (useForeignDTD) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3397 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3398 if (paramEntityParsing && externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3399 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3400 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3401 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3402 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3403 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3404 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3405 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3406 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3407 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3408 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3409 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3410 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3411 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3412 if (dtd->paramEntityRead && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3413 !dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3414 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3415 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3416 return XML_ERROR_NOT_STANDALONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3417 /* end of DTD - no need to update dtd->keepProcessing */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3418 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3419 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3420 #endif /* XML_DTD */ |
| 21930 | 3421 processor = contentProcessor; |
| 3422 return contentProcessor(parser, s, end, nextPtr); | |
| 3423 case XML_ROLE_ATTLIST_ELEMENT_NAME: | |
| 3424 declElementType = getElementType(parser, enc, s, next); | |
| 3425 if (!declElementType) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3426 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3427 goto checkAttListDeclHandler; |
| 21930 | 3428 case XML_ROLE_ATTRIBUTE_NAME: |
| 3429 declAttributeId = getAttributeId(parser, enc, s, next); | |
| 3430 if (!declAttributeId) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3431 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3432 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3433 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3434 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3435 goto checkAttListDeclHandler; |
| 21930 | 3436 case XML_ROLE_ATTRIBUTE_TYPE_CDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3437 declAttributeIsCdata = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3438 declAttributeType = atypeCDATA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3439 goto checkAttListDeclHandler; |
| 21930 | 3440 case XML_ROLE_ATTRIBUTE_TYPE_ID: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3441 declAttributeIsId = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3442 declAttributeType = atypeID; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3443 goto checkAttListDeclHandler; |
| 21930 | 3444 case XML_ROLE_ATTRIBUTE_TYPE_IDREF: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3445 declAttributeType = atypeIDREF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3446 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3447 case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3448 declAttributeType = atypeIDREFS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3449 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3450 case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3451 declAttributeType = atypeENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3452 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3453 case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3454 declAttributeType = atypeENTITIES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3455 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3456 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3457 declAttributeType = atypeNMTOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3458 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3459 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3460 declAttributeType = atypeNMTOKENS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3461 checkAttListDeclHandler: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3462 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3463 handleDefault = XML_FALSE; |
| 21930 | 3464 break; |
| 3465 case XML_ROLE_ATTRIBUTE_ENUM_VALUE: | |
| 3466 case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3467 if (dtd->keepProcessing && attlistDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3468 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3469 if (declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3470 prefix = enumValueSep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3471 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3472 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3473 prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3474 ? notationPrefix |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3475 : enumValueStart); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3476 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3477 if (!poolAppendString(&tempPool, prefix)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3478 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3479 if (!poolAppend(&tempPool, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3480 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3481 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3482 handleDefault = XML_FALSE; |
| 21930 | 3483 } |
| 3484 break; | |
| 3485 case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: | |
| 3486 case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3487 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3488 if (!defineAttribute(declElementType, declAttributeId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3489 declAttributeIsCdata, declAttributeIsId, 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3490 parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3491 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3492 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3493 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3494 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3495 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3496 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3497 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3498 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3499 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3500 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3501 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3502 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3503 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3504 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3505 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3506 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3507 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3508 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3509 } |
| 21930 | 3510 } |
| 3511 break; | |
| 3512 case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: | |
| 3513 case XML_ROLE_FIXED_ATTRIBUTE_VALUE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3514 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3515 const XML_Char *attVal; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3516 enum XML_Error result |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3517 = storeAttributeValue(parser, enc, declAttributeIsCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3518 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3519 next - enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3520 &dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3521 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3522 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3523 attVal = poolStart(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3524 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3525 /* ID attributes aren't allowed to have a default */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3526 if (!defineAttribute(declElementType, declAttributeId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3527 declAttributeIsCdata, XML_FALSE, attVal, parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3528 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3529 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3530 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3531 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3532 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3533 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3534 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3535 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3536 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3537 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3538 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3539 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3540 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3541 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3542 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3543 attVal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3544 role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3545 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3546 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3547 } |
| 21930 | 3548 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3549 break; |
| 21930 | 3550 case XML_ROLE_ENTITY_VALUE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3551 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3552 enum XML_Error result = storeEntityValue(parser, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3553 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3554 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3555 if (declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3556 declEntity->textPtr = poolStart(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3557 declEntity->textLen = poolLength(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3558 poolFinish(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3559 if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3560 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3561 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3562 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3563 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3564 declEntity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3565 declEntity->textLen, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3566 curBase, 0, 0, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3567 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3568 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3569 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3570 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3571 poolDiscard(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3572 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3573 return result; |
| 21930 | 3574 } |
| 3575 break; | |
| 3576 case XML_ROLE_DOCTYPE_SYSTEM_ID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3577 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3578 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3579 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3580 dtd->hasParamEntityRefs = XML_TRUE; |
| 21930 | 3581 if (startDoctypeDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3582 doctypeSysid = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3583 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3584 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3585 if (doctypeSysid == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3586 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3587 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3588 handleDefault = XML_FALSE; |
| 21930 | 3589 } |
| 3590 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3591 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3592 /* use externalSubsetName to make doctypeSysid non-NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3593 for the case where no startDoctypeDeclHandler is set */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3594 doctypeSysid = externalSubsetName; |
| 21930 | 3595 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3596 if (!dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3597 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3598 && !paramEntityParsing |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3599 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3600 && notStandaloneHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3601 && !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3602 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 3603 #ifndef XML_DTD |
| 3604 break; | |
| 3605 #else /* XML_DTD */ | |
| 3606 if (!declEntity) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3607 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3608 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3609 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3610 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3611 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3612 declEntity->publicId = NULL; |
| 21930 | 3613 } |
| 3614 /* fall through */ | |
| 3615 #endif /* XML_DTD */ | |
| 3616 case XML_ROLE_ENTITY_SYSTEM_ID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3617 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3618 declEntity->systemId = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3619 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3620 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3621 if (!declEntity->systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3622 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3623 declEntity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3624 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3625 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3626 handleDefault = XML_FALSE; |
| 21930 | 3627 } |
| 3628 break; | |
| 3629 case XML_ROLE_ENTITY_COMPLETE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3630 if (dtd->keepProcessing && declEntity && entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3631 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3632 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3633 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3634 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3635 0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3636 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3637 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3638 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3639 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3640 handleDefault = XML_FALSE; |
| 21930 | 3641 } |
| 3642 break; | |
| 3643 case XML_ROLE_ENTITY_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3644 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3645 declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3646 if (!declEntity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3647 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3648 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3649 if (unparsedEntityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3650 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3651 unparsedEntityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3652 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3653 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3654 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3655 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3656 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3657 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3658 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3659 else if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3660 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3661 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3662 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3663 0,0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3664 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3665 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3666 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3667 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3668 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3669 } |
| 21930 | 3670 } |
| 3671 break; | |
| 3672 case XML_ROLE_GENERAL_ENTITY_NAME: | |
| 3673 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3674 if (XmlPredefinedEntityName(enc, s, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3675 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3676 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3677 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3678 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3679 const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3680 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3681 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3682 declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3683 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3684 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3685 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3686 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3687 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3688 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3689 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3690 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3691 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3692 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3693 declEntity->is_param = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3694 /* if we have a parent parser or are reading an internal parameter |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3695 entity, then the entity declaration is not considered "internal" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3696 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3697 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3698 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3699 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3700 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3701 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3702 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3703 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3704 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3705 } |
| 21930 | 3706 } |
| 3707 break; | |
| 3708 case XML_ROLE_PARAM_ENTITY_NAME: | |
| 3709 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3710 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3711 const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3712 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3713 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3714 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3715 name, sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3716 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3717 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3718 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3719 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3720 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3721 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3722 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3723 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3724 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3725 declEntity->is_param = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3726 /* if we have a parent parser or are reading an internal parameter |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3727 entity, then the entity declaration is not considered "internal" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3728 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3729 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3730 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3731 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3732 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3733 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3734 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3735 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3736 declEntity = NULL; |
| 21930 | 3737 } |
| 3738 #else /* not XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3739 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3740 #endif /* XML_DTD */ |
| 21930 | 3741 break; |
| 3742 case XML_ROLE_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3743 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3744 declNotationName = NULL; |
| 21930 | 3745 if (notationDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3746 declNotationName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3747 if (!declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3748 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3749 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3750 handleDefault = XML_FALSE; |
| 21930 | 3751 } |
| 3752 break; | |
| 3753 case XML_ROLE_NOTATION_PUBLIC_ID: | |
| 3754 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3755 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3756 if (declNotationName) { /* means notationDeclHandler != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3757 XML_Char *tem = poolStoreString(&tempPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3758 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3759 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3760 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3761 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3762 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3763 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3764 declNotationPublicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3765 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3766 handleDefault = XML_FALSE; |
| 21930 | 3767 } |
| 3768 break; | |
| 3769 case XML_ROLE_NOTATION_SYSTEM_ID: | |
| 3770 if (declNotationName && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3771 const XML_Char *systemId |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3772 = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3773 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3774 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3775 if (!systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3776 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3777 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3778 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3779 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3780 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3781 systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3782 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3783 handleDefault = XML_FALSE; |
| 21930 | 3784 } |
| 3785 poolClear(&tempPool); | |
| 3786 break; | |
| 3787 case XML_ROLE_NOTATION_NO_SYSTEM_ID: | |
| 3788 if (declNotationPublicId && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3789 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3790 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3791 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3792 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3793 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3794 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3795 handleDefault = XML_FALSE; |
| 21930 | 3796 } |
| 3797 poolClear(&tempPool); | |
| 3798 break; | |
| 3799 case XML_ROLE_ERROR: | |
| 3800 switch (tok) { | |
| 3801 case XML_TOK_PARAM_ENTITY_REF: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3802 return XML_ERROR_PARAM_ENTITY_REF; |
| 21930 | 3803 case XML_TOK_XML_DECL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3804 return XML_ERROR_MISPLACED_XML_PI; |
| 21930 | 3805 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3806 return XML_ERROR_SYNTAX; |
| 21930 | 3807 } |
| 3808 #ifdef XML_DTD | |
| 3809 case XML_ROLE_IGNORE_SECT: | |
| 3810 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3811 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3812 if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3813 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3814 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3815 result = doIgnoreSection(parser, enc, &next, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3816 if (!next) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3817 processor = ignoreSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3818 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3819 } |
| 21930 | 3820 } |
| 3821 break; | |
| 3822 #endif /* XML_DTD */ | |
| 3823 case XML_ROLE_GROUP_OPEN: | |
| 3824 if (prologState.level >= groupSize) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3825 if (groupSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3826 char *temp = (char *)REALLOC(groupConnector, groupSize *= 2); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3827 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3828 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3829 groupConnector = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3830 if (dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3831 int *temp = (int *)REALLOC(dtd->scaffIndex, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3832 groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3833 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3834 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3835 dtd->scaffIndex = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3836 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3837 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3838 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3839 groupConnector = (char *)MALLOC(groupSize = 32); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3840 if (!groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3841 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3842 } |
| 21930 | 3843 } |
| 3844 groupConnector[prologState.level] = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3845 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3846 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3847 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3848 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3849 dtd->scaffIndex[dtd->scaffLevel] = myindex; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3850 dtd->scaffLevel++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3851 dtd->scaffold[myindex].type = XML_CTYPE_SEQ; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3852 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3853 handleDefault = XML_FALSE; |
| 21930 | 3854 } |
| 3855 break; | |
| 3856 case XML_ROLE_GROUP_SEQUENCE: | |
| 3857 if (groupConnector[prologState.level] == '|') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3858 return XML_ERROR_SYNTAX; |
| 21930 | 3859 groupConnector[prologState.level] = ','; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3860 if (dtd->in_eldecl && elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3861 handleDefault = XML_FALSE; |
| 21930 | 3862 break; |
| 3863 case XML_ROLE_GROUP_CHOICE: | |
| 3864 if (groupConnector[prologState.level] == ',') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3865 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3866 if (dtd->in_eldecl |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3867 && !groupConnector[prologState.level] |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3868 && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3869 != XML_CTYPE_MIXED) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3870 ) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3871 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3872 = XML_CTYPE_CHOICE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3873 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3874 handleDefault = XML_FALSE; |
| 21930 | 3875 } |
| 3876 groupConnector[prologState.level] = '|'; | |
| 3877 break; | |
| 3878 case XML_ROLE_PARAM_ENTITY_REF: | |
| 3879 #ifdef XML_DTD | |
| 3880 case XML_ROLE_INNER_PARAM_ENTITY_REF: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3881 /* PE references in internal subset are |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3882 not allowed within declarations */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3883 if (prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3884 role == XML_ROLE_INNER_PARAM_ENTITY_REF) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3885 return XML_ERROR_PARAM_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3886 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3887 if (!paramEntityParsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3888 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3889 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3890 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3891 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3892 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3893 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3894 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3895 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3896 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3897 entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3898 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3899 /* first, determine if a check for an existing declaration is needed; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3900 if yes, check that the entity exists, and that it is internal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3901 otherwise call the skipped entity handler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3902 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3903 if (prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3904 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3905 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3906 : !dtd->hasParamEntityRefs)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3907 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3908 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3909 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3910 return XML_ERROR_ENTITY_DECLARED_IN_PE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3911 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3912 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3913 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3914 /* cannot report skipped entities in declarations */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3915 if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3916 skippedEntityHandler(handlerArg, name, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3917 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3918 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3919 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3920 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3921 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3922 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3923 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3924 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3925 result = processInternalParamEntity(parser, entity); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3926 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3927 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3928 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3929 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3930 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3931 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3932 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3933 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3934 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3935 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3936 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3937 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3938 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3939 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3940 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3941 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3942 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3943 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3944 if (!dtd->paramEntityRead) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3945 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3946 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3947 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3948 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3949 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3950 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3951 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3952 } |
| 21930 | 3953 } |
| 3954 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3955 if (!dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3956 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3957 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3958 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 3959 break; |
| 3960 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3961 /* Element declaration stuff */ |
| 21930 | 3962 |
| 3963 case XML_ROLE_ELEMENT_NAME: | |
| 3964 if (elementDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3965 declElementType = getElementType(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3966 if (!declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3967 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3968 dtd->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3969 dtd->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3970 dtd->in_eldecl = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3971 handleDefault = XML_FALSE; |
| 21930 | 3972 } |
| 3973 break; | |
| 3974 | |
| 3975 case XML_ROLE_CONTENT_ANY: | |
| 3976 case XML_ROLE_CONTENT_EMPTY: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3977 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3978 if (elementDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3979 XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3980 if (!content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3981 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3982 content->quant = XML_CQUANT_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3983 content->name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3984 content->numchildren = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3985 content->children = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3986 content->type = ((role == XML_ROLE_CONTENT_ANY) ? |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3987 XML_CTYPE_ANY : |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3988 XML_CTYPE_EMPTY); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3989 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3990 elementDeclHandler(handlerArg, declElementType->name, content); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3991 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3992 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3993 dtd->in_eldecl = XML_FALSE; |
| 21930 | 3994 } |
| 3995 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3996 |
| 21930 | 3997 case XML_ROLE_CONTENT_PCDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3998 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3999 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4000 = XML_CTYPE_MIXED; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4001 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4002 handleDefault = XML_FALSE; |
| 21930 | 4003 } |
| 4004 break; | |
| 4005 | |
| 4006 case XML_ROLE_CONTENT_ELEMENT: | |
| 4007 quant = XML_CQUANT_NONE; | |
| 4008 goto elementContent; | |
| 4009 case XML_ROLE_CONTENT_ELEMENT_OPT: | |
| 4010 quant = XML_CQUANT_OPT; | |
| 4011 goto elementContent; | |
| 4012 case XML_ROLE_CONTENT_ELEMENT_REP: | |
| 4013 quant = XML_CQUANT_REP; | |
| 4014 goto elementContent; | |
| 4015 case XML_ROLE_CONTENT_ELEMENT_PLUS: | |
| 4016 quant = XML_CQUANT_PLUS; | |
| 4017 elementContent: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4018 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4019 ELEMENT_TYPE *el; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4020 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4021 int nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4022 const char *nxt = (quant == XML_CQUANT_NONE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4023 ? next |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4024 : next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4025 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4026 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4027 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4028 dtd->scaffold[myindex].type = XML_CTYPE_NAME; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4029 dtd->scaffold[myindex].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4030 el = getElementType(parser, enc, s, nxt); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4031 if (!el) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4032 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4033 name = el->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4034 dtd->scaffold[myindex].name = name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4035 nameLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4036 for (; name[nameLen++]; ); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4037 dtd->contentStringLen += nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4038 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4039 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4040 } |
| 21930 | 4041 break; |
| 4042 | |
| 4043 case XML_ROLE_GROUP_CLOSE: | |
| 4044 quant = XML_CQUANT_NONE; | |
| 4045 goto closeGroup; | |
| 4046 case XML_ROLE_GROUP_CLOSE_OPT: | |
| 4047 quant = XML_CQUANT_OPT; | |
| 4048 goto closeGroup; | |
| 4049 case XML_ROLE_GROUP_CLOSE_REP: | |
| 4050 quant = XML_CQUANT_REP; | |
| 4051 goto closeGroup; | |
| 4052 case XML_ROLE_GROUP_CLOSE_PLUS: | |
| 4053 quant = XML_CQUANT_PLUS; | |
| 4054 closeGroup: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4055 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4056 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4057 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4058 dtd->scaffLevel--; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4059 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4060 if (dtd->scaffLevel == 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4061 if (!handleDefault) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4062 XML_Content *model = build_model(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4063 if (!model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4064 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4065 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4066 elementDeclHandler(handlerArg, declElementType->name, model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4067 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4068 dtd->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4069 dtd->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4070 } |
| 21930 | 4071 } |
| 4072 break; | |
| 4073 /* End element declaration stuff */ | |
| 4074 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4075 case XML_ROLE_PI: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4076 if (!reportProcessingInstruction(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4077 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4078 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4079 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4080 case XML_ROLE_COMMENT: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4081 if (!reportComment(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4082 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4083 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4084 break; |
| 21930 | 4085 case XML_ROLE_NONE: |
| 4086 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4087 case XML_TOK_BOM: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4088 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4089 break; |
| 21930 | 4090 } |
| 4091 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4092 case XML_ROLE_DOCTYPE_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4093 if (startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4094 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4095 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4096 case XML_ROLE_ENTITY_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4097 if (dtd->keepProcessing && entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4098 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4099 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4100 case XML_ROLE_NOTATION_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4101 if (notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4102 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4103 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4104 case XML_ROLE_ATTLIST_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4105 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4106 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4107 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4108 case XML_ROLE_ELEMENT_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4109 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4110 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4111 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4112 } /* end of big switch */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4113 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4114 if (handleDefault && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4115 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4116 |
| 21930 | 4117 s = next; |
| 4118 tok = XmlPrologTok(enc, s, end, &next); | |
| 4119 } | |
| 4120 /* not reached */ | |
| 4121 } | |
| 4122 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4123 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4124 epilogProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4125 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4126 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4127 const char **nextPtr) |
| 21930 | 4128 { |
| 4129 processor = epilogProcessor; | |
| 4130 eventPtr = s; | |
| 4131 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4132 const char *next = NULL; |
| 21930 | 4133 int tok = XmlPrologTok(encoding, s, end, &next); |
| 4134 eventEndPtr = next; | |
| 4135 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4136 /* report partial linebreak - it might be the last token */ |
| 21930 | 4137 case -XML_TOK_PROLOG_S: |
| 4138 if (defaultHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4139 eventEndPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4140 reportDefault(parser, encoding, s, next); |
| 21930 | 4141 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4142 if (nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4143 *nextPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4144 return XML_ERROR_NONE; |
| 21930 | 4145 case XML_TOK_NONE: |
| 4146 if (nextPtr) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4147 *nextPtr = s; |
| 21930 | 4148 return XML_ERROR_NONE; |
| 4149 case XML_TOK_PROLOG_S: | |
| 4150 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4151 reportDefault(parser, encoding, s, next); |
| 21930 | 4152 break; |
| 4153 case XML_TOK_PI: | |
| 4154 if (!reportProcessingInstruction(parser, encoding, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4155 return XML_ERROR_NO_MEMORY; |
| 21930 | 4156 break; |
| 4157 case XML_TOK_COMMENT: | |
| 4158 if (!reportComment(parser, encoding, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4159 return XML_ERROR_NO_MEMORY; |
| 21930 | 4160 break; |
| 4161 case XML_TOK_INVALID: | |
| 4162 eventPtr = next; | |
| 4163 return XML_ERROR_INVALID_TOKEN; | |
| 4164 case XML_TOK_PARTIAL: | |
| 4165 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4166 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4167 return XML_ERROR_NONE; |
| 21930 | 4168 } |
| 4169 return XML_ERROR_UNCLOSED_TOKEN; | |
| 4170 case XML_TOK_PARTIAL_CHAR: | |
| 4171 if (nextPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4172 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4173 return XML_ERROR_NONE; |
| 21930 | 4174 } |
| 4175 return XML_ERROR_PARTIAL_CHAR; | |
| 4176 default: | |
| 4177 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; | |
| 4178 } | |
| 4179 eventPtr = s = next; | |
| 4180 } | |
| 4181 } | |
| 4182 | |
| 4183 #ifdef XML_DTD | |
| 4184 | |
| 4185 static enum XML_Error | |
| 4186 processInternalParamEntity(XML_Parser parser, ENTITY *entity) | |
| 4187 { | |
| 4188 const char *s, *end, *next; | |
| 4189 int tok; | |
| 4190 enum XML_Error result; | |
| 4191 OPEN_INTERNAL_ENTITY openEntity; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4192 entity->open = XML_TRUE; |
| 21930 | 4193 openEntity.next = openInternalEntities; |
| 4194 openInternalEntities = &openEntity; | |
| 4195 openEntity.entity = entity; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4196 openEntity.internalEventPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4197 openEntity.internalEventEndPtr = NULL; |
| 21930 | 4198 s = (char *)entity->textPtr; |
| 4199 end = (char *)(entity->textPtr + entity->textLen); | |
| 4200 tok = XmlPrologTok(internalEncoding, s, end, &next); | |
| 4201 result = doProlog(parser, internalEncoding, s, end, tok, next, 0); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4202 entity->open = XML_FALSE; |
| 21930 | 4203 openInternalEntities = openEntity.next; |
| 4204 return result; | |
| 4205 } | |
| 4206 | |
| 4207 #endif /* XML_DTD */ | |
| 4208 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4209 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4210 errorProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4211 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4212 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4213 const char **nextPtr) |
| 21930 | 4214 { |
| 4215 return errorCode; | |
| 4216 } | |
| 4217 | |
| 4218 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4219 storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4220 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4221 STRING_POOL *pool) |
| 21930 | 4222 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4223 enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4224 end, pool); |
| 21930 | 4225 if (result) |
| 4226 return result; | |
| 4227 if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) | |
| 4228 poolChop(pool); | |
| 4229 if (!poolAppendChar(pool, XML_T('\0'))) | |
| 4230 return XML_ERROR_NO_MEMORY; | |
| 4231 return XML_ERROR_NONE; | |
| 4232 } | |
| 4233 | |
| 4234 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4235 appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4236 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4237 STRING_POOL *pool) |
| 21930 | 4238 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4239 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4240 for (;;) { |
| 4241 const char *next; | |
| 4242 int tok = XmlAttributeValueTok(enc, ptr, end, &next); | |
| 4243 switch (tok) { | |
| 4244 case XML_TOK_NONE: | |
| 4245 return XML_ERROR_NONE; | |
| 4246 case XML_TOK_INVALID: | |
| 4247 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4248 eventPtr = next; |
| 21930 | 4249 return XML_ERROR_INVALID_TOKEN; |
| 4250 case XML_TOK_PARTIAL: | |
| 4251 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4252 eventPtr = ptr; |
| 21930 | 4253 return XML_ERROR_INVALID_TOKEN; |
| 4254 case XML_TOK_CHAR_REF: | |
| 4255 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4256 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4257 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4258 int n = XmlCharRefNumber(enc, ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4259 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4260 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4261 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4262 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4263 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4264 if (!isCdata |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4265 && n == 0x20 /* space */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4266 && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4267 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4268 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4269 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4270 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4271 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4272 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4273 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4274 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4275 if (!poolAppendChar(pool, buf[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4276 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4277 } |
| 21930 | 4278 } |
| 4279 break; | |
| 4280 case XML_TOK_DATA_CHARS: | |
| 4281 if (!poolAppend(pool, enc, ptr, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4282 return XML_ERROR_NO_MEMORY; |
| 21930 | 4283 break; |
| 4284 case XML_TOK_TRAILING_CR: | |
| 4285 next = ptr + enc->minBytesPerChar; | |
| 4286 /* fall through */ | |
| 4287 case XML_TOK_ATTRIBUTE_VALUE_S: | |
| 4288 case XML_TOK_DATA_NEWLINE: | |
| 4289 if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4290 break; |
| 21930 | 4291 if (!poolAppendChar(pool, 0x20)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4292 return XML_ERROR_NO_MEMORY; |
| 21930 | 4293 break; |
| 4294 case XML_TOK_ENTITY_REF: | |
| 4295 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4296 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4297 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4298 char checkEntityDecl; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4299 XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4300 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4301 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4302 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4303 if (!poolAppendChar(pool, ch)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4304 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4305 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4306 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4307 name = poolStoreString(&temp2Pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4308 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4309 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4310 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4311 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4312 entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4313 poolDiscard(&temp2Pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4314 /* first, determine if a check for an existing declaration is needed; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4315 if yes, check that the entity exists, and that it is internal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4316 otherwise call the default handler (if called from content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4317 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4318 if (pool == &dtd->pool) /* are we called from prolog? */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4319 checkEntityDecl = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4320 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4321 prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4322 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4323 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4324 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4325 : !dtd->hasParamEntityRefs); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4326 else /* if (pool == &tempPool): we are called from content */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4327 checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4328 if (checkEntityDecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4329 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4330 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4331 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4332 return XML_ERROR_ENTITY_DECLARED_IN_PE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4333 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4334 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4335 /* cannot report skipped entity here - see comments on |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4336 skippedEntityHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4337 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4338 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4339 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4340 if ((pool == &tempPool) && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4341 reportDefault(parser, enc, ptr, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4342 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4343 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4344 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4345 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4346 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4347 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4348 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4349 if (entity->notation) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4350 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4351 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4352 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4353 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4354 if (!entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4355 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4356 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4357 return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4358 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4359 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4360 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4361 const XML_Char *textEnd = entity->textPtr + entity->textLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4362 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4363 result = appendAttributeValue(parser, internalEncoding, isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4364 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4365 (char *)textEnd, pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4366 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4367 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4368 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4369 } |
| 21930 | 4370 } |
| 4371 break; | |
| 4372 default: | |
| 4373 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4374 eventPtr = ptr; |
| 21930 | 4375 return XML_ERROR_UNEXPECTED_STATE; |
| 4376 } | |
| 4377 ptr = next; | |
| 4378 } | |
| 4379 /* not reached */ | |
| 4380 } | |
| 4381 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4382 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4383 storeEntityValue(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4384 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4385 const char *entityTextPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4386 const char *entityTextEnd) |
| 21930 | 4387 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4388 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4389 STRING_POOL *pool = &(dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4390 enum XML_Error result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4391 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4392 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4393 prologState.inEntityValue = 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4394 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4395 /* never return Null for the value argument in EntityDeclHandler, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4396 since this would indicate an external entity; therefore we |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4397 have to make sure that entityValuePool.start is not null */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4398 if (!pool->blocks) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4399 if (!poolGrow(pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4400 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4401 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4402 |
| 21930 | 4403 for (;;) { |
| 4404 const char *next; | |
| 4405 int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); | |
| 4406 switch (tok) { | |
| 4407 case XML_TOK_PARAM_ENTITY_REF: | |
| 4408 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4409 if (isParamEntity || enc != encoding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4410 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4411 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4412 name = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4413 entityTextPtr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4414 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4415 if (!name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4416 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4417 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4418 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4419 entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4420 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4421 if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4422 /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4423 /* cannot report skipped entity here - see comments on |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4424 skippedEntityHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4425 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4426 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4427 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4428 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4429 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4430 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4431 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4432 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4433 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4434 result = XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4435 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4436 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4437 if (entity->systemId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4438 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4439 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4440 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4441 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4442 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4443 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4444 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4445 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4446 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4447 result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4448 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4449 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4450 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4451 if (!dtd->paramEntityRead) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4452 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4453 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4454 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4455 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4456 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4457 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4458 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4459 result = storeEntityValue(parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4460 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4461 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4462 (char *)(entity->textPtr |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4463 + entity->textLen)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4464 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4465 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4466 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4467 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4468 break; |
| 21930 | 4469 } |
| 4470 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4471 /* in the internal subset, PE references are not legal |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4472 within markup declarations, e.g entity values in this case */ |
| 21930 | 4473 eventPtr = entityTextPtr; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4474 result = XML_ERROR_PARAM_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4475 goto endEntityValue; |
| 21930 | 4476 case XML_TOK_NONE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4477 result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4478 goto endEntityValue; |
| 21930 | 4479 case XML_TOK_ENTITY_REF: |
| 4480 case XML_TOK_DATA_CHARS: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4481 if (!poolAppend(pool, enc, entityTextPtr, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4482 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4483 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4484 } |
| 21930 | 4485 break; |
| 4486 case XML_TOK_TRAILING_CR: | |
| 4487 next = entityTextPtr + enc->minBytesPerChar; | |
| 4488 /* fall through */ | |
| 4489 case XML_TOK_DATA_NEWLINE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4490 if (pool->end == pool->ptr && !poolGrow(pool)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4491 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4492 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4493 } |
| 21930 | 4494 *(pool->ptr)++ = 0xA; |
| 4495 break; | |
| 4496 case XML_TOK_CHAR_REF: | |
| 4497 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4498 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4499 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4500 int n = XmlCharRefNumber(enc, entityTextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4501 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4502 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4503 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4504 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4505 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4506 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4507 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4508 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4509 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4510 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4511 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4512 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4513 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4514 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4515 if (pool->end == pool->ptr && !poolGrow(pool)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4516 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4517 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4518 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4519 *(pool->ptr)++ = buf[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4520 } |
| 21930 | 4521 } |
| 4522 break; | |
| 4523 case XML_TOK_PARTIAL: | |
| 4524 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4525 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4526 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4527 goto endEntityValue; |
| 21930 | 4528 case XML_TOK_INVALID: |
| 4529 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4530 eventPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4531 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4532 goto endEntityValue; |
| 21930 | 4533 default: |
| 4534 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4535 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4536 result = XML_ERROR_UNEXPECTED_STATE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4537 goto endEntityValue; |
| 21930 | 4538 } |
| 4539 entityTextPtr = next; | |
| 4540 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4541 endEntityValue: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4542 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4543 prologState.inEntityValue = oldInEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4544 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4545 return result; |
| 21930 | 4546 } |
| 4547 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4548 static void FASTCALL |
| 21930 | 4549 normalizeLines(XML_Char *s) |
| 4550 { | |
| 4551 XML_Char *p; | |
| 4552 for (;; s++) { | |
| 4553 if (*s == XML_T('\0')) | |
| 4554 return; | |
| 4555 if (*s == 0xD) | |
| 4556 break; | |
| 4557 } | |
| 4558 p = s; | |
| 4559 do { | |
| 4560 if (*s == 0xD) { | |
| 4561 *p++ = 0xA; | |
| 4562 if (*++s == 0xA) | |
| 4563 s++; | |
| 4564 } | |
| 4565 else | |
| 4566 *p++ = *s++; | |
| 4567 } while (*s); | |
| 4568 *p = XML_T('\0'); | |
| 4569 } | |
| 4570 | |
| 4571 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4572 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4573 const char *start, const char *end) |
| 21930 | 4574 { |
| 4575 const XML_Char *target; | |
| 4576 XML_Char *data; | |
| 4577 const char *tem; | |
| 4578 if (!processingInstructionHandler) { | |
| 4579 if (defaultHandler) | |
| 4580 reportDefault(parser, enc, start, end); | |
| 4581 return 1; | |
| 4582 } | |
| 4583 start += enc->minBytesPerChar * 2; | |
| 4584 tem = start + XmlNameLength(enc, start); | |
| 4585 target = poolStoreString(&tempPool, enc, start, tem); | |
| 4586 if (!target) | |
| 4587 return 0; | |
| 4588 poolFinish(&tempPool); | |
| 4589 data = poolStoreString(&tempPool, enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4590 XmlSkipS(enc, tem), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4591 end - enc->minBytesPerChar*2); |
| 21930 | 4592 if (!data) |
| 4593 return 0; | |
| 4594 normalizeLines(data); | |
| 4595 processingInstructionHandler(handlerArg, target, data); | |
| 4596 poolClear(&tempPool); | |
| 4597 return 1; | |
| 4598 } | |
| 4599 | |
| 4600 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4601 reportComment(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4602 const char *start, const char *end) |
| 21930 | 4603 { |
| 4604 XML_Char *data; | |
| 4605 if (!commentHandler) { | |
| 4606 if (defaultHandler) | |
| 4607 reportDefault(parser, enc, start, end); | |
| 4608 return 1; | |
| 4609 } | |
| 4610 data = poolStoreString(&tempPool, | |
| 4611 enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4612 start + enc->minBytesPerChar * 4, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4613 end - enc->minBytesPerChar * 3); |
| 21930 | 4614 if (!data) |
| 4615 return 0; | |
| 4616 normalizeLines(data); | |
| 4617 commentHandler(handlerArg, data); | |
| 4618 poolClear(&tempPool); | |
| 4619 return 1; | |
| 4620 } | |
| 4621 | |
| 4622 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4623 reportDefault(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4624 const char *s, const char *end) |
| 21930 | 4625 { |
| 4626 if (MUST_CONVERT(enc, s)) { | |
| 4627 const char **eventPP; | |
| 4628 const char **eventEndPP; | |
| 4629 if (enc == encoding) { | |
| 4630 eventPP = &eventPtr; | |
| 4631 eventEndPP = &eventEndPtr; | |
| 4632 } | |
| 4633 else { | |
| 4634 eventPP = &(openInternalEntities->internalEventPtr); | |
| 4635 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 4636 } | |
| 4637 do { | |
| 4638 ICHAR *dataPtr = (ICHAR *)dataBuf; | |
| 4639 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | |
| 4640 *eventEndPP = s; | |
| 4641 defaultHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf); | |
| 4642 *eventPP = s; | |
| 4643 } while (s != end); | |
| 4644 } | |
| 4645 else | |
| 4646 defaultHandler(handlerArg, (XML_Char *)s, (XML_Char *)end - (XML_Char *)s); | |
| 4647 } | |
| 4648 | |
| 4649 | |
| 4650 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4651 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4652 XML_Bool isId, const XML_Char *value, XML_Parser parser) |
| 21930 | 4653 { |
| 4654 DEFAULT_ATTRIBUTE *att; | |
| 4655 if (value || isId) { | |
| 4656 /* The handling of default attributes gets messed up if we have | |
| 4657 a default which duplicates a non-default. */ | |
| 4658 int i; | |
| 4659 for (i = 0; i < type->nDefaultAtts; i++) | |
| 4660 if (attId == type->defaultAtts[i].id) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4661 return 1; |
| 21930 | 4662 if (isId && !type->idAtt && !attId->xmlns) |
| 4663 type->idAtt = attId; | |
| 4664 } | |
| 4665 if (type->nDefaultAtts == type->allocDefaultAtts) { | |
| 4666 if (type->allocDefaultAtts == 0) { | |
| 4667 type->allocDefaultAtts = 8; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4668 type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4669 * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4670 if (!type->defaultAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4671 return 0; |
| 21930 | 4672 } |
| 4673 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4674 DEFAULT_ATTRIBUTE *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4675 int count = type->allocDefaultAtts * 2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4676 temp = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4677 REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4678 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4679 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4680 type->allocDefaultAtts = count; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4681 type->defaultAtts = temp; |
| 21930 | 4682 } |
| 4683 } | |
| 4684 att = type->defaultAtts + type->nDefaultAtts; | |
| 4685 att->id = attId; | |
| 4686 att->value = value; | |
| 4687 att->isCdata = isCdata; | |
| 4688 if (!isCdata) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4689 attId->maybeTokenized = XML_TRUE; |
| 21930 | 4690 type->nDefaultAtts += 1; |
| 4691 return 1; | |
| 4692 } | |
| 4693 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4694 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4695 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) |
| 21930 | 4696 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4697 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4698 const XML_Char *name; |
| 4699 for (name = elementType->name; *name; name++) { | |
| 4700 if (*name == XML_T(':')) { | |
| 4701 PREFIX *prefix; | |
| 4702 const XML_Char *s; | |
| 4703 for (s = elementType->name; s != name; s++) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4704 if (!poolAppendChar(&dtd->pool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4705 return 0; |
| 21930 | 4706 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4707 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4708 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4709 prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4710 sizeof(PREFIX)); |
| 21930 | 4711 if (!prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4712 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4713 if (prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4714 poolFinish(&dtd->pool); |
| 21930 | 4715 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4716 poolDiscard(&dtd->pool); |
| 21930 | 4717 elementType->prefix = prefix; |
| 4718 | |
| 4719 } | |
| 4720 } | |
| 4721 return 1; | |
| 4722 } | |
| 4723 | |
| 4724 static ATTRIBUTE_ID * | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4725 getAttributeId(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4726 const char *start, const char *end) |
| 21930 | 4727 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4728 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4729 ATTRIBUTE_ID *id; |
| 4730 const XML_Char *name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4731 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4732 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4733 name = poolStoreString(&dtd->pool, enc, start, end); |
| 21930 | 4734 if (!name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4735 return NULL; |
| 21930 | 4736 ++name; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4737 id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); |
| 21930 | 4738 if (!id) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4739 return NULL; |
| 21930 | 4740 if (id->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4741 poolDiscard(&dtd->pool); |
| 21930 | 4742 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4743 poolFinish(&dtd->pool); |
| 21930 | 4744 if (!ns) |
| 4745 ; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4746 else if (name[0] == XML_T('x') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4747 && name[1] == XML_T('m') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4748 && name[2] == XML_T('l') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4749 && name[3] == XML_T('n') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4750 && name[4] == XML_T('s') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4751 && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4752 if (name[5] == XML_T('\0')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4753 id->prefix = &dtd->defaultPrefix; |
| 21930 | 4754 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4755 id->prefix = (PREFIX *)lookup(&dtd->prefixes, name + 6, sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4756 id->xmlns = XML_TRUE; |
| 21930 | 4757 } |
| 4758 else { | |
| 4759 int i; | |
| 4760 for (i = 0; name[i]; i++) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4761 if (name[i] == XML_T(':')) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4762 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4763 for (j = 0; j < i; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4764 if (!poolAppendChar(&dtd->pool, name[j])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4765 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4766 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4767 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4768 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4769 id->prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4770 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4771 if (id->prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4772 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4773 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4774 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4775 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4776 } |
| 21930 | 4777 } |
| 4778 } | |
| 4779 } | |
| 4780 return id; | |
| 4781 } | |
| 4782 | |
| 4783 #define CONTEXT_SEP XML_T('\f') | |
| 4784 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4785 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4786 getContext(XML_Parser parser) |
| 21930 | 4787 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4788 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4789 HASH_TABLE_ITER iter; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4790 XML_Bool needSep = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4791 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4792 if (dtd->defaultPrefix.binding) { |
| 21930 | 4793 int i; |
| 4794 int len; | |
| 4795 if (!poolAppendChar(&tempPool, XML_T('='))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4796 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4797 len = dtd->defaultPrefix.binding->uriLen; |
| 21930 | 4798 if (namespaceSeparator != XML_T('\0')) |
| 4799 len--; | |
| 4800 for (i = 0; i < len; i++) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4801 if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4802 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4803 needSep = XML_TRUE; |
| 21930 | 4804 } |
| 4805 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4806 hashTableIterInit(&iter, &(dtd->prefixes)); |
| 21930 | 4807 for (;;) { |
| 4808 int i; | |
| 4809 int len; | |
| 4810 const XML_Char *s; | |
| 4811 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); | |
| 4812 if (!prefix) | |
| 4813 break; | |
| 4814 if (!prefix->binding) | |
| 4815 continue; | |
| 4816 if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4817 return NULL; |
| 21930 | 4818 for (s = prefix->name; *s; s++) |
| 4819 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4820 return NULL; |
| 21930 | 4821 if (!poolAppendChar(&tempPool, XML_T('='))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4822 return NULL; |
| 21930 | 4823 len = prefix->binding->uriLen; |
| 4824 if (namespaceSeparator != XML_T('\0')) | |
| 4825 len--; | |
| 4826 for (i = 0; i < len; i++) | |
| 4827 if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4828 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4829 needSep = XML_TRUE; |
| 21930 | 4830 } |
| 4831 | |
| 4832 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4833 hashTableIterInit(&iter, &(dtd->generalEntities)); |
| 21930 | 4834 for (;;) { |
| 4835 const XML_Char *s; | |
| 4836 ENTITY *e = (ENTITY *)hashTableIterNext(&iter); | |
| 4837 if (!e) | |
| 4838 break; | |
| 4839 if (!e->open) | |
| 4840 continue; | |
| 4841 if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4842 return NULL; |
| 21930 | 4843 for (s = e->name; *s; s++) |
| 4844 if (!poolAppendChar(&tempPool, *s)) | |
| 4845 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4846 needSep = XML_TRUE; |
| 21930 | 4847 } |
| 4848 | |
| 4849 if (!poolAppendChar(&tempPool, XML_T('\0'))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4850 return NULL; |
| 21930 | 4851 return tempPool.start; |
| 4852 } | |
| 4853 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4854 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4855 setContext(XML_Parser parser, const XML_Char *context) |
| 21930 | 4856 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4857 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4858 const XML_Char *s = context; |
| 4859 | |
| 4860 while (*context != XML_T('\0')) { | |
| 4861 if (*s == CONTEXT_SEP || *s == XML_T('\0')) { | |
| 4862 ENTITY *e; | |
| 4863 if (!poolAppendChar(&tempPool, XML_T('\0'))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4864 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4865 e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); |
| 21930 | 4866 if (e) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4867 e->open = XML_TRUE; |
| 21930 | 4868 if (*s != XML_T('\0')) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4869 s++; |
| 21930 | 4870 context = s; |
| 4871 poolDiscard(&tempPool); | |
| 4872 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4873 else if (*s == XML_T('=')) { |
| 21930 | 4874 PREFIX *prefix; |
| 4875 if (poolLength(&tempPool) == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4876 prefix = &dtd->defaultPrefix; |
| 21930 | 4877 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4878 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4879 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4880 prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&tempPool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4881 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4882 if (!prefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4883 return XML_FALSE; |
| 21930 | 4884 if (prefix->name == poolStart(&tempPool)) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4885 prefix->name = poolCopyString(&dtd->pool, prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4886 if (!prefix->name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4887 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4888 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4889 poolDiscard(&tempPool); |
| 21930 | 4890 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4891 for (context = s + 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4892 *context != CONTEXT_SEP && *context != XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4893 context++) |
| 21930 | 4894 if (!poolAppendChar(&tempPool, *context)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4895 return XML_FALSE; |
| 21930 | 4896 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4897 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4898 if (addBinding(parser, prefix, 0, poolStart(&tempPool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4899 &inheritedBindings) != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4900 return XML_FALSE; |
| 21930 | 4901 poolDiscard(&tempPool); |
| 4902 if (*context != XML_T('\0')) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4903 ++context; |
| 21930 | 4904 s = context; |
| 4905 } | |
| 4906 else { | |
| 4907 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4908 return XML_FALSE; |
| 21930 | 4909 s++; |
| 4910 } | |
| 4911 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4912 return XML_TRUE; |
| 21930 | 4913 } |
| 4914 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4915 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4916 normalizePublicId(XML_Char *publicId) |
| 21930 | 4917 { |
| 4918 XML_Char *p = publicId; | |
| 4919 XML_Char *s; | |
| 4920 for (s = publicId; *s; s++) { | |
| 4921 switch (*s) { | |
| 4922 case 0x20: | |
| 4923 case 0xD: | |
| 4924 case 0xA: | |
| 4925 if (p != publicId && p[-1] != 0x20) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4926 *p++ = 0x20; |
| 21930 | 4927 break; |
| 4928 default: | |
| 4929 *p++ = *s; | |
| 4930 } | |
| 4931 } | |
| 4932 if (p != publicId && p[-1] == 0x20) | |
| 4933 --p; | |
| 4934 *p = XML_T('\0'); | |
| 4935 } | |
| 4936 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4937 static DTD * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4938 dtdCreate(const XML_Memory_Handling_Suite *ms) |
| 21930 | 4939 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4940 DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4941 if (p == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4942 return p; |
| 21930 | 4943 poolInit(&(p->pool), ms); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4944 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4945 poolInit(&(p->entityValuePool), ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4946 #endif /* XML_DTD */ |
| 21930 | 4947 hashTableInit(&(p->generalEntities), ms); |
| 4948 hashTableInit(&(p->elementTypes), ms); | |
| 4949 hashTableInit(&(p->attributeIds), ms); | |
| 4950 hashTableInit(&(p->prefixes), ms); | |
| 4951 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4952 p->paramEntityRead = XML_FALSE; |
| 21930 | 4953 hashTableInit(&(p->paramEntities), ms); |
| 4954 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4955 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4956 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4957 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4958 p->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4959 p->scaffIndex = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4960 p->scaffold = NULL; |
| 21930 | 4961 p->scaffLevel = 0; |
| 4962 p->scaffSize = 0; | |
| 4963 p->scaffCount = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4964 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4965 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4966 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4967 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4968 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4969 return p; |
| 21930 | 4970 } |
| 4971 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4972 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4973 dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 4974 { |
| 4975 HASH_TABLE_ITER iter; | |
| 4976 hashTableIterInit(&iter, &(p->elementTypes)); | |
| 4977 for (;;) { | |
| 4978 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 4979 if (!e) | |
| 4980 break; | |
| 4981 if (e->allocDefaultAtts != 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4982 ms->free_fcn(e->defaultAtts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4983 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4984 hashTableClear(&(p->generalEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4985 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4986 p->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4987 hashTableClear(&(p->paramEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4988 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4989 hashTableClear(&(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4990 hashTableClear(&(p->attributeIds)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4991 hashTableClear(&(p->prefixes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4992 poolClear(&(p->pool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4993 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4994 poolClear(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4995 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4996 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4997 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4998 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4999 p->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5000 if (p->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5001 ms->free_fcn(p->scaffIndex); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5002 p->scaffIndex = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5003 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5004 if (p->scaffold) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5005 ms->free_fcn(p->scaffold); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5006 p->scaffold = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5007 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5008 p->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5009 p->scaffSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5010 p->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5011 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5012 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5013 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5014 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5015 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5016 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5017 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5018 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5019 dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5020 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5021 HASH_TABLE_ITER iter; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5022 hashTableIterInit(&iter, &(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5023 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5024 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5025 if (!e) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5026 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5027 if (e->allocDefaultAtts != 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5028 ms->free_fcn(e->defaultAtts); |
| 21930 | 5029 } |
| 5030 hashTableDestroy(&(p->generalEntities)); | |
| 5031 #ifdef XML_DTD | |
| 5032 hashTableDestroy(&(p->paramEntities)); | |
| 5033 #endif /* XML_DTD */ | |
| 5034 hashTableDestroy(&(p->elementTypes)); | |
| 5035 hashTableDestroy(&(p->attributeIds)); | |
| 5036 hashTableDestroy(&(p->prefixes)); | |
| 5037 poolDestroy(&(p->pool)); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5038 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5039 poolDestroy(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5040 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5041 if (isDocEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5042 if (p->scaffIndex) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5043 ms->free_fcn(p->scaffIndex); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5044 if (p->scaffold) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5045 ms->free_fcn(p->scaffold); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5046 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5047 ms->free_fcn(p); |
| 21930 | 5048 } |
| 5049 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5050 /* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5051 The new DTD has already been initialized. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5052 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5053 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5054 dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5055 { |
| 5056 HASH_TABLE_ITER iter; | |
| 5057 | |
| 5058 /* Copy the prefix table. */ | |
| 5059 | |
| 5060 hashTableIterInit(&iter, &(oldDtd->prefixes)); | |
| 5061 for (;;) { | |
| 5062 const XML_Char *name; | |
| 5063 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); | |
| 5064 if (!oldP) | |
| 5065 break; | |
| 5066 name = poolCopyString(&(newDtd->pool), oldP->name); | |
| 5067 if (!name) | |
| 5068 return 0; | |
| 5069 if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) | |
| 5070 return 0; | |
| 5071 } | |
| 5072 | |
| 5073 hashTableIterInit(&iter, &(oldDtd->attributeIds)); | |
| 5074 | |
| 5075 /* Copy the attribute id table. */ | |
| 5076 | |
| 5077 for (;;) { | |
| 5078 ATTRIBUTE_ID *newA; | |
| 5079 const XML_Char *name; | |
| 5080 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); | |
| 5081 | |
| 5082 if (!oldA) | |
| 5083 break; | |
| 5084 /* Remember to allocate the scratch byte before the name. */ | |
| 5085 if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) | |
| 5086 return 0; | |
| 5087 name = poolCopyString(&(newDtd->pool), oldA->name); | |
| 5088 if (!name) | |
| 5089 return 0; | |
| 5090 ++name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5091 newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5092 sizeof(ATTRIBUTE_ID)); |
| 21930 | 5093 if (!newA) |
| 5094 return 0; | |
| 5095 newA->maybeTokenized = oldA->maybeTokenized; | |
| 5096 if (oldA->prefix) { | |
| 5097 newA->xmlns = oldA->xmlns; | |
| 5098 if (oldA->prefix == &oldDtd->defaultPrefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5099 newA->prefix = &newDtd->defaultPrefix; |
| 21930 | 5100 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5101 newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5102 oldA->prefix->name, 0); |
| 21930 | 5103 } |
| 5104 } | |
| 5105 | |
| 5106 /* Copy the element type table. */ | |
| 5107 | |
| 5108 hashTableIterInit(&iter, &(oldDtd->elementTypes)); | |
| 5109 | |
| 5110 for (;;) { | |
| 5111 int i; | |
| 5112 ELEMENT_TYPE *newE; | |
| 5113 const XML_Char *name; | |
| 5114 const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5115 if (!oldE) | |
| 5116 break; | |
| 5117 name = poolCopyString(&(newDtd->pool), oldE->name); | |
| 5118 if (!name) | |
| 5119 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5120 newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5121 sizeof(ELEMENT_TYPE)); |
| 21930 | 5122 if (!newE) |
| 5123 return 0; | |
| 5124 if (oldE->nDefaultAtts) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5125 newE->defaultAtts = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5126 ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5127 if (!newE->defaultAtts) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5128 ms->free_fcn(newE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5129 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5130 } |
| 21930 | 5131 } |
| 5132 if (oldE->idAtt) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5133 newE->idAtt = (ATTRIBUTE_ID *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5134 lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); |
| 21930 | 5135 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; |
| 5136 if (oldE->prefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5137 newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5138 oldE->prefix->name, 0); |
| 21930 | 5139 for (i = 0; i < newE->nDefaultAtts; i++) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5140 newE->defaultAtts[i].id = (ATTRIBUTE_ID *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5141 lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); |
| 21930 | 5142 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; |
| 5143 if (oldE->defaultAtts[i].value) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5144 newE->defaultAtts[i].value |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5145 = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5146 if (!newE->defaultAtts[i].value) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5147 return 0; |
| 21930 | 5148 } |
| 5149 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5150 newE->defaultAtts[i].value = NULL; |
| 21930 | 5151 } |
| 5152 } | |
| 5153 | |
| 5154 /* Copy the entity tables. */ | |
| 5155 if (!copyEntityTable(&(newDtd->generalEntities), | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5156 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5157 &(oldDtd->generalEntities))) |
| 21930 | 5158 return 0; |
| 5159 | |
| 5160 #ifdef XML_DTD | |
| 5161 if (!copyEntityTable(&(newDtd->paramEntities), | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5162 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5163 &(oldDtd->paramEntities))) |
| 21930 | 5164 return 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5165 newDtd->paramEntityRead = oldDtd->paramEntityRead; |
| 21930 | 5166 #endif /* XML_DTD */ |
| 5167 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5168 newDtd->keepProcessing = oldDtd->keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5169 newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; |
| 21930 | 5170 newDtd->standalone = oldDtd->standalone; |
| 5171 | |
| 5172 /* Don't want deep copying for scaffolding */ | |
| 5173 newDtd->in_eldecl = oldDtd->in_eldecl; | |
| 5174 newDtd->scaffold = oldDtd->scaffold; | |
| 5175 newDtd->contentStringLen = oldDtd->contentStringLen; | |
| 5176 newDtd->scaffSize = oldDtd->scaffSize; | |
| 5177 newDtd->scaffLevel = oldDtd->scaffLevel; | |
| 5178 newDtd->scaffIndex = oldDtd->scaffIndex; | |
| 5179 | |
| 5180 return 1; | |
| 5181 } /* End dtdCopy */ | |
| 5182 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5183 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5184 copyEntityTable(HASH_TABLE *newTable, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5185 STRING_POOL *newPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5186 const HASH_TABLE *oldTable) |
| 21930 | 5187 { |
| 5188 HASH_TABLE_ITER iter; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5189 const XML_Char *cachedOldBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5190 const XML_Char *cachedNewBase = NULL; |
| 21930 | 5191 |
| 5192 hashTableIterInit(&iter, oldTable); | |
| 5193 | |
| 5194 for (;;) { | |
| 5195 ENTITY *newE; | |
| 5196 const XML_Char *name; | |
| 5197 const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); | |
| 5198 if (!oldE) | |
| 5199 break; | |
| 5200 name = poolCopyString(newPool, oldE->name); | |
| 5201 if (!name) | |
| 5202 return 0; | |
| 5203 newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); | |
| 5204 if (!newE) | |
| 5205 return 0; | |
| 5206 if (oldE->systemId) { | |
| 5207 const XML_Char *tem = poolCopyString(newPool, oldE->systemId); | |
| 5208 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5209 return 0; |
| 21930 | 5210 newE->systemId = tem; |
| 5211 if (oldE->base) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5212 if (oldE->base == cachedOldBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5213 newE->base = cachedNewBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5214 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5215 cachedOldBase = oldE->base; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5216 tem = poolCopyString(newPool, cachedOldBase); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5217 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5218 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5219 cachedNewBase = newE->base = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5220 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5221 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5222 if (oldE->publicId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5223 tem = poolCopyString(newPool, oldE->publicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5224 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5225 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5226 newE->publicId = tem; |
| 21930 | 5227 } |
| 5228 } | |
| 5229 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5230 const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5231 oldE->textLen); |
| 21930 | 5232 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5233 return 0; |
| 21930 | 5234 newE->textPtr = tem; |
| 5235 newE->textLen = oldE->textLen; | |
| 5236 } | |
| 5237 if (oldE->notation) { | |
| 5238 const XML_Char *tem = poolCopyString(newPool, oldE->notation); | |
| 5239 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5240 return 0; |
| 21930 | 5241 newE->notation = tem; |
| 5242 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5243 newE->is_param = oldE->is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5244 newE->is_internal = oldE->is_internal; |
| 21930 | 5245 } |
| 5246 return 1; | |
| 5247 } | |
| 5248 | |
| 5249 #define INIT_SIZE 64 | |
| 5250 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5251 static int FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5252 keyeq(KEY s1, KEY s2) |
| 21930 | 5253 { |
| 5254 for (; *s1 == *s2; s1++, s2++) | |
| 5255 if (*s1 == 0) | |
| 5256 return 1; | |
| 5257 return 0; | |
| 5258 } | |
| 5259 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5260 static unsigned long FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5261 hash(KEY s) |
| 21930 | 5262 { |
| 5263 unsigned long h = 0; | |
| 5264 while (*s) | |
| 5265 h = (h << 5) + h + (unsigned char)*s++; | |
| 5266 return h; | |
| 5267 } | |
| 5268 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5269 static NAMED * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5270 lookup(HASH_TABLE *table, KEY name, size_t createSize) |
| 21930 | 5271 { |
| 5272 size_t i; | |
| 5273 if (table->size == 0) { | |
| 5274 size_t tsize; | |
| 5275 | |
| 5276 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5277 return NULL; |
| 21930 | 5278 tsize = INIT_SIZE * sizeof(NAMED *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5279 table->v = (NAMED **)table->mem->malloc_fcn(tsize); |
| 21930 | 5280 if (!table->v) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5281 return NULL; |
| 21930 | 5282 memset(table->v, 0, tsize); |
| 5283 table->size = INIT_SIZE; | |
| 5284 table->usedLim = INIT_SIZE / 2; | |
| 5285 i = hash(name) & (table->size - 1); | |
| 5286 } | |
| 5287 else { | |
| 5288 unsigned long h = hash(name); | |
| 5289 for (i = h & (table->size - 1); | |
| 5290 table->v[i]; | |
| 5291 i == 0 ? i = table->size - 1 : --i) { | |
| 5292 if (keyeq(name, table->v[i]->name)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5293 return table->v[i]; |
| 21930 | 5294 } |
| 5295 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5296 return NULL; |
| 21930 | 5297 if (table->used == table->usedLim) { |
| 5298 /* check for overflow */ | |
| 5299 size_t newSize = table->size * 2; | |
| 5300 size_t tsize = newSize * sizeof(NAMED *); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5301 NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); |
| 21930 | 5302 if (!newV) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5303 return NULL; |
| 21930 | 5304 memset(newV, 0, tsize); |
| 5305 for (i = 0; i < table->size; i++) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5306 if (table->v[i]) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5307 size_t j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5308 for (j = hash(table->v[i]->name) & (newSize - 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5309 newV[j]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5310 j == 0 ? j = newSize - 1 : --j) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5311 ; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5312 newV[j] = table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5313 } |
| 21930 | 5314 table->mem->free_fcn(table->v); |
| 5315 table->v = newV; | |
| 5316 table->size = newSize; | |
| 5317 table->usedLim = newSize/2; | |
| 5318 for (i = h & (table->size - 1); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5319 table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5320 i == 0 ? i = table->size - 1 : --i) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5321 ; |
| 21930 | 5322 } |
| 5323 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5324 table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); |
| 21930 | 5325 if (!table->v[i]) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5326 return NULL; |
| 21930 | 5327 memset(table->v[i], 0, createSize); |
| 5328 table->v[i]->name = name; | |
| 5329 (table->used)++; | |
| 5330 return table->v[i]; | |
| 5331 } | |
| 5332 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5333 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5334 hashTableClear(HASH_TABLE *table) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5335 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5336 size_t i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5337 for (i = 0; i < table->size; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5338 NAMED *p = table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5339 if (p) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5340 table->mem->free_fcn(p); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5341 table->v[i] = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5342 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5343 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5344 table->usedLim = table->size / 2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5345 table->used = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5346 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5347 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5348 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5349 hashTableDestroy(HASH_TABLE *table) |
| 21930 | 5350 { |
| 5351 size_t i; | |
| 5352 for (i = 0; i < table->size; i++) { | |
| 5353 NAMED *p = table->v[i]; | |
| 5354 if (p) | |
| 5355 table->mem->free_fcn(p); | |
| 5356 } | |
| 5357 if (table->v) | |
| 5358 table->mem->free_fcn(table->v); | |
| 5359 } | |
| 5360 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5361 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5362 hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5363 { |
| 5364 p->size = 0; | |
| 5365 p->usedLim = 0; | |
| 5366 p->used = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5367 p->v = NULL; |
| 21930 | 5368 p->mem = ms; |
| 5369 } | |
| 5370 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5371 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5372 hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) |
| 21930 | 5373 { |
| 5374 iter->p = table->v; | |
| 5375 iter->end = iter->p + table->size; | |
| 5376 } | |
| 5377 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5378 static NAMED * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5379 hashTableIterNext(HASH_TABLE_ITER *iter) |
| 21930 | 5380 { |
| 5381 while (iter->p != iter->end) { | |
| 5382 NAMED *tem = *(iter->p)++; | |
| 5383 if (tem) | |
| 5384 return tem; | |
| 5385 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5386 return NULL; |
| 21930 | 5387 } |
| 5388 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5389 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5390 poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5391 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5392 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5393 pool->freeBlocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5394 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5395 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5396 pool->end = NULL; |
| 21930 | 5397 pool->mem = ms; |
| 5398 } | |
| 5399 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5400 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5401 poolClear(STRING_POOL *pool) |
| 21930 | 5402 { |
| 5403 if (!pool->freeBlocks) | |
| 5404 pool->freeBlocks = pool->blocks; | |
| 5405 else { | |
| 5406 BLOCK *p = pool->blocks; | |
| 5407 while (p) { | |
| 5408 BLOCK *tem = p->next; | |
| 5409 p->next = pool->freeBlocks; | |
| 5410 pool->freeBlocks = p; | |
| 5411 p = tem; | |
| 5412 } | |
| 5413 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5414 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5415 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5416 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5417 pool->end = NULL; |
| 21930 | 5418 } |
| 5419 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5420 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5421 poolDestroy(STRING_POOL *pool) |
| 21930 | 5422 { |
| 5423 BLOCK *p = pool->blocks; | |
| 5424 while (p) { | |
| 5425 BLOCK *tem = p->next; | |
| 5426 pool->mem->free_fcn(p); | |
| 5427 p = tem; | |
| 5428 } | |
| 5429 p = pool->freeBlocks; | |
| 5430 while (p) { | |
| 5431 BLOCK *tem = p->next; | |
| 5432 pool->mem->free_fcn(p); | |
| 5433 p = tem; | |
| 5434 } | |
| 5435 } | |
| 5436 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5437 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5438 poolAppend(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5439 const char *ptr, const char *end) |
| 21930 | 5440 { |
| 5441 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5442 return NULL; |
| 21930 | 5443 for (;;) { |
| 5444 XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); | |
| 5445 if (ptr == end) | |
| 5446 break; | |
| 5447 if (!poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5448 return NULL; |
| 21930 | 5449 } |
| 5450 return pool->start; | |
| 5451 } | |
| 5452 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5453 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5454 poolCopyString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 5455 { |
| 5456 do { | |
| 5457 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5458 return NULL; |
| 21930 | 5459 } while (*s++); |
| 5460 s = pool->start; | |
| 5461 poolFinish(pool); | |
| 5462 return s; | |
| 5463 } | |
| 5464 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5465 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5466 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) |
| 21930 | 5467 { |
| 5468 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5469 return NULL; |
| 21930 | 5470 for (; n > 0; --n, s++) { |
| 5471 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5472 return NULL; |
| 21930 | 5473 } |
| 5474 s = pool->start; | |
| 5475 poolFinish(pool); | |
| 5476 return s; | |
| 5477 } | |
| 5478 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5479 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5480 poolAppendString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 5481 { |
| 5482 while (*s) { | |
| 5483 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5484 return NULL; |
| 21930 | 5485 s++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5486 } |
| 21930 | 5487 return pool->start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5488 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5489 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5490 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5491 poolStoreString(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5492 const char *ptr, const char *end) |
| 21930 | 5493 { |
| 5494 if (!poolAppend(pool, enc, ptr, end)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5495 return NULL; |
| 21930 | 5496 if (pool->ptr == pool->end && !poolGrow(pool)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5497 return NULL; |
| 21930 | 5498 *(pool->ptr)++ = 0; |
| 5499 return pool->start; | |
| 5500 } | |
| 5501 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5502 static XML_Bool FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5503 poolGrow(STRING_POOL *pool) |
| 21930 | 5504 { |
| 5505 if (pool->freeBlocks) { | |
| 5506 if (pool->start == 0) { | |
| 5507 pool->blocks = pool->freeBlocks; | |
| 5508 pool->freeBlocks = pool->freeBlocks->next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5509 pool->blocks->next = NULL; |
| 21930 | 5510 pool->start = pool->blocks->s; |
| 5511 pool->end = pool->start + pool->blocks->size; | |
| 5512 pool->ptr = pool->start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5513 return XML_TRUE; |
| 21930 | 5514 } |
| 5515 if (pool->end - pool->start < pool->freeBlocks->size) { | |
| 5516 BLOCK *tem = pool->freeBlocks->next; | |
| 5517 pool->freeBlocks->next = pool->blocks; | |
| 5518 pool->blocks = pool->freeBlocks; | |
| 5519 pool->freeBlocks = tem; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5520 memcpy(pool->blocks->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5521 (pool->end - pool->start) * sizeof(XML_Char)); |
| 21930 | 5522 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); |
| 5523 pool->start = pool->blocks->s; | |
| 5524 pool->end = pool->start + pool->blocks->size; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5525 return XML_TRUE; |
| 21930 | 5526 } |
| 5527 } | |
| 5528 if (pool->blocks && pool->start == pool->blocks->s) { | |
| 5529 int blockSize = (pool->end - pool->start)*2; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5530 pool->blocks = (BLOCK *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5531 pool->mem->realloc_fcn(pool->blocks, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5532 (offsetof(BLOCK, s) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5533 + blockSize * sizeof(XML_Char))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5534 if (pool->blocks == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5535 return XML_FALSE; |
| 21930 | 5536 pool->blocks->size = blockSize; |
| 5537 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); | |
| 5538 pool->start = pool->blocks->s; | |
| 5539 pool->end = pool->start + blockSize; | |
| 5540 } | |
| 5541 else { | |
| 5542 BLOCK *tem; | |
| 5543 int blockSize = pool->end - pool->start; | |
| 5544 if (blockSize < INIT_BLOCK_SIZE) | |
| 5545 blockSize = INIT_BLOCK_SIZE; | |
| 5546 else | |
| 5547 blockSize *= 2; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5548 tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5549 + blockSize * sizeof(XML_Char)); |
| 21930 | 5550 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5551 return XML_FALSE; |
| 21930 | 5552 tem->size = blockSize; |
| 5553 tem->next = pool->blocks; | |
| 5554 pool->blocks = tem; | |
| 5555 if (pool->ptr != pool->start) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5556 memcpy(tem->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5557 (pool->ptr - pool->start) * sizeof(XML_Char)); |
| 21930 | 5558 pool->ptr = tem->s + (pool->ptr - pool->start); |
| 5559 pool->start = tem->s; | |
| 5560 pool->end = tem->s + blockSize; | |
| 5561 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5562 return XML_TRUE; |
| 21930 | 5563 } |
| 5564 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5565 static int FASTCALL |
| 21930 | 5566 nextScaffoldPart(XML_Parser parser) |
| 5567 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5568 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5569 CONTENT_SCAFFOLD * me; |
| 5570 int next; | |
| 5571 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5572 if (!dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5573 dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5574 if (!dtd->scaffIndex) |
| 21930 | 5575 return -1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5576 dtd->scaffIndex[0] = 0; |
| 21930 | 5577 } |
| 5578 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5579 if (dtd->scaffCount >= dtd->scaffSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5580 CONTENT_SCAFFOLD *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5581 if (dtd->scaffold) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5582 temp = (CONTENT_SCAFFOLD *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5583 REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5584 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5585 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5586 dtd->scaffSize *= 2; |
| 21930 | 5587 } |
| 5588 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5589 temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5590 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5591 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5592 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5593 dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; |
| 21930 | 5594 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5595 dtd->scaffold = temp; |
| 21930 | 5596 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5597 next = dtd->scaffCount++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5598 me = &dtd->scaffold[next]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5599 if (dtd->scaffLevel) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5600 CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; |
| 21930 | 5601 if (parent->lastchild) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5602 dtd->scaffold[parent->lastchild].nextsib = next; |
| 21930 | 5603 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5604 if (!parent->childcnt) |
| 21930 | 5605 parent->firstchild = next; |
| 5606 parent->lastchild = next; | |
| 5607 parent->childcnt++; | |
| 5608 } | |
| 5609 me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; | |
| 5610 return next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5611 } |
| 21930 | 5612 |
| 5613 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5614 build_node(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5615 int src_node, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5616 XML_Content *dest, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5617 XML_Content **contpos, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5618 XML_Char **strpos) |
| 21930 | 5619 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5620 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5621 dest->type = dtd->scaffold[src_node].type; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5622 dest->quant = dtd->scaffold[src_node].quant; |
| 21930 | 5623 if (dest->type == XML_CTYPE_NAME) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5624 const XML_Char *src; |
| 21930 | 5625 dest->name = *strpos; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5626 src = dtd->scaffold[src_node].name; |
| 21930 | 5627 for (;;) { |
| 5628 *(*strpos)++ = *src; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5629 if (!*src) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5630 break; |
| 21930 | 5631 src++; |
| 5632 } | |
| 5633 dest->numchildren = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5634 dest->children = NULL; |
| 21930 | 5635 } |
| 5636 else { | |
| 5637 unsigned int i; | |
| 5638 int cn; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5639 dest->numchildren = dtd->scaffold[src_node].childcnt; |
| 21930 | 5640 dest->children = *contpos; |
| 5641 *contpos += dest->numchildren; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5642 for (i = 0, cn = dtd->scaffold[src_node].firstchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5643 i < dest->numchildren; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5644 i++, cn = dtd->scaffold[cn].nextsib) { |
| 21930 | 5645 build_node(parser, cn, &(dest->children[i]), contpos, strpos); |
| 5646 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5647 dest->name = NULL; |
| 21930 | 5648 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5649 } |
| 21930 | 5650 |
| 5651 static XML_Content * | |
| 5652 build_model (XML_Parser parser) | |
| 5653 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5654 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5655 XML_Content *ret; |
| 5656 XML_Content *cpos; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5657 XML_Char * str; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5658 int allocsize = (dtd->scaffCount * sizeof(XML_Content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5659 + (dtd->contentStringLen * sizeof(XML_Char))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5660 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5661 ret = (XML_Content *)MALLOC(allocsize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5662 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5663 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5664 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5665 str = (XML_Char *) (&ret[dtd->scaffCount]); |
| 21930 | 5666 cpos = &ret[1]; |
| 5667 | |
| 5668 build_node(parser, 0, ret, &cpos, &str); | |
| 5669 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5670 } |
| 21930 | 5671 |
| 5672 static ELEMENT_TYPE * | |
| 5673 getElementType(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5674 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5675 const char *ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5676 const char *end) |
| 21930 | 5677 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5678 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5679 const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); |
| 21930 | 5680 ELEMENT_TYPE *ret; |
| 5681 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5682 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5683 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5684 ret = (ELEMENT_TYPE *) lookup(&dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5685 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5686 return NULL; |
| 21930 | 5687 if (ret->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5688 poolDiscard(&dtd->pool); |
| 21930 | 5689 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5690 poolFinish(&dtd->pool); |
| 21930 | 5691 if (!setElementTypePrefix(parser, ret)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5692 return NULL; |
| 21930 | 5693 } |
| 5694 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5695 } |
