Mercurial > cpython-lru_cache-weakref
annotate Modules/expat/xmlparse.c @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | bc74afb8e4ef |
| children | 9e124e6402bc |
| 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 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5 #define XML_BUILDING_EXPAT 1 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6 |
| 21930 | 7 #ifdef COMPILED_FROM_DSP |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
8 #include "winconfig.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
9 #elif defined(MACOS_CLASSIC) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
10 #include "macconfig.h" |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
11 #elif defined(__amigaos4__) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
12 #include "amigaconfig.h" |
| 32911 | 13 #elif defined(HAVE_EXPAT_CONFIG_H) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
14 #include <expat_config.h> |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
15 #endif /* ndef COMPILED_FROM_DSP */ |
| 21930 | 16 |
|
38080
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
17 #include <stddef.h> |
|
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
18 #include <string.h> /* memset(), memcpy() */ |
|
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
19 #include <assert.h> |
|
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
20 |
| 21930 | 21 #include "expat.h" |
| 22 | |
| 23 #ifdef XML_UNICODE | |
| 24 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX | |
| 25 #define XmlConvert XmlUtf16Convert | |
| 26 #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding | |
| 27 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS | |
| 28 #define XmlEncode XmlUtf16Encode | |
| 29 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) | |
| 30 typedef unsigned short ICHAR; | |
| 31 #else | |
| 32 #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX | |
| 33 #define XmlConvert XmlUtf8Convert | |
| 34 #define XmlGetInternalEncoding XmlGetUtf8InternalEncoding | |
| 35 #define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS | |
| 36 #define XmlEncode XmlUtf8Encode | |
| 37 #define MUST_CONVERT(enc, s) (!(enc)->isUtf8) | |
| 38 typedef char ICHAR; | |
| 39 #endif | |
| 40 | |
| 41 | |
| 42 #ifndef XML_NS | |
| 43 | |
| 44 #define XmlInitEncodingNS XmlInitEncoding | |
| 45 #define XmlInitUnknownEncodingNS XmlInitUnknownEncoding | |
| 46 #undef XmlGetInternalEncodingNS | |
| 47 #define XmlGetInternalEncodingNS XmlGetInternalEncoding | |
| 48 #define XmlParseXmlDeclNS XmlParseXmlDecl | |
| 49 | |
| 50 #endif | |
| 51 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
52 #ifdef XML_UNICODE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
53 |
| 21930 | 54 #ifdef XML_UNICODE_WCHAR_T |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
55 #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
|
56 #define XML_L(x) L ## x |
| 21930 | 57 #else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
58 #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
|
59 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
60 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
61 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
62 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
63 |
| 21930 | 64 #define XML_T(x) x |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
65 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
66 |
| 21930 | 67 #endif |
| 68 | |
| 69 /* Round up n to be a multiple of sz, where sz is a power of 2. */ | |
| 70 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) | |
| 71 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
72 /* Handle the case where memmove() doesn't exist. */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
73 #ifndef HAVE_MEMMOVE |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
74 #ifdef HAVE_BCOPY |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
75 #define memmove(d,s,l) bcopy((s),(d),(l)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
76 #else |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
77 #error memmove does not exist on this platform, nor is a substitute available |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
78 #endif /* HAVE_BCOPY */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
79 #endif /* HAVE_MEMMOVE */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
80 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
81 #include "internal.h" |
| 21930 | 82 #include "xmltok.h" |
| 83 #include "xmlrole.h" | |
| 84 | |
| 85 typedef const XML_Char *KEY; | |
| 86 | |
| 87 typedef struct { | |
| 88 KEY name; | |
| 89 } NAMED; | |
| 90 | |
| 91 typedef struct { | |
| 92 NAMED **v; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
93 unsigned char power; |
| 21930 | 94 size_t size; |
| 95 size_t used; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
96 const XML_Memory_Handling_Suite *mem; |
| 21930 | 97 } HASH_TABLE; |
| 98 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
99 /* Basic character hash algorithm, taken from Python's string hash: |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
100 h = h * 1000003 ^ character, the constant being a prime number. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
101 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
102 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
103 #ifdef XML_UNICODE |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
104 #define CHAR_HASH(h, c) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
105 (((h) * 0xF4243) ^ (unsigned short)(c)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
106 #else |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
107 #define CHAR_HASH(h, c) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
108 (((h) * 0xF4243) ^ (unsigned char)(c)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
109 #endif |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
110 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
111 /* For probing (after a collision) we need a step size relative prime |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
112 to the hash table size, which is a power of 2. We use double-hashing, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
113 since we can calculate a second hash value cheaply by taking those bits |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
114 of the first hash value that were discarded (masked out) when the table |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
115 index was calculated: index = hash & mask, where mask = table->size - 1. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
116 We limit the maximum step size to table->size / 4 (mask >> 2) and make |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
117 it odd, since odd numbers are always relative prime to a power of 2. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
118 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
119 #define SECOND_HASH(hash, mask, power) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
120 ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
121 #define PROBE_STEP(hash, mask, power) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
122 ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
123 |
| 21930 | 124 typedef struct { |
| 125 NAMED **p; | |
| 126 NAMED **end; | |
| 127 } HASH_TABLE_ITER; | |
| 128 | |
| 129 #define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ | |
| 130 #define INIT_DATA_BUF_SIZE 1024 | |
| 131 #define INIT_ATTS_SIZE 16 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
132 #define INIT_ATTS_VERSION 0xFFFFFFFF |
| 21930 | 133 #define INIT_BLOCK_SIZE 1024 |
| 134 #define INIT_BUFFER_SIZE 1024 | |
| 135 | |
| 136 #define EXPAND_SPARE 24 | |
| 137 | |
| 138 typedef struct binding { | |
| 139 struct prefix *prefix; | |
| 140 struct binding *nextTagBinding; | |
| 141 struct binding *prevPrefixBinding; | |
| 142 const struct attribute_id *attId; | |
| 143 XML_Char *uri; | |
| 144 int uriLen; | |
| 145 int uriAlloc; | |
| 146 } BINDING; | |
| 147 | |
| 148 typedef struct prefix { | |
| 149 const XML_Char *name; | |
| 150 BINDING *binding; | |
| 151 } PREFIX; | |
| 152 | |
| 153 typedef struct { | |
| 154 const XML_Char *str; | |
| 155 const XML_Char *localPart; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
156 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
157 int strLen; |
| 21930 | 158 int uriLen; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
159 int prefixLen; |
| 21930 | 160 } TAG_NAME; |
| 161 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
162 /* TAG represents an open element. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 contain the 'raw' name as well. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
171 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
172 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
|
173 TAG objects in a free list. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
174 */ |
| 21930 | 175 typedef struct tag { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
176 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
|
177 const char *rawName; /* tagName in the original encoding */ |
| 21930 | 178 int rawNameLength; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
179 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
|
180 char *buf; /* buffer for name components */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
181 char *bufEnd; /* end of the buffer */ |
| 21930 | 182 BINDING *bindings; |
| 183 } TAG; | |
| 184 | |
| 185 typedef struct { | |
| 186 const XML_Char *name; | |
| 187 const XML_Char *textPtr; | |
| 32911 | 188 int textLen; /* length in XML_Chars */ |
| 189 int processed; /* # of processed bytes - when suspended */ | |
| 21930 | 190 const XML_Char *systemId; |
| 191 const XML_Char *base; | |
| 192 const XML_Char *publicId; | |
| 193 const XML_Char *notation; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
194 XML_Bool open; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
195 XML_Bool is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
196 XML_Bool is_internal; /* true if declared in internal subset outside PE */ |
| 21930 | 197 } ENTITY; |
| 198 | |
| 199 typedef struct { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
200 enum XML_Content_Type type; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
201 enum XML_Content_Quant quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
202 const XML_Char * name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
203 int firstchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
204 int lastchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
205 int childcnt; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
206 int nextsib; |
| 21930 | 207 } CONTENT_SCAFFOLD; |
| 208 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
209 #define INIT_SCAFFOLD_ELEMENTS 32 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
210 |
| 21930 | 211 typedef struct block { |
| 212 struct block *next; | |
| 213 int size; | |
| 214 XML_Char s[1]; | |
| 215 } BLOCK; | |
| 216 | |
| 217 typedef struct { | |
| 218 BLOCK *blocks; | |
| 219 BLOCK *freeBlocks; | |
| 220 const XML_Char *end; | |
| 221 XML_Char *ptr; | |
| 222 XML_Char *start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
223 const XML_Memory_Handling_Suite *mem; |
| 21930 | 224 } STRING_POOL; |
| 225 | |
| 226 /* 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
|
227 an attribute has been specified. */ |
| 21930 | 228 typedef struct attribute_id { |
| 229 XML_Char *name; | |
| 230 PREFIX *prefix; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
231 XML_Bool maybeTokenized; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
232 XML_Bool xmlns; |
| 21930 | 233 } ATTRIBUTE_ID; |
| 234 | |
| 235 typedef struct { | |
| 236 const ATTRIBUTE_ID *id; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
237 XML_Bool isCdata; |
| 21930 | 238 const XML_Char *value; |
| 239 } DEFAULT_ATTRIBUTE; | |
| 240 | |
| 241 typedef struct { | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
242 unsigned long version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
243 unsigned long hash; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
244 const XML_Char *uriName; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
245 } NS_ATT; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
246 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
247 typedef struct { |
| 21930 | 248 const XML_Char *name; |
| 249 PREFIX *prefix; | |
| 250 const ATTRIBUTE_ID *idAtt; | |
| 251 int nDefaultAtts; | |
| 252 int allocDefaultAtts; | |
| 253 DEFAULT_ATTRIBUTE *defaultAtts; | |
| 254 } ELEMENT_TYPE; | |
| 255 | |
| 256 typedef struct { | |
| 257 HASH_TABLE generalEntities; | |
| 258 HASH_TABLE elementTypes; | |
| 259 HASH_TABLE attributeIds; | |
| 260 HASH_TABLE prefixes; | |
| 261 STRING_POOL pool; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
262 STRING_POOL entityValuePool; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
263 /* 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
|
264 XML_Bool keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
265 /* 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
|
266 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
|
267 XML_Bool hasParamEntityRefs; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
268 XML_Bool standalone; |
| 21930 | 269 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
270 /* 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
|
271 XML_Bool paramEntityRead; |
| 21930 | 272 HASH_TABLE paramEntities; |
| 273 #endif /* XML_DTD */ | |
| 274 PREFIX defaultPrefix; | |
| 275 /* === scaffolding for building content model === */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
276 XML_Bool in_eldecl; |
| 21930 | 277 CONTENT_SCAFFOLD *scaffold; |
| 278 unsigned contentStringLen; | |
| 279 unsigned scaffSize; | |
| 280 unsigned scaffCount; | |
| 281 int scaffLevel; | |
| 282 int *scaffIndex; | |
| 283 } DTD; | |
| 284 | |
| 285 typedef struct open_internal_entity { | |
| 286 const char *internalEventPtr; | |
| 287 const char *internalEventEndPtr; | |
| 288 struct open_internal_entity *next; | |
| 289 ENTITY *entity; | |
| 32911 | 290 int startTagLevel; |
| 291 XML_Bool betweenDecl; /* WFC: PE Between Declarations */ | |
| 21930 | 292 } OPEN_INTERNAL_ENTITY; |
| 293 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
294 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
|
295 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
296 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
297 const char **endPtr); |
| 21930 | 298 |
| 299 static Processor prologProcessor; | |
| 300 static Processor prologInitProcessor; | |
| 301 static Processor contentProcessor; | |
| 302 static Processor cdataSectionProcessor; | |
| 303 #ifdef XML_DTD | |
| 304 static Processor ignoreSectionProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
305 static Processor externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
306 static Processor externalParEntInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
307 static Processor entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
308 static Processor entityValueInitProcessor; |
| 21930 | 309 #endif /* XML_DTD */ |
| 310 static Processor epilogProcessor; | |
| 311 static Processor errorProcessor; | |
| 312 static Processor externalEntityInitProcessor; | |
| 313 static Processor externalEntityInitProcessor2; | |
| 314 static Processor externalEntityInitProcessor3; | |
| 315 static Processor externalEntityContentProcessor; | |
| 32911 | 316 static Processor internalEntityProcessor; |
| 21930 | 317 |
| 318 static enum XML_Error | |
| 319 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); | |
| 320 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
321 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, |
| 32911 | 322 const char *s, const char *next); |
| 21930 | 323 static enum XML_Error |
| 324 initializeEncoding(XML_Parser parser); | |
| 325 static enum XML_Error | |
| 32911 | 326 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, |
| 327 const char *end, int tok, const char *next, const char **nextPtr, | |
| 328 XML_Bool haveMore); | |
| 21930 | 329 static enum XML_Error |
| 32911 | 330 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 331 XML_Bool betweenDecl); | |
| 21930 | 332 static enum XML_Error |
| 333 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, | |
| 32911 | 334 const char *start, const char *end, const char **endPtr, |
| 335 XML_Bool haveMore); | |
| 21930 | 336 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
337 doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
| 32911 | 338 const char *end, const char **nextPtr, XML_Bool haveMore); |
| 21930 | 339 #ifdef XML_DTD |
| 340 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
341 doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
| 32911 | 342 const char *end, const char **nextPtr, XML_Bool haveMore); |
| 21930 | 343 #endif /* XML_DTD */ |
| 344 | |
| 345 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
|
346 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
|
347 TAG_NAME *tagNamePtr, BINDING **bindingsPtr); |
| 21930 | 348 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
349 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
|
350 const XML_Char *uri, BINDING **bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
351 static int |
| 32911 | 352 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, |
| 353 XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
354 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
355 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
|
356 const char *, const char *, STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
357 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
358 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
|
359 const char *, const char *, STRING_POOL *); |
| 21930 | 360 static ATTRIBUTE_ID * |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
361 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
|
362 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
363 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
364 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); |
| 21930 | 365 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
366 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
|
367 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
368 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
369 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
|
370 const char *start, const char *end); |
| 21930 | 371 static int |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
372 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
|
373 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
374 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
375 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
|
376 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
377 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
378 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
|
379 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
380 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
|
381 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
382 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
|
383 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
384 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
|
385 /* do not call if parentParser != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
386 static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); |
| 21930 | 387 static void |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
388 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
|
389 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
390 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
|
391 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
392 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
|
393 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
394 static NAMED * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
395 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
|
396 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
397 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
|
398 static void FASTCALL hashTableClear(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
399 static void FASTCALL hashTableDestroy(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
400 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
401 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
|
402 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
|
403 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
404 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
405 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
|
406 static void FASTCALL poolClear(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
407 static void FASTCALL poolDestroy(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
408 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
409 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
|
410 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
411 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
412 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
|
413 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
414 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
|
415 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
416 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
|
417 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
418 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
|
419 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
420 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
|
421 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
422 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
|
423 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
|
424 static ELEMENT_TYPE * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
425 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
|
426 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
427 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
428 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
429 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
430 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
431 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
432 DTD *dtd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
433 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
434 parserInit(XML_Parser parser, const XML_Char *encodingName); |
| 21930 | 435 |
| 436 #define poolStart(pool) ((pool)->start) | |
| 437 #define poolEnd(pool) ((pool)->ptr) | |
| 438 #define poolLength(pool) ((pool)->ptr - (pool)->start) | |
| 439 #define poolChop(pool) ((void)--(pool->ptr)) | |
| 440 #define poolLastChar(pool) (((pool)->ptr)[-1]) | |
| 441 #define poolDiscard(pool) ((pool)->ptr = (pool)->start) | |
| 442 #define poolFinish(pool) ((pool)->start = (pool)->ptr) | |
| 443 #define poolAppendChar(pool, c) \ | |
| 444 (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ | |
| 445 ? 0 \ | |
| 446 : ((*((pool)->ptr)++ = c), 1)) | |
| 447 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
448 struct XML_ParserStruct { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
449 /* 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
|
450 macro works. */ |
| 21930 | 451 void *m_userData; |
| 452 void *m_handlerArg; | |
| 453 char *m_buffer; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
454 const XML_Memory_Handling_Suite m_mem; |
| 21930 | 455 /* first character to be parsed */ |
| 456 const char *m_bufferPtr; | |
| 457 /* past last character to be parsed */ | |
| 458 char *m_bufferEnd; | |
| 459 /* allocated end of buffer */ | |
| 460 const char *m_bufferLim; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
461 XML_Index m_parseEndByteIndex; |
| 21930 | 462 const char *m_parseEndPtr; |
| 463 XML_Char *m_dataBuf; | |
| 464 XML_Char *m_dataBufEnd; | |
| 465 XML_StartElementHandler m_startElementHandler; | |
| 466 XML_EndElementHandler m_endElementHandler; | |
| 467 XML_CharacterDataHandler m_characterDataHandler; | |
| 468 XML_ProcessingInstructionHandler m_processingInstructionHandler; | |
| 469 XML_CommentHandler m_commentHandler; | |
| 470 XML_StartCdataSectionHandler m_startCdataSectionHandler; | |
| 471 XML_EndCdataSectionHandler m_endCdataSectionHandler; | |
| 472 XML_DefaultHandler m_defaultHandler; | |
| 473 XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; | |
| 474 XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; | |
| 475 XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; | |
| 476 XML_NotationDeclHandler m_notationDeclHandler; | |
| 477 XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; | |
| 478 XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; | |
| 479 XML_NotStandaloneHandler m_notStandaloneHandler; | |
| 480 XML_ExternalEntityRefHandler m_externalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
481 XML_Parser m_externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
482 XML_SkippedEntityHandler m_skippedEntityHandler; |
| 21930 | 483 XML_UnknownEncodingHandler m_unknownEncodingHandler; |
| 484 XML_ElementDeclHandler m_elementDeclHandler; | |
| 485 XML_AttlistDeclHandler m_attlistDeclHandler; | |
| 486 XML_EntityDeclHandler m_entityDeclHandler; | |
| 487 XML_XmlDeclHandler m_xmlDeclHandler; | |
| 488 const ENCODING *m_encoding; | |
| 489 INIT_ENCODING m_initEncoding; | |
| 490 const ENCODING *m_internalEncoding; | |
| 491 const XML_Char *m_protocolEncodingName; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
492 XML_Bool m_ns; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
493 XML_Bool m_ns_triplets; |
| 21930 | 494 void *m_unknownEncodingMem; |
| 495 void *m_unknownEncodingData; | |
| 496 void *m_unknownEncodingHandlerData; | |
| 32911 | 497 void (XMLCALL *m_unknownEncodingRelease)(void *); |
| 21930 | 498 PROLOG_STATE m_prologState; |
| 499 Processor *m_processor; | |
| 500 enum XML_Error m_errorCode; | |
| 501 const char *m_eventPtr; | |
| 502 const char *m_eventEndPtr; | |
| 503 const char *m_positionPtr; | |
| 504 OPEN_INTERNAL_ENTITY *m_openInternalEntities; | |
| 32911 | 505 OPEN_INTERNAL_ENTITY *m_freeInternalEntities; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
506 XML_Bool m_defaultExpandInternalEntities; |
| 21930 | 507 int m_tagLevel; |
| 508 ENTITY *m_declEntity; | |
| 509 const XML_Char *m_doctypeName; | |
| 510 const XML_Char *m_doctypeSysid; | |
| 511 const XML_Char *m_doctypePubid; | |
| 512 const XML_Char *m_declAttributeType; | |
| 513 const XML_Char *m_declNotationName; | |
| 514 const XML_Char *m_declNotationPublicId; | |
| 515 ELEMENT_TYPE *m_declElementType; | |
| 516 ATTRIBUTE_ID *m_declAttributeId; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
517 XML_Bool m_declAttributeIsCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
518 XML_Bool m_declAttributeIsId; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
519 DTD *m_dtd; |
| 21930 | 520 const XML_Char *m_curBase; |
| 521 TAG *m_tagStack; | |
| 522 TAG *m_freeTagList; | |
| 523 BINDING *m_inheritedBindings; | |
| 524 BINDING *m_freeBindingList; | |
| 525 int m_attsSize; | |
| 526 int m_nSpecifiedAtts; | |
| 527 int m_idAttIndex; | |
| 528 ATTRIBUTE *m_atts; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
529 NS_ATT *m_nsAtts; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
530 unsigned long m_nsAttsVersion; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
531 unsigned char m_nsAttsPower; |
| 21930 | 532 POSITION m_position; |
| 533 STRING_POOL m_tempPool; | |
| 534 STRING_POOL m_temp2Pool; | |
| 535 char *m_groupConnector; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
536 unsigned int m_groupSize; |
| 21930 | 537 XML_Char m_namespaceSeparator; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
538 XML_Parser m_parentParser; |
| 32911 | 539 XML_ParsingStatus m_parsingStatus; |
| 21930 | 540 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
541 XML_Bool m_isParamEntity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
542 XML_Bool m_useForeignDTD; |
| 21930 | 543 enum XML_ParamEntityParsing m_paramEntityParsing; |
| 544 #endif | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
545 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
546 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
547 #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
|
548 #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
|
549 #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
|
550 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
551 #define userData (parser->m_userData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
552 #define handlerArg (parser->m_handlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
553 #define startElementHandler (parser->m_startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
554 #define endElementHandler (parser->m_endElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
555 #define characterDataHandler (parser->m_characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
556 #define processingInstructionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
557 (parser->m_processingInstructionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
558 #define commentHandler (parser->m_commentHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
559 #define startCdataSectionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
560 (parser->m_startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
561 #define endCdataSectionHandler (parser->m_endCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
562 #define defaultHandler (parser->m_defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
563 #define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
564 #define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
565 #define unparsedEntityDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
566 (parser->m_unparsedEntityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
567 #define notationDeclHandler (parser->m_notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
568 #define startNamespaceDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
569 (parser->m_startNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
570 #define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
571 #define notStandaloneHandler (parser->m_notStandaloneHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
572 #define externalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
573 (parser->m_externalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
574 #define externalEntityRefHandlerArg \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
575 (parser->m_externalEntityRefHandlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
576 #define internalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
577 (parser->m_internalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
578 #define skippedEntityHandler (parser->m_skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
579 #define unknownEncodingHandler (parser->m_unknownEncodingHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
580 #define elementDeclHandler (parser->m_elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
581 #define attlistDeclHandler (parser->m_attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
582 #define entityDeclHandler (parser->m_entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
583 #define xmlDeclHandler (parser->m_xmlDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
584 #define encoding (parser->m_encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
585 #define initEncoding (parser->m_initEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
586 #define internalEncoding (parser->m_internalEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
587 #define unknownEncodingMem (parser->m_unknownEncodingMem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
588 #define unknownEncodingData (parser->m_unknownEncodingData) |
| 21930 | 589 #define unknownEncodingHandlerData \ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
590 (parser->m_unknownEncodingHandlerData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
591 #define unknownEncodingRelease (parser->m_unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
592 #define protocolEncodingName (parser->m_protocolEncodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
593 #define ns (parser->m_ns) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
594 #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
|
595 #define prologState (parser->m_prologState) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
596 #define processor (parser->m_processor) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
597 #define errorCode (parser->m_errorCode) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
598 #define eventPtr (parser->m_eventPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
599 #define eventEndPtr (parser->m_eventEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
600 #define positionPtr (parser->m_positionPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
601 #define position (parser->m_position) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
602 #define openInternalEntities (parser->m_openInternalEntities) |
| 32911 | 603 #define freeInternalEntities (parser->m_freeInternalEntities) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
604 #define defaultExpandInternalEntities \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
605 (parser->m_defaultExpandInternalEntities) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
606 #define tagLevel (parser->m_tagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
607 #define buffer (parser->m_buffer) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
608 #define bufferPtr (parser->m_bufferPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
609 #define bufferEnd (parser->m_bufferEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
610 #define parseEndByteIndex (parser->m_parseEndByteIndex) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
611 #define parseEndPtr (parser->m_parseEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
612 #define bufferLim (parser->m_bufferLim) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
613 #define dataBuf (parser->m_dataBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
614 #define dataBufEnd (parser->m_dataBufEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
615 #define _dtd (parser->m_dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
616 #define curBase (parser->m_curBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
617 #define declEntity (parser->m_declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
618 #define doctypeName (parser->m_doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
619 #define doctypeSysid (parser->m_doctypeSysid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
620 #define doctypePubid (parser->m_doctypePubid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
621 #define declAttributeType (parser->m_declAttributeType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
622 #define declNotationName (parser->m_declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
623 #define declNotationPublicId (parser->m_declNotationPublicId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
624 #define declElementType (parser->m_declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
625 #define declAttributeId (parser->m_declAttributeId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
626 #define declAttributeIsCdata (parser->m_declAttributeIsCdata) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
627 #define declAttributeIsId (parser->m_declAttributeIsId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
628 #define freeTagList (parser->m_freeTagList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
629 #define freeBindingList (parser->m_freeBindingList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
630 #define inheritedBindings (parser->m_inheritedBindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
631 #define tagStack (parser->m_tagStack) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
632 #define atts (parser->m_atts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
633 #define attsSize (parser->m_attsSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
634 #define nSpecifiedAtts (parser->m_nSpecifiedAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
635 #define idAttIndex (parser->m_idAttIndex) |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
636 #define nsAtts (parser->m_nsAtts) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
637 #define nsAttsVersion (parser->m_nsAttsVersion) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
638 #define nsAttsPower (parser->m_nsAttsPower) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
639 #define tempPool (parser->m_tempPool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
640 #define temp2Pool (parser->m_temp2Pool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
641 #define groupConnector (parser->m_groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
642 #define groupSize (parser->m_groupSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
643 #define namespaceSeparator (parser->m_namespaceSeparator) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
644 #define parentParser (parser->m_parentParser) |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
645 #define ps_parsing (parser->m_parsingStatus.parsing) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
646 #define ps_finalBuffer (parser->m_parsingStatus.finalBuffer) |
| 21930 | 647 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
648 #define isParamEntity (parser->m_isParamEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
649 #define useForeignDTD (parser->m_useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
650 #define paramEntityParsing (parser->m_paramEntityParsing) |
| 21930 | 651 #endif /* XML_DTD */ |
| 652 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
653 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
654 XML_ParserCreate(const XML_Char *encodingName) |
| 21930 | 655 { |
| 656 return XML_ParserCreate_MM(encodingName, NULL, NULL); | |
| 657 } | |
| 658 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
659 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
660 XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) |
| 21930 | 661 { |
| 662 XML_Char tmp[2]; | |
| 663 *tmp = nsSep; | |
| 664 return XML_ParserCreate_MM(encodingName, NULL, tmp); | |
| 665 } | |
| 666 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
667 static const XML_Char implicitContext[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
668 '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
|
669 '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
|
670 '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
|
671 '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
|
672 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
673 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
674 XML_Parser XMLCALL |
| 21930 | 675 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
|
676 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
677 const XML_Char *nameSep) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
678 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
679 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
|
680 if (parser != NULL && ns) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
681 /* 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
|
682 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
|
683 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
684 if (!setContext(parser, implicitContext)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
685 XML_ParserFree(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
686 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
687 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
688 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
689 return parser; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
690 } |
|
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 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
693 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
694 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
695 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
696 DTD *dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
697 { |
| 21930 | 698 XML_Parser parser; |
| 699 | |
| 700 if (memsuite) { | |
| 701 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
702 parser = (XML_Parser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
703 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
|
704 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
705 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
|
706 mtemp->malloc_fcn = memsuite->malloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
707 mtemp->realloc_fcn = memsuite->realloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
708 mtemp->free_fcn = memsuite->free_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
709 } |
| 21930 | 710 } |
| 711 else { | |
| 712 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
713 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
|
714 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
715 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
|
716 mtemp->malloc_fcn = malloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
717 mtemp->realloc_fcn = realloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
718 mtemp->free_fcn = free; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
719 } |
| 21930 | 720 } |
| 721 | |
| 722 if (!parser) | |
| 723 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
724 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
725 buffer = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
726 bufferLim = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
727 |
| 21930 | 728 attsSize = INIT_ATTS_SIZE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
729 atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
730 if (atts == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
731 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
732 return NULL; |
|
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 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
|
735 if (dataBuf == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
736 FREE(atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
737 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
738 return NULL; |
| 21930 | 739 } |
| 740 dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; | |
| 741 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
742 if (dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
743 _dtd = dtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
744 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
745 _dtd = dtdCreate(&parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
746 if (_dtd == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
747 FREE(dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
748 FREE(atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
749 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
750 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
751 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
752 } |
|
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 freeBindingList = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
755 freeTagList = NULL; |
| 32911 | 756 freeInternalEntities = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
757 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
758 groupSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
759 groupConnector = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
760 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
761 unknownEncodingHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
762 unknownEncodingHandlerData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
763 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
764 namespaceSeparator = '!'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
765 ns = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
766 ns_triplets = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
767 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
768 nsAtts = NULL; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
769 nsAttsVersion = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
770 nsAttsPower = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
771 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
772 poolInit(&tempPool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
773 poolInit(&temp2Pool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
774 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
775 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
776 if (encodingName && !protocolEncodingName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
777 XML_ParserFree(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
778 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
779 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
780 |
| 21930 | 781 if (nameSep) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
782 ns = XML_TRUE; |
| 21930 | 783 internalEncoding = XmlGetInternalEncodingNS(); |
| 784 namespaceSeparator = *nameSep; | |
| 785 } | |
| 786 else { | |
| 787 internalEncoding = XmlGetInternalEncoding(); | |
| 788 } | |
| 789 | |
| 790 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
791 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
792 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
793 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
794 parserInit(XML_Parser parser, const XML_Char *encodingName) |
| 21930 | 795 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
796 processor = prologInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
797 XmlPrologStateInit(&prologState); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
798 protocolEncodingName = (encodingName != NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
799 ? poolCopyString(&tempPool, encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
800 : NULL); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
801 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
802 XmlInitEncoding(&initEncoding, &encoding, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
803 userData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
804 handlerArg = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
805 startElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
806 endElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
807 characterDataHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
808 processingInstructionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
809 commentHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
810 startCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
811 endCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
812 defaultHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
813 startDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
814 endDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
815 unparsedEntityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
816 notationDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
817 startNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
818 endNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
819 notStandaloneHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
820 externalEntityRefHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
821 externalEntityRefHandlerArg = parser; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
822 skippedEntityHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
823 elementDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
824 attlistDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
825 entityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
826 xmlDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
827 bufferPtr = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
828 bufferEnd = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
829 parseEndByteIndex = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
830 parseEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
831 declElementType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
832 declAttributeId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
833 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
834 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
835 doctypeSysid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
836 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
837 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
838 declNotationName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
839 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
840 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
841 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
842 memset(&position, 0, sizeof(POSITION)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
843 errorCode = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
844 eventPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
845 eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
846 positionPtr = NULL; |
| 32911 | 847 openInternalEntities = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
848 defaultExpandInternalEntities = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
849 tagLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
850 tagStack = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
851 inheritedBindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
852 nSpecifiedAtts = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
853 unknownEncodingMem = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
854 unknownEncodingRelease = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
855 unknownEncodingData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
856 parentParser = NULL; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
857 ps_parsing = XML_INITIALIZED; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
858 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
859 isParamEntity = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
860 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
861 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
862 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
863 } |
|
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 /* moves list of bindings to freeBindingList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
866 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
867 moveToFreeBindingList(XML_Parser parser, BINDING *bindings) |
|
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 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
870 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
871 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
872 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
873 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
874 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
875 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
876 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
877 XML_Bool XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
878 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
|
879 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
880 TAG *tStk; |
| 32911 | 881 OPEN_INTERNAL_ENTITY *openEntityList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
882 if (parentParser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
883 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
884 /* move tagStack to freeTagList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
885 tStk = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
886 while (tStk) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
887 TAG *tag = tStk; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
888 tStk = tStk->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
889 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
890 moveToFreeBindingList(parser, tag->bindings); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
891 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
892 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
893 } |
| 32911 | 894 /* move openInternalEntities to freeInternalEntities */ |
| 895 openEntityList = openInternalEntities; | |
| 896 while (openEntityList) { | |
| 897 OPEN_INTERNAL_ENTITY *openEntity = openEntityList; | |
| 898 openEntityList = openEntity->next; | |
| 899 openEntity->next = freeInternalEntities; | |
| 900 freeInternalEntities = openEntity; | |
| 901 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
902 moveToFreeBindingList(parser, inheritedBindings); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
903 FREE(unknownEncodingMem); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
904 if (unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
905 unknownEncodingRelease(unknownEncodingData); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
906 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
907 poolClear(&temp2Pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
908 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
909 dtdReset(_dtd, &parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
910 return setContext(parser, implicitContext); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
911 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
912 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
913 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
914 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
|
915 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
916 /* 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
|
917 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
|
918 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
|
919 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
920 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
921 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
922 if (encodingName == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
923 protocolEncodingName = NULL; |
| 21930 | 924 else { |
| 925 protocolEncodingName = poolCopyString(&tempPool, encodingName); | |
| 926 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
927 return XML_STATUS_ERROR; |
| 21930 | 928 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
929 return XML_STATUS_OK; |
| 21930 | 930 } |
| 931 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
932 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
933 XML_ExternalEntityParserCreate(XML_Parser oldParser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
934 const XML_Char *context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
935 const XML_Char *encodingName) |
| 21930 | 936 { |
| 937 XML_Parser parser = oldParser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
938 DTD *newDtd = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
939 DTD *oldDtd = _dtd; |
| 21930 | 940 XML_StartElementHandler oldStartElementHandler = startElementHandler; |
| 941 XML_EndElementHandler oldEndElementHandler = endElementHandler; | |
| 942 XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
943 XML_ProcessingInstructionHandler oldProcessingInstructionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
944 = processingInstructionHandler; |
| 21930 | 945 XML_CommentHandler oldCommentHandler = commentHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
946 XML_StartCdataSectionHandler oldStartCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
947 = startCdataSectionHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
948 XML_EndCdataSectionHandler oldEndCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
949 = endCdataSectionHandler; |
| 21930 | 950 XML_DefaultHandler oldDefaultHandler = defaultHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
951 XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
952 = unparsedEntityDeclHandler; |
| 21930 | 953 XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
954 XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
955 = startNamespaceDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
956 XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
957 = endNamespaceDeclHandler; |
| 21930 | 958 XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
959 XML_ExternalEntityRefHandler oldExternalEntityRefHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
960 = externalEntityRefHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
961 XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
962 XML_UnknownEncodingHandler oldUnknownEncodingHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
963 = unknownEncodingHandler; |
| 21930 | 964 XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; |
| 965 XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; | |
| 966 XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; | |
| 967 XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; | |
| 968 ELEMENT_TYPE * oldDeclElementType = declElementType; | |
| 969 | |
| 970 void *oldUserData = userData; | |
| 971 void *oldHandlerArg = handlerArg; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
972 XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
973 XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
974 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
975 enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
976 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
977 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
978 XML_Bool oldns_triplets = ns_triplets; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
979 |
| 21930 | 980 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
981 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
982 newDtd = oldDtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
983 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
984 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
985 /* 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
|
986 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
|
987 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
|
988 would be otherwise. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
989 */ |
| 21930 | 990 if (ns) { |
| 991 XML_Char tmp[2]; | |
| 992 *tmp = namespaceSeparator; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
993 parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); |
| 21930 | 994 } |
| 995 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
996 parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); |
| 21930 | 997 } |
| 998 | |
| 999 if (!parser) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1000 return NULL; |
| 21930 | 1001 |
| 1002 startElementHandler = oldStartElementHandler; | |
| 1003 endElementHandler = oldEndElementHandler; | |
| 1004 characterDataHandler = oldCharacterDataHandler; | |
| 1005 processingInstructionHandler = oldProcessingInstructionHandler; | |
| 1006 commentHandler = oldCommentHandler; | |
| 1007 startCdataSectionHandler = oldStartCdataSectionHandler; | |
| 1008 endCdataSectionHandler = oldEndCdataSectionHandler; | |
| 1009 defaultHandler = oldDefaultHandler; | |
| 1010 unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; | |
| 1011 notationDeclHandler = oldNotationDeclHandler; | |
| 1012 startNamespaceDeclHandler = oldStartNamespaceDeclHandler; | |
| 1013 endNamespaceDeclHandler = oldEndNamespaceDeclHandler; | |
| 1014 notStandaloneHandler = oldNotStandaloneHandler; | |
| 1015 externalEntityRefHandler = oldExternalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1016 skippedEntityHandler = oldSkippedEntityHandler; |
| 21930 | 1017 unknownEncodingHandler = oldUnknownEncodingHandler; |
| 1018 elementDeclHandler = oldElementDeclHandler; | |
| 1019 attlistDeclHandler = oldAttlistDeclHandler; | |
| 1020 entityDeclHandler = oldEntityDeclHandler; | |
| 1021 xmlDeclHandler = oldXmlDeclHandler; | |
| 1022 declElementType = oldDeclElementType; | |
| 1023 userData = oldUserData; | |
| 1024 if (oldUserData == oldHandlerArg) | |
| 1025 handlerArg = userData; | |
| 1026 else | |
| 1027 handlerArg = parser; | |
| 1028 if (oldExternalEntityRefHandlerArg != oldParser) | |
| 1029 externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; | |
| 1030 defaultExpandInternalEntities = oldDefaultExpandInternalEntities; | |
| 1031 ns_triplets = oldns_triplets; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1032 parentParser = oldParser; |
| 21930 | 1033 #ifdef XML_DTD |
| 1034 paramEntityParsing = oldParamEntityParsing; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1035 prologState.inEntityValue = oldInEntityValue; |
| 21930 | 1036 if (context) { |
| 1037 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1038 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
|
1039 || !setContext(parser, context)) { |
| 21930 | 1040 XML_ParserFree(parser); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1041 return NULL; |
| 21930 | 1042 } |
| 1043 processor = externalEntityInitProcessor; | |
| 1044 #ifdef XML_DTD | |
| 1045 } | |
| 1046 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1047 /* 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
|
1048 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
|
1049 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
|
1050 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
|
1051 _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
|
1052 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
|
1053 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1054 isParamEntity = XML_TRUE; |
| 21930 | 1055 XmlPrologStateInitExternalEntity(&prologState); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1056 processor = externalParEntInitProcessor; |
| 21930 | 1057 } |
| 1058 #endif /* XML_DTD */ | |
| 1059 return parser; | |
| 1060 } | |
| 1061 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1062 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1063 destroyBindings(BINDING *bindings, XML_Parser parser) |
| 21930 | 1064 { |
| 1065 for (;;) { | |
| 1066 BINDING *b = bindings; | |
| 1067 if (!b) | |
| 1068 break; | |
| 1069 bindings = b->nextTagBinding; | |
| 1070 FREE(b->uri); | |
| 1071 FREE(b); | |
| 1072 } | |
| 1073 } | |
| 1074 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1075 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1076 XML_ParserFree(XML_Parser parser) |
| 21930 | 1077 { |
| 32911 | 1078 TAG *tagList; |
| 1079 OPEN_INTERNAL_ENTITY *entityList; | |
| 1080 if (parser == NULL) | |
| 1081 return; | |
| 1082 /* free tagStack and freeTagList */ | |
| 1083 tagList = tagStack; | |
| 21930 | 1084 for (;;) { |
| 1085 TAG *p; | |
| 32911 | 1086 if (tagList == NULL) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1087 if (freeTagList == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1088 break; |
| 32911 | 1089 tagList = freeTagList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1090 freeTagList = NULL; |
| 21930 | 1091 } |
| 32911 | 1092 p = tagList; |
| 1093 tagList = tagList->parent; | |
| 21930 | 1094 FREE(p->buf); |
| 1095 destroyBindings(p->bindings, parser); | |
| 1096 FREE(p); | |
| 1097 } | |
| 32911 | 1098 /* free openInternalEntities and freeInternalEntities */ |
| 1099 entityList = openInternalEntities; | |
| 1100 for (;;) { | |
| 1101 OPEN_INTERNAL_ENTITY *openEntity; | |
| 1102 if (entityList == NULL) { | |
| 1103 if (freeInternalEntities == NULL) | |
| 1104 break; | |
| 1105 entityList = freeInternalEntities; | |
| 1106 freeInternalEntities = NULL; | |
| 1107 } | |
| 1108 openEntity = entityList; | |
| 1109 entityList = entityList->next; | |
| 1110 FREE(openEntity); | |
| 1111 } | |
| 1112 | |
| 21930 | 1113 destroyBindings(freeBindingList, parser); |
| 1114 destroyBindings(inheritedBindings, parser); | |
| 1115 poolDestroy(&tempPool); | |
| 1116 poolDestroy(&temp2Pool); | |
| 1117 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1118 /* 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
|
1119 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
|
1120 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1121 if (!isParamEntity && _dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1122 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1123 if (_dtd) |
| 21930 | 1124 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1125 dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); |
| 21930 | 1126 FREE((void *)atts); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1127 FREE(groupConnector); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1128 FREE(buffer); |
| 21930 | 1129 FREE(dataBuf); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1130 FREE(nsAtts); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1131 FREE(unknownEncodingMem); |
| 21930 | 1132 if (unknownEncodingRelease) |
| 1133 unknownEncodingRelease(unknownEncodingData); | |
| 1134 FREE(parser); | |
| 1135 } | |
| 1136 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1137 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1138 XML_UseParserAsHandlerArg(XML_Parser parser) |
| 21930 | 1139 { |
| 1140 handlerArg = parser; | |
| 1141 } | |
| 1142 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1143 enum XML_Error XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1144 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
|
1145 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1146 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1147 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1148 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1149 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
|
1150 useForeignDTD = useDTD; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1151 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1152 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1153 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
|
1154 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1155 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1156 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1157 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1158 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
|
1159 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1160 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1161 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1162 return; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1163 ns_triplets = do_nst ? XML_TRUE : XML_FALSE; |
| 21930 | 1164 } |
| 1165 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1166 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1167 XML_SetUserData(XML_Parser parser, void *p) |
| 21930 | 1168 { |
| 1169 if (handlerArg == userData) | |
| 1170 handlerArg = userData = p; | |
| 1171 else | |
| 1172 userData = p; | |
| 1173 } | |
| 1174 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1175 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1176 XML_SetBase(XML_Parser parser, const XML_Char *p) |
| 21930 | 1177 { |
| 1178 if (p) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1179 p = poolCopyString(&_dtd->pool, p); |
| 21930 | 1180 if (!p) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1181 return XML_STATUS_ERROR; |
| 21930 | 1182 curBase = p; |
| 1183 } | |
| 1184 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1185 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1186 return XML_STATUS_OK; |
| 21930 | 1187 } |
| 1188 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1189 const XML_Char * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1190 XML_GetBase(XML_Parser parser) |
| 21930 | 1191 { |
| 1192 return curBase; | |
| 1193 } | |
| 1194 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1195 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1196 XML_GetSpecifiedAttributeCount(XML_Parser parser) |
| 21930 | 1197 { |
| 1198 return nSpecifiedAtts; | |
| 1199 } | |
| 1200 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1201 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1202 XML_GetIdAttributeIndex(XML_Parser parser) |
| 21930 | 1203 { |
| 1204 return idAttIndex; | |
| 1205 } | |
| 1206 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1207 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1208 XML_SetElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1209 XML_StartElementHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1210 XML_EndElementHandler end) |
| 21930 | 1211 { |
| 1212 startElementHandler = start; | |
| 1213 endElementHandler = end; | |
| 1214 } | |
| 1215 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1216 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1217 XML_SetStartElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1218 XML_StartElementHandler start) { |
| 21930 | 1219 startElementHandler = start; |
| 1220 } | |
| 1221 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1222 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1223 XML_SetEndElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1224 XML_EndElementHandler end) { |
| 21930 | 1225 endElementHandler = end; |
| 1226 } | |
| 1227 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1228 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1229 XML_SetCharacterDataHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1230 XML_CharacterDataHandler handler) |
| 21930 | 1231 { |
| 1232 characterDataHandler = handler; | |
| 1233 } | |
| 1234 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1235 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1236 XML_SetProcessingInstructionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1237 XML_ProcessingInstructionHandler handler) |
| 21930 | 1238 { |
| 1239 processingInstructionHandler = handler; | |
| 1240 } | |
| 1241 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1242 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1243 XML_SetCommentHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1244 XML_CommentHandler handler) |
| 21930 | 1245 { |
| 1246 commentHandler = handler; | |
| 1247 } | |
| 1248 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1249 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1250 XML_SetCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1251 XML_StartCdataSectionHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1252 XML_EndCdataSectionHandler end) |
| 21930 | 1253 { |
| 1254 startCdataSectionHandler = start; | |
| 1255 endCdataSectionHandler = end; | |
| 1256 } | |
| 1257 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1258 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1259 XML_SetStartCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1260 XML_StartCdataSectionHandler start) { |
| 21930 | 1261 startCdataSectionHandler = start; |
| 1262 } | |
| 1263 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1264 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1265 XML_SetEndCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1266 XML_EndCdataSectionHandler end) { |
| 21930 | 1267 endCdataSectionHandler = end; |
| 1268 } | |
| 1269 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1270 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1271 XML_SetDefaultHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1272 XML_DefaultHandler handler) |
| 21930 | 1273 { |
| 1274 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1275 defaultExpandInternalEntities = XML_FALSE; |
| 21930 | 1276 } |
| 1277 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1278 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1279 XML_SetDefaultHandlerExpand(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1280 XML_DefaultHandler handler) |
| 21930 | 1281 { |
| 1282 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1283 defaultExpandInternalEntities = XML_TRUE; |
| 21930 | 1284 } |
| 1285 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1286 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1287 XML_SetDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1288 XML_StartDoctypeDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1289 XML_EndDoctypeDeclHandler end) |
| 21930 | 1290 { |
| 1291 startDoctypeDeclHandler = start; | |
| 1292 endDoctypeDeclHandler = end; | |
| 1293 } | |
| 1294 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1295 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1296 XML_SetStartDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1297 XML_StartDoctypeDeclHandler start) { |
| 21930 | 1298 startDoctypeDeclHandler = start; |
| 1299 } | |
| 1300 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1301 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1302 XML_SetEndDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1303 XML_EndDoctypeDeclHandler end) { |
| 21930 | 1304 endDoctypeDeclHandler = end; |
| 1305 } | |
| 1306 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1307 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1308 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1309 XML_UnparsedEntityDeclHandler handler) |
| 21930 | 1310 { |
| 1311 unparsedEntityDeclHandler = handler; | |
| 1312 } | |
| 1313 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1314 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1315 XML_SetNotationDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1316 XML_NotationDeclHandler handler) |
| 21930 | 1317 { |
| 1318 notationDeclHandler = handler; | |
| 1319 } | |
| 1320 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1321 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1322 XML_SetNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1323 XML_StartNamespaceDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1324 XML_EndNamespaceDeclHandler end) |
| 21930 | 1325 { |
| 1326 startNamespaceDeclHandler = start; | |
| 1327 endNamespaceDeclHandler = end; | |
| 1328 } | |
| 1329 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1330 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1331 XML_SetStartNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1332 XML_StartNamespaceDeclHandler start) { |
| 21930 | 1333 startNamespaceDeclHandler = start; |
| 1334 } | |
| 1335 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1336 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1337 XML_SetEndNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1338 XML_EndNamespaceDeclHandler end) { |
| 21930 | 1339 endNamespaceDeclHandler = end; |
| 1340 } | |
| 1341 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1342 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1343 XML_SetNotStandaloneHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1344 XML_NotStandaloneHandler handler) |
| 21930 | 1345 { |
| 1346 notStandaloneHandler = handler; | |
| 1347 } | |
| 1348 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1349 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1350 XML_SetExternalEntityRefHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1351 XML_ExternalEntityRefHandler handler) |
| 21930 | 1352 { |
| 1353 externalEntityRefHandler = handler; | |
| 1354 } | |
| 1355 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1356 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1357 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) |
| 21930 | 1358 { |
| 1359 if (arg) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1360 externalEntityRefHandlerArg = (XML_Parser)arg; |
| 21930 | 1361 else |
| 1362 externalEntityRefHandlerArg = parser; | |
| 1363 } | |
| 1364 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1365 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1366 XML_SetSkippedEntityHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1367 XML_SkippedEntityHandler handler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1368 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1369 skippedEntityHandler = handler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1370 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1371 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1372 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1373 XML_SetUnknownEncodingHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1374 XML_UnknownEncodingHandler handler, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1375 void *data) |
| 21930 | 1376 { |
| 1377 unknownEncodingHandler = handler; | |
| 1378 unknownEncodingHandlerData = data; | |
| 1379 } | |
| 1380 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1381 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1382 XML_SetElementDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1383 XML_ElementDeclHandler eldecl) |
| 21930 | 1384 { |
| 1385 elementDeclHandler = eldecl; | |
| 1386 } | |
| 1387 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1388 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1389 XML_SetAttlistDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1390 XML_AttlistDeclHandler attdecl) |
| 21930 | 1391 { |
| 1392 attlistDeclHandler = attdecl; | |
| 1393 } | |
| 1394 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1395 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1396 XML_SetEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1397 XML_EntityDeclHandler handler) |
| 21930 | 1398 { |
| 1399 entityDeclHandler = handler; | |
| 1400 } | |
| 1401 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1402 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1403 XML_SetXmlDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1404 XML_XmlDeclHandler handler) { |
| 21930 | 1405 xmlDeclHandler = handler; |
| 1406 } | |
| 1407 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1408 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1409 XML_SetParamEntityParsing(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1410 enum XML_ParamEntityParsing peParsing) |
| 21930 | 1411 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1412 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1413 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1414 return 0; |
| 21930 | 1415 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1416 paramEntityParsing = peParsing; |
| 21930 | 1417 return 1; |
| 1418 #else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1419 return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; |
| 21930 | 1420 #endif |
| 1421 } | |
| 1422 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1423 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1424 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) |
| 21930 | 1425 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1426 switch (ps_parsing) { |
| 32911 | 1427 case XML_SUSPENDED: |
| 1428 errorCode = XML_ERROR_SUSPENDED; | |
| 1429 return XML_STATUS_ERROR; | |
| 1430 case XML_FINISHED: | |
| 1431 errorCode = XML_ERROR_FINISHED; | |
| 1432 return XML_STATUS_ERROR; | |
| 1433 default: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1434 ps_parsing = XML_PARSING; |
| 32911 | 1435 } |
| 1436 | |
| 21930 | 1437 if (len == 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1438 ps_finalBuffer = (XML_Bool)isFinal; |
| 21930 | 1439 if (!isFinal) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1440 return XML_STATUS_OK; |
| 21930 | 1441 positionPtr = bufferPtr; |
| 32911 | 1442 parseEndPtr = bufferEnd; |
| 1443 | |
| 1444 /* If data are left over from last buffer, and we now know that these | |
| 1445 data are the final chunk of input, then we have to check them again | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1446 to detect errors based on that fact. |
| 32911 | 1447 */ |
| 1448 errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | |
| 1449 | |
| 1450 if (errorCode == XML_ERROR_NONE) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1451 switch (ps_parsing) { |
| 32911 | 1452 case XML_SUSPENDED: |
| 1453 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1454 positionPtr = bufferPtr; | |
| 1455 return XML_STATUS_SUSPENDED; | |
| 1456 case XML_INITIALIZED: | |
| 1457 case XML_PARSING: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1458 ps_parsing = XML_FINISHED; |
| 32911 | 1459 /* fall through */ |
| 1460 default: | |
| 1461 return XML_STATUS_OK; | |
| 1462 } | |
| 1463 } | |
| 21930 | 1464 eventEndPtr = eventPtr; |
| 1465 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1466 return XML_STATUS_ERROR; |
| 21930 | 1467 } |
| 1468 #ifndef XML_CONTEXT_BYTES | |
| 1469 else if (bufferPtr == bufferEnd) { | |
| 1470 const char *end; | |
| 1471 int nLeftOver; | |
| 32911 | 1472 enum XML_Error result; |
| 21930 | 1473 parseEndByteIndex += len; |
| 1474 positionPtr = s; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1475 ps_finalBuffer = (XML_Bool)isFinal; |
| 32911 | 1476 |
| 21930 | 1477 errorCode = processor(parser, s, parseEndPtr = s + len, &end); |
| 32911 | 1478 |
| 21930 | 1479 if (errorCode != XML_ERROR_NONE) { |
| 1480 eventEndPtr = eventPtr; | |
| 1481 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1482 return XML_STATUS_ERROR; |
| 21930 | 1483 } |
| 32911 | 1484 else { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1485 switch (ps_parsing) { |
| 32911 | 1486 case XML_SUSPENDED: |
| 1487 result = XML_STATUS_SUSPENDED; | |
| 1488 break; | |
| 1489 case XML_INITIALIZED: | |
| 1490 case XML_PARSING: | |
| 1491 result = XML_STATUS_OK; | |
| 1492 if (isFinal) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1493 ps_parsing = XML_FINISHED; |
| 32911 | 1494 return result; |
| 1495 } | |
| 1496 } | |
| 1497 } | |
| 1498 | |
| 21930 | 1499 XmlUpdatePosition(encoding, positionPtr, end, &position); |
| 1500 nLeftOver = s + len - end; | |
| 1501 if (nLeftOver) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1502 if (buffer == NULL || nLeftOver > bufferLim - buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1503 /* FIXME avoid integer overflow */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1504 char *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1505 temp = (buffer == NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1506 ? (char *)MALLOC(len * 2) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1507 : (char *)REALLOC(buffer, len * 2)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1508 if (temp == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1509 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1510 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1511 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1512 buffer = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1513 if (!buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1514 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1515 eventPtr = eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1516 processor = errorProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1517 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1518 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1519 bufferLim = buffer + len * 2; |
| 21930 | 1520 } |
| 1521 memcpy(buffer, end, nLeftOver); | |
| 1522 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1523 bufferPtr = buffer; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1524 bufferEnd = buffer + nLeftOver; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1525 positionPtr = bufferPtr; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1526 parseEndPtr = bufferEnd; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1527 eventPtr = bufferPtr; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1528 eventEndPtr = bufferPtr; |
| 32911 | 1529 return result; |
| 21930 | 1530 } |
| 1531 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1532 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1533 void *buff = XML_GetBuffer(parser, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1534 if (buff == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1535 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1536 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1537 memcpy(buff, s, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1538 return XML_ParseBuffer(parser, len, isFinal); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1539 } |
| 21930 | 1540 } |
| 1541 } | |
| 1542 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1543 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1544 XML_ParseBuffer(XML_Parser parser, int len, int isFinal) |
| 21930 | 1545 { |
| 32911 | 1546 const char *start; |
|
36223
cf69e3191218
Fix icc warnings: using wrong enum type
Neal Norwitz <nnorwitz@gmail.com>
parents:
32911
diff
changeset
|
1547 enum XML_Status result = XML_STATUS_OK; |
| 32911 | 1548 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1549 switch (ps_parsing) { |
| 32911 | 1550 case XML_SUSPENDED: |
| 1551 errorCode = XML_ERROR_SUSPENDED; | |
| 1552 return XML_STATUS_ERROR; | |
| 1553 case XML_FINISHED: | |
| 1554 errorCode = XML_ERROR_FINISHED; | |
| 1555 return XML_STATUS_ERROR; | |
| 1556 default: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1557 ps_parsing = XML_PARSING; |
| 32911 | 1558 } |
| 1559 | |
| 1560 start = bufferPtr; | |
| 21930 | 1561 positionPtr = start; |
| 1562 bufferEnd += len; | |
| 32911 | 1563 parseEndPtr = bufferEnd; |
| 21930 | 1564 parseEndByteIndex += len; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1565 ps_finalBuffer = (XML_Bool)isFinal; |
| 32911 | 1566 |
| 1567 errorCode = processor(parser, start, parseEndPtr, &bufferPtr); | |
| 1568 | |
| 1569 if (errorCode != XML_ERROR_NONE) { | |
| 21930 | 1570 eventEndPtr = eventPtr; |
| 1571 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1572 return XML_STATUS_ERROR; |
| 21930 | 1573 } |
| 32911 | 1574 else { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1575 switch (ps_parsing) { |
| 32911 | 1576 case XML_SUSPENDED: |
| 1577 result = XML_STATUS_SUSPENDED; | |
| 1578 break; | |
| 1579 case XML_INITIALIZED: | |
| 1580 case XML_PARSING: | |
| 1581 if (isFinal) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1582 ps_parsing = XML_FINISHED; |
| 32911 | 1583 return result; |
| 1584 } | |
| 1585 default: ; /* should not happen */ | |
| 1586 } | |
| 1587 } | |
| 1588 | |
| 1589 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1590 positionPtr = bufferPtr; | |
| 1591 return result; | |
| 21930 | 1592 } |
| 1593 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1594 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1595 XML_GetBuffer(XML_Parser parser, int len) |
| 21930 | 1596 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1597 switch (ps_parsing) { |
| 32911 | 1598 case XML_SUSPENDED: |
| 1599 errorCode = XML_ERROR_SUSPENDED; | |
| 1600 return NULL; | |
| 1601 case XML_FINISHED: | |
| 1602 errorCode = XML_ERROR_FINISHED; | |
| 1603 return NULL; | |
| 1604 default: ; | |
| 1605 } | |
| 1606 | |
| 21930 | 1607 if (len > bufferLim - bufferEnd) { |
| 1608 /* FIXME avoid integer overflow */ | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1609 int neededSize = len + (int)(bufferEnd - bufferPtr); |
| 21930 | 1610 #ifdef XML_CONTEXT_BYTES |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1611 int keep = (int)(bufferPtr - buffer); |
| 21930 | 1612 |
| 1613 if (keep > XML_CONTEXT_BYTES) | |
| 1614 keep = XML_CONTEXT_BYTES; | |
| 1615 neededSize += keep; | |
| 1616 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1617 if (neededSize <= bufferLim - buffer) { | |
| 1618 #ifdef XML_CONTEXT_BYTES | |
| 1619 if (keep < bufferPtr - buffer) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1620 int offset = (int)(bufferPtr - buffer) - keep; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1621 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
|
1622 bufferEnd -= offset; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1623 bufferPtr -= offset; |
| 21930 | 1624 } |
| 1625 #else | |
| 1626 memmove(buffer, bufferPtr, bufferEnd - bufferPtr); | |
| 1627 bufferEnd = buffer + (bufferEnd - bufferPtr); | |
| 1628 bufferPtr = buffer; | |
| 1629 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1630 } | |
| 1631 else { | |
| 1632 char *newBuf; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1633 int bufferSize = (int)(bufferLim - bufferPtr); |
| 21930 | 1634 if (bufferSize == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1635 bufferSize = INIT_BUFFER_SIZE; |
| 21930 | 1636 do { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1637 bufferSize *= 2; |
| 21930 | 1638 } while (bufferSize < neededSize); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1639 newBuf = (char *)MALLOC(bufferSize); |
| 21930 | 1640 if (newBuf == 0) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1641 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1642 return NULL; |
| 21930 | 1643 } |
| 1644 bufferLim = newBuf + bufferSize; | |
| 1645 #ifdef XML_CONTEXT_BYTES | |
| 1646 if (bufferPtr) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1647 int keep = (int)(bufferPtr - buffer); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1648 if (keep > XML_CONTEXT_BYTES) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1649 keep = XML_CONTEXT_BYTES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1650 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
|
1651 FREE(buffer); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1652 buffer = newBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1653 bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1654 bufferPtr = buffer + keep; |
| 21930 | 1655 } |
| 1656 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1657 bufferEnd = newBuf + (bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1658 bufferPtr = buffer = newBuf; |
| 21930 | 1659 } |
| 1660 #else | |
| 1661 if (bufferPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1662 memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1663 FREE(buffer); |
| 21930 | 1664 } |
| 1665 bufferEnd = newBuf + (bufferEnd - bufferPtr); | |
| 1666 bufferPtr = buffer = newBuf; | |
| 1667 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1668 } | |
| 1669 } | |
| 1670 return bufferEnd; | |
| 1671 } | |
| 1672 | |
| 32911 | 1673 enum XML_Status XMLCALL |
| 1674 XML_StopParser(XML_Parser parser, XML_Bool resumable) | |
| 1675 { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1676 switch (ps_parsing) { |
| 32911 | 1677 case XML_SUSPENDED: |
| 1678 if (resumable) { | |
| 1679 errorCode = XML_ERROR_SUSPENDED; | |
| 1680 return XML_STATUS_ERROR; | |
| 1681 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1682 ps_parsing = XML_FINISHED; |
| 32911 | 1683 break; |
| 1684 case XML_FINISHED: | |
| 1685 errorCode = XML_ERROR_FINISHED; | |
| 1686 return XML_STATUS_ERROR; | |
| 1687 default: | |
| 1688 if (resumable) { | |
| 1689 #ifdef XML_DTD | |
| 1690 if (isParamEntity) { | |
| 1691 errorCode = XML_ERROR_SUSPEND_PE; | |
| 1692 return XML_STATUS_ERROR; | |
| 1693 } | |
| 1694 #endif | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1695 ps_parsing = XML_SUSPENDED; |
| 32911 | 1696 } |
| 1697 else | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1698 ps_parsing = XML_FINISHED; |
| 32911 | 1699 } |
| 1700 return XML_STATUS_OK; | |
| 1701 } | |
| 1702 | |
| 1703 enum XML_Status XMLCALL | |
| 1704 XML_ResumeParser(XML_Parser parser) | |
| 1705 { | |
|
36223
cf69e3191218
Fix icc warnings: using wrong enum type
Neal Norwitz <nnorwitz@gmail.com>
parents:
32911
diff
changeset
|
1706 enum XML_Status result = XML_STATUS_OK; |
| 32911 | 1707 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1708 if (ps_parsing != XML_SUSPENDED) { |
| 32911 | 1709 errorCode = XML_ERROR_NOT_SUSPENDED; |
| 1710 return XML_STATUS_ERROR; | |
| 1711 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1712 ps_parsing = XML_PARSING; |
| 32911 | 1713 |
| 1714 errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | |
| 1715 | |
| 1716 if (errorCode != XML_ERROR_NONE) { | |
| 1717 eventEndPtr = eventPtr; | |
| 1718 processor = errorProcessor; | |
| 1719 return XML_STATUS_ERROR; | |
| 1720 } | |
| 1721 else { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1722 switch (ps_parsing) { |
| 32911 | 1723 case XML_SUSPENDED: |
| 1724 result = XML_STATUS_SUSPENDED; | |
| 1725 break; | |
| 1726 case XML_INITIALIZED: | |
| 1727 case XML_PARSING: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1728 if (ps_finalBuffer) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1729 ps_parsing = XML_FINISHED; |
| 32911 | 1730 return result; |
| 1731 } | |
| 1732 default: ; | |
| 1733 } | |
| 1734 } | |
| 1735 | |
| 1736 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1737 positionPtr = bufferPtr; | |
| 1738 return result; | |
| 1739 } | |
| 1740 | |
| 1741 void XMLCALL | |
| 1742 XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) | |
| 1743 { | |
| 1744 assert(status != NULL); | |
| 1745 *status = parser->m_parsingStatus; | |
| 1746 } | |
| 1747 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1748 enum XML_Error XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1749 XML_GetErrorCode(XML_Parser parser) |
| 21930 | 1750 { |
| 1751 return errorCode; | |
| 1752 } | |
| 1753 | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1754 XML_Index XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1755 XML_GetCurrentByteIndex(XML_Parser parser) |
| 21930 | 1756 { |
| 1757 if (eventPtr) | |
| 1758 return parseEndByteIndex - (parseEndPtr - eventPtr); | |
| 1759 return -1; | |
| 1760 } | |
| 1761 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1762 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1763 XML_GetCurrentByteCount(XML_Parser parser) |
| 21930 | 1764 { |
| 1765 if (eventEndPtr && eventPtr) | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1766 return (int)(eventEndPtr - eventPtr); |
| 21930 | 1767 return 0; |
| 1768 } | |
| 1769 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1770 const char * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1771 XML_GetInputContext(XML_Parser parser, int *offset, int *size) |
| 21930 | 1772 { |
| 1773 #ifdef XML_CONTEXT_BYTES | |
| 1774 if (eventPtr && buffer) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1775 *offset = (int)(eventPtr - buffer); |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1776 *size = (int)(bufferEnd - buffer); |
| 21930 | 1777 return buffer; |
| 1778 } | |
| 1779 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1780 return (char *) 0; | |
| 1781 } | |
| 1782 | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1783 XML_Size XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1784 XML_GetCurrentLineNumber(XML_Parser parser) |
| 21930 | 1785 { |
| 32911 | 1786 if (eventPtr && eventPtr >= positionPtr) { |
| 21930 | 1787 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); |
| 1788 positionPtr = eventPtr; | |
| 1789 } | |
| 1790 return position.lineNumber + 1; | |
| 1791 } | |
| 1792 | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1793 XML_Size XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1794 XML_GetCurrentColumnNumber(XML_Parser parser) |
| 21930 | 1795 { |
| 32911 | 1796 if (eventPtr && eventPtr >= positionPtr) { |
| 21930 | 1797 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); |
| 1798 positionPtr = eventPtr; | |
| 1799 } | |
| 1800 return position.columnNumber; | |
| 1801 } | |
| 1802 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1803 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1804 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
|
1805 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1806 FREE(model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1807 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1808 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1809 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1810 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
|
1811 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1812 return MALLOC(size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1813 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1814 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1815 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1816 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
|
1817 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1818 return REALLOC(ptr, size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1819 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1820 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1821 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1822 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
|
1823 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1824 FREE(ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1825 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1826 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1827 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1828 XML_DefaultCurrent(XML_Parser parser) |
| 21930 | 1829 { |
| 1830 if (defaultHandler) { | |
| 1831 if (openInternalEntities) | |
| 1832 reportDefault(parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1833 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1834 openInternalEntities->internalEventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1835 openInternalEntities->internalEventEndPtr); |
| 21930 | 1836 else |
| 1837 reportDefault(parser, encoding, eventPtr, eventEndPtr); | |
| 1838 } | |
| 1839 } | |
| 1840 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1841 const XML_LChar * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1842 XML_ErrorString(enum XML_Error code) |
| 21930 | 1843 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1844 static const XML_LChar* const message[] = { |
| 21930 | 1845 0, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1846 XML_L("out of memory"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1847 XML_L("syntax error"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1848 XML_L("no element found"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1849 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
|
1850 XML_L("unclosed token"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1851 XML_L("partial character"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1852 XML_L("mismatched tag"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1853 XML_L("duplicate attribute"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1854 XML_L("junk after document element"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1855 XML_L("illegal parameter entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1856 XML_L("undefined entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1857 XML_L("recursive entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1858 XML_L("asynchronous entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1859 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
|
1860 XML_L("reference to binary entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1861 XML_L("reference to external entity in attribute"), |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1862 XML_L("XML or text declaration not at start of entity"), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1863 XML_L("unknown encoding"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1864 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
|
1865 XML_L("unclosed CDATA section"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1866 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
|
1867 XML_L("document is not standalone"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1868 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
|
1869 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
|
1870 XML_L("requested feature requires XML_DTD support in Expat"), |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1871 XML_L("cannot change setting once parsing has begun"), |
| 32911 | 1872 XML_L("unbound prefix"), |
| 1873 XML_L("must not undeclare prefix"), | |
| 1874 XML_L("incomplete markup in parameter entity"), | |
| 1875 XML_L("XML declaration not well-formed"), | |
| 1876 XML_L("text declaration not well-formed"), | |
| 1877 XML_L("illegal character(s) in public id"), | |
| 1878 XML_L("parser suspended"), | |
| 1879 XML_L("parser not suspended"), | |
| 1880 XML_L("parsing aborted"), | |
| 1881 XML_L("parsing finished"), | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1882 XML_L("cannot suspend in external parameter entity"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1883 XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1884 XML_L("reserved prefix (xmlns) must not be declared or undeclared"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1885 XML_L("prefix must not be bound to one of the reserved namespace names") |
| 21930 | 1886 }; |
| 1887 if (code > 0 && code < sizeof(message)/sizeof(message[0])) | |
| 1888 return message[code]; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1889 return NULL; |
| 21930 | 1890 } |
| 1891 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1892 const XML_LChar * XMLCALL |
| 21930 | 1893 XML_ExpatVersion(void) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1894 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1895 /* 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
|
1896 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
|
1897 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
|
1898 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
|
1899 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
|
1900 with the correct numerals. */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1901 /* ### 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
|
1902 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1903 #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
|
1904 #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
|
1905 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1906 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
|
1907 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1908 #undef V1 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1909 #undef V2 |
| 21930 | 1910 } |
| 1911 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1912 XML_Expat_Version XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1913 XML_ExpatVersionInfo(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1914 { |
| 21930 | 1915 XML_Expat_Version version; |
| 1916 | |
| 1917 version.major = XML_MAJOR_VERSION; | |
| 1918 version.minor = XML_MINOR_VERSION; | |
| 1919 version.micro = XML_MICRO_VERSION; | |
| 1920 | |
| 1921 return version; | |
| 1922 } | |
| 1923 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1924 const XML_Feature * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1925 XML_GetFeatureList(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1926 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1927 static const XML_Feature features[] = { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1928 {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1929 sizeof(XML_Char)}, |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1930 {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1931 sizeof(XML_LChar)}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1932 #ifdef XML_UNICODE |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1933 {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1934 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1935 #ifdef XML_UNICODE_WCHAR_T |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1936 {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1937 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1938 #ifdef XML_DTD |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1939 {XML_FEATURE_DTD, XML_L("XML_DTD"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1940 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1941 #ifdef XML_CONTEXT_BYTES |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1942 {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
|
1943 XML_CONTEXT_BYTES}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1944 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1945 #ifdef XML_MIN_SIZE |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1946 {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1947 #endif |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1948 #ifdef XML_NS |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1949 {XML_FEATURE_NS, XML_L("XML_NS"), 0}, |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1950 #endif |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1951 {XML_FEATURE_END, NULL, 0} |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1952 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1953 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1954 return features; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1955 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1956 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1957 /* 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
|
1958 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
|
1959 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
|
1960 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
|
1961 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1962 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1963 storeRawNames(XML_Parser parser) |
| 21930 | 1964 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1965 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1966 while (tag) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1967 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1968 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
|
1969 char *rawNameBuf = tag->buf + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1970 /* 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
|
1971 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
|
1972 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
|
1973 previous call to this function. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1974 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1975 if (tag->rawName == rawNameBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1976 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1977 /* 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
|
1978 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
|
1979 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1980 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
|
1981 if (bufSize > tag->bufEnd - tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1982 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
|
1983 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1984 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1985 /* 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
|
1986 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
|
1987 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1988 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
|
1989 tag->name.str = (XML_Char *)temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1990 /* 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
|
1991 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
|
1992 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1993 if (tag->name.localPart) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1994 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
|
1995 (XML_Char *)tag->buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1996 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1997 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1998 rawNameBuf = temp + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1999 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2000 memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2001 tag->rawName = rawNameBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2002 tag = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2003 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2004 return XML_TRUE; |
| 21930 | 2005 } |
| 2006 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2007 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2008 contentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2009 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2010 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2011 const char **endPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2012 { |
| 32911 | 2013 enum XML_Error result = doContent(parser, 0, encoding, start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2014 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 2015 if (result == XML_ERROR_NONE) { |
| 2016 if (!storeRawNames(parser)) | |
| 2017 return XML_ERROR_NO_MEMORY; | |
| 2018 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2019 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2020 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2021 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2022 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2023 externalEntityInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2024 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2025 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2026 const char **endPtr) |
| 21930 | 2027 { |
| 2028 enum XML_Error result = initializeEncoding(parser); | |
| 2029 if (result != XML_ERROR_NONE) | |
| 2030 return result; | |
| 2031 processor = externalEntityInitProcessor2; | |
| 2032 return externalEntityInitProcessor2(parser, start, end, endPtr); | |
| 2033 } | |
| 2034 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2035 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2036 externalEntityInitProcessor2(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2037 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2038 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2039 const char **endPtr) |
| 21930 | 2040 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2041 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 21930 | 2042 int tok = XmlContentTok(encoding, start, end, &next); |
| 2043 switch (tok) { | |
| 2044 case XML_TOK_BOM: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2045 /* 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
|
2046 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
|
2047 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
|
2048 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
|
2049 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2050 if (next == end && !ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2051 *endPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2052 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2053 } |
| 21930 | 2054 start = next; |
| 2055 break; | |
| 2056 case XML_TOK_PARTIAL: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2057 if (!ps_finalBuffer) { |
| 21930 | 2058 *endPtr = start; |
| 2059 return XML_ERROR_NONE; | |
| 2060 } | |
| 2061 eventPtr = start; | |
| 2062 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2063 case XML_TOK_PARTIAL_CHAR: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2064 if (!ps_finalBuffer) { |
| 21930 | 2065 *endPtr = start; |
| 2066 return XML_ERROR_NONE; | |
| 2067 } | |
| 2068 eventPtr = start; | |
| 2069 return XML_ERROR_PARTIAL_CHAR; | |
| 2070 } | |
| 2071 processor = externalEntityInitProcessor3; | |
| 2072 return externalEntityInitProcessor3(parser, start, end, endPtr); | |
| 2073 } | |
| 2074 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2075 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2076 externalEntityInitProcessor3(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2077 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2078 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2079 const char **endPtr) |
| 21930 | 2080 { |
| 32911 | 2081 int tok; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2082 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 32911 | 2083 eventPtr = start; |
| 2084 tok = XmlContentTok(encoding, start, end, &next); | |
| 2085 eventEndPtr = next; | |
| 2086 | |
| 21930 | 2087 switch (tok) { |
| 2088 case XML_TOK_XML_DECL: | |
| 2089 { | |
| 32911 | 2090 enum XML_Error result; |
| 2091 result = processXmlDecl(parser, 1, start, next); | |
| 21930 | 2092 if (result != XML_ERROR_NONE) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2093 return result; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2094 switch (ps_parsing) { |
| 32911 | 2095 case XML_SUSPENDED: |
| 2096 *endPtr = next; | |
| 2097 return XML_ERROR_NONE; | |
| 2098 case XML_FINISHED: | |
| 2099 return XML_ERROR_ABORTED; | |
| 2100 default: | |
| 2101 start = next; | |
| 2102 } | |
| 21930 | 2103 } |
| 2104 break; | |
| 2105 case XML_TOK_PARTIAL: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2106 if (!ps_finalBuffer) { |
| 21930 | 2107 *endPtr = start; |
| 2108 return XML_ERROR_NONE; | |
| 2109 } | |
| 2110 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2111 case XML_TOK_PARTIAL_CHAR: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2112 if (!ps_finalBuffer) { |
| 21930 | 2113 *endPtr = start; |
| 2114 return XML_ERROR_NONE; | |
| 2115 } | |
| 2116 return XML_ERROR_PARTIAL_CHAR; | |
| 2117 } | |
| 2118 processor = externalEntityContentProcessor; | |
| 2119 tagLevel = 1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2120 return externalEntityContentProcessor(parser, start, end, endPtr); |
| 21930 | 2121 } |
| 2122 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2123 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2124 externalEntityContentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2125 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2126 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2127 const char **endPtr) |
| 21930 | 2128 { |
| 32911 | 2129 enum XML_Error result = doContent(parser, 1, encoding, start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2130 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 2131 if (result == XML_ERROR_NONE) { |
| 2132 if (!storeRawNames(parser)) | |
| 2133 return XML_ERROR_NO_MEMORY; | |
| 2134 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2135 return result; |
| 21930 | 2136 } |
| 2137 | |
| 2138 static enum XML_Error | |
| 2139 doContent(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2140 int startTagLevel, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2141 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2142 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2143 const char *end, |
| 32911 | 2144 const char **nextPtr, |
| 2145 XML_Bool haveMore) | |
| 21930 | 2146 { |
| 32911 | 2147 /* save one level of indirection */ |
| 2148 DTD * const dtd = _dtd; | |
| 2149 | |
| 21930 | 2150 const char **eventPP; |
| 2151 const char **eventEndPP; | |
| 2152 if (enc == encoding) { | |
| 2153 eventPP = &eventPtr; | |
| 2154 eventEndPP = &eventEndPtr; | |
| 2155 } | |
| 2156 else { | |
| 2157 eventPP = &(openInternalEntities->internalEventPtr); | |
| 2158 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 2159 } | |
| 2160 *eventPP = s; | |
| 32911 | 2161 |
| 21930 | 2162 for (;;) { |
| 2163 const char *next = s; /* XmlContentTok doesn't always set the last arg */ | |
| 2164 int tok = XmlContentTok(enc, s, end, &next); | |
| 2165 *eventEndPP = next; | |
| 2166 switch (tok) { | |
| 2167 case XML_TOK_TRAILING_CR: | |
| 32911 | 2168 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2169 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2170 return XML_ERROR_NONE; |
| 21930 | 2171 } |
| 2172 *eventEndPP = end; | |
| 2173 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2174 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2175 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2176 } |
| 2177 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2178 reportDefault(parser, enc, s, end); |
| 32911 | 2179 /* We are at the end of the final buffer, should we check for |
| 2180 XML_SUSPENDED, XML_FINISHED? | |
| 2181 */ | |
| 21930 | 2182 if (startTagLevel == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2183 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2184 if (tagLevel != startTagLevel) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2185 return XML_ERROR_ASYNC_ENTITY; |
| 32911 | 2186 *nextPtr = end; |
| 21930 | 2187 return XML_ERROR_NONE; |
| 2188 case XML_TOK_NONE: | |
| 32911 | 2189 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2190 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2191 return XML_ERROR_NONE; |
| 21930 | 2192 } |
| 2193 if (startTagLevel > 0) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2194 if (tagLevel != startTagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2195 return XML_ERROR_ASYNC_ENTITY; |
| 32911 | 2196 *nextPtr = s; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2197 return XML_ERROR_NONE; |
| 21930 | 2198 } |
| 2199 return XML_ERROR_NO_ELEMENTS; | |
| 2200 case XML_TOK_INVALID: | |
| 2201 *eventPP = next; | |
| 2202 return XML_ERROR_INVALID_TOKEN; | |
| 2203 case XML_TOK_PARTIAL: | |
| 32911 | 2204 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2205 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2206 return XML_ERROR_NONE; |
| 21930 | 2207 } |
| 2208 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2209 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 2210 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2211 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2212 return XML_ERROR_NONE; |
| 21930 | 2213 } |
| 2214 return XML_ERROR_PARTIAL_CHAR; | |
| 2215 case XML_TOK_ENTITY_REF: | |
| 2216 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2217 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2218 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2219 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
|
2220 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2221 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2222 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2223 if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2224 characterDataHandler(handlerArg, &ch, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2225 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2226 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2227 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2228 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2229 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2230 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2231 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2232 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2233 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2234 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
|
2235 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2236 /* 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
|
2237 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
|
2238 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
|
2239 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2240 if (!dtd->hasParamEntityRefs || dtd->standalone) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2241 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2242 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2243 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2244 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
|
2245 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2246 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2247 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2248 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2249 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2250 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2251 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2252 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2253 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2254 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2255 if (entity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2256 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2257 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2258 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2259 if (!defaultExpandInternalEntities) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2260 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2261 skippedEntityHandler(handlerArg, entity->name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2262 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2263 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2264 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2265 } |
| 32911 | 2266 result = processInternalEntity(parser, entity, XML_FALSE); |
| 2267 if (result != XML_ERROR_NONE) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2268 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2269 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2270 else if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2271 const XML_Char *context; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2272 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2273 context = getContext(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2274 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2275 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2276 return XML_ERROR_NO_MEMORY; |
| 32911 | 2277 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2278 context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2279 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2280 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2281 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2282 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2283 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2284 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2285 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2286 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2287 break; |
| 21930 | 2288 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2289 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
|
2290 /* fall through */ |
| 21930 | 2291 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
|
2292 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2293 TAG *tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2294 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2295 XML_Char *toPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2296 if (freeTagList) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2297 tag = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2298 freeTagList = freeTagList->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2299 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2300 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2301 tag = (TAG *)MALLOC(sizeof(TAG)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2302 if (!tag) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2303 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2304 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
|
2305 if (!tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2306 FREE(tag); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2307 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2308 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2309 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
|
2310 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2311 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2312 tag->parent = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2313 tagStack = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2314 tag->name.localPart = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2315 tag->name.prefix = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2316 tag->rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2317 tag->rawNameLength = XmlNameLength(enc, tag->rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2318 ++tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2319 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2320 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
|
2321 const char *fromPtr = tag->rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2322 toPtr = (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2323 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2324 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2325 int convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2326 XmlConvert(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2327 &fromPtr, rawNameEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2328 (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2329 convLen = (int)(toPtr - (XML_Char *)tag->buf); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2330 if (fromPtr == rawNameEnd) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2331 tag->name.strLen = convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2332 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2333 } |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2334 bufSize = (int)(tag->bufEnd - tag->buf) << 1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2335 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2336 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
|
2337 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2338 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2339 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2340 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2341 toPtr = (XML_Char *)temp + convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2342 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2343 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2344 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2345 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
|
2346 *toPtr = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2347 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
|
2348 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2349 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2350 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2351 startElementHandler(handlerArg, tag->name.str, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2352 (const XML_Char **)atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2353 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2354 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2355 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2356 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2357 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2358 case XML_TOK_EMPTY_ELEMENT_NO_ATTS: |
| 21930 | 2359 /* fall through */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2360 case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: |
| 21930 | 2361 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2362 const char *rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2363 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2364 BINDING *bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2365 XML_Bool noElmHandlers = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2366 TAG_NAME name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2367 name.str = poolStoreString(&tempPool, enc, rawName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2368 rawName + XmlNameLength(enc, rawName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2369 if (!name.str) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2370 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2371 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
|
2372 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
|
2373 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2374 return result; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2375 poolFinish(&tempPool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2376 if (startElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2377 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
|
2378 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2379 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2380 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2381 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2382 *eventPP = *eventEndPP; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2383 endElementHandler(handlerArg, name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2384 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2385 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2386 if (noElmHandlers && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2387 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2388 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2389 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2390 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2391 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2392 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2393 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2394 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2395 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2396 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2397 } |
| 21930 | 2398 } |
| 2399 if (tagLevel == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2400 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2401 break; |
| 2402 case XML_TOK_END_TAG: | |
| 2403 if (tagLevel == startTagLevel) | |
| 2404 return XML_ERROR_ASYNC_ENTITY; | |
| 2405 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2406 int len; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2407 const char *rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2408 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2409 tagStack = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2410 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2411 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2412 rawName = s + enc->minBytesPerChar*2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2413 len = XmlNameLength(enc, rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2414 if (len != tag->rawNameLength |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2415 || memcmp(tag->rawName, rawName, len) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2416 *eventPP = rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2417 return XML_ERROR_TAG_MISMATCH; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2418 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2419 --tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2420 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2421 const XML_Char *localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2422 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2423 XML_Char *uri; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2424 localPart = tag->name.localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2425 if (ns && localPart) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2426 /* 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
|
2427 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
|
2428 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
|
2429 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2430 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
|
2431 /* 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
|
2432 while (*localPart) *uri++ = *localPart++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2433 prefix = (XML_Char *)tag->name.prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2434 if (ns_triplets && prefix) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2435 *uri++ = namespaceSeparator; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2436 while (*prefix) *uri++ = *prefix++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2437 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2438 *uri = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2439 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2440 endElementHandler(handlerArg, tag->name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2441 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2442 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2443 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2444 while (tag->bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2445 BINDING *b = tag->bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2446 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2447 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2448 tag->bindings = tag->bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2449 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2450 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2451 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2452 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2453 if (tagLevel == 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2454 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2455 } |
| 2456 break; | |
| 2457 case XML_TOK_CHAR_REF: | |
| 2458 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2459 int n = XmlCharRefNumber(enc, s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2460 if (n < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2461 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2462 if (characterDataHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2463 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2464 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
|
2465 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2466 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2467 reportDefault(parser, enc, s, next); |
| 21930 | 2468 } |
| 2469 break; | |
| 2470 case XML_TOK_XML_DECL: | |
| 2471 return XML_ERROR_MISPLACED_XML_PI; | |
| 2472 case XML_TOK_DATA_NEWLINE: | |
| 2473 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2474 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2475 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2476 } |
| 2477 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2478 reportDefault(parser, enc, s, next); |
| 21930 | 2479 break; |
| 2480 case XML_TOK_CDATA_SECT_OPEN: | |
| 2481 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2482 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2483 if (startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2484 startCdataSectionHandler(handlerArg); |
| 21930 | 2485 #if 0 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2486 /* 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
|
2487 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
|
2488 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
|
2489 characters through. The characterDataHandler does the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2490 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
|
2491 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
|
2492 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
|
2493 be incorrectly escaped). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2494 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2495 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
|
2496 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
|
2497 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2498 else if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2499 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 2500 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2501 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2502 reportDefault(parser, enc, s, next); |
| 32911 | 2503 result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); |
| 2504 if (result != XML_ERROR_NONE) | |
| 2505 return result; | |
| 2506 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2507 processor = cdataSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2508 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2509 } |
| 21930 | 2510 } |
| 2511 break; | |
| 2512 case XML_TOK_TRAILING_RSQB: | |
| 32911 | 2513 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2514 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2515 return XML_ERROR_NONE; |
| 21930 | 2516 } |
| 2517 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2518 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2519 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2520 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
|
2521 characterDataHandler(handlerArg, dataBuf, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2522 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2523 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2524 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2525 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2526 (XML_Char *)s, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2527 (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 2528 } |
| 2529 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2530 reportDefault(parser, enc, s, end); |
| 32911 | 2531 /* We are at the end of the final buffer, should we check for |
| 2532 XML_SUSPENDED, XML_FINISHED? | |
| 2533 */ | |
| 21930 | 2534 if (startTagLevel == 0) { |
| 2535 *eventPP = end; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2536 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2537 } |
| 2538 if (tagLevel != startTagLevel) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2539 *eventPP = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2540 return XML_ERROR_ASYNC_ENTITY; |
| 21930 | 2541 } |
| 32911 | 2542 *nextPtr = end; |
| 21930 | 2543 return XML_ERROR_NONE; |
| 2544 case XML_TOK_DATA_CHARS: | |
| 2545 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2546 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2547 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2548 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2549 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
|
2550 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2551 characterDataHandler(handlerArg, dataBuf, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2552 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2553 if (s == next) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2554 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2555 *eventPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2556 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2557 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2558 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2559 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2560 (XML_Char *)s, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2561 (int)((XML_Char *)next - (XML_Char *)s)); |
| 21930 | 2562 } |
| 2563 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2564 reportDefault(parser, enc, s, next); |
| 21930 | 2565 break; |
| 2566 case XML_TOK_PI: | |
| 2567 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
|
2568 return XML_ERROR_NO_MEMORY; |
| 21930 | 2569 break; |
| 2570 case XML_TOK_COMMENT: | |
| 2571 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
|
2572 return XML_ERROR_NO_MEMORY; |
| 21930 | 2573 break; |
| 2574 default: | |
| 2575 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2576 reportDefault(parser, enc, s, next); |
| 21930 | 2577 break; |
| 2578 } | |
| 2579 *eventPP = s = next; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2580 switch (ps_parsing) { |
| 32911 | 2581 case XML_SUSPENDED: |
| 2582 *nextPtr = next; | |
| 2583 return XML_ERROR_NONE; | |
| 2584 case XML_FINISHED: | |
| 2585 return XML_ERROR_ABORTED; | |
| 2586 default: ; | |
| 2587 } | |
| 21930 | 2588 } |
| 2589 /* not reached */ | |
| 2590 } | |
| 2591 | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2592 /* 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
|
2593 Purpose: |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2594 - normalize attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2595 - 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
|
2596 - 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
|
2597 - 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
|
2598 - default attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2599 - 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
|
2600 - 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
|
2601 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2602 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2603 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
|
2604 const char *attStr, TAG_NAME *tagNamePtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2605 BINDING **bindingsPtr) |
| 21930 | 2606 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2607 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2608 ELEMENT_TYPE *elementType; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2609 int nDefaultAtts; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2610 const XML_Char **appAtts; /* the attribute list for the application */ |
| 21930 | 2611 int attIndex = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2612 int prefixLen; |
| 21930 | 2613 int i; |
| 2614 int n; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2615 XML_Char *uri; |
| 21930 | 2616 int nPrefixes = 0; |
| 2617 BINDING *binding; | |
| 2618 const XML_Char *localPart; | |
| 2619 | |
| 2620 /* 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
|
2621 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
|
2622 if (!elementType) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2623 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
|
2624 if (!name) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2625 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
|
2626 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
|
2627 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
|
2628 if (!elementType) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2629 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
|
2630 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
|
2631 return XML_ERROR_NO_MEMORY; |
| 21930 | 2632 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2633 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
|
2634 |
| 21930 | 2635 /* get the attributes from the tokenizer */ |
| 2636 n = XmlGetAttributes(enc, attStr, attsSize, atts); | |
| 2637 if (n + nDefaultAtts > attsSize) { | |
| 2638 int oldAttsSize = attsSize; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2639 ATTRIBUTE *temp; |
| 21930 | 2640 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
|
2641 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
|
2642 if (temp == NULL) |
| 21930 | 2643 return XML_ERROR_NO_MEMORY; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2644 atts = temp; |
| 21930 | 2645 if (n > oldAttsSize) |
| 2646 XmlGetAttributes(enc, attStr, n, atts); | |
| 2647 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2648 |
| 21930 | 2649 appAtts = (const XML_Char **)atts; |
| 2650 for (i = 0; i < n; i++) { | |
| 2651 /* add the name and value to the attribute list */ | |
| 2652 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
|
2653 atts[i].name |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2654 + XmlNameLength(enc, atts[i].name)); |
| 21930 | 2655 if (!attId) |
| 2656 return XML_ERROR_NO_MEMORY; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2657 /* Detect duplicate attributes by their QNames. This does not work when |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2658 namespace processing is turned on and different prefixes for the same |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2659 namespace are used. For this case we have a check further down. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2660 */ |
| 21930 | 2661 if ((attId->name)[-1]) { |
| 2662 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2663 eventPtr = atts[i].name; |
| 21930 | 2664 return XML_ERROR_DUPLICATE_ATTRIBUTE; |
| 2665 } | |
| 2666 (attId->name)[-1] = 1; | |
| 2667 appAtts[attIndex++] = attId->name; | |
| 2668 if (!atts[i].normalized) { | |
| 2669 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2670 XML_Bool isCdata = XML_TRUE; |
| 21930 | 2671 |
| 2672 /* figure out whether declared as other than CDATA */ | |
| 2673 if (attId->maybeTokenized) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2674 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2675 for (j = 0; j < nDefaultAtts; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2676 if (attId == elementType->defaultAtts[j].id) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2677 isCdata = elementType->defaultAtts[j].isCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2678 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2679 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2680 } |
| 21930 | 2681 } |
| 2682 | |
| 2683 /* normalize the attribute value */ | |
| 2684 result = storeAttributeValue(parser, enc, isCdata, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2685 atts[i].valuePtr, atts[i].valueEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2686 &tempPool); |
| 21930 | 2687 if (result) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2688 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
|
2689 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
|
2690 poolFinish(&tempPool); |
| 21930 | 2691 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2692 else { |
| 21930 | 2693 /* 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
|
2694 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
|
2695 atts[i].valueEnd); |
| 21930 | 2696 if (appAtts[attIndex] == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2697 return XML_ERROR_NO_MEMORY; |
| 21930 | 2698 poolFinish(&tempPool); |
| 2699 } | |
| 2700 /* 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
|
2701 if (attId->prefix) { |
| 21930 | 2702 if (attId->xmlns) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2703 /* deal with namespace declarations here */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2704 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
|
2705 appAtts[attIndex], bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2706 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2707 return result; |
| 21930 | 2708 --attIndex; |
| 2709 } | |
| 2710 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2711 /* deal with other prefixed names later */ |
| 21930 | 2712 attIndex++; |
| 2713 nPrefixes++; | |
| 2714 (attId->name)[-1] = 2; | |
| 2715 } | |
| 2716 } | |
| 2717 else | |
| 2718 attIndex++; | |
| 2719 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2720 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2721 /* 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
|
2722 nSpecifiedAtts = attIndex; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2723 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
|
2724 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
|
2725 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
|
2726 idAttIndex = i; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2727 break; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2728 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2729 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2730 else |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2731 idAttIndex = -1; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2732 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2733 /* 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
|
2734 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
|
2735 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
|
2736 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
|
2737 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
|
2738 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
|
2739 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
|
2740 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
|
2741 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2742 return result; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2743 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2744 else { |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2745 (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
|
2746 nPrefixes++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2747 appAtts[attIndex++] = da->id->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2748 appAtts[attIndex++] = da->value; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2749 } |
| 21930 | 2750 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2751 else { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2752 (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
|
2753 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
|
2754 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
|
2755 } |
| 21930 | 2756 } |
| 2757 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2758 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
|
2759 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2760 /* expand prefixed attribute names, check for duplicates, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2761 and clear flags that say whether attributes were specified */ |
| 21930 | 2762 i = 0; |
| 2763 if (nPrefixes) { | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2764 int j; /* hash table index */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2765 unsigned long version = nsAttsVersion; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2766 int nsAttsSize = (int)1 << nsAttsPower; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2767 /* size of hash table must be at least 2 * (# of prefixed attributes) */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2768 if ((nPrefixes << 1) >> nsAttsPower) { /* true for nsAttsPower = 0 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2769 NS_ATT *temp; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2770 /* hash table size must also be a power of 2 and >= 8 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2771 while (nPrefixes >> nsAttsPower++); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2772 if (nsAttsPower < 3) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2773 nsAttsPower = 3; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2774 nsAttsSize = (int)1 << nsAttsPower; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2775 temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT)); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2776 if (!temp) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2777 return XML_ERROR_NO_MEMORY; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2778 nsAtts = temp; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2779 version = 0; /* force re-initialization of nsAtts hash table */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2780 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2781 /* using a version flag saves us from initializing nsAtts every time */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2782 if (!version) { /* initialize version flags when version wraps around */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2783 version = INIT_ATTS_VERSION; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2784 for (j = nsAttsSize; j != 0; ) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2785 nsAtts[--j].version = version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2786 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2787 nsAttsVersion = --version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2788 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2789 /* expand prefixed names and check for duplicates */ |
| 21930 | 2790 for (; i < attIndex; i += 2) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2791 const XML_Char *s = appAtts[i]; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2792 if (s[-1] == 2) { /* prefixed */ |
| 21930 | 2793 ATTRIBUTE_ID *id; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2794 const BINDING *b; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2795 unsigned long uriHash = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2796 ((XML_Char *)s)[-1] = 0; /* clear flag */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2797 id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); |
|
39473
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
2798 if (!id) |
|
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
2799 return XML_ERROR_NO_MEMORY; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2800 b = id->prefix->binding; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2801 if (!b) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2802 return XML_ERROR_UNBOUND_PREFIX; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2803 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2804 /* as we expand the name we also calculate its hash value */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2805 for (j = 0; j < b->uriLen; j++) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2806 const XML_Char c = b->uri[j]; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2807 if (!poolAppendChar(&tempPool, c)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2808 return XML_ERROR_NO_MEMORY; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2809 uriHash = CHAR_HASH(uriHash, c); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2810 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2811 while (*s++ != XML_T(':')) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2812 ; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2813 do { /* copies null terminator */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2814 const XML_Char c = *s; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2815 if (!poolAppendChar(&tempPool, *s)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2816 return XML_ERROR_NO_MEMORY; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2817 uriHash = CHAR_HASH(uriHash, c); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2818 } while (*s++); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2819 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2820 { /* Check hash table for duplicate of expanded name (uriName). |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2821 Derived from code in lookup(HASH_TABLE *table, ...). |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2822 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2823 unsigned char step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2824 unsigned long mask = nsAttsSize - 1; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2825 j = uriHash & mask; /* index into hash table */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2826 while (nsAtts[j].version == version) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2827 /* for speed we compare stored hash values first */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2828 if (uriHash == nsAtts[j].hash) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2829 const XML_Char *s1 = poolStart(&tempPool); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2830 const XML_Char *s2 = nsAtts[j].uriName; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2831 /* s1 is null terminated, but not s2 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2832 for (; *s1 == *s2 && *s1 != 0; s1++, s2++); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2833 if (*s1 == 0) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2834 return XML_ERROR_DUPLICATE_ATTRIBUTE; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2835 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2836 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2837 step = PROBE_STEP(uriHash, mask, nsAttsPower); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2838 j < step ? (j += nsAttsSize - step) : (j -= step); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2839 } |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2840 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2841 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2842 if (ns_triplets) { /* append namespace separator and prefix */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2843 tempPool.ptr[-1] = namespaceSeparator; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2844 s = b->prefix->name; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2845 do { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2846 if (!poolAppendChar(&tempPool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2847 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2848 } while (*s++); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2849 } |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2850 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2851 /* store expanded name in attribute list */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2852 s = poolStart(&tempPool); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2853 poolFinish(&tempPool); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2854 appAtts[i] = s; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2855 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2856 /* fill empty slot with new version, uriName and hash value */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2857 nsAtts[j].version = version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2858 nsAtts[j].hash = uriHash; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2859 nsAtts[j].uriName = s; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2860 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2861 if (!--nPrefixes) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2862 i += 2; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2863 break; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2864 } |
| 21930 | 2865 } |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2866 else /* not prefixed */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2867 ((XML_Char *)s)[-1] = 0; /* clear flag */ |
| 21930 | 2868 } |
| 2869 } | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2870 /* clear flags for the remaining attributes */ |
| 21930 | 2871 for (; i < attIndex; i += 2) |
| 2872 ((XML_Char *)(appAtts[i]))[-1] = 0; | |
| 2873 for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) | |
| 2874 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
|
2875 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2876 if (!ns) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2877 return XML_ERROR_NONE; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2878 |
| 21930 | 2879 /* expand the element type name */ |
| 2880 if (elementType->prefix) { | |
| 2881 binding = elementType->prefix->binding; | |
| 2882 if (!binding) | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2883 return XML_ERROR_UNBOUND_PREFIX; |
| 21930 | 2884 localPart = tagNamePtr->str; |
| 2885 while (*localPart++ != XML_T(':')) | |
| 2886 ; | |
| 2887 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2888 else if (dtd->defaultPrefix.binding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2889 binding = dtd->defaultPrefix.binding; |
| 21930 | 2890 localPart = tagNamePtr->str; |
| 2891 } | |
| 2892 else | |
| 2893 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2894 prefixLen = 0; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2895 if (ns_triplets && binding->prefix->name) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2896 for (; binding->prefix->name[prefixLen++];) |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2897 ; /* prefixLen includes null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2898 } |
| 21930 | 2899 tagNamePtr->localPart = localPart; |
| 2900 tagNamePtr->uriLen = binding->uriLen; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2901 tagNamePtr->prefix = binding->prefix->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2902 tagNamePtr->prefixLen = prefixLen; |
| 21930 | 2903 for (i = 0; localPart[i++];) |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2904 ; /* i includes null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2905 n = i + binding->uriLen + prefixLen; |
| 21930 | 2906 if (n > binding->uriAlloc) { |
| 2907 TAG *p; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2908 uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); |
| 21930 | 2909 if (!uri) |
| 2910 return XML_ERROR_NO_MEMORY; | |
| 2911 binding->uriAlloc = n + EXPAND_SPARE; | |
| 2912 memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); | |
| 2913 for (p = tagStack; p; p = p->parent) | |
| 2914 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
|
2915 p->name.str = uri; |
| 21930 | 2916 FREE(binding->uri); |
| 2917 binding->uri = uri; | |
| 2918 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2919 /* if namespaceSeparator != '\0' then uri includes it already */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2920 uri = binding->uri + binding->uriLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2921 memcpy(uri, localPart, i * sizeof(XML_Char)); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2922 /* we always have a namespace separator between localPart and prefix */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2923 if (prefixLen) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2924 uri += i - 1; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2925 *uri = namespaceSeparator; /* replace null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2926 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
|
2927 } |
| 21930 | 2928 tagNamePtr->str = binding->uri; |
| 2929 return XML_ERROR_NONE; | |
| 2930 } | |
| 2931 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2932 /* 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
|
2933 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
|
2934 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2935 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2936 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
|
2937 const XML_Char *uri, BINDING **bindingsPtr) |
| 21930 | 2938 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2939 static const XML_Char xmlNamespace[] = { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2940 'h', 't', 't', 'p', ':', '/', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2941 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2942 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2943 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2944 }; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2945 static const int xmlLen = |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2946 (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2947 static const XML_Char xmlnsNamespace[] = { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2948 'h', 't', 't', 'p', ':', '/', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2949 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2950 '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2951 }; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2952 static const int xmlnsLen = |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2953 (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2954 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2955 XML_Bool mustBeXML = XML_FALSE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2956 XML_Bool isXML = XML_TRUE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2957 XML_Bool isXMLNS = XML_TRUE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2958 |
| 21930 | 2959 BINDING *b; |
| 2960 int len; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2961 |
| 32911 | 2962 /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2963 if (*uri == XML_T('\0') && prefix->name) |
| 32911 | 2964 return XML_ERROR_UNDECLARING_PREFIX; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2965 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2966 if (prefix->name |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2967 && prefix->name[0] == XML_T('x') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2968 && prefix->name[1] == XML_T('m') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2969 && prefix->name[2] == XML_T('l')) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2970 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2971 /* Not allowed to bind xmlns */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2972 if (prefix->name[3] == XML_T('n') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2973 && prefix->name[4] == XML_T('s') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2974 && prefix->name[5] == XML_T('\0')) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2975 return XML_ERROR_RESERVED_PREFIX_XMLNS; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2976 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2977 if (prefix->name[3] == XML_T('\0')) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2978 mustBeXML = XML_TRUE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2979 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2980 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2981 for (len = 0; uri[len]; len++) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2982 if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2983 isXML = XML_FALSE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2984 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2985 if (!mustBeXML && isXMLNS |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2986 && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2987 isXMLNS = XML_FALSE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2988 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2989 isXML = isXML && len == xmlLen; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2990 isXMLNS = isXMLNS && len == xmlnsLen; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2991 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2992 if (mustBeXML != isXML) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2993 return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2994 : XML_ERROR_RESERVED_NAMESPACE_URI; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2995 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2996 if (isXMLNS) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2997 return XML_ERROR_RESERVED_NAMESPACE_URI; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2998 |
| 21930 | 2999 if (namespaceSeparator) |
| 3000 len++; | |
| 3001 if (freeBindingList) { | |
| 3002 b = freeBindingList; | |
| 3003 if (len > b->uriAlloc) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3004 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
|
3005 sizeof(XML_Char) * (len + EXPAND_SPARE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3006 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3007 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3008 b->uri = temp; |
| 21930 | 3009 b->uriAlloc = len + EXPAND_SPARE; |
| 3010 } | |
| 3011 freeBindingList = b->nextTagBinding; | |
| 3012 } | |
| 3013 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3014 b = (BINDING *)MALLOC(sizeof(BINDING)); |
| 21930 | 3015 if (!b) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3016 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3017 b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); |
| 21930 | 3018 if (!b->uri) { |
| 3019 FREE(b); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3020 return XML_ERROR_NO_MEMORY; |
| 21930 | 3021 } |
| 3022 b->uriAlloc = len + EXPAND_SPARE; | |
| 3023 } | |
| 3024 b->uriLen = len; | |
| 3025 memcpy(b->uri, uri, len * sizeof(XML_Char)); | |
| 3026 if (namespaceSeparator) | |
| 3027 b->uri[len - 1] = namespaceSeparator; | |
| 3028 b->prefix = prefix; | |
| 3029 b->attId = attId; | |
| 3030 b->prevPrefixBinding = prefix->binding; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3031 /* NULL binding when default namespace undeclared */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3032 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
|
3033 prefix->binding = NULL; |
| 21930 | 3034 else |
| 3035 prefix->binding = b; | |
| 3036 b->nextTagBinding = *bindingsPtr; | |
| 3037 *bindingsPtr = b; | |
| 32911 | 3038 /* if attId == NULL then we are not starting a namespace scope */ |
| 3039 if (attId && startNamespaceDeclHandler) | |
| 21930 | 3040 startNamespaceDeclHandler(handlerArg, prefix->name, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3041 prefix->binding ? uri : 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3042 return XML_ERROR_NONE; |
| 21930 | 3043 } |
| 3044 | |
| 3045 /* 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
|
3046 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
|
3047 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3048 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3049 cdataSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3050 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3051 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3052 const char **endPtr) |
| 21930 | 3053 { |
| 32911 | 3054 enum XML_Error result = doCdataSection(parser, encoding, &start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3055 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 3056 if (result != XML_ERROR_NONE) |
| 3057 return result; | |
| 21930 | 3058 if (start) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3059 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
|
3060 processor = externalEntityContentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3061 return externalEntityContentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3062 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3063 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3064 processor = contentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3065 return contentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3066 } |
| 21930 | 3067 } |
| 3068 return result; | |
| 3069 } | |
| 3070 | |
| 32911 | 3071 /* startPtr gets set to non-null if 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
|
3072 the section is not yet closed. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3073 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3074 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3075 doCdataSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3076 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3077 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3078 const char *end, |
| 32911 | 3079 const char **nextPtr, |
| 3080 XML_Bool haveMore) | |
| 21930 | 3081 { |
| 3082 const char *s = *startPtr; | |
| 3083 const char **eventPP; | |
| 3084 const char **eventEndPP; | |
| 3085 if (enc == encoding) { | |
| 3086 eventPP = &eventPtr; | |
| 3087 *eventPP = s; | |
| 3088 eventEndPP = &eventEndPtr; | |
| 3089 } | |
| 3090 else { | |
| 3091 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3092 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3093 } | |
| 3094 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3095 *startPtr = NULL; |
| 32911 | 3096 |
| 21930 | 3097 for (;;) { |
| 3098 const char *next; | |
| 3099 int tok = XmlCdataSectionTok(enc, s, end, &next); | |
| 3100 *eventEndPP = next; | |
| 3101 switch (tok) { | |
| 3102 case XML_TOK_CDATA_SECT_CLOSE: | |
| 3103 if (endCdataSectionHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3104 endCdataSectionHandler(handlerArg); |
| 21930 | 3105 #if 0 |
| 3106 /* see comment under XML_TOK_CDATA_SECT_OPEN */ | |
| 3107 else if (characterDataHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3108 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 3109 #endif |
| 3110 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3111 reportDefault(parser, enc, s, next); |
| 21930 | 3112 *startPtr = next; |
| 32911 | 3113 *nextPtr = next; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3114 if (ps_parsing == XML_FINISHED) |
| 32911 | 3115 return XML_ERROR_ABORTED; |
| 3116 else | |
| 3117 return XML_ERROR_NONE; | |
| 21930 | 3118 case XML_TOK_DATA_NEWLINE: |
| 3119 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3120 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3121 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 3122 } |
| 3123 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3124 reportDefault(parser, enc, s, next); |
| 21930 | 3125 break; |
| 3126 case XML_TOK_DATA_CHARS: | |
| 3127 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3128 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3129 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3130 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3131 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
|
3132 *eventEndPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3133 characterDataHandler(handlerArg, dataBuf, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3134 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3135 if (s == next) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3136 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3137 *eventPP = s; |
|
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 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3141 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3142 (XML_Char *)s, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3143 (int)((XML_Char *)next - (XML_Char *)s)); |
| 21930 | 3144 } |
| 3145 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3146 reportDefault(parser, enc, s, next); |
| 21930 | 3147 break; |
| 3148 case XML_TOK_INVALID: | |
| 3149 *eventPP = next; | |
| 3150 return XML_ERROR_INVALID_TOKEN; | |
| 3151 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 3152 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3153 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3154 return XML_ERROR_NONE; |
| 21930 | 3155 } |
| 3156 return XML_ERROR_PARTIAL_CHAR; | |
| 3157 case XML_TOK_PARTIAL: | |
| 3158 case XML_TOK_NONE: | |
| 32911 | 3159 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3160 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3161 return XML_ERROR_NONE; |
| 21930 | 3162 } |
| 3163 return XML_ERROR_UNCLOSED_CDATA_SECTION; | |
| 3164 default: | |
| 3165 *eventPP = next; | |
| 3166 return XML_ERROR_UNEXPECTED_STATE; | |
| 3167 } | |
| 32911 | 3168 |
| 21930 | 3169 *eventPP = s = next; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3170 switch (ps_parsing) { |
| 32911 | 3171 case XML_SUSPENDED: |
| 3172 *nextPtr = next; | |
| 3173 return XML_ERROR_NONE; | |
| 3174 case XML_FINISHED: | |
| 3175 return XML_ERROR_ABORTED; | |
| 3176 default: ; | |
| 3177 } | |
| 21930 | 3178 } |
| 3179 /* not reached */ | |
| 3180 } | |
| 3181 | |
| 3182 #ifdef XML_DTD | |
| 3183 | |
| 3184 /* 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
|
3185 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
|
3186 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3187 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3188 ignoreSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3189 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3190 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3191 const char **endPtr) |
| 21930 | 3192 { |
| 32911 | 3193 enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3194 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 3195 if (result != XML_ERROR_NONE) |
| 3196 return result; | |
| 21930 | 3197 if (start) { |
| 3198 processor = prologProcessor; | |
| 3199 return prologProcessor(parser, start, end, endPtr); | |
| 3200 } | |
| 3201 return result; | |
| 3202 } | |
| 3203 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3204 /* 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
|
3205 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
|
3206 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3207 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3208 doIgnoreSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3209 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3210 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3211 const char *end, |
| 32911 | 3212 const char **nextPtr, |
| 3213 XML_Bool haveMore) | |
| 21930 | 3214 { |
| 3215 const char *next; | |
| 3216 int tok; | |
| 3217 const char *s = *startPtr; | |
| 3218 const char **eventPP; | |
| 3219 const char **eventEndPP; | |
| 3220 if (enc == encoding) { | |
| 3221 eventPP = &eventPtr; | |
| 3222 *eventPP = s; | |
| 3223 eventEndPP = &eventEndPtr; | |
| 3224 } | |
| 3225 else { | |
| 3226 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3227 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3228 } | |
| 3229 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3230 *startPtr = NULL; |
| 21930 | 3231 tok = XmlIgnoreSectionTok(enc, s, end, &next); |
| 3232 *eventEndPP = next; | |
| 3233 switch (tok) { | |
| 3234 case XML_TOK_IGNORE_SECT: | |
| 3235 if (defaultHandler) | |
| 3236 reportDefault(parser, enc, s, next); | |
| 3237 *startPtr = next; | |
| 32911 | 3238 *nextPtr = next; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3239 if (ps_parsing == XML_FINISHED) |
| 32911 | 3240 return XML_ERROR_ABORTED; |
| 3241 else | |
| 3242 return XML_ERROR_NONE; | |
| 21930 | 3243 case XML_TOK_INVALID: |
| 3244 *eventPP = next; | |
| 3245 return XML_ERROR_INVALID_TOKEN; | |
| 3246 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 3247 if (haveMore) { |
| 21930 | 3248 *nextPtr = s; |
| 3249 return XML_ERROR_NONE; | |
| 3250 } | |
| 3251 return XML_ERROR_PARTIAL_CHAR; | |
| 3252 case XML_TOK_PARTIAL: | |
| 3253 case XML_TOK_NONE: | |
| 32911 | 3254 if (haveMore) { |
| 21930 | 3255 *nextPtr = s; |
| 3256 return XML_ERROR_NONE; | |
| 3257 } | |
| 3258 return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ | |
| 3259 default: | |
| 3260 *eventPP = next; | |
| 3261 return XML_ERROR_UNEXPECTED_STATE; | |
| 3262 } | |
| 3263 /* not reached */ | |
| 3264 } | |
| 3265 | |
| 3266 #endif /* XML_DTD */ | |
| 3267 | |
| 3268 static enum XML_Error | |
| 3269 initializeEncoding(XML_Parser parser) | |
| 3270 { | |
| 3271 const char *s; | |
| 3272 #ifdef XML_UNICODE | |
| 3273 char encodingBuf[128]; | |
| 3274 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3275 s = NULL; |
| 21930 | 3276 else { |
| 3277 int i; | |
| 3278 for (i = 0; protocolEncodingName[i]; i++) { | |
| 3279 if (i == sizeof(encodingBuf) - 1 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3280 || (protocolEncodingName[i] & ~0x7f) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3281 encodingBuf[0] = '\0'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3282 break; |
| 21930 | 3283 } |
| 3284 encodingBuf[i] = (char)protocolEncodingName[i]; | |
| 3285 } | |
| 3286 encodingBuf[i] = '\0'; | |
| 3287 s = encodingBuf; | |
| 3288 } | |
| 3289 #else | |
| 3290 s = protocolEncodingName; | |
| 3291 #endif | |
| 3292 if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) | |
| 3293 return XML_ERROR_NONE; | |
| 3294 return handleUnknownEncoding(parser, protocolEncodingName); | |
| 3295 } | |
| 3296 | |
| 3297 static enum XML_Error | |
| 3298 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
|
3299 const char *s, const char *next) |
| 21930 | 3300 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3301 const char *encodingName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3302 const XML_Char *storedEncName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3303 const ENCODING *newEncoding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3304 const char *version = NULL; |
| 21930 | 3305 const char *versionend; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3306 const XML_Char *storedversion = NULL; |
| 21930 | 3307 int standalone = -1; |
| 3308 if (!(ns | |
| 3309 ? XmlParseXmlDeclNS | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3310 : XmlParseXmlDecl)(isGeneralTextEntity, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3311 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3312 s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3313 next, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3314 &eventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3315 &version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3316 &versionend, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3317 &encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3318 &newEncoding, |
| 32911 | 3319 &standalone)) { |
| 3320 if (isGeneralTextEntity) | |
| 3321 return XML_ERROR_TEXT_DECL; | |
| 3322 else | |
| 3323 return XML_ERROR_XML_DECL; | |
| 3324 } | |
| 21930 | 3325 if (!isGeneralTextEntity && standalone == 1) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3326 _dtd->standalone = XML_TRUE; |
| 21930 | 3327 #ifdef XML_DTD |
| 3328 if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) | |
| 3329 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; | |
| 3330 #endif /* XML_DTD */ | |
| 3331 } | |
| 3332 if (xmlDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3333 if (encodingName != NULL) { |
| 21930 | 3334 storedEncName = poolStoreString(&temp2Pool, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3335 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3336 encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3337 encodingName |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3338 + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3339 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3340 return XML_ERROR_NO_MEMORY; |
| 21930 | 3341 poolFinish(&temp2Pool); |
| 3342 } | |
| 3343 if (version) { | |
| 3344 storedversion = poolStoreString(&temp2Pool, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3345 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3346 version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3347 versionend - encoding->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3348 if (!storedversion) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3349 return XML_ERROR_NO_MEMORY; |
| 21930 | 3350 } |
| 3351 xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); | |
| 3352 } | |
| 3353 else if (defaultHandler) | |
| 3354 reportDefault(parser, encoding, s, next); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3355 if (protocolEncodingName == NULL) { |
| 21930 | 3356 if (newEncoding) { |
| 3357 if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3358 eventPtr = encodingName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3359 return XML_ERROR_INCORRECT_ENCODING; |
| 21930 | 3360 } |
| 3361 encoding = newEncoding; | |
| 3362 } | |
| 3363 else if (encodingName) { | |
| 3364 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3365 if (!storedEncName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3366 storedEncName = poolStoreString( |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3367 &temp2Pool, encoding, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3368 encodingName + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3369 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3370 return XML_ERROR_NO_MEMORY; |
| 21930 | 3371 } |
| 3372 result = handleUnknownEncoding(parser, storedEncName); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3373 poolClear(&temp2Pool); |
| 21930 | 3374 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
|
3375 eventPtr = encodingName; |
| 21930 | 3376 return result; |
| 3377 } | |
| 3378 } | |
| 3379 | |
| 3380 if (storedEncName || storedversion) | |
| 3381 poolClear(&temp2Pool); | |
| 3382 | |
| 3383 return XML_ERROR_NONE; | |
| 3384 } | |
| 3385 | |
| 3386 static enum XML_Error | |
| 3387 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) | |
| 3388 { | |
| 3389 if (unknownEncodingHandler) { | |
| 3390 XML_Encoding info; | |
| 3391 int i; | |
| 3392 for (i = 0; i < 256; i++) | |
| 3393 info.map[i] = -1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3394 info.convert = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3395 info.data = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3396 info.release = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3397 if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3398 &info)) { |
| 21930 | 3399 ENCODING *enc; |
| 3400 unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); | |
| 3401 if (!unknownEncodingMem) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3402 if (info.release) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3403 info.release(info.data); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3404 return XML_ERROR_NO_MEMORY; |
| 21930 | 3405 } |
| 3406 enc = (ns | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3407 ? XmlInitUnknownEncodingNS |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3408 : XmlInitUnknownEncoding)(unknownEncodingMem, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3409 info.map, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3410 info.convert, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3411 info.data); |
| 21930 | 3412 if (enc) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3413 unknownEncodingData = info.data; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3414 unknownEncodingRelease = info.release; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3415 encoding = enc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3416 return XML_ERROR_NONE; |
| 21930 | 3417 } |
| 3418 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3419 if (info.release != NULL) |
| 21930 | 3420 info.release(info.data); |
| 3421 } | |
| 3422 return XML_ERROR_UNKNOWN_ENCODING; | |
| 3423 } | |
| 3424 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3425 static enum XML_Error PTRCALL |
| 21930 | 3426 prologInitProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3427 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3428 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3429 const char **nextPtr) |
| 21930 | 3430 { |
| 3431 enum XML_Error result = initializeEncoding(parser); | |
| 3432 if (result != XML_ERROR_NONE) | |
| 3433 return result; | |
| 3434 processor = prologProcessor; | |
| 3435 return prologProcessor(parser, s, end, nextPtr); | |
| 3436 } | |
| 3437 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3438 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3439 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3440 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3441 externalParEntInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3442 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3443 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3444 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3445 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3446 enum XML_Error result = initializeEncoding(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3447 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3448 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3449 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3450 /* 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
|
3451 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
|
3452 _dtd->paramEntityRead = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3453 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3454 if (prologState.inEntityValue) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3455 processor = entityValueInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3456 return entityValueInitProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3457 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3458 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3459 processor = externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3460 return externalParEntProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3461 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3462 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3463 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3464 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3465 entityValueInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3466 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3467 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3468 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3469 { |
| 32911 | 3470 int tok; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3471 const char *start = s; |
| 32911 | 3472 const char *next = start; |
| 3473 eventPtr = start; | |
| 3474 | |
| 3475 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3476 tok = XmlPrologTok(encoding, start, end, &next); |
| 32911 | 3477 eventEndPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3478 if (tok <= 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3479 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
| 32911 | 3480 *nextPtr = s; |
| 3481 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3482 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3483 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3484 case XML_TOK_INVALID: |
| 32911 | 3485 return XML_ERROR_INVALID_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3486 case XML_TOK_PARTIAL: |
| 32911 | 3487 return XML_ERROR_UNCLOSED_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3488 case XML_TOK_PARTIAL_CHAR: |
| 32911 | 3489 return XML_ERROR_PARTIAL_CHAR; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3490 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3491 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3492 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3493 } |
| 32911 | 3494 /* found end of entity value - can store it now */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3495 return storeEntityValue(parser, encoding, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3496 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3497 else if (tok == XML_TOK_XML_DECL) { |
| 32911 | 3498 enum XML_Error result; |
| 3499 result = processXmlDecl(parser, 0, start, next); | |
| 3500 if (result != XML_ERROR_NONE) | |
| 3501 return result; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3502 switch (ps_parsing) { |
| 32911 | 3503 case XML_SUSPENDED: |
| 3504 *nextPtr = next; | |
| 3505 return XML_ERROR_NONE; | |
| 3506 case XML_FINISHED: | |
| 3507 return XML_ERROR_ABORTED; | |
| 3508 default: | |
| 3509 *nextPtr = next; | |
| 3510 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3511 /* 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
|
3512 processor = entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3513 return entityValueProcessor(parser, next, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3514 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3515 /* 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
|
3516 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
|
3517 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
|
3518 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
|
3519 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
|
3520 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
|
3521 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3522 else if (tok == XML_TOK_BOM && next == end && !ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3523 *nextPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3524 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3525 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3526 start = next; |
| 32911 | 3527 eventPtr = start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3528 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3529 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3530 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3531 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3532 externalParEntProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3533 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3534 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3535 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3536 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3537 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3538 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3539 |
| 32911 | 3540 tok = XmlPrologTok(encoding, s, end, &next); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3541 if (tok <= 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3542 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3543 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3544 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3545 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3546 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3547 case XML_TOK_INVALID: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3548 return XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3549 case XML_TOK_PARTIAL: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3550 return XML_ERROR_UNCLOSED_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3551 case XML_TOK_PARTIAL_CHAR: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3552 return XML_ERROR_PARTIAL_CHAR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3553 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3554 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3555 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3556 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3557 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3558 /* 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
|
3559 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
|
3560 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
|
3561 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3562 else if (tok == XML_TOK_BOM) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3563 s = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3564 tok = XmlPrologTok(encoding, s, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3565 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3566 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3567 processor = prologProcessor; |
| 32911 | 3568 return doProlog(parser, encoding, s, end, tok, next, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3569 nextPtr, (XML_Bool)!ps_finalBuffer); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3570 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3571 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3572 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3573 entityValueProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3574 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3575 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3576 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3577 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3578 const char *start = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3579 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3580 const ENCODING *enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3581 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3582 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3583 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3584 tok = XmlPrologTok(enc, start, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3585 if (tok <= 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3586 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3587 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3588 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3589 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3590 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3591 case XML_TOK_INVALID: |
| 32911 | 3592 return XML_ERROR_INVALID_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3593 case XML_TOK_PARTIAL: |
| 32911 | 3594 return XML_ERROR_UNCLOSED_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3595 case XML_TOK_PARTIAL_CHAR: |
| 32911 | 3596 return XML_ERROR_PARTIAL_CHAR; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3597 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3598 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3599 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3600 } |
| 32911 | 3601 /* found end of entity value - can store it now */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3602 return storeEntityValue(parser, enc, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3603 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3604 start = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3605 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3606 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3607 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3608 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3609 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3610 static enum XML_Error PTRCALL |
| 21930 | 3611 prologProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3612 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3613 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3614 const char **nextPtr) |
| 21930 | 3615 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3616 const char *next = s; |
| 21930 | 3617 int tok = XmlPrologTok(encoding, s, end, &next); |
| 32911 | 3618 return doProlog(parser, encoding, s, end, tok, next, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3619 nextPtr, (XML_Bool)!ps_finalBuffer); |
| 21930 | 3620 } |
| 3621 | |
| 3622 static enum XML_Error | |
| 3623 doProlog(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3624 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3625 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3626 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3627 int tok, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3628 const char *next, |
| 32911 | 3629 const char **nextPtr, |
| 3630 XML_Bool haveMore) | |
| 21930 | 3631 { |
| 3632 #ifdef XML_DTD | |
| 3633 static const XML_Char externalSubsetName[] = { '#' , '\0' }; | |
| 3634 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3635 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
|
3636 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
|
3637 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
|
3638 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
|
3639 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
|
3640 static const XML_Char atypeENTITIES[] = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3641 { '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
|
3642 static const XML_Char atypeNMTOKEN[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3643 '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
|
3644 static const XML_Char atypeNMTOKENS[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3645 '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
|
3646 static const XML_Char notationPrefix[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3647 '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
|
3648 static const XML_Char enumValueSep[] = { '|', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3649 static const XML_Char enumValueStart[] = { '(', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3650 |
| 32911 | 3651 /* save one level of indirection */ |
| 3652 DTD * const dtd = _dtd; | |
| 21930 | 3653 |
| 3654 const char **eventPP; | |
| 3655 const char **eventEndPP; | |
| 3656 enum XML_Content_Quant quant; | |
| 3657 | |
| 3658 if (enc == encoding) { | |
| 3659 eventPP = &eventPtr; | |
| 3660 eventEndPP = &eventEndPtr; | |
| 3661 } | |
| 3662 else { | |
| 3663 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3664 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3665 } | |
| 32911 | 3666 |
| 21930 | 3667 for (;;) { |
| 3668 int role; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3669 XML_Bool handleDefault = XML_TRUE; |
| 21930 | 3670 *eventPP = s; |
| 3671 *eventEndPP = next; | |
| 3672 if (tok <= 0) { | |
| 32911 | 3673 if (haveMore && tok != XML_TOK_INVALID) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3674 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3675 return XML_ERROR_NONE; |
| 21930 | 3676 } |
| 3677 switch (tok) { | |
| 3678 case XML_TOK_INVALID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3679 *eventPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3680 return XML_ERROR_INVALID_TOKEN; |
| 21930 | 3681 case XML_TOK_PARTIAL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3682 return XML_ERROR_UNCLOSED_TOKEN; |
| 21930 | 3683 case XML_TOK_PARTIAL_CHAR: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3684 return XML_ERROR_PARTIAL_CHAR; |
| 21930 | 3685 case XML_TOK_NONE: |
| 3686 #ifdef XML_DTD | |
| 32911 | 3687 /* for internal PE NOT referenced between declarations */ |
| 3688 if (enc != encoding && !openInternalEntities->betweenDecl) { | |
| 3689 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3690 return XML_ERROR_NONE; |
| 32911 | 3691 } |
| 3692 /* WFC: PE Between Declarations - must check that PE contains | |
| 3693 complete markup, not only for external PEs, but also for | |
| 3694 internal PEs if the reference occurs between declarations. | |
| 3695 */ | |
| 3696 if (isParamEntity || enc != encoding) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3697 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
|
3698 == XML_ROLE_ERROR) |
| 32911 | 3699 return XML_ERROR_INCOMPLETE_PE; |
| 3700 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3701 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3702 } |
| 21930 | 3703 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3704 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 3705 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3706 tok = -tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3707 next = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3708 break; |
| 21930 | 3709 } |
| 3710 } | |
| 3711 role = XmlTokenRole(&prologState, tok, s, next, enc); | |
| 3712 switch (role) { | |
| 3713 case XML_ROLE_XML_DECL: | |
| 3714 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3715 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
|
3716 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3717 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3718 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3719 handleDefault = XML_FALSE; |
| 21930 | 3720 } |
| 3721 break; | |
| 3722 case XML_ROLE_DOCTYPE_NAME: | |
| 3723 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3724 doctypeName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3725 if (!doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3726 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3727 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3728 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3729 handleDefault = XML_FALSE; |
| 21930 | 3730 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3731 doctypeSysid = NULL; /* always initialize to NULL */ |
| 21930 | 3732 break; |
| 3733 case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: | |
| 3734 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3735 startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3736 doctypePubid, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3737 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3738 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3739 handleDefault = XML_FALSE; |
| 21930 | 3740 } |
| 3741 break; | |
| 3742 #ifdef XML_DTD | |
| 3743 case XML_ROLE_TEXT_DECL: | |
| 3744 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3745 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
|
3746 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3747 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3748 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3749 handleDefault = XML_FALSE; |
| 21930 | 3750 } |
| 3751 break; | |
| 3752 #endif /* XML_DTD */ | |
| 3753 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
|
3754 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3755 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3756 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3757 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3758 sizeof(ENTITY)); |
| 21930 | 3759 if (!declEntity) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3760 return XML_ERROR_NO_MEMORY; |
| 21930 | 3761 #endif /* XML_DTD */ |
| 32911 | 3762 dtd->hasParamEntityRefs = XML_TRUE; |
| 3763 if (startDoctypeDeclHandler) { | |
| 3764 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 3765 return XML_ERROR_PUBLICID; | |
| 3766 doctypePubid = poolStoreString(&tempPool, enc, | |
| 3767 s + enc->minBytesPerChar, | |
| 3768 next - enc->minBytesPerChar); | |
| 3769 if (!doctypePubid) | |
| 3770 return XML_ERROR_NO_MEMORY; | |
| 3771 normalizePublicId((XML_Char *)doctypePubid); | |
| 3772 poolFinish(&tempPool); | |
| 3773 handleDefault = XML_FALSE; | |
| 3774 goto alreadyChecked; | |
| 3775 } | |
| 21930 | 3776 /* fall through */ |
| 3777 case XML_ROLE_ENTITY_PUBLIC_ID: | |
| 3778 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 3779 return XML_ERROR_PUBLICID; |
| 3780 alreadyChecked: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3781 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3782 XML_Char *tem = poolStoreString(&dtd->pool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3783 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3784 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3785 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3786 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3787 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3788 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3789 declEntity->publicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3790 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3791 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3792 handleDefault = XML_FALSE; |
| 21930 | 3793 } |
| 3794 break; | |
| 3795 case XML_ROLE_DOCTYPE_CLOSE: | |
| 3796 if (doctypeName) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3797 startDoctypeDeclHandler(handlerArg, doctypeName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3798 doctypeSysid, doctypePubid, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3799 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3800 handleDefault = XML_FALSE; |
| 21930 | 3801 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3802 /* 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
|
3803 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
|
3804 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
|
3805 */ |
| 21930 | 3806 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3807 if (doctypeSysid || useForeignDTD) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3808 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3809 dtd->hasParamEntityRefs = XML_TRUE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3810 if (paramEntityParsing && externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3811 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3812 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3813 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3814 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3815 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3816 if (useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3817 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3818 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3819 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3820 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3821 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3822 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3823 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3824 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3825 if (dtd->paramEntityRead) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3826 if (!dtd->standalone && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3827 notStandaloneHandler && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3828 !notStandaloneHandler(handlerArg)) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3829 return XML_ERROR_NOT_STANDALONE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3830 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3831 /* if we didn't read the foreign DTD then this means that there |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3832 is no external subset and we must reset dtd->hasParamEntityRefs |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3833 */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3834 else if (!doctypeSysid) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3835 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3836 /* 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
|
3837 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3838 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3839 } |
| 21930 | 3840 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3841 if (endDoctypeDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3842 endDoctypeDeclHandler(handlerArg); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3843 handleDefault = XML_FALSE; |
| 21930 | 3844 } |
| 3845 break; | |
| 3846 case XML_ROLE_INSTANCE_START: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3847 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3848 /* 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
|
3849 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
|
3850 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3851 if (useForeignDTD) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3852 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3853 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3854 if (paramEntityParsing && externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3855 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3856 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3857 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3858 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3859 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3860 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3861 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3862 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3863 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3864 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3865 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3866 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3867 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3868 if (dtd->paramEntityRead) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3869 if (!dtd->standalone && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3870 notStandaloneHandler && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3871 !notStandaloneHandler(handlerArg)) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3872 return XML_ERROR_NOT_STANDALONE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3873 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3874 /* if we didn't read the foreign DTD then this means that there |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3875 is no external subset and we must reset dtd->hasParamEntityRefs |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3876 */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3877 else |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3878 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3879 /* 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
|
3880 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3881 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3882 #endif /* XML_DTD */ |
| 21930 | 3883 processor = contentProcessor; |
| 3884 return contentProcessor(parser, s, end, nextPtr); | |
| 3885 case XML_ROLE_ATTLIST_ELEMENT_NAME: | |
| 3886 declElementType = getElementType(parser, enc, s, next); | |
| 3887 if (!declElementType) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3888 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3889 goto checkAttListDeclHandler; |
| 21930 | 3890 case XML_ROLE_ATTRIBUTE_NAME: |
| 3891 declAttributeId = getAttributeId(parser, enc, s, next); | |
| 3892 if (!declAttributeId) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3893 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3894 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3895 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3896 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3897 goto checkAttListDeclHandler; |
| 21930 | 3898 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
|
3899 declAttributeIsCdata = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3900 declAttributeType = atypeCDATA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3901 goto checkAttListDeclHandler; |
| 21930 | 3902 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
|
3903 declAttributeIsId = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3904 declAttributeType = atypeID; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3905 goto checkAttListDeclHandler; |
| 21930 | 3906 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
|
3907 declAttributeType = atypeIDREF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3908 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3909 case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3910 declAttributeType = atypeIDREFS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3911 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3912 case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3913 declAttributeType = atypeENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3914 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3915 case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3916 declAttributeType = atypeENTITIES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3917 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3918 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3919 declAttributeType = atypeNMTOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3920 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3921 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3922 declAttributeType = atypeNMTOKENS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3923 checkAttListDeclHandler: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3924 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3925 handleDefault = XML_FALSE; |
| 21930 | 3926 break; |
| 3927 case XML_ROLE_ATTRIBUTE_ENUM_VALUE: | |
| 3928 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
|
3929 if (dtd->keepProcessing && attlistDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3930 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3931 if (declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3932 prefix = enumValueSep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3933 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3934 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3935 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
|
3936 ? notationPrefix |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3937 : enumValueStart); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3938 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3939 if (!poolAppendString(&tempPool, prefix)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3940 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3941 if (!poolAppend(&tempPool, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3942 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3943 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3944 handleDefault = XML_FALSE; |
| 21930 | 3945 } |
| 3946 break; | |
| 3947 case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: | |
| 3948 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
|
3949 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3950 if (!defineAttribute(declElementType, declAttributeId, |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3951 declAttributeIsCdata, declAttributeIsId, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3952 0, parser)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3953 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3954 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3955 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3956 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3957 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3958 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3959 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3960 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3961 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3962 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3963 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3964 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3965 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3966 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3967 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3968 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
|
3969 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3970 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3971 } |
| 21930 | 3972 } |
| 3973 break; | |
| 3974 case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: | |
| 3975 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
|
3976 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3977 const XML_Char *attVal; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3978 enum XML_Error result = |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3979 storeAttributeValue(parser, enc, declAttributeIsCdata, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3980 s + enc->minBytesPerChar, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3981 next - enc->minBytesPerChar, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3982 &dtd->pool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3983 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3984 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3985 attVal = poolStart(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3986 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3987 /* 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
|
3988 if (!defineAttribute(declElementType, declAttributeId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3989 declAttributeIsCdata, XML_FALSE, attVal, parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3990 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3991 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3992 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3993 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3994 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3995 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3996 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3997 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3998 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3999 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4000 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4001 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4002 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4003 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4004 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4005 attVal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4006 role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4007 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4008 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4009 } |
| 21930 | 4010 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4011 break; |
| 21930 | 4012 case XML_ROLE_ENTITY_VALUE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4013 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4014 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
|
4015 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4016 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4017 if (declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4018 declEntity->textPtr = poolStart(&dtd->entityValuePool); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4019 declEntity->textLen = (int)(poolLength(&dtd->entityValuePool)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4020 poolFinish(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4021 if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4022 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4023 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4024 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4025 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4026 declEntity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4027 declEntity->textLen, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4028 curBase, 0, 0, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4029 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4030 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4031 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4032 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4033 poolDiscard(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4034 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4035 return result; |
| 21930 | 4036 } |
| 4037 break; | |
| 4038 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
|
4039 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4040 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4041 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4042 dtd->hasParamEntityRefs = XML_TRUE; |
| 21930 | 4043 if (startDoctypeDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4044 doctypeSysid = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4045 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4046 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4047 if (doctypeSysid == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4048 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4049 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4050 handleDefault = XML_FALSE; |
| 21930 | 4051 } |
| 4052 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4053 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4054 /* 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
|
4055 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
|
4056 doctypeSysid = externalSubsetName; |
| 21930 | 4057 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4058 if (!dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4059 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4060 && !paramEntityParsing |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4061 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4062 && notStandaloneHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4063 && !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4064 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4065 #ifndef XML_DTD |
| 4066 break; | |
| 4067 #else /* XML_DTD */ | |
| 4068 if (!declEntity) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4069 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4070 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4071 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4072 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4073 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4074 declEntity->publicId = NULL; |
| 21930 | 4075 } |
| 4076 /* fall through */ | |
| 4077 #endif /* XML_DTD */ | |
| 4078 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
|
4079 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4080 declEntity->systemId = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4081 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4082 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4083 if (!declEntity->systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4084 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4085 declEntity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4086 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4087 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4088 handleDefault = XML_FALSE; |
| 21930 | 4089 } |
| 4090 break; | |
| 4091 case XML_ROLE_ENTITY_COMPLETE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4092 if (dtd->keepProcessing && declEntity && entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4093 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4094 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4095 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4096 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4097 0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4098 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4099 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4100 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4101 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4102 handleDefault = XML_FALSE; |
| 21930 | 4103 } |
| 4104 break; | |
| 4105 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
|
4106 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4107 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
|
4108 if (!declEntity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4109 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4110 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4111 if (unparsedEntityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4112 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4113 unparsedEntityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4114 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4115 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4116 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4117 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4118 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4119 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4120 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4121 else if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4122 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4123 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4124 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4125 0,0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4126 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4127 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4128 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4129 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4130 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4131 } |
| 21930 | 4132 } |
| 4133 break; | |
| 4134 case XML_ROLE_GENERAL_ENTITY_NAME: | |
| 4135 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4136 if (XmlPredefinedEntityName(enc, s, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4137 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4138 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4139 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4140 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4141 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
|
4142 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4143 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4144 declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4145 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4146 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4147 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4148 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4149 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4150 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4151 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4152 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4153 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4154 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4155 declEntity->is_param = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4156 /* 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
|
4157 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
|
4158 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4159 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4160 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4161 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4162 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4163 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4164 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4165 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4166 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4167 } |
| 21930 | 4168 } |
| 4169 break; | |
| 4170 case XML_ROLE_PARAM_ENTITY_NAME: | |
| 4171 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4172 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4173 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
|
4174 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4175 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4176 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4177 name, sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4178 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4179 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4180 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4181 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4182 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4183 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4184 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4185 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4186 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4187 declEntity->is_param = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4188 /* 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
|
4189 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
|
4190 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4191 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4192 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4193 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4194 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4195 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4196 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4197 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4198 declEntity = NULL; |
| 21930 | 4199 } |
| 4200 #else /* not XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4201 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4202 #endif /* XML_DTD */ |
| 21930 | 4203 break; |
| 4204 case XML_ROLE_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4205 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4206 declNotationName = NULL; |
| 21930 | 4207 if (notationDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4208 declNotationName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4209 if (!declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4210 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4211 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4212 handleDefault = XML_FALSE; |
| 21930 | 4213 } |
| 4214 break; | |
| 4215 case XML_ROLE_NOTATION_PUBLIC_ID: | |
| 4216 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 4217 return XML_ERROR_PUBLICID; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4218 if (declNotationName) { /* means notationDeclHandler != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4219 XML_Char *tem = poolStoreString(&tempPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4220 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4221 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4222 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4223 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4224 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4225 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4226 declNotationPublicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4227 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4228 handleDefault = XML_FALSE; |
| 21930 | 4229 } |
| 4230 break; | |
| 4231 case XML_ROLE_NOTATION_SYSTEM_ID: | |
| 4232 if (declNotationName && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4233 const XML_Char *systemId |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4234 = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4235 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4236 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4237 if (!systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4238 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4239 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4240 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4241 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4242 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4243 systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4244 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4245 handleDefault = XML_FALSE; |
| 21930 | 4246 } |
| 4247 poolClear(&tempPool); | |
| 4248 break; | |
| 4249 case XML_ROLE_NOTATION_NO_SYSTEM_ID: | |
| 4250 if (declNotationPublicId && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4251 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4252 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4253 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4254 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4255 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4256 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4257 handleDefault = XML_FALSE; |
| 21930 | 4258 } |
| 4259 poolClear(&tempPool); | |
| 4260 break; | |
| 4261 case XML_ROLE_ERROR: | |
| 4262 switch (tok) { | |
| 4263 case XML_TOK_PARAM_ENTITY_REF: | |
| 32911 | 4264 /* PE references in internal subset are |
| 4265 not allowed within declarations. */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4266 return XML_ERROR_PARAM_ENTITY_REF; |
| 21930 | 4267 case XML_TOK_XML_DECL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4268 return XML_ERROR_MISPLACED_XML_PI; |
| 21930 | 4269 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4270 return XML_ERROR_SYNTAX; |
| 21930 | 4271 } |
| 4272 #ifdef XML_DTD | |
| 4273 case XML_ROLE_IGNORE_SECT: | |
| 4274 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4275 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4276 if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4277 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4278 handleDefault = XML_FALSE; |
| 32911 | 4279 result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); |
| 4280 if (result != XML_ERROR_NONE) | |
| 4281 return result; | |
| 4282 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4283 processor = ignoreSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4284 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4285 } |
| 21930 | 4286 } |
| 4287 break; | |
| 4288 #endif /* XML_DTD */ | |
| 4289 case XML_ROLE_GROUP_OPEN: | |
| 4290 if (prologState.level >= groupSize) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4291 if (groupSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4292 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
|
4293 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4294 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4295 groupConnector = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4296 if (dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4297 int *temp = (int *)REALLOC(dtd->scaffIndex, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4298 groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4299 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4300 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4301 dtd->scaffIndex = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4302 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4303 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4304 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4305 groupConnector = (char *)MALLOC(groupSize = 32); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4306 if (!groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4307 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4308 } |
| 21930 | 4309 } |
| 4310 groupConnector[prologState.level] = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4311 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4312 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4313 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4314 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4315 dtd->scaffIndex[dtd->scaffLevel] = myindex; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4316 dtd->scaffLevel++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4317 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
|
4318 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4319 handleDefault = XML_FALSE; |
| 21930 | 4320 } |
| 4321 break; | |
| 4322 case XML_ROLE_GROUP_SEQUENCE: | |
| 4323 if (groupConnector[prologState.level] == '|') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4324 return XML_ERROR_SYNTAX; |
| 21930 | 4325 groupConnector[prologState.level] = ','; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4326 if (dtd->in_eldecl && elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4327 handleDefault = XML_FALSE; |
| 21930 | 4328 break; |
| 4329 case XML_ROLE_GROUP_CHOICE: | |
| 4330 if (groupConnector[prologState.level] == ',') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4331 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4332 if (dtd->in_eldecl |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4333 && !groupConnector[prologState.level] |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4334 && (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
|
4335 != XML_CTYPE_MIXED) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4336 ) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4337 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
|
4338 = XML_CTYPE_CHOICE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4339 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4340 handleDefault = XML_FALSE; |
| 21930 | 4341 } |
| 4342 groupConnector[prologState.level] = '|'; | |
| 4343 break; | |
| 4344 case XML_ROLE_PARAM_ENTITY_REF: | |
| 4345 #ifdef XML_DTD | |
| 4346 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
|
4347 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4348 if (!paramEntityParsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4349 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4350 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4351 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4352 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4353 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4354 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4355 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4356 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4357 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4358 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
|
4359 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4360 /* 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
|
4361 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
|
4362 otherwise call the skipped entity handler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4363 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4364 if (prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4365 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4366 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4367 : !dtd->hasParamEntityRefs)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4368 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4369 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4370 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4371 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
|
4372 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4373 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4374 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4375 /* cannot report skipped entities in declarations */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4376 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
|
4377 skippedEntityHandler(handlerArg, name, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4378 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4379 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4380 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4381 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4382 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4383 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4384 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4385 enum XML_Error result; |
| 32911 | 4386 XML_Bool betweenDecl = |
| 4387 (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); | |
| 4388 result = processInternalEntity(parser, entity, betweenDecl); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4389 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4390 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4391 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4392 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4393 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4394 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4395 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4396 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4397 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4398 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4399 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4400 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4401 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4402 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4403 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4404 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4405 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4406 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4407 if (!dtd->paramEntityRead) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4408 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4409 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4410 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4411 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4412 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4413 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4414 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4415 } |
| 21930 | 4416 } |
| 4417 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4418 if (!dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4419 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4420 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4421 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4422 break; |
| 4423 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4424 /* Element declaration stuff */ |
| 21930 | 4425 |
| 4426 case XML_ROLE_ELEMENT_NAME: | |
| 4427 if (elementDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4428 declElementType = getElementType(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4429 if (!declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4430 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4431 dtd->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4432 dtd->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4433 dtd->in_eldecl = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4434 handleDefault = XML_FALSE; |
| 21930 | 4435 } |
| 4436 break; | |
| 4437 | |
| 4438 case XML_ROLE_CONTENT_ANY: | |
| 4439 case XML_ROLE_CONTENT_EMPTY: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4440 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4441 if (elementDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4442 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
|
4443 if (!content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4444 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4445 content->quant = XML_CQUANT_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4446 content->name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4447 content->numchildren = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4448 content->children = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4449 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
|
4450 XML_CTYPE_ANY : |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4451 XML_CTYPE_EMPTY); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4452 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4453 elementDeclHandler(handlerArg, declElementType->name, content); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4454 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4455 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4456 dtd->in_eldecl = XML_FALSE; |
| 21930 | 4457 } |
| 4458 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4459 |
| 21930 | 4460 case XML_ROLE_CONTENT_PCDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4461 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4462 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
|
4463 = XML_CTYPE_MIXED; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4464 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4465 handleDefault = XML_FALSE; |
| 21930 | 4466 } |
| 4467 break; | |
| 4468 | |
| 4469 case XML_ROLE_CONTENT_ELEMENT: | |
| 4470 quant = XML_CQUANT_NONE; | |
| 4471 goto elementContent; | |
| 4472 case XML_ROLE_CONTENT_ELEMENT_OPT: | |
| 4473 quant = XML_CQUANT_OPT; | |
| 4474 goto elementContent; | |
| 4475 case XML_ROLE_CONTENT_ELEMENT_REP: | |
| 4476 quant = XML_CQUANT_REP; | |
| 4477 goto elementContent; | |
| 4478 case XML_ROLE_CONTENT_ELEMENT_PLUS: | |
| 4479 quant = XML_CQUANT_PLUS; | |
| 4480 elementContent: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4481 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4482 ELEMENT_TYPE *el; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4483 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4484 int nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4485 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
|
4486 ? next |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4487 : next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4488 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4489 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4490 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4491 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
|
4492 dtd->scaffold[myindex].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4493 el = getElementType(parser, enc, s, nxt); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4494 if (!el) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4495 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4496 name = el->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4497 dtd->scaffold[myindex].name = name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4498 nameLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4499 for (; name[nameLen++]; ); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4500 dtd->contentStringLen += nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4501 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4502 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4503 } |
| 21930 | 4504 break; |
| 4505 | |
| 4506 case XML_ROLE_GROUP_CLOSE: | |
| 4507 quant = XML_CQUANT_NONE; | |
| 4508 goto closeGroup; | |
| 4509 case XML_ROLE_GROUP_CLOSE_OPT: | |
| 4510 quant = XML_CQUANT_OPT; | |
| 4511 goto closeGroup; | |
| 4512 case XML_ROLE_GROUP_CLOSE_REP: | |
| 4513 quant = XML_CQUANT_REP; | |
| 4514 goto closeGroup; | |
| 4515 case XML_ROLE_GROUP_CLOSE_PLUS: | |
| 4516 quant = XML_CQUANT_PLUS; | |
| 4517 closeGroup: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4518 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4519 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4520 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4521 dtd->scaffLevel--; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4522 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
|
4523 if (dtd->scaffLevel == 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4524 if (!handleDefault) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4525 XML_Content *model = build_model(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4526 if (!model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4527 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4528 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4529 elementDeclHandler(handlerArg, declElementType->name, model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4530 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4531 dtd->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4532 dtd->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4533 } |
| 21930 | 4534 } |
| 4535 break; | |
| 4536 /* End element declaration stuff */ | |
| 4537 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4538 case XML_ROLE_PI: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4539 if (!reportProcessingInstruction(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4540 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4541 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4542 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4543 case XML_ROLE_COMMENT: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4544 if (!reportComment(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4545 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4546 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4547 break; |
| 21930 | 4548 case XML_ROLE_NONE: |
| 4549 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4550 case XML_TOK_BOM: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4551 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4552 break; |
| 21930 | 4553 } |
| 4554 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4555 case XML_ROLE_DOCTYPE_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4556 if (startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4557 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4558 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4559 case XML_ROLE_ENTITY_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4560 if (dtd->keepProcessing && entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4561 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4562 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4563 case XML_ROLE_NOTATION_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4564 if (notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4565 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4566 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4567 case XML_ROLE_ATTLIST_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4568 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4569 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4570 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4571 case XML_ROLE_ELEMENT_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4572 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4573 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4574 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4575 } /* end of big switch */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4576 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4577 if (handleDefault && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4578 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4579 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4580 switch (ps_parsing) { |
| 32911 | 4581 case XML_SUSPENDED: |
| 4582 *nextPtr = next; | |
| 4583 return XML_ERROR_NONE; | |
| 4584 case XML_FINISHED: | |
| 4585 return XML_ERROR_ABORTED; | |
| 4586 default: | |
| 4587 s = next; | |
| 4588 tok = XmlPrologTok(enc, s, end, &next); | |
| 4589 } | |
| 21930 | 4590 } |
| 4591 /* not reached */ | |
| 4592 } | |
| 4593 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4594 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4595 epilogProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4596 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4597 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4598 const char **nextPtr) |
| 21930 | 4599 { |
| 4600 processor = epilogProcessor; | |
| 4601 eventPtr = s; | |
| 4602 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4603 const char *next = NULL; |
| 21930 | 4604 int tok = XmlPrologTok(encoding, s, end, &next); |
| 4605 eventEndPtr = next; | |
| 4606 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4607 /* report partial linebreak - it might be the last token */ |
| 21930 | 4608 case -XML_TOK_PROLOG_S: |
| 4609 if (defaultHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4610 reportDefault(parser, encoding, s, next); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4611 if (ps_parsing == XML_FINISHED) |
| 32911 | 4612 return XML_ERROR_ABORTED; |
| 21930 | 4613 } |
| 32911 | 4614 *nextPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4615 return XML_ERROR_NONE; |
| 21930 | 4616 case XML_TOK_NONE: |
| 32911 | 4617 *nextPtr = s; |
| 21930 | 4618 return XML_ERROR_NONE; |
| 4619 case XML_TOK_PROLOG_S: | |
| 4620 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4621 reportDefault(parser, encoding, s, next); |
| 21930 | 4622 break; |
| 4623 case XML_TOK_PI: | |
| 4624 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
|
4625 return XML_ERROR_NO_MEMORY; |
| 21930 | 4626 break; |
| 4627 case XML_TOK_COMMENT: | |
| 4628 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
|
4629 return XML_ERROR_NO_MEMORY; |
| 21930 | 4630 break; |
| 4631 case XML_TOK_INVALID: | |
| 4632 eventPtr = next; | |
| 4633 return XML_ERROR_INVALID_TOKEN; | |
| 4634 case XML_TOK_PARTIAL: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4635 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4636 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4637 return XML_ERROR_NONE; |
| 21930 | 4638 } |
| 4639 return XML_ERROR_UNCLOSED_TOKEN; | |
| 4640 case XML_TOK_PARTIAL_CHAR: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4641 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4642 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4643 return XML_ERROR_NONE; |
| 21930 | 4644 } |
| 4645 return XML_ERROR_PARTIAL_CHAR; | |
| 4646 default: | |
| 4647 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; | |
| 4648 } | |
| 4649 eventPtr = s = next; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4650 switch (ps_parsing) { |
| 32911 | 4651 case XML_SUSPENDED: |
| 4652 *nextPtr = next; | |
| 4653 return XML_ERROR_NONE; | |
| 4654 case XML_FINISHED: | |
| 4655 return XML_ERROR_ABORTED; | |
| 4656 default: ; | |
| 4657 } | |
| 21930 | 4658 } |
| 4659 } | |
| 4660 | |
| 4661 static enum XML_Error | |
| 32911 | 4662 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 4663 XML_Bool betweenDecl) | |
| 21930 | 4664 { |
| 32911 | 4665 const char *textStart, *textEnd; |
| 4666 const char *next; | |
| 21930 | 4667 enum XML_Error result; |
| 32911 | 4668 OPEN_INTERNAL_ENTITY *openEntity; |
| 4669 | |
| 4670 if (freeInternalEntities) { | |
| 4671 openEntity = freeInternalEntities; | |
| 4672 freeInternalEntities = openEntity->next; | |
| 4673 } | |
| 4674 else { | |
| 4675 openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY)); | |
| 4676 if (!openEntity) | |
| 4677 return XML_ERROR_NO_MEMORY; | |
| 4678 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4679 entity->open = XML_TRUE; |
| 32911 | 4680 entity->processed = 0; |
| 4681 openEntity->next = openInternalEntities; | |
| 4682 openInternalEntities = openEntity; | |
| 4683 openEntity->entity = entity; | |
| 4684 openEntity->startTagLevel = tagLevel; | |
| 4685 openEntity->betweenDecl = betweenDecl; | |
| 4686 openEntity->internalEventPtr = NULL; | |
| 4687 openEntity->internalEventEndPtr = NULL; | |
| 4688 textStart = (char *)entity->textPtr; | |
| 4689 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4690 | |
| 4691 #ifdef XML_DTD | |
| 4692 if (entity->is_param) { | |
| 4693 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
| 4694 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | |
| 4695 next, &next, XML_FALSE); | |
| 4696 } | |
| 4697 else | |
| 4698 #endif /* XML_DTD */ | |
| 4699 result = doContent(parser, tagLevel, internalEncoding, textStart, | |
| 4700 textEnd, &next, XML_FALSE); | |
| 4701 | |
| 4702 if (result == XML_ERROR_NONE) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4703 if (textEnd != next && ps_parsing == XML_SUSPENDED) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4704 entity->processed = (int)(next - textStart); |
| 32911 | 4705 processor = internalEntityProcessor; |
| 4706 } | |
| 4707 else { | |
| 4708 entity->open = XML_FALSE; | |
| 4709 openInternalEntities = openEntity->next; | |
| 4710 /* put openEntity back in list of free instances */ | |
| 4711 openEntity->next = freeInternalEntities; | |
| 4712 freeInternalEntities = openEntity; | |
| 4713 } | |
| 4714 } | |
| 21930 | 4715 return result; |
| 4716 } | |
| 4717 | |
| 32911 | 4718 static enum XML_Error PTRCALL |
| 4719 internalEntityProcessor(XML_Parser parser, | |
| 4720 const char *s, | |
| 4721 const char *end, | |
| 4722 const char **nextPtr) | |
| 4723 { | |
| 4724 ENTITY *entity; | |
| 4725 const char *textStart, *textEnd; | |
| 4726 const char *next; | |
| 4727 enum XML_Error result; | |
| 4728 OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; | |
| 4729 if (!openEntity) | |
| 4730 return XML_ERROR_UNEXPECTED_STATE; | |
| 4731 | |
| 4732 entity = openEntity->entity; | |
| 4733 textStart = ((char *)entity->textPtr) + entity->processed; | |
| 4734 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4735 | |
| 4736 #ifdef XML_DTD | |
| 4737 if (entity->is_param) { | |
| 4738 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
| 4739 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | |
| 4740 next, &next, XML_FALSE); | |
| 4741 } | |
| 4742 else | |
| 21930 | 4743 #endif /* XML_DTD */ |
| 32911 | 4744 result = doContent(parser, openEntity->startTagLevel, internalEncoding, |
| 4745 textStart, textEnd, &next, XML_FALSE); | |
| 4746 | |
| 4747 if (result != XML_ERROR_NONE) | |
| 4748 return result; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4749 else if (textEnd != next && ps_parsing == XML_SUSPENDED) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4750 entity->processed = (int)(next - (char *)entity->textPtr); |
| 32911 | 4751 return result; |
| 4752 } | |
| 4753 else { | |
| 4754 entity->open = XML_FALSE; | |
| 4755 openInternalEntities = openEntity->next; | |
| 4756 /* put openEntity back in list of free instances */ | |
| 4757 openEntity->next = freeInternalEntities; | |
| 4758 freeInternalEntities = openEntity; | |
| 4759 } | |
| 4760 | |
| 4761 #ifdef XML_DTD | |
| 4762 if (entity->is_param) { | |
| 4763 int tok; | |
| 4764 processor = prologProcessor; | |
| 4765 tok = XmlPrologTok(encoding, s, end, &next); | |
| 4766 return doProlog(parser, encoding, s, end, tok, next, nextPtr, | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4767 (XML_Bool)!ps_finalBuffer); |
| 32911 | 4768 } |
| 4769 else | |
| 4770 #endif /* XML_DTD */ | |
| 4771 { | |
| 4772 processor = contentProcessor; | |
| 4773 /* see externalEntityContentProcessor vs contentProcessor */ | |
| 4774 return doContent(parser, parentParser ? 1 : 0, encoding, s, end, | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4775 nextPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 4776 } |
| 4777 } | |
| 21930 | 4778 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4779 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4780 errorProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4781 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4782 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4783 const char **nextPtr) |
| 21930 | 4784 { |
| 4785 return errorCode; | |
| 4786 } | |
| 4787 | |
| 4788 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4789 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
|
4790 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4791 STRING_POOL *pool) |
| 21930 | 4792 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4793 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
|
4794 end, pool); |
| 21930 | 4795 if (result) |
| 4796 return result; | |
| 4797 if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) | |
| 4798 poolChop(pool); | |
| 4799 if (!poolAppendChar(pool, XML_T('\0'))) | |
| 4800 return XML_ERROR_NO_MEMORY; | |
| 4801 return XML_ERROR_NONE; | |
| 4802 } | |
| 4803 | |
| 4804 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4805 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
|
4806 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4807 STRING_POOL *pool) |
| 21930 | 4808 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4809 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4810 for (;;) { |
| 4811 const char *next; | |
| 4812 int tok = XmlAttributeValueTok(enc, ptr, end, &next); | |
| 4813 switch (tok) { | |
| 4814 case XML_TOK_NONE: | |
| 4815 return XML_ERROR_NONE; | |
| 4816 case XML_TOK_INVALID: | |
| 4817 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4818 eventPtr = next; |
| 21930 | 4819 return XML_ERROR_INVALID_TOKEN; |
| 4820 case XML_TOK_PARTIAL: | |
| 4821 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4822 eventPtr = ptr; |
| 21930 | 4823 return XML_ERROR_INVALID_TOKEN; |
| 4824 case XML_TOK_CHAR_REF: | |
| 4825 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4826 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4827 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4828 int n = XmlCharRefNumber(enc, ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4829 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4830 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4831 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4832 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4833 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4834 if (!isCdata |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4835 && n == 0x20 /* space */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4836 && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4837 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4838 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4839 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4840 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4841 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4842 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4843 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4844 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4845 if (!poolAppendChar(pool, buf[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4846 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4847 } |
| 21930 | 4848 } |
| 4849 break; | |
| 4850 case XML_TOK_DATA_CHARS: | |
| 4851 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
|
4852 return XML_ERROR_NO_MEMORY; |
| 21930 | 4853 break; |
| 4854 case XML_TOK_TRAILING_CR: | |
| 4855 next = ptr + enc->minBytesPerChar; | |
| 4856 /* fall through */ | |
| 4857 case XML_TOK_ATTRIBUTE_VALUE_S: | |
| 4858 case XML_TOK_DATA_NEWLINE: | |
| 4859 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
|
4860 break; |
| 21930 | 4861 if (!poolAppendChar(pool, 0x20)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4862 return XML_ERROR_NO_MEMORY; |
| 21930 | 4863 break; |
| 4864 case XML_TOK_ENTITY_REF: | |
| 4865 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4866 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4867 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4868 char checkEntityDecl; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4869 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
|
4870 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4871 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4872 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4873 if (!poolAppendChar(pool, ch)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4874 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4875 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4876 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4877 name = poolStoreString(&temp2Pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4878 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4879 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4880 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4881 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4882 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
|
4883 poolDiscard(&temp2Pool); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4884 /* First, determine if a check for an existing declaration is needed; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4885 if yes, check that the entity exists, and that it is internal. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4886 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4887 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
|
4888 checkEntityDecl = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4889 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4890 prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4891 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4892 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4893 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4894 : !dtd->hasParamEntityRefs); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4895 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
|
4896 checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4897 if (checkEntityDecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4898 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4899 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4900 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4901 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
|
4902 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4903 else if (!entity) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4904 /* Cannot report skipped entity here - see comments on |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4905 skippedEntityHandler. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4906 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4907 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4908 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4909 /* Cannot call the default handler because this would be |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4910 out of sync with the call to the startElementHandler. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4911 if ((pool == &tempPool) && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4912 reportDefault(parser, enc, ptr, next); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4913 */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4914 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4915 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4916 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4917 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4918 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4919 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4920 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4921 if (entity->notation) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4922 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4923 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4924 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4925 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4926 if (!entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4927 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4928 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4929 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
|
4930 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4931 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4932 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4933 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
|
4934 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4935 result = appendAttributeValue(parser, internalEncoding, isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4936 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4937 (char *)textEnd, pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4938 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4939 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4940 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4941 } |
| 21930 | 4942 } |
| 4943 break; | |
| 4944 default: | |
| 4945 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4946 eventPtr = ptr; |
| 21930 | 4947 return XML_ERROR_UNEXPECTED_STATE; |
| 4948 } | |
| 4949 ptr = next; | |
| 4950 } | |
| 4951 /* not reached */ | |
| 4952 } | |
| 4953 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4954 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4955 storeEntityValue(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4956 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4957 const char *entityTextPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4958 const char *entityTextEnd) |
| 21930 | 4959 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4960 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
|
4961 STRING_POOL *pool = &(dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4962 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
|
4963 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4964 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4965 prologState.inEntityValue = 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4966 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4967 /* 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
|
4968 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
|
4969 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
|
4970 if (!pool->blocks) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4971 if (!poolGrow(pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4972 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4973 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4974 |
| 21930 | 4975 for (;;) { |
| 4976 const char *next; | |
| 4977 int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); | |
| 4978 switch (tok) { | |
| 4979 case XML_TOK_PARAM_ENTITY_REF: | |
| 4980 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4981 if (isParamEntity || enc != encoding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4982 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4983 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4984 name = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4985 entityTextPtr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4986 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4987 if (!name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4988 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4989 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4990 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4991 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
|
4992 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4993 if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4994 /* 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
|
4995 /* 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
|
4996 skippedEntityHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4997 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4998 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4999 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5000 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5001 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5002 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5003 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5004 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5005 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5006 result = XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5007 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5008 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5009 if (entity->systemId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5010 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5011 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5012 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5013 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5014 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5015 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5016 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5017 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5018 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5019 result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5020 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5021 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5022 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5023 if (!dtd->paramEntityRead) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5024 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5025 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5026 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5027 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5028 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5029 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5030 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5031 result = storeEntityValue(parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5032 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5033 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5034 (char *)(entity->textPtr |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5035 + entity->textLen)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5036 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5037 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5038 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5039 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5040 break; |
| 21930 | 5041 } |
| 5042 #endif /* XML_DTD */ | |
| 32911 | 5043 /* In the internal subset, PE references are not legal |
| 5044 within markup declarations, e.g entity values in this case. */ | |
| 21930 | 5045 eventPtr = entityTextPtr; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5046 result = XML_ERROR_PARAM_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5047 goto endEntityValue; |
| 21930 | 5048 case XML_TOK_NONE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5049 result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5050 goto endEntityValue; |
| 21930 | 5051 case XML_TOK_ENTITY_REF: |
| 5052 case XML_TOK_DATA_CHARS: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5053 if (!poolAppend(pool, enc, entityTextPtr, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5054 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5055 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5056 } |
| 21930 | 5057 break; |
| 5058 case XML_TOK_TRAILING_CR: | |
| 5059 next = entityTextPtr + enc->minBytesPerChar; | |
| 5060 /* fall through */ | |
| 5061 case XML_TOK_DATA_NEWLINE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5062 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
|
5063 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5064 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5065 } |
| 21930 | 5066 *(pool->ptr)++ = 0xA; |
| 5067 break; | |
| 5068 case XML_TOK_CHAR_REF: | |
| 5069 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5070 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5071 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5072 int n = XmlCharRefNumber(enc, entityTextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5073 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5074 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5075 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5076 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5077 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5078 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5079 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5080 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5081 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5082 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5083 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5084 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5085 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5086 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5087 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
|
5088 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5089 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5090 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5091 *(pool->ptr)++ = buf[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5092 } |
| 21930 | 5093 } |
| 5094 break; | |
| 5095 case XML_TOK_PARTIAL: | |
| 5096 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5097 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5098 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5099 goto endEntityValue; |
| 21930 | 5100 case XML_TOK_INVALID: |
| 5101 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5102 eventPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5103 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5104 goto endEntityValue; |
| 21930 | 5105 default: |
| 5106 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5107 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5108 result = XML_ERROR_UNEXPECTED_STATE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5109 goto endEntityValue; |
| 21930 | 5110 } |
| 5111 entityTextPtr = next; | |
| 5112 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5113 endEntityValue: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5114 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5115 prologState.inEntityValue = oldInEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5116 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5117 return result; |
| 21930 | 5118 } |
| 5119 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5120 static void FASTCALL |
| 21930 | 5121 normalizeLines(XML_Char *s) |
| 5122 { | |
| 5123 XML_Char *p; | |
| 5124 for (;; s++) { | |
| 5125 if (*s == XML_T('\0')) | |
| 5126 return; | |
| 5127 if (*s == 0xD) | |
| 5128 break; | |
| 5129 } | |
| 5130 p = s; | |
| 5131 do { | |
| 5132 if (*s == 0xD) { | |
| 5133 *p++ = 0xA; | |
| 5134 if (*++s == 0xA) | |
| 5135 s++; | |
| 5136 } | |
| 5137 else | |
| 5138 *p++ = *s++; | |
| 5139 } while (*s); | |
| 5140 *p = XML_T('\0'); | |
| 5141 } | |
| 5142 | |
| 5143 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5144 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
|
5145 const char *start, const char *end) |
| 21930 | 5146 { |
| 5147 const XML_Char *target; | |
| 5148 XML_Char *data; | |
| 5149 const char *tem; | |
| 5150 if (!processingInstructionHandler) { | |
| 5151 if (defaultHandler) | |
| 5152 reportDefault(parser, enc, start, end); | |
| 5153 return 1; | |
| 5154 } | |
| 5155 start += enc->minBytesPerChar * 2; | |
| 5156 tem = start + XmlNameLength(enc, start); | |
| 5157 target = poolStoreString(&tempPool, enc, start, tem); | |
| 5158 if (!target) | |
| 5159 return 0; | |
| 5160 poolFinish(&tempPool); | |
| 5161 data = poolStoreString(&tempPool, enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5162 XmlSkipS(enc, tem), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5163 end - enc->minBytesPerChar*2); |
| 21930 | 5164 if (!data) |
| 5165 return 0; | |
| 5166 normalizeLines(data); | |
| 5167 processingInstructionHandler(handlerArg, target, data); | |
| 5168 poolClear(&tempPool); | |
| 5169 return 1; | |
| 5170 } | |
| 5171 | |
| 5172 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5173 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
|
5174 const char *start, const char *end) |
| 21930 | 5175 { |
| 5176 XML_Char *data; | |
| 5177 if (!commentHandler) { | |
| 5178 if (defaultHandler) | |
| 5179 reportDefault(parser, enc, start, end); | |
| 5180 return 1; | |
| 5181 } | |
| 5182 data = poolStoreString(&tempPool, | |
| 5183 enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5184 start + enc->minBytesPerChar * 4, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5185 end - enc->minBytesPerChar * 3); |
| 21930 | 5186 if (!data) |
| 5187 return 0; | |
| 5188 normalizeLines(data); | |
| 5189 commentHandler(handlerArg, data); | |
| 5190 poolClear(&tempPool); | |
| 5191 return 1; | |
| 5192 } | |
| 5193 | |
| 5194 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5195 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
|
5196 const char *s, const char *end) |
| 21930 | 5197 { |
| 5198 if (MUST_CONVERT(enc, s)) { | |
| 5199 const char **eventPP; | |
| 5200 const char **eventEndPP; | |
| 5201 if (enc == encoding) { | |
| 5202 eventPP = &eventPtr; | |
| 5203 eventEndPP = &eventEndPtr; | |
| 5204 } | |
| 5205 else { | |
| 5206 eventPP = &(openInternalEntities->internalEventPtr); | |
| 5207 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 5208 } | |
| 5209 do { | |
| 5210 ICHAR *dataPtr = (ICHAR *)dataBuf; | |
| 5211 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | |
| 5212 *eventEndPP = s; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5213 defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); |
| 21930 | 5214 *eventPP = s; |
| 5215 } while (s != end); | |
| 5216 } | |
| 5217 else | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5218 defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 5219 } |
| 5220 | |
| 5221 | |
| 5222 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5223 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
|
5224 XML_Bool isId, const XML_Char *value, XML_Parser parser) |
| 21930 | 5225 { |
| 5226 DEFAULT_ATTRIBUTE *att; | |
| 5227 if (value || isId) { | |
| 5228 /* The handling of default attributes gets messed up if we have | |
| 5229 a default which duplicates a non-default. */ | |
| 5230 int i; | |
| 5231 for (i = 0; i < type->nDefaultAtts; i++) | |
| 5232 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
|
5233 return 1; |
| 21930 | 5234 if (isId && !type->idAtt && !attId->xmlns) |
| 5235 type->idAtt = attId; | |
| 5236 } | |
| 5237 if (type->nDefaultAtts == type->allocDefaultAtts) { | |
| 5238 if (type->allocDefaultAtts == 0) { | |
| 5239 type->allocDefaultAtts = 8; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5240 type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5241 * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5242 if (!type->defaultAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5243 return 0; |
| 21930 | 5244 } |
| 5245 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5246 DEFAULT_ATTRIBUTE *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5247 int count = type->allocDefaultAtts * 2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5248 temp = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5249 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
|
5250 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5251 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5252 type->allocDefaultAtts = count; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5253 type->defaultAtts = temp; |
| 21930 | 5254 } |
| 5255 } | |
| 5256 att = type->defaultAtts + type->nDefaultAtts; | |
| 5257 att->id = attId; | |
| 5258 att->value = value; | |
| 5259 att->isCdata = isCdata; | |
| 5260 if (!isCdata) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5261 attId->maybeTokenized = XML_TRUE; |
| 21930 | 5262 type->nDefaultAtts += 1; |
| 5263 return 1; | |
| 5264 } | |
| 5265 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5266 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5267 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) |
| 21930 | 5268 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5269 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5270 const XML_Char *name; |
| 5271 for (name = elementType->name; *name; name++) { | |
| 5272 if (*name == XML_T(':')) { | |
| 5273 PREFIX *prefix; | |
| 5274 const XML_Char *s; | |
| 5275 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
|
5276 if (!poolAppendChar(&dtd->pool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5277 return 0; |
| 21930 | 5278 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5279 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
|
5280 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5281 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
|
5282 sizeof(PREFIX)); |
| 21930 | 5283 if (!prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5284 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5285 if (prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5286 poolFinish(&dtd->pool); |
| 21930 | 5287 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5288 poolDiscard(&dtd->pool); |
| 21930 | 5289 elementType->prefix = prefix; |
| 5290 | |
| 5291 } | |
| 5292 } | |
| 5293 return 1; | |
| 5294 } | |
| 5295 | |
| 5296 static ATTRIBUTE_ID * | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5297 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
|
5298 const char *start, const char *end) |
| 21930 | 5299 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5300 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5301 ATTRIBUTE_ID *id; |
| 5302 const XML_Char *name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5303 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
|
5304 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5305 name = poolStoreString(&dtd->pool, enc, start, end); |
| 21930 | 5306 if (!name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5307 return NULL; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5308 /* skip quotation mark - its storage will be re-used (like in name[-1]) */ |
| 21930 | 5309 ++name; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5310 id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); |
| 21930 | 5311 if (!id) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5312 return NULL; |
| 21930 | 5313 if (id->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5314 poolDiscard(&dtd->pool); |
| 21930 | 5315 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5316 poolFinish(&dtd->pool); |
| 21930 | 5317 if (!ns) |
| 5318 ; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5319 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
|
5320 && name[1] == XML_T('m') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5321 && name[2] == XML_T('l') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5322 && name[3] == XML_T('n') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5323 && name[4] == XML_T('s') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5324 && (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
|
5325 if (name[5] == XML_T('\0')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5326 id->prefix = &dtd->defaultPrefix; |
| 21930 | 5327 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5328 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
|
5329 id->xmlns = XML_TRUE; |
| 21930 | 5330 } |
| 5331 else { | |
| 5332 int i; | |
| 5333 for (i = 0; name[i]; i++) { | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5334 /* attributes without prefix are *not* in the default namespace */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5335 if (name[i] == XML_T(':')) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5336 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5337 for (j = 0; j < i; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5338 if (!poolAppendChar(&dtd->pool, name[j])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5339 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5340 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5341 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
|
5342 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5343 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
|
5344 sizeof(PREFIX)); |
|
39473
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
5345 if (!id->prefix) |
|
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
5346 return NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5347 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
|
5348 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5349 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5350 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5351 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5352 } |
| 21930 | 5353 } |
| 5354 } | |
| 5355 } | |
| 5356 return id; | |
| 5357 } | |
| 5358 | |
| 5359 #define CONTEXT_SEP XML_T('\f') | |
| 5360 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5361 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5362 getContext(XML_Parser parser) |
| 21930 | 5363 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5364 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5365 HASH_TABLE_ITER iter; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5366 XML_Bool needSep = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5367 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5368 if (dtd->defaultPrefix.binding) { |
| 21930 | 5369 int i; |
| 5370 int len; | |
| 5371 if (!poolAppendChar(&tempPool, XML_T('='))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5372 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5373 len = dtd->defaultPrefix.binding->uriLen; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5374 if (namespaceSeparator) |
| 21930 | 5375 len--; |
| 5376 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
|
5377 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
|
5378 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5379 needSep = XML_TRUE; |
| 21930 | 5380 } |
| 5381 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5382 hashTableIterInit(&iter, &(dtd->prefixes)); |
| 21930 | 5383 for (;;) { |
| 5384 int i; | |
| 5385 int len; | |
| 5386 const XML_Char *s; | |
| 5387 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); | |
| 5388 if (!prefix) | |
| 5389 break; | |
| 5390 if (!prefix->binding) | |
| 5391 continue; | |
| 5392 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
|
5393 return NULL; |
| 21930 | 5394 for (s = prefix->name; *s; s++) |
| 5395 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5396 return NULL; |
| 21930 | 5397 if (!poolAppendChar(&tempPool, XML_T('='))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5398 return NULL; |
| 21930 | 5399 len = prefix->binding->uriLen; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5400 if (namespaceSeparator) |
| 21930 | 5401 len--; |
| 5402 for (i = 0; i < len; i++) | |
| 5403 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
|
5404 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5405 needSep = XML_TRUE; |
| 21930 | 5406 } |
| 5407 | |
| 5408 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5409 hashTableIterInit(&iter, &(dtd->generalEntities)); |
| 21930 | 5410 for (;;) { |
| 5411 const XML_Char *s; | |
| 5412 ENTITY *e = (ENTITY *)hashTableIterNext(&iter); | |
| 5413 if (!e) | |
| 5414 break; | |
| 5415 if (!e->open) | |
| 5416 continue; | |
| 5417 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
|
5418 return NULL; |
| 21930 | 5419 for (s = e->name; *s; s++) |
| 5420 if (!poolAppendChar(&tempPool, *s)) | |
| 5421 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5422 needSep = XML_TRUE; |
| 21930 | 5423 } |
| 5424 | |
| 5425 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
|
5426 return NULL; |
| 21930 | 5427 return tempPool.start; |
| 5428 } | |
| 5429 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5430 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5431 setContext(XML_Parser parser, const XML_Char *context) |
| 21930 | 5432 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5433 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5434 const XML_Char *s = context; |
| 5435 | |
| 5436 while (*context != XML_T('\0')) { | |
| 5437 if (*s == CONTEXT_SEP || *s == XML_T('\0')) { | |
| 5438 ENTITY *e; | |
| 5439 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
|
5440 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5441 e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); |
| 21930 | 5442 if (e) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5443 e->open = XML_TRUE; |
| 21930 | 5444 if (*s != XML_T('\0')) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5445 s++; |
| 21930 | 5446 context = s; |
| 5447 poolDiscard(&tempPool); | |
| 5448 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5449 else if (*s == XML_T('=')) { |
| 21930 | 5450 PREFIX *prefix; |
| 5451 if (poolLength(&tempPool) == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5452 prefix = &dtd->defaultPrefix; |
| 21930 | 5453 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5454 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5455 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5456 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
|
5457 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5458 if (!prefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5459 return XML_FALSE; |
| 21930 | 5460 if (prefix->name == poolStart(&tempPool)) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5461 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
|
5462 if (!prefix->name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5463 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5464 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5465 poolDiscard(&tempPool); |
| 21930 | 5466 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5467 for (context = s + 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5468 *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
|
5469 context++) |
| 21930 | 5470 if (!poolAppendChar(&tempPool, *context)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5471 return XML_FALSE; |
| 21930 | 5472 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
|
5473 return XML_FALSE; |
| 32911 | 5474 if (addBinding(parser, prefix, NULL, poolStart(&tempPool), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5475 &inheritedBindings) != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5476 return XML_FALSE; |
| 21930 | 5477 poolDiscard(&tempPool); |
| 5478 if (*context != XML_T('\0')) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5479 ++context; |
| 21930 | 5480 s = context; |
| 5481 } | |
| 5482 else { | |
| 5483 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5484 return XML_FALSE; |
| 21930 | 5485 s++; |
| 5486 } | |
| 5487 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5488 return XML_TRUE; |
| 21930 | 5489 } |
| 5490 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5491 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5492 normalizePublicId(XML_Char *publicId) |
| 21930 | 5493 { |
| 5494 XML_Char *p = publicId; | |
| 5495 XML_Char *s; | |
| 5496 for (s = publicId; *s; s++) { | |
| 5497 switch (*s) { | |
| 5498 case 0x20: | |
| 5499 case 0xD: | |
| 5500 case 0xA: | |
| 5501 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
|
5502 *p++ = 0x20; |
| 21930 | 5503 break; |
| 5504 default: | |
| 5505 *p++ = *s; | |
| 5506 } | |
| 5507 } | |
| 5508 if (p != publicId && p[-1] == 0x20) | |
| 5509 --p; | |
| 5510 *p = XML_T('\0'); | |
| 5511 } | |
| 5512 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5513 static DTD * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5514 dtdCreate(const XML_Memory_Handling_Suite *ms) |
| 21930 | 5515 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5516 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
|
5517 if (p == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5518 return p; |
| 21930 | 5519 poolInit(&(p->pool), ms); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5520 poolInit(&(p->entityValuePool), ms); |
| 21930 | 5521 hashTableInit(&(p->generalEntities), ms); |
| 5522 hashTableInit(&(p->elementTypes), ms); | |
| 5523 hashTableInit(&(p->attributeIds), ms); | |
| 5524 hashTableInit(&(p->prefixes), ms); | |
| 5525 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5526 p->paramEntityRead = XML_FALSE; |
| 21930 | 5527 hashTableInit(&(p->paramEntities), ms); |
| 5528 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5529 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5530 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5531 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5532 p->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5533 p->scaffIndex = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5534 p->scaffold = NULL; |
| 21930 | 5535 p->scaffLevel = 0; |
| 5536 p->scaffSize = 0; | |
| 5537 p->scaffCount = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5538 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5539 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5540 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5541 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5542 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5543 return p; |
| 21930 | 5544 } |
| 5545 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5546 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5547 dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5548 { |
| 5549 HASH_TABLE_ITER iter; | |
| 5550 hashTableIterInit(&iter, &(p->elementTypes)); | |
| 5551 for (;;) { | |
| 5552 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5553 if (!e) | |
| 5554 break; | |
| 5555 if (e->allocDefaultAtts != 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5556 ms->free_fcn(e->defaultAtts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5557 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5558 hashTableClear(&(p->generalEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5559 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5560 p->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5561 hashTableClear(&(p->paramEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5562 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5563 hashTableClear(&(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5564 hashTableClear(&(p->attributeIds)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5565 hashTableClear(&(p->prefixes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5566 poolClear(&(p->pool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5567 poolClear(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5568 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5569 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5570 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5571 p->in_eldecl = XML_FALSE; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5572 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5573 ms->free_fcn(p->scaffIndex); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5574 p->scaffIndex = NULL; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5575 ms->free_fcn(p->scaffold); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5576 p->scaffold = NULL; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5577 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5578 p->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5579 p->scaffSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5580 p->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5581 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5582 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5583 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5584 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5585 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5586 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5587 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5588 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5589 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
|
5590 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5591 HASH_TABLE_ITER iter; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5592 hashTableIterInit(&iter, &(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5593 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5594 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
|
5595 if (!e) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5596 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5597 if (e->allocDefaultAtts != 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5598 ms->free_fcn(e->defaultAtts); |
| 21930 | 5599 } |
| 5600 hashTableDestroy(&(p->generalEntities)); | |
| 5601 #ifdef XML_DTD | |
| 5602 hashTableDestroy(&(p->paramEntities)); | |
| 5603 #endif /* XML_DTD */ | |
| 5604 hashTableDestroy(&(p->elementTypes)); | |
| 5605 hashTableDestroy(&(p->attributeIds)); | |
| 5606 hashTableDestroy(&(p->prefixes)); | |
| 5607 poolDestroy(&(p->pool)); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5608 poolDestroy(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5609 if (isDocEntity) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5610 ms->free_fcn(p->scaffIndex); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5611 ms->free_fcn(p->scaffold); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5612 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5613 ms->free_fcn(p); |
| 21930 | 5614 } |
| 5615 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5616 /* 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
|
5617 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
|
5618 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5619 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5620 dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5621 { |
| 5622 HASH_TABLE_ITER iter; | |
| 5623 | |
| 5624 /* Copy the prefix table. */ | |
| 5625 | |
| 5626 hashTableIterInit(&iter, &(oldDtd->prefixes)); | |
| 5627 for (;;) { | |
| 5628 const XML_Char *name; | |
| 5629 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); | |
| 5630 if (!oldP) | |
| 5631 break; | |
| 5632 name = poolCopyString(&(newDtd->pool), oldP->name); | |
| 5633 if (!name) | |
| 5634 return 0; | |
| 5635 if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) | |
| 5636 return 0; | |
| 5637 } | |
| 5638 | |
| 5639 hashTableIterInit(&iter, &(oldDtd->attributeIds)); | |
| 5640 | |
| 5641 /* Copy the attribute id table. */ | |
| 5642 | |
| 5643 for (;;) { | |
| 5644 ATTRIBUTE_ID *newA; | |
| 5645 const XML_Char *name; | |
| 5646 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); | |
| 5647 | |
| 5648 if (!oldA) | |
| 5649 break; | |
| 5650 /* Remember to allocate the scratch byte before the name. */ | |
| 5651 if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) | |
| 5652 return 0; | |
| 5653 name = poolCopyString(&(newDtd->pool), oldA->name); | |
| 5654 if (!name) | |
| 5655 return 0; | |
| 5656 ++name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5657 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
|
5658 sizeof(ATTRIBUTE_ID)); |
| 21930 | 5659 if (!newA) |
| 5660 return 0; | |
| 5661 newA->maybeTokenized = oldA->maybeTokenized; | |
| 5662 if (oldA->prefix) { | |
| 5663 newA->xmlns = oldA->xmlns; | |
| 5664 if (oldA->prefix == &oldDtd->defaultPrefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5665 newA->prefix = &newDtd->defaultPrefix; |
| 21930 | 5666 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5667 newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5668 oldA->prefix->name, 0); |
| 21930 | 5669 } |
| 5670 } | |
| 5671 | |
| 5672 /* Copy the element type table. */ | |
| 5673 | |
| 5674 hashTableIterInit(&iter, &(oldDtd->elementTypes)); | |
| 5675 | |
| 5676 for (;;) { | |
| 5677 int i; | |
| 5678 ELEMENT_TYPE *newE; | |
| 5679 const XML_Char *name; | |
| 5680 const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5681 if (!oldE) | |
| 5682 break; | |
| 5683 name = poolCopyString(&(newDtd->pool), oldE->name); | |
| 5684 if (!name) | |
| 5685 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5686 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
|
5687 sizeof(ELEMENT_TYPE)); |
| 21930 | 5688 if (!newE) |
| 5689 return 0; | |
| 5690 if (oldE->nDefaultAtts) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5691 newE->defaultAtts = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5692 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
|
5693 if (!newE->defaultAtts) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5694 ms->free_fcn(newE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5695 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5696 } |
| 21930 | 5697 } |
| 5698 if (oldE->idAtt) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5699 newE->idAtt = (ATTRIBUTE_ID *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5700 lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); |
| 21930 | 5701 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; |
| 5702 if (oldE->prefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5703 newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5704 oldE->prefix->name, 0); |
| 21930 | 5705 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
|
5706 newE->defaultAtts[i].id = (ATTRIBUTE_ID *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5707 lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); |
| 21930 | 5708 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; |
| 5709 if (oldE->defaultAtts[i].value) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5710 newE->defaultAtts[i].value |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5711 = 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
|
5712 if (!newE->defaultAtts[i].value) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5713 return 0; |
| 21930 | 5714 } |
| 5715 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5716 newE->defaultAtts[i].value = NULL; |
| 21930 | 5717 } |
| 5718 } | |
| 5719 | |
| 5720 /* Copy the entity tables. */ | |
| 5721 if (!copyEntityTable(&(newDtd->generalEntities), | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5722 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5723 &(oldDtd->generalEntities))) |
| 21930 | 5724 return 0; |
| 5725 | |
| 5726 #ifdef XML_DTD | |
| 5727 if (!copyEntityTable(&(newDtd->paramEntities), | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5728 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5729 &(oldDtd->paramEntities))) |
| 21930 | 5730 return 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5731 newDtd->paramEntityRead = oldDtd->paramEntityRead; |
| 21930 | 5732 #endif /* XML_DTD */ |
| 5733 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5734 newDtd->keepProcessing = oldDtd->keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5735 newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; |
| 21930 | 5736 newDtd->standalone = oldDtd->standalone; |
| 5737 | |
| 5738 /* Don't want deep copying for scaffolding */ | |
| 5739 newDtd->in_eldecl = oldDtd->in_eldecl; | |
| 5740 newDtd->scaffold = oldDtd->scaffold; | |
| 5741 newDtd->contentStringLen = oldDtd->contentStringLen; | |
| 5742 newDtd->scaffSize = oldDtd->scaffSize; | |
| 5743 newDtd->scaffLevel = oldDtd->scaffLevel; | |
| 5744 newDtd->scaffIndex = oldDtd->scaffIndex; | |
| 5745 | |
| 5746 return 1; | |
| 5747 } /* End dtdCopy */ | |
| 5748 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5749 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5750 copyEntityTable(HASH_TABLE *newTable, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5751 STRING_POOL *newPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5752 const HASH_TABLE *oldTable) |
| 21930 | 5753 { |
| 5754 HASH_TABLE_ITER iter; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5755 const XML_Char *cachedOldBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5756 const XML_Char *cachedNewBase = NULL; |
| 21930 | 5757 |
| 5758 hashTableIterInit(&iter, oldTable); | |
| 5759 | |
| 5760 for (;;) { | |
| 5761 ENTITY *newE; | |
| 5762 const XML_Char *name; | |
| 5763 const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); | |
| 5764 if (!oldE) | |
| 5765 break; | |
| 5766 name = poolCopyString(newPool, oldE->name); | |
| 5767 if (!name) | |
| 5768 return 0; | |
| 5769 newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); | |
| 5770 if (!newE) | |
| 5771 return 0; | |
| 5772 if (oldE->systemId) { | |
| 5773 const XML_Char *tem = poolCopyString(newPool, oldE->systemId); | |
| 5774 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5775 return 0; |
| 21930 | 5776 newE->systemId = tem; |
| 5777 if (oldE->base) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5778 if (oldE->base == cachedOldBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5779 newE->base = cachedNewBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5780 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5781 cachedOldBase = oldE->base; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5782 tem = poolCopyString(newPool, cachedOldBase); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5783 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5784 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5785 cachedNewBase = newE->base = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5786 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5787 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5788 if (oldE->publicId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5789 tem = poolCopyString(newPool, oldE->publicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5790 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5791 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5792 newE->publicId = tem; |
| 21930 | 5793 } |
| 5794 } | |
| 5795 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5796 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
|
5797 oldE->textLen); |
| 21930 | 5798 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5799 return 0; |
| 21930 | 5800 newE->textPtr = tem; |
| 5801 newE->textLen = oldE->textLen; | |
| 5802 } | |
| 5803 if (oldE->notation) { | |
| 5804 const XML_Char *tem = poolCopyString(newPool, oldE->notation); | |
| 5805 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5806 return 0; |
| 21930 | 5807 newE->notation = tem; |
| 5808 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5809 newE->is_param = oldE->is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5810 newE->is_internal = oldE->is_internal; |
| 21930 | 5811 } |
| 5812 return 1; | |
| 5813 } | |
| 5814 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5815 #define INIT_POWER 6 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5816 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5817 static XML_Bool FASTCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5818 keyeq(KEY s1, KEY s2) |
| 21930 | 5819 { |
| 5820 for (; *s1 == *s2; s1++, s2++) | |
| 5821 if (*s1 == 0) | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5822 return XML_TRUE; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5823 return XML_FALSE; |
| 21930 | 5824 } |
| 5825 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5826 static unsigned long FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5827 hash(KEY s) |
| 21930 | 5828 { |
| 5829 unsigned long h = 0; | |
| 5830 while (*s) | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5831 h = CHAR_HASH(h, *s++); |
| 21930 | 5832 return h; |
| 5833 } | |
| 5834 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5835 static NAMED * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5836 lookup(HASH_TABLE *table, KEY name, size_t createSize) |
| 21930 | 5837 { |
| 5838 size_t i; | |
| 5839 if (table->size == 0) { | |
| 5840 size_t tsize; | |
| 5841 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5842 return NULL; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5843 table->power = INIT_POWER; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5844 /* table->size is a power of 2 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5845 table->size = (size_t)1 << INIT_POWER; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5846 tsize = table->size * sizeof(NAMED *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5847 table->v = (NAMED **)table->mem->malloc_fcn(tsize); |
| 32911 | 5848 if (!table->v) { |
| 5849 table->size = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5850 return NULL; |
| 32911 | 5851 } |
| 21930 | 5852 memset(table->v, 0, tsize); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5853 i = hash(name) & ((unsigned long)table->size - 1); |
| 21930 | 5854 } |
| 5855 else { | |
| 5856 unsigned long h = hash(name); | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5857 unsigned long mask = (unsigned long)table->size - 1; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5858 unsigned char step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5859 i = h & mask; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5860 while (table->v[i]) { |
| 21930 | 5861 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
|
5862 return table->v[i]; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5863 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5864 step = PROBE_STEP(h, mask, table->power); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5865 i < step ? (i += table->size - step) : (i -= step); |
| 21930 | 5866 } |
| 5867 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5868 return NULL; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5869 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5870 /* check for overflow (table is half full) */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5871 if (table->used >> (table->power - 1)) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5872 unsigned char newPower = table->power + 1; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5873 size_t newSize = (size_t)1 << newPower; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5874 unsigned long newMask = (unsigned long)newSize - 1; |
| 21930 | 5875 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
|
5876 NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); |
| 21930 | 5877 if (!newV) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5878 return NULL; |
| 21930 | 5879 memset(newV, 0, tsize); |
| 5880 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
|
5881 if (table->v[i]) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5882 unsigned long newHash = hash(table->v[i]->name); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5883 size_t j = newHash & newMask; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5884 step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5885 while (newV[j]) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5886 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5887 step = PROBE_STEP(newHash, newMask, newPower); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5888 j < step ? (j += newSize - step) : (j -= step); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5889 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5890 newV[j] = table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5891 } |
| 21930 | 5892 table->mem->free_fcn(table->v); |
| 5893 table->v = newV; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5894 table->power = newPower; |
| 21930 | 5895 table->size = newSize; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5896 i = h & newMask; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5897 step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5898 while (table->v[i]) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5899 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5900 step = PROBE_STEP(h, newMask, newPower); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5901 i < step ? (i += newSize - step) : (i -= step); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5902 } |
| 21930 | 5903 } |
| 5904 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5905 table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); |
| 21930 | 5906 if (!table->v[i]) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5907 return NULL; |
| 21930 | 5908 memset(table->v[i], 0, createSize); |
| 5909 table->v[i]->name = name; | |
| 5910 (table->used)++; | |
| 5911 return table->v[i]; | |
| 5912 } | |
| 5913 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5914 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5915 hashTableClear(HASH_TABLE *table) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5916 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5917 size_t i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5918 for (i = 0; i < table->size; i++) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5919 table->mem->free_fcn(table->v[i]); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5920 table->v[i] = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5921 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5922 table->used = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5923 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5924 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5925 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5926 hashTableDestroy(HASH_TABLE *table) |
| 21930 | 5927 { |
| 5928 size_t i; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5929 for (i = 0; i < table->size; i++) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5930 table->mem->free_fcn(table->v[i]); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5931 table->mem->free_fcn(table->v); |
| 21930 | 5932 } |
| 5933 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5934 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5935 hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5936 { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5937 p->power = 0; |
| 21930 | 5938 p->size = 0; |
| 5939 p->used = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5940 p->v = NULL; |
| 21930 | 5941 p->mem = ms; |
| 5942 } | |
| 5943 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5944 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5945 hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) |
| 21930 | 5946 { |
| 5947 iter->p = table->v; | |
| 5948 iter->end = iter->p + table->size; | |
| 5949 } | |
| 5950 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5951 static NAMED * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5952 hashTableIterNext(HASH_TABLE_ITER *iter) |
| 21930 | 5953 { |
| 5954 while (iter->p != iter->end) { | |
| 5955 NAMED *tem = *(iter->p)++; | |
| 5956 if (tem) | |
| 5957 return tem; | |
| 5958 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5959 return NULL; |
| 21930 | 5960 } |
| 5961 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5962 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5963 poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5964 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5965 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5966 pool->freeBlocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5967 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5968 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5969 pool->end = NULL; |
| 21930 | 5970 pool->mem = ms; |
| 5971 } | |
| 5972 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5973 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5974 poolClear(STRING_POOL *pool) |
| 21930 | 5975 { |
| 5976 if (!pool->freeBlocks) | |
| 5977 pool->freeBlocks = pool->blocks; | |
| 5978 else { | |
| 5979 BLOCK *p = pool->blocks; | |
| 5980 while (p) { | |
| 5981 BLOCK *tem = p->next; | |
| 5982 p->next = pool->freeBlocks; | |
| 5983 pool->freeBlocks = p; | |
| 5984 p = tem; | |
| 5985 } | |
| 5986 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5987 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5988 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5989 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5990 pool->end = NULL; |
| 21930 | 5991 } |
| 5992 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5993 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5994 poolDestroy(STRING_POOL *pool) |
| 21930 | 5995 { |
| 5996 BLOCK *p = pool->blocks; | |
| 5997 while (p) { | |
| 5998 BLOCK *tem = p->next; | |
| 5999 pool->mem->free_fcn(p); | |
| 6000 p = tem; | |
| 6001 } | |
| 6002 p = pool->freeBlocks; | |
| 6003 while (p) { | |
| 6004 BLOCK *tem = p->next; | |
| 6005 pool->mem->free_fcn(p); | |
| 6006 p = tem; | |
| 6007 } | |
| 6008 } | |
| 6009 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6010 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6011 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
|
6012 const char *ptr, const char *end) |
| 21930 | 6013 { |
| 6014 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6015 return NULL; |
| 21930 | 6016 for (;;) { |
| 6017 XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); | |
| 6018 if (ptr == end) | |
| 6019 break; | |
| 6020 if (!poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6021 return NULL; |
| 21930 | 6022 } |
| 6023 return pool->start; | |
| 6024 } | |
| 6025 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6026 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6027 poolCopyString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6028 { |
| 6029 do { | |
| 6030 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6031 return NULL; |
| 21930 | 6032 } while (*s++); |
| 6033 s = pool->start; | |
| 6034 poolFinish(pool); | |
| 6035 return s; | |
| 6036 } | |
| 6037 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6038 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6039 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) |
| 21930 | 6040 { |
| 6041 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6042 return NULL; |
| 21930 | 6043 for (; n > 0; --n, s++) { |
| 6044 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6045 return NULL; |
| 21930 | 6046 } |
| 6047 s = pool->start; | |
| 6048 poolFinish(pool); | |
| 6049 return s; | |
| 6050 } | |
| 6051 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6052 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6053 poolAppendString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6054 { |
| 6055 while (*s) { | |
| 6056 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6057 return NULL; |
| 21930 | 6058 s++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6059 } |
| 21930 | 6060 return pool->start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6061 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6062 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6063 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6064 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
|
6065 const char *ptr, const char *end) |
| 21930 | 6066 { |
| 6067 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
|
6068 return NULL; |
| 21930 | 6069 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
|
6070 return NULL; |
| 21930 | 6071 *(pool->ptr)++ = 0; |
| 6072 return pool->start; | |
| 6073 } | |
| 6074 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6075 static XML_Bool FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6076 poolGrow(STRING_POOL *pool) |
| 21930 | 6077 { |
| 6078 if (pool->freeBlocks) { | |
| 6079 if (pool->start == 0) { | |
| 6080 pool->blocks = pool->freeBlocks; | |
| 6081 pool->freeBlocks = pool->freeBlocks->next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6082 pool->blocks->next = NULL; |
| 21930 | 6083 pool->start = pool->blocks->s; |
| 6084 pool->end = pool->start + pool->blocks->size; | |
| 6085 pool->ptr = pool->start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6086 return XML_TRUE; |
| 21930 | 6087 } |
| 6088 if (pool->end - pool->start < pool->freeBlocks->size) { | |
| 6089 BLOCK *tem = pool->freeBlocks->next; | |
| 6090 pool->freeBlocks->next = pool->blocks; | |
| 6091 pool->blocks = pool->freeBlocks; | |
| 6092 pool->freeBlocks = tem; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6093 memcpy(pool->blocks->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6094 (pool->end - pool->start) * sizeof(XML_Char)); |
| 21930 | 6095 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); |
| 6096 pool->start = pool->blocks->s; | |
| 6097 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
|
6098 return XML_TRUE; |
| 21930 | 6099 } |
| 6100 } | |
| 6101 if (pool->blocks && pool->start == pool->blocks->s) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
6102 int blockSize = (int)(pool->end - pool->start)*2; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6103 pool->blocks = (BLOCK *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6104 pool->mem->realloc_fcn(pool->blocks, |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6105 (offsetof(BLOCK, s) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6106 + blockSize * sizeof(XML_Char))); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6107 if (pool->blocks == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6108 return XML_FALSE; |
| 21930 | 6109 pool->blocks->size = blockSize; |
| 6110 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); | |
| 6111 pool->start = pool->blocks->s; | |
| 6112 pool->end = pool->start + blockSize; | |
| 6113 } | |
| 6114 else { | |
| 6115 BLOCK *tem; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
6116 int blockSize = (int)(pool->end - pool->start); |
| 21930 | 6117 if (blockSize < INIT_BLOCK_SIZE) |
| 6118 blockSize = INIT_BLOCK_SIZE; | |
| 6119 else | |
| 6120 blockSize *= 2; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6121 tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6122 + blockSize * sizeof(XML_Char)); |
| 21930 | 6123 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6124 return XML_FALSE; |
| 21930 | 6125 tem->size = blockSize; |
| 6126 tem->next = pool->blocks; | |
| 6127 pool->blocks = tem; | |
| 6128 if (pool->ptr != pool->start) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6129 memcpy(tem->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6130 (pool->ptr - pool->start) * sizeof(XML_Char)); |
| 21930 | 6131 pool->ptr = tem->s + (pool->ptr - pool->start); |
| 6132 pool->start = tem->s; | |
| 6133 pool->end = tem->s + blockSize; | |
| 6134 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6135 return XML_TRUE; |
| 21930 | 6136 } |
| 6137 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6138 static int FASTCALL |
| 21930 | 6139 nextScaffoldPart(XML_Parser parser) |
| 6140 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6141 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6142 CONTENT_SCAFFOLD * me; |
| 6143 int next; | |
| 6144 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6145 if (!dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6146 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
|
6147 if (!dtd->scaffIndex) |
| 21930 | 6148 return -1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6149 dtd->scaffIndex[0] = 0; |
| 21930 | 6150 } |
| 6151 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6152 if (dtd->scaffCount >= dtd->scaffSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6153 CONTENT_SCAFFOLD *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6154 if (dtd->scaffold) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6155 temp = (CONTENT_SCAFFOLD *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6156 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
|
6157 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6158 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6159 dtd->scaffSize *= 2; |
| 21930 | 6160 } |
| 6161 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6162 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
|
6163 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6164 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6165 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6166 dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; |
| 21930 | 6167 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6168 dtd->scaffold = temp; |
| 21930 | 6169 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6170 next = dtd->scaffCount++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6171 me = &dtd->scaffold[next]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6172 if (dtd->scaffLevel) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6173 CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; |
| 21930 | 6174 if (parent->lastchild) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6175 dtd->scaffold[parent->lastchild].nextsib = next; |
| 21930 | 6176 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6177 if (!parent->childcnt) |
| 21930 | 6178 parent->firstchild = next; |
| 6179 parent->lastchild = next; | |
| 6180 parent->childcnt++; | |
| 6181 } | |
| 6182 me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; | |
| 6183 return next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6184 } |
| 21930 | 6185 |
| 6186 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6187 build_node(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6188 int src_node, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6189 XML_Content *dest, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6190 XML_Content **contpos, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6191 XML_Char **strpos) |
| 21930 | 6192 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6193 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
|
6194 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
|
6195 dest->quant = dtd->scaffold[src_node].quant; |
| 21930 | 6196 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
|
6197 const XML_Char *src; |
| 21930 | 6198 dest->name = *strpos; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6199 src = dtd->scaffold[src_node].name; |
| 21930 | 6200 for (;;) { |
| 6201 *(*strpos)++ = *src; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6202 if (!*src) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6203 break; |
| 21930 | 6204 src++; |
| 6205 } | |
| 6206 dest->numchildren = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6207 dest->children = NULL; |
| 21930 | 6208 } |
| 6209 else { | |
| 6210 unsigned int i; | |
| 6211 int cn; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6212 dest->numchildren = dtd->scaffold[src_node].childcnt; |
| 21930 | 6213 dest->children = *contpos; |
| 6214 *contpos += dest->numchildren; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6215 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
|
6216 i < dest->numchildren; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6217 i++, cn = dtd->scaffold[cn].nextsib) { |
| 21930 | 6218 build_node(parser, cn, &(dest->children[i]), contpos, strpos); |
| 6219 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6220 dest->name = NULL; |
| 21930 | 6221 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6222 } |
| 21930 | 6223 |
| 6224 static XML_Content * | |
| 6225 build_model (XML_Parser parser) | |
| 6226 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6227 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6228 XML_Content *ret; |
| 6229 XML_Content *cpos; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6230 XML_Char * str; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6231 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
|
6232 + (dtd->contentStringLen * sizeof(XML_Char))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6233 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6234 ret = (XML_Content *)MALLOC(allocsize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6235 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6236 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6237 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6238 str = (XML_Char *) (&ret[dtd->scaffCount]); |
| 21930 | 6239 cpos = &ret[1]; |
| 6240 | |
| 6241 build_node(parser, 0, ret, &cpos, &str); | |
| 6242 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6243 } |
| 21930 | 6244 |
| 6245 static ELEMENT_TYPE * | |
| 6246 getElementType(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6247 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6248 const char *ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6249 const char *end) |
| 21930 | 6250 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6251 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
|
6252 const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); |
| 21930 | 6253 ELEMENT_TYPE *ret; |
| 6254 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6255 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6256 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6257 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
|
6258 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6259 return NULL; |
| 21930 | 6260 if (ret->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6261 poolDiscard(&dtd->pool); |
| 21930 | 6262 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6263 poolFinish(&dtd->pool); |
| 21930 | 6264 if (!setElementTypePrefix(parser, ret)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6265 return NULL; |
| 21930 | 6266 } |
| 6267 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6268 } |
