Mercurial > cpython-lru_cache-weakref
annotate Modules/expat/xmlparse.c @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 9e124e6402bc |
| children | b54f5849013c |
| 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; |
|
58437
9e124e6402bc
- Expat: Fix DoS via XML document with malformed UTF-8 sequences
Matthias Klose <doko@ubuntu.com>
parents:
39473
diff
changeset
|
3685 case -XML_TOK_PROLOG_S: |
|
9e124e6402bc
- Expat: Fix DoS via XML document with malformed UTF-8 sequences
Matthias Klose <doko@ubuntu.com>
parents:
39473
diff
changeset
|
3686 tok = -tok; |
|
9e124e6402bc
- Expat: Fix DoS via XML document with malformed UTF-8 sequences
Matthias Klose <doko@ubuntu.com>
parents:
39473
diff
changeset
|
3687 break; |
| 21930 | 3688 case XML_TOK_NONE: |
| 3689 #ifdef XML_DTD | |
| 32911 | 3690 /* for internal PE NOT referenced between declarations */ |
| 3691 if (enc != encoding && !openInternalEntities->betweenDecl) { | |
| 3692 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3693 return XML_ERROR_NONE; |
| 32911 | 3694 } |
| 3695 /* WFC: PE Between Declarations - must check that PE contains | |
| 3696 complete markup, not only for external PEs, but also for | |
| 3697 internal PEs if the reference occurs between declarations. | |
| 3698 */ | |
| 3699 if (isParamEntity || enc != encoding) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3700 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
|
3701 == XML_ROLE_ERROR) |
| 32911 | 3702 return XML_ERROR_INCOMPLETE_PE; |
| 3703 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3704 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3705 } |
| 21930 | 3706 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3707 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 3708 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3709 tok = -tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3710 next = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3711 break; |
| 21930 | 3712 } |
| 3713 } | |
| 3714 role = XmlTokenRole(&prologState, tok, s, next, enc); | |
| 3715 switch (role) { | |
| 3716 case XML_ROLE_XML_DECL: | |
| 3717 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3718 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
|
3719 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3720 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3721 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3722 handleDefault = XML_FALSE; |
| 21930 | 3723 } |
| 3724 break; | |
| 3725 case XML_ROLE_DOCTYPE_NAME: | |
| 3726 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3727 doctypeName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3728 if (!doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3729 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3730 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3731 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3732 handleDefault = XML_FALSE; |
| 21930 | 3733 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3734 doctypeSysid = NULL; /* always initialize to NULL */ |
| 21930 | 3735 break; |
| 3736 case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: | |
| 3737 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3738 startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3739 doctypePubid, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3740 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3741 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3742 handleDefault = XML_FALSE; |
| 21930 | 3743 } |
| 3744 break; | |
| 3745 #ifdef XML_DTD | |
| 3746 case XML_ROLE_TEXT_DECL: | |
| 3747 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3748 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
|
3749 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3750 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3751 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3752 handleDefault = XML_FALSE; |
| 21930 | 3753 } |
| 3754 break; | |
| 3755 #endif /* XML_DTD */ | |
| 3756 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
|
3757 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3758 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3759 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3760 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3761 sizeof(ENTITY)); |
| 21930 | 3762 if (!declEntity) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3763 return XML_ERROR_NO_MEMORY; |
| 21930 | 3764 #endif /* XML_DTD */ |
| 32911 | 3765 dtd->hasParamEntityRefs = XML_TRUE; |
| 3766 if (startDoctypeDeclHandler) { | |
| 3767 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 3768 return XML_ERROR_PUBLICID; | |
| 3769 doctypePubid = poolStoreString(&tempPool, enc, | |
| 3770 s + enc->minBytesPerChar, | |
| 3771 next - enc->minBytesPerChar); | |
| 3772 if (!doctypePubid) | |
| 3773 return XML_ERROR_NO_MEMORY; | |
| 3774 normalizePublicId((XML_Char *)doctypePubid); | |
| 3775 poolFinish(&tempPool); | |
| 3776 handleDefault = XML_FALSE; | |
| 3777 goto alreadyChecked; | |
| 3778 } | |
| 21930 | 3779 /* fall through */ |
| 3780 case XML_ROLE_ENTITY_PUBLIC_ID: | |
| 3781 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 3782 return XML_ERROR_PUBLICID; |
| 3783 alreadyChecked: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3784 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3785 XML_Char *tem = poolStoreString(&dtd->pool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3786 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3787 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3788 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3789 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3790 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3791 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3792 declEntity->publicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3793 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3794 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3795 handleDefault = XML_FALSE; |
| 21930 | 3796 } |
| 3797 break; | |
| 3798 case XML_ROLE_DOCTYPE_CLOSE: | |
| 3799 if (doctypeName) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3800 startDoctypeDeclHandler(handlerArg, doctypeName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3801 doctypeSysid, doctypePubid, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3802 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3803 handleDefault = XML_FALSE; |
| 21930 | 3804 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3805 /* 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
|
3806 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
|
3807 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
|
3808 */ |
| 21930 | 3809 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3810 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
|
3811 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
|
3812 dtd->hasParamEntityRefs = XML_TRUE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3813 if (paramEntityParsing && externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3814 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3815 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3816 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3817 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3818 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3819 if (useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3820 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3821 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3822 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3823 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3824 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3825 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3826 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3827 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
|
3828 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
|
3829 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
|
3830 notStandaloneHandler && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3831 !notStandaloneHandler(handlerArg)) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3832 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
|
3833 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3834 /* 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
|
3835 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
|
3836 */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3837 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
|
3838 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3839 /* 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
|
3840 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3841 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3842 } |
| 21930 | 3843 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3844 if (endDoctypeDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3845 endDoctypeDeclHandler(handlerArg); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3846 handleDefault = XML_FALSE; |
| 21930 | 3847 } |
| 3848 break; | |
| 3849 case XML_ROLE_INSTANCE_START: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3850 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3851 /* 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
|
3852 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
|
3853 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3854 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
|
3855 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3856 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3857 if (paramEntityParsing && externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3858 ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3859 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3860 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3861 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3862 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3863 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3864 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3865 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3866 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3867 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3868 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3869 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3870 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
|
3871 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
|
3872 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
|
3873 notStandaloneHandler && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3874 !notStandaloneHandler(handlerArg)) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3875 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
|
3876 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3877 /* 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
|
3878 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
|
3879 */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3880 else |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3881 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3882 /* 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
|
3883 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3884 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3885 #endif /* XML_DTD */ |
| 21930 | 3886 processor = contentProcessor; |
| 3887 return contentProcessor(parser, s, end, nextPtr); | |
| 3888 case XML_ROLE_ATTLIST_ELEMENT_NAME: | |
| 3889 declElementType = getElementType(parser, enc, s, next); | |
| 3890 if (!declElementType) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3891 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3892 goto checkAttListDeclHandler; |
| 21930 | 3893 case XML_ROLE_ATTRIBUTE_NAME: |
| 3894 declAttributeId = getAttributeId(parser, enc, s, next); | |
| 3895 if (!declAttributeId) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3896 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3897 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3898 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3899 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3900 goto checkAttListDeclHandler; |
| 21930 | 3901 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
|
3902 declAttributeIsCdata = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3903 declAttributeType = atypeCDATA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3904 goto checkAttListDeclHandler; |
| 21930 | 3905 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
|
3906 declAttributeIsId = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3907 declAttributeType = atypeID; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3908 goto checkAttListDeclHandler; |
| 21930 | 3909 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
|
3910 declAttributeType = atypeIDREF; |
|
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_IDREFS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3913 declAttributeType = atypeIDREFS; |
|
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_ENTITY: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3916 declAttributeType = atypeENTITY; |
|
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_ENTITIES: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3919 declAttributeType = atypeENTITIES; |
|
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_NMTOKEN: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3922 declAttributeType = atypeNMTOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3923 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3924 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3925 declAttributeType = atypeNMTOKENS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3926 checkAttListDeclHandler: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3927 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3928 handleDefault = XML_FALSE; |
| 21930 | 3929 break; |
| 3930 case XML_ROLE_ATTRIBUTE_ENUM_VALUE: | |
| 3931 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
|
3932 if (dtd->keepProcessing && attlistDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3933 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3934 if (declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3935 prefix = enumValueSep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3936 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3937 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3938 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
|
3939 ? notationPrefix |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3940 : enumValueStart); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3941 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3942 if (!poolAppendString(&tempPool, prefix)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3943 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3944 if (!poolAppend(&tempPool, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3945 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3946 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3947 handleDefault = XML_FALSE; |
| 21930 | 3948 } |
| 3949 break; | |
| 3950 case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: | |
| 3951 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
|
3952 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3953 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
|
3954 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
|
3955 0, parser)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3956 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3957 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3958 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3959 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3960 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3961 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3962 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3963 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3964 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3965 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3966 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3967 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3968 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3969 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3970 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3971 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
|
3972 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3973 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3974 } |
| 21930 | 3975 } |
| 3976 break; | |
| 3977 case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: | |
| 3978 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
|
3979 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3980 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
|
3981 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
|
3982 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
|
3983 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
|
3984 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
|
3985 &dtd->pool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3986 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3987 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3988 attVal = poolStart(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3989 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3990 /* 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
|
3991 if (!defineAttribute(declElementType, declAttributeId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3992 declAttributeIsCdata, XML_FALSE, attVal, parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3993 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3994 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3995 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3996 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3997 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3998 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3999 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4000 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4001 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4002 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4003 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4004 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4005 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4006 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4007 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4008 attVal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4009 role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4010 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4011 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4012 } |
| 21930 | 4013 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4014 break; |
| 21930 | 4015 case XML_ROLE_ENTITY_VALUE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4016 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4017 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
|
4018 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4019 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4020 if (declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4021 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
|
4022 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
|
4023 poolFinish(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4024 if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4025 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4026 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4027 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4028 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4029 declEntity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4030 declEntity->textLen, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4031 curBase, 0, 0, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4032 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4033 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4034 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4035 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4036 poolDiscard(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4037 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4038 return result; |
| 21930 | 4039 } |
| 4040 break; | |
| 4041 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
|
4042 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4043 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4044 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4045 dtd->hasParamEntityRefs = XML_TRUE; |
| 21930 | 4046 if (startDoctypeDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4047 doctypeSysid = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4048 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4049 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4050 if (doctypeSysid == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4051 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4052 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4053 handleDefault = XML_FALSE; |
| 21930 | 4054 } |
| 4055 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4056 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4057 /* 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
|
4058 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
|
4059 doctypeSysid = externalSubsetName; |
| 21930 | 4060 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4061 if (!dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4062 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4063 && !paramEntityParsing |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4064 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4065 && notStandaloneHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4066 && !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4067 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4068 #ifndef XML_DTD |
| 4069 break; | |
| 4070 #else /* XML_DTD */ | |
| 4071 if (!declEntity) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4072 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4073 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4074 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4075 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4076 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4077 declEntity->publicId = NULL; |
| 21930 | 4078 } |
| 4079 /* fall through */ | |
| 4080 #endif /* XML_DTD */ | |
| 4081 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
|
4082 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4083 declEntity->systemId = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4084 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4085 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4086 if (!declEntity->systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4087 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4088 declEntity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4089 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4090 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4091 handleDefault = XML_FALSE; |
| 21930 | 4092 } |
| 4093 break; | |
| 4094 case XML_ROLE_ENTITY_COMPLETE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4095 if (dtd->keepProcessing && declEntity && entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4096 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4097 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4098 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4099 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4100 0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4101 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4102 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4103 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4104 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4105 handleDefault = XML_FALSE; |
| 21930 | 4106 } |
| 4107 break; | |
| 4108 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
|
4109 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4110 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
|
4111 if (!declEntity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4112 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4113 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4114 if (unparsedEntityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4115 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4116 unparsedEntityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4117 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4118 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4119 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4120 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4121 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4122 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4123 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4124 else if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4125 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4126 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4127 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4128 0,0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4129 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4130 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4131 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4132 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4133 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4134 } |
| 21930 | 4135 } |
| 4136 break; | |
| 4137 case XML_ROLE_GENERAL_ENTITY_NAME: | |
| 4138 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4139 if (XmlPredefinedEntityName(enc, s, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4140 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4141 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4142 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4143 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4144 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
|
4145 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4146 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4147 declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4148 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4149 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4150 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4151 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4152 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4153 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4154 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4155 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4156 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4157 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4158 declEntity->is_param = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4159 /* 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
|
4160 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
|
4161 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4162 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4163 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4164 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4165 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4166 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4167 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4168 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4169 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4170 } |
| 21930 | 4171 } |
| 4172 break; | |
| 4173 case XML_ROLE_PARAM_ENTITY_NAME: | |
| 4174 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4175 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4176 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
|
4177 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4178 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4179 declEntity = (ENTITY *)lookup(&dtd->paramEntities, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4180 name, sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4181 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4182 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4183 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4184 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4185 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4186 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4187 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4188 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4189 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4190 declEntity->is_param = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4191 /* 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
|
4192 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
|
4193 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4194 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4195 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4196 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4197 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4198 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4199 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4200 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4201 declEntity = NULL; |
| 21930 | 4202 } |
| 4203 #else /* not XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4204 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4205 #endif /* XML_DTD */ |
| 21930 | 4206 break; |
| 4207 case XML_ROLE_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4208 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4209 declNotationName = NULL; |
| 21930 | 4210 if (notationDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4211 declNotationName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4212 if (!declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4213 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4214 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4215 handleDefault = XML_FALSE; |
| 21930 | 4216 } |
| 4217 break; | |
| 4218 case XML_ROLE_NOTATION_PUBLIC_ID: | |
| 4219 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 4220 return XML_ERROR_PUBLICID; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4221 if (declNotationName) { /* means notationDeclHandler != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4222 XML_Char *tem = poolStoreString(&tempPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4223 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4224 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4225 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4226 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4227 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4228 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4229 declNotationPublicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4230 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4231 handleDefault = XML_FALSE; |
| 21930 | 4232 } |
| 4233 break; | |
| 4234 case XML_ROLE_NOTATION_SYSTEM_ID: | |
| 4235 if (declNotationName && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4236 const XML_Char *systemId |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4237 = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4238 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4239 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4240 if (!systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4241 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4242 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4243 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4244 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4245 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4246 systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4247 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4248 handleDefault = XML_FALSE; |
| 21930 | 4249 } |
| 4250 poolClear(&tempPool); | |
| 4251 break; | |
| 4252 case XML_ROLE_NOTATION_NO_SYSTEM_ID: | |
| 4253 if (declNotationPublicId && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4254 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4255 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4256 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4257 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4258 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4259 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4260 handleDefault = XML_FALSE; |
| 21930 | 4261 } |
| 4262 poolClear(&tempPool); | |
| 4263 break; | |
| 4264 case XML_ROLE_ERROR: | |
| 4265 switch (tok) { | |
| 4266 case XML_TOK_PARAM_ENTITY_REF: | |
| 32911 | 4267 /* PE references in internal subset are |
| 4268 not allowed within declarations. */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4269 return XML_ERROR_PARAM_ENTITY_REF; |
| 21930 | 4270 case XML_TOK_XML_DECL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4271 return XML_ERROR_MISPLACED_XML_PI; |
| 21930 | 4272 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4273 return XML_ERROR_SYNTAX; |
| 21930 | 4274 } |
| 4275 #ifdef XML_DTD | |
| 4276 case XML_ROLE_IGNORE_SECT: | |
| 4277 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4278 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4279 if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4280 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4281 handleDefault = XML_FALSE; |
| 32911 | 4282 result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); |
| 4283 if (result != XML_ERROR_NONE) | |
| 4284 return result; | |
| 4285 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4286 processor = ignoreSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4287 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4288 } |
| 21930 | 4289 } |
| 4290 break; | |
| 4291 #endif /* XML_DTD */ | |
| 4292 case XML_ROLE_GROUP_OPEN: | |
| 4293 if (prologState.level >= groupSize) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4294 if (groupSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4295 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
|
4296 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4297 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4298 groupConnector = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4299 if (dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4300 int *temp = (int *)REALLOC(dtd->scaffIndex, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4301 groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4302 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4303 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4304 dtd->scaffIndex = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4305 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4306 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4307 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4308 groupConnector = (char *)MALLOC(groupSize = 32); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4309 if (!groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4310 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4311 } |
| 21930 | 4312 } |
| 4313 groupConnector[prologState.level] = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4314 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4315 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4316 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4317 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4318 dtd->scaffIndex[dtd->scaffLevel] = myindex; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4319 dtd->scaffLevel++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4320 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
|
4321 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4322 handleDefault = XML_FALSE; |
| 21930 | 4323 } |
| 4324 break; | |
| 4325 case XML_ROLE_GROUP_SEQUENCE: | |
| 4326 if (groupConnector[prologState.level] == '|') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4327 return XML_ERROR_SYNTAX; |
| 21930 | 4328 groupConnector[prologState.level] = ','; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4329 if (dtd->in_eldecl && elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4330 handleDefault = XML_FALSE; |
| 21930 | 4331 break; |
| 4332 case XML_ROLE_GROUP_CHOICE: | |
| 4333 if (groupConnector[prologState.level] == ',') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4334 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4335 if (dtd->in_eldecl |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4336 && !groupConnector[prologState.level] |
|
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_MIXED) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4339 ) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4340 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
|
4341 = XML_CTYPE_CHOICE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4342 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4343 handleDefault = XML_FALSE; |
| 21930 | 4344 } |
| 4345 groupConnector[prologState.level] = '|'; | |
| 4346 break; | |
| 4347 case XML_ROLE_PARAM_ENTITY_REF: | |
| 4348 #ifdef XML_DTD | |
| 4349 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
|
4350 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4351 if (!paramEntityParsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4352 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4353 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4354 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4355 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4356 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4357 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4358 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4359 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4360 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4361 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
|
4362 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4363 /* 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
|
4364 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
|
4365 otherwise call the skipped entity handler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4366 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4367 if (prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4368 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4369 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4370 : !dtd->hasParamEntityRefs)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4371 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4372 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4373 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4374 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
|
4375 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4376 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4377 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4378 /* cannot report skipped entities in declarations */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4379 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
|
4380 skippedEntityHandler(handlerArg, name, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4381 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4382 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4383 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4384 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4385 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4386 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4387 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4388 enum XML_Error result; |
| 32911 | 4389 XML_Bool betweenDecl = |
| 4390 (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); | |
| 4391 result = processInternalEntity(parser, entity, betweenDecl); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4392 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4393 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4394 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4395 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4396 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4397 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4398 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4399 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4400 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4401 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4402 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4403 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4404 entity->publicId)) { |
|
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 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4407 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4408 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4409 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4410 if (!dtd->paramEntityRead) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4411 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4412 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4413 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4414 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4415 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4416 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4417 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4418 } |
| 21930 | 4419 } |
| 4420 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4421 if (!dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4422 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4423 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4424 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4425 break; |
| 4426 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4427 /* Element declaration stuff */ |
| 21930 | 4428 |
| 4429 case XML_ROLE_ELEMENT_NAME: | |
| 4430 if (elementDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4431 declElementType = getElementType(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4432 if (!declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4433 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4434 dtd->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4435 dtd->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4436 dtd->in_eldecl = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4437 handleDefault = XML_FALSE; |
| 21930 | 4438 } |
| 4439 break; | |
| 4440 | |
| 4441 case XML_ROLE_CONTENT_ANY: | |
| 4442 case XML_ROLE_CONTENT_EMPTY: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4443 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4444 if (elementDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4445 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
|
4446 if (!content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4447 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4448 content->quant = XML_CQUANT_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4449 content->name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4450 content->numchildren = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4451 content->children = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4452 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
|
4453 XML_CTYPE_ANY : |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4454 XML_CTYPE_EMPTY); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4455 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4456 elementDeclHandler(handlerArg, declElementType->name, content); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4457 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4458 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4459 dtd->in_eldecl = XML_FALSE; |
| 21930 | 4460 } |
| 4461 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4462 |
| 21930 | 4463 case XML_ROLE_CONTENT_PCDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4464 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4465 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
|
4466 = XML_CTYPE_MIXED; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4467 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4468 handleDefault = XML_FALSE; |
| 21930 | 4469 } |
| 4470 break; | |
| 4471 | |
| 4472 case XML_ROLE_CONTENT_ELEMENT: | |
| 4473 quant = XML_CQUANT_NONE; | |
| 4474 goto elementContent; | |
| 4475 case XML_ROLE_CONTENT_ELEMENT_OPT: | |
| 4476 quant = XML_CQUANT_OPT; | |
| 4477 goto elementContent; | |
| 4478 case XML_ROLE_CONTENT_ELEMENT_REP: | |
| 4479 quant = XML_CQUANT_REP; | |
| 4480 goto elementContent; | |
| 4481 case XML_ROLE_CONTENT_ELEMENT_PLUS: | |
| 4482 quant = XML_CQUANT_PLUS; | |
| 4483 elementContent: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4484 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4485 ELEMENT_TYPE *el; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4486 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4487 int nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4488 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
|
4489 ? next |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4490 : next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4491 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4492 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4493 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4494 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
|
4495 dtd->scaffold[myindex].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4496 el = getElementType(parser, enc, s, nxt); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4497 if (!el) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4498 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4499 name = el->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4500 dtd->scaffold[myindex].name = name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4501 nameLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4502 for (; name[nameLen++]; ); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4503 dtd->contentStringLen += nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4504 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4505 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4506 } |
| 21930 | 4507 break; |
| 4508 | |
| 4509 case XML_ROLE_GROUP_CLOSE: | |
| 4510 quant = XML_CQUANT_NONE; | |
| 4511 goto closeGroup; | |
| 4512 case XML_ROLE_GROUP_CLOSE_OPT: | |
| 4513 quant = XML_CQUANT_OPT; | |
| 4514 goto closeGroup; | |
| 4515 case XML_ROLE_GROUP_CLOSE_REP: | |
| 4516 quant = XML_CQUANT_REP; | |
| 4517 goto closeGroup; | |
| 4518 case XML_ROLE_GROUP_CLOSE_PLUS: | |
| 4519 quant = XML_CQUANT_PLUS; | |
| 4520 closeGroup: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4521 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4522 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4523 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4524 dtd->scaffLevel--; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4525 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
|
4526 if (dtd->scaffLevel == 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4527 if (!handleDefault) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4528 XML_Content *model = build_model(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4529 if (!model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4530 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4531 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4532 elementDeclHandler(handlerArg, declElementType->name, model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4533 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4534 dtd->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4535 dtd->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4536 } |
| 21930 | 4537 } |
| 4538 break; | |
| 4539 /* End element declaration stuff */ | |
| 4540 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4541 case XML_ROLE_PI: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4542 if (!reportProcessingInstruction(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4543 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4544 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4545 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4546 case XML_ROLE_COMMENT: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4547 if (!reportComment(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4548 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4549 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4550 break; |
| 21930 | 4551 case XML_ROLE_NONE: |
| 4552 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4553 case XML_TOK_BOM: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4554 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4555 break; |
| 21930 | 4556 } |
| 4557 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4558 case XML_ROLE_DOCTYPE_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4559 if (startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4560 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4561 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4562 case XML_ROLE_ENTITY_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4563 if (dtd->keepProcessing && entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4564 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4565 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4566 case XML_ROLE_NOTATION_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4567 if (notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4568 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4569 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4570 case XML_ROLE_ATTLIST_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4571 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4572 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4573 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4574 case XML_ROLE_ELEMENT_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4575 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4576 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4577 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4578 } /* end of big switch */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4579 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4580 if (handleDefault && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4581 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4582 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4583 switch (ps_parsing) { |
| 32911 | 4584 case XML_SUSPENDED: |
| 4585 *nextPtr = next; | |
| 4586 return XML_ERROR_NONE; | |
| 4587 case XML_FINISHED: | |
| 4588 return XML_ERROR_ABORTED; | |
| 4589 default: | |
| 4590 s = next; | |
| 4591 tok = XmlPrologTok(enc, s, end, &next); | |
| 4592 } | |
| 21930 | 4593 } |
| 4594 /* not reached */ | |
| 4595 } | |
| 4596 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4597 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4598 epilogProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4599 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4600 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4601 const char **nextPtr) |
| 21930 | 4602 { |
| 4603 processor = epilogProcessor; | |
| 4604 eventPtr = s; | |
| 4605 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4606 const char *next = NULL; |
| 21930 | 4607 int tok = XmlPrologTok(encoding, s, end, &next); |
| 4608 eventEndPtr = next; | |
| 4609 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4610 /* report partial linebreak - it might be the last token */ |
| 21930 | 4611 case -XML_TOK_PROLOG_S: |
| 4612 if (defaultHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4613 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
|
4614 if (ps_parsing == XML_FINISHED) |
| 32911 | 4615 return XML_ERROR_ABORTED; |
| 21930 | 4616 } |
| 32911 | 4617 *nextPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4618 return XML_ERROR_NONE; |
| 21930 | 4619 case XML_TOK_NONE: |
| 32911 | 4620 *nextPtr = s; |
| 21930 | 4621 return XML_ERROR_NONE; |
| 4622 case XML_TOK_PROLOG_S: | |
| 4623 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4624 reportDefault(parser, encoding, s, next); |
| 21930 | 4625 break; |
| 4626 case XML_TOK_PI: | |
| 4627 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
|
4628 return XML_ERROR_NO_MEMORY; |
| 21930 | 4629 break; |
| 4630 case XML_TOK_COMMENT: | |
| 4631 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
|
4632 return XML_ERROR_NO_MEMORY; |
| 21930 | 4633 break; |
| 4634 case XML_TOK_INVALID: | |
| 4635 eventPtr = next; | |
| 4636 return XML_ERROR_INVALID_TOKEN; | |
| 4637 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
|
4638 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4639 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4640 return XML_ERROR_NONE; |
| 21930 | 4641 } |
| 4642 return XML_ERROR_UNCLOSED_TOKEN; | |
| 4643 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
|
4644 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4645 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4646 return XML_ERROR_NONE; |
| 21930 | 4647 } |
| 4648 return XML_ERROR_PARTIAL_CHAR; | |
| 4649 default: | |
| 4650 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; | |
| 4651 } | |
| 4652 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
|
4653 switch (ps_parsing) { |
| 32911 | 4654 case XML_SUSPENDED: |
| 4655 *nextPtr = next; | |
| 4656 return XML_ERROR_NONE; | |
| 4657 case XML_FINISHED: | |
| 4658 return XML_ERROR_ABORTED; | |
| 4659 default: ; | |
| 4660 } | |
| 21930 | 4661 } |
| 4662 } | |
| 4663 | |
| 4664 static enum XML_Error | |
| 32911 | 4665 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 4666 XML_Bool betweenDecl) | |
| 21930 | 4667 { |
| 32911 | 4668 const char *textStart, *textEnd; |
| 4669 const char *next; | |
| 21930 | 4670 enum XML_Error result; |
| 32911 | 4671 OPEN_INTERNAL_ENTITY *openEntity; |
| 4672 | |
| 4673 if (freeInternalEntities) { | |
| 4674 openEntity = freeInternalEntities; | |
| 4675 freeInternalEntities = openEntity->next; | |
| 4676 } | |
| 4677 else { | |
| 4678 openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY)); | |
| 4679 if (!openEntity) | |
| 4680 return XML_ERROR_NO_MEMORY; | |
| 4681 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4682 entity->open = XML_TRUE; |
| 32911 | 4683 entity->processed = 0; |
| 4684 openEntity->next = openInternalEntities; | |
| 4685 openInternalEntities = openEntity; | |
| 4686 openEntity->entity = entity; | |
| 4687 openEntity->startTagLevel = tagLevel; | |
| 4688 openEntity->betweenDecl = betweenDecl; | |
| 4689 openEntity->internalEventPtr = NULL; | |
| 4690 openEntity->internalEventEndPtr = NULL; | |
| 4691 textStart = (char *)entity->textPtr; | |
| 4692 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4693 | |
| 4694 #ifdef XML_DTD | |
| 4695 if (entity->is_param) { | |
| 4696 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
| 4697 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | |
| 4698 next, &next, XML_FALSE); | |
| 4699 } | |
| 4700 else | |
| 4701 #endif /* XML_DTD */ | |
| 4702 result = doContent(parser, tagLevel, internalEncoding, textStart, | |
| 4703 textEnd, &next, XML_FALSE); | |
| 4704 | |
| 4705 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
|
4706 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
|
4707 entity->processed = (int)(next - textStart); |
| 32911 | 4708 processor = internalEntityProcessor; |
| 4709 } | |
| 4710 else { | |
| 4711 entity->open = XML_FALSE; | |
| 4712 openInternalEntities = openEntity->next; | |
| 4713 /* put openEntity back in list of free instances */ | |
| 4714 openEntity->next = freeInternalEntities; | |
| 4715 freeInternalEntities = openEntity; | |
| 4716 } | |
| 4717 } | |
| 21930 | 4718 return result; |
| 4719 } | |
| 4720 | |
| 32911 | 4721 static enum XML_Error PTRCALL |
| 4722 internalEntityProcessor(XML_Parser parser, | |
| 4723 const char *s, | |
| 4724 const char *end, | |
| 4725 const char **nextPtr) | |
| 4726 { | |
| 4727 ENTITY *entity; | |
| 4728 const char *textStart, *textEnd; | |
| 4729 const char *next; | |
| 4730 enum XML_Error result; | |
| 4731 OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; | |
| 4732 if (!openEntity) | |
| 4733 return XML_ERROR_UNEXPECTED_STATE; | |
| 4734 | |
| 4735 entity = openEntity->entity; | |
| 4736 textStart = ((char *)entity->textPtr) + entity->processed; | |
| 4737 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4738 | |
| 4739 #ifdef XML_DTD | |
| 4740 if (entity->is_param) { | |
| 4741 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
| 4742 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | |
| 4743 next, &next, XML_FALSE); | |
| 4744 } | |
| 4745 else | |
| 21930 | 4746 #endif /* XML_DTD */ |
| 32911 | 4747 result = doContent(parser, openEntity->startTagLevel, internalEncoding, |
| 4748 textStart, textEnd, &next, XML_FALSE); | |
| 4749 | |
| 4750 if (result != XML_ERROR_NONE) | |
| 4751 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
|
4752 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
|
4753 entity->processed = (int)(next - (char *)entity->textPtr); |
| 32911 | 4754 return result; |
| 4755 } | |
| 4756 else { | |
| 4757 entity->open = XML_FALSE; | |
| 4758 openInternalEntities = openEntity->next; | |
| 4759 /* put openEntity back in list of free instances */ | |
| 4760 openEntity->next = freeInternalEntities; | |
| 4761 freeInternalEntities = openEntity; | |
| 4762 } | |
| 4763 | |
| 4764 #ifdef XML_DTD | |
| 4765 if (entity->is_param) { | |
| 4766 int tok; | |
| 4767 processor = prologProcessor; | |
| 4768 tok = XmlPrologTok(encoding, s, end, &next); | |
| 4769 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
|
4770 (XML_Bool)!ps_finalBuffer); |
| 32911 | 4771 } |
| 4772 else | |
| 4773 #endif /* XML_DTD */ | |
| 4774 { | |
| 4775 processor = contentProcessor; | |
| 4776 /* see externalEntityContentProcessor vs contentProcessor */ | |
| 4777 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
|
4778 nextPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 4779 } |
| 4780 } | |
| 21930 | 4781 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4782 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4783 errorProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4784 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4785 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4786 const char **nextPtr) |
| 21930 | 4787 { |
| 4788 return errorCode; | |
| 4789 } | |
| 4790 | |
| 4791 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4792 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
|
4793 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4794 STRING_POOL *pool) |
| 21930 | 4795 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4796 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
|
4797 end, pool); |
| 21930 | 4798 if (result) |
| 4799 return result; | |
| 4800 if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) | |
| 4801 poolChop(pool); | |
| 4802 if (!poolAppendChar(pool, XML_T('\0'))) | |
| 4803 return XML_ERROR_NO_MEMORY; | |
| 4804 return XML_ERROR_NONE; | |
| 4805 } | |
| 4806 | |
| 4807 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4808 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
|
4809 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4810 STRING_POOL *pool) |
| 21930 | 4811 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4812 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4813 for (;;) { |
| 4814 const char *next; | |
| 4815 int tok = XmlAttributeValueTok(enc, ptr, end, &next); | |
| 4816 switch (tok) { | |
| 4817 case XML_TOK_NONE: | |
| 4818 return XML_ERROR_NONE; | |
| 4819 case XML_TOK_INVALID: | |
| 4820 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4821 eventPtr = next; |
| 21930 | 4822 return XML_ERROR_INVALID_TOKEN; |
| 4823 case XML_TOK_PARTIAL: | |
| 4824 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4825 eventPtr = ptr; |
| 21930 | 4826 return XML_ERROR_INVALID_TOKEN; |
| 4827 case XML_TOK_CHAR_REF: | |
| 4828 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4829 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4830 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4831 int n = XmlCharRefNumber(enc, ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4832 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4833 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4834 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4835 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4836 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4837 if (!isCdata |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4838 && n == 0x20 /* space */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4839 && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4840 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4841 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4842 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4843 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4844 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4845 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4846 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4847 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4848 if (!poolAppendChar(pool, buf[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4849 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4850 } |
| 21930 | 4851 } |
| 4852 break; | |
| 4853 case XML_TOK_DATA_CHARS: | |
| 4854 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
|
4855 return XML_ERROR_NO_MEMORY; |
| 21930 | 4856 break; |
| 4857 case XML_TOK_TRAILING_CR: | |
| 4858 next = ptr + enc->minBytesPerChar; | |
| 4859 /* fall through */ | |
| 4860 case XML_TOK_ATTRIBUTE_VALUE_S: | |
| 4861 case XML_TOK_DATA_NEWLINE: | |
| 4862 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
|
4863 break; |
| 21930 | 4864 if (!poolAppendChar(pool, 0x20)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4865 return XML_ERROR_NO_MEMORY; |
| 21930 | 4866 break; |
| 4867 case XML_TOK_ENTITY_REF: | |
| 4868 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4869 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4870 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4871 char checkEntityDecl; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4872 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
|
4873 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4874 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4875 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4876 if (!poolAppendChar(pool, ch)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4877 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4878 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4879 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4880 name = poolStoreString(&temp2Pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4881 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4882 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4883 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4884 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4885 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
|
4886 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
|
4887 /* 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
|
4888 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
|
4889 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4890 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
|
4891 checkEntityDecl = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4892 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4893 prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4894 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4895 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4896 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4897 : !dtd->hasParamEntityRefs); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4898 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
|
4899 checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4900 if (checkEntityDecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4901 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4902 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4903 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4904 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
|
4905 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4906 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
|
4907 /* 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
|
4908 skippedEntityHandler. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4909 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4910 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4911 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4912 /* 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
|
4913 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
|
4914 if ((pool == &tempPool) && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4915 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
|
4916 */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4917 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4918 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4919 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4920 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4921 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4922 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4923 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4924 if (entity->notation) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4925 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4926 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4927 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4928 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4929 if (!entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4930 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4931 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4932 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
|
4933 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4934 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4935 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4936 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
|
4937 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4938 result = appendAttributeValue(parser, internalEncoding, isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4939 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4940 (char *)textEnd, pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4941 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4942 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4943 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4944 } |
| 21930 | 4945 } |
| 4946 break; | |
| 4947 default: | |
| 4948 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4949 eventPtr = ptr; |
| 21930 | 4950 return XML_ERROR_UNEXPECTED_STATE; |
| 4951 } | |
| 4952 ptr = next; | |
| 4953 } | |
| 4954 /* not reached */ | |
| 4955 } | |
| 4956 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4957 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4958 storeEntityValue(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4959 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4960 const char *entityTextPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4961 const char *entityTextEnd) |
| 21930 | 4962 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4963 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
|
4964 STRING_POOL *pool = &(dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4965 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
|
4966 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4967 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4968 prologState.inEntityValue = 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4969 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4970 /* 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
|
4971 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
|
4972 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
|
4973 if (!pool->blocks) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4974 if (!poolGrow(pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4975 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4976 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4977 |
| 21930 | 4978 for (;;) { |
| 4979 const char *next; | |
| 4980 int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); | |
| 4981 switch (tok) { | |
| 4982 case XML_TOK_PARAM_ENTITY_REF: | |
| 4983 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4984 if (isParamEntity || enc != encoding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4985 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4986 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4987 name = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4988 entityTextPtr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4989 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4990 if (!name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4991 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4992 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4993 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4994 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
|
4995 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4996 if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4997 /* 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
|
4998 /* 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
|
4999 skippedEntityHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5000 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5001 skippedEntityHandler(handlerArg, name, 0); |
|
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 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5004 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5005 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5006 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5007 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5008 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5009 result = XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5010 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5011 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5012 if (entity->systemId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5013 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5014 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5015 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5016 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5017 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5018 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5019 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5020 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5021 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5022 result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5023 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5024 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5025 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5026 if (!dtd->paramEntityRead) |
|
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 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5031 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5032 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5033 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5034 result = storeEntityValue(parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5035 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5036 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5037 (char *)(entity->textPtr |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5038 + entity->textLen)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5039 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5040 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5041 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5042 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5043 break; |
| 21930 | 5044 } |
| 5045 #endif /* XML_DTD */ | |
| 32911 | 5046 /* In the internal subset, PE references are not legal |
| 5047 within markup declarations, e.g entity values in this case. */ | |
| 21930 | 5048 eventPtr = entityTextPtr; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5049 result = XML_ERROR_PARAM_ENTITY_REF; |
|
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_NONE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5052 result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5053 goto endEntityValue; |
| 21930 | 5054 case XML_TOK_ENTITY_REF: |
| 5055 case XML_TOK_DATA_CHARS: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5056 if (!poolAppend(pool, enc, entityTextPtr, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5057 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5058 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5059 } |
| 21930 | 5060 break; |
| 5061 case XML_TOK_TRAILING_CR: | |
| 5062 next = entityTextPtr + enc->minBytesPerChar; | |
| 5063 /* fall through */ | |
| 5064 case XML_TOK_DATA_NEWLINE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5065 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
|
5066 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5067 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5068 } |
| 21930 | 5069 *(pool->ptr)++ = 0xA; |
| 5070 break; | |
| 5071 case XML_TOK_CHAR_REF: | |
| 5072 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5073 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5074 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5075 int n = XmlCharRefNumber(enc, entityTextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5076 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5077 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5078 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5079 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5080 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5081 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5082 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5083 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5084 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5085 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5086 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5087 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5088 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5089 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5090 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
|
5091 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5092 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5093 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5094 *(pool->ptr)++ = buf[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5095 } |
| 21930 | 5096 } |
| 5097 break; | |
| 5098 case XML_TOK_PARTIAL: | |
| 5099 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5100 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5101 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5102 goto endEntityValue; |
| 21930 | 5103 case XML_TOK_INVALID: |
| 5104 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5105 eventPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5106 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5107 goto endEntityValue; |
| 21930 | 5108 default: |
| 5109 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5110 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5111 result = XML_ERROR_UNEXPECTED_STATE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5112 goto endEntityValue; |
| 21930 | 5113 } |
| 5114 entityTextPtr = next; | |
| 5115 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5116 endEntityValue: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5117 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5118 prologState.inEntityValue = oldInEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5119 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5120 return result; |
| 21930 | 5121 } |
| 5122 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5123 static void FASTCALL |
| 21930 | 5124 normalizeLines(XML_Char *s) |
| 5125 { | |
| 5126 XML_Char *p; | |
| 5127 for (;; s++) { | |
| 5128 if (*s == XML_T('\0')) | |
| 5129 return; | |
| 5130 if (*s == 0xD) | |
| 5131 break; | |
| 5132 } | |
| 5133 p = s; | |
| 5134 do { | |
| 5135 if (*s == 0xD) { | |
| 5136 *p++ = 0xA; | |
| 5137 if (*++s == 0xA) | |
| 5138 s++; | |
| 5139 } | |
| 5140 else | |
| 5141 *p++ = *s++; | |
| 5142 } while (*s); | |
| 5143 *p = XML_T('\0'); | |
| 5144 } | |
| 5145 | |
| 5146 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5147 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
|
5148 const char *start, const char *end) |
| 21930 | 5149 { |
| 5150 const XML_Char *target; | |
| 5151 XML_Char *data; | |
| 5152 const char *tem; | |
| 5153 if (!processingInstructionHandler) { | |
| 5154 if (defaultHandler) | |
| 5155 reportDefault(parser, enc, start, end); | |
| 5156 return 1; | |
| 5157 } | |
| 5158 start += enc->minBytesPerChar * 2; | |
| 5159 tem = start + XmlNameLength(enc, start); | |
| 5160 target = poolStoreString(&tempPool, enc, start, tem); | |
| 5161 if (!target) | |
| 5162 return 0; | |
| 5163 poolFinish(&tempPool); | |
| 5164 data = poolStoreString(&tempPool, enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5165 XmlSkipS(enc, tem), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5166 end - enc->minBytesPerChar*2); |
| 21930 | 5167 if (!data) |
| 5168 return 0; | |
| 5169 normalizeLines(data); | |
| 5170 processingInstructionHandler(handlerArg, target, data); | |
| 5171 poolClear(&tempPool); | |
| 5172 return 1; | |
| 5173 } | |
| 5174 | |
| 5175 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5176 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
|
5177 const char *start, const char *end) |
| 21930 | 5178 { |
| 5179 XML_Char *data; | |
| 5180 if (!commentHandler) { | |
| 5181 if (defaultHandler) | |
| 5182 reportDefault(parser, enc, start, end); | |
| 5183 return 1; | |
| 5184 } | |
| 5185 data = poolStoreString(&tempPool, | |
| 5186 enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5187 start + enc->minBytesPerChar * 4, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5188 end - enc->minBytesPerChar * 3); |
| 21930 | 5189 if (!data) |
| 5190 return 0; | |
| 5191 normalizeLines(data); | |
| 5192 commentHandler(handlerArg, data); | |
| 5193 poolClear(&tempPool); | |
| 5194 return 1; | |
| 5195 } | |
| 5196 | |
| 5197 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5198 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
|
5199 const char *s, const char *end) |
| 21930 | 5200 { |
| 5201 if (MUST_CONVERT(enc, s)) { | |
| 5202 const char **eventPP; | |
| 5203 const char **eventEndPP; | |
| 5204 if (enc == encoding) { | |
| 5205 eventPP = &eventPtr; | |
| 5206 eventEndPP = &eventEndPtr; | |
| 5207 } | |
| 5208 else { | |
| 5209 eventPP = &(openInternalEntities->internalEventPtr); | |
| 5210 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 5211 } | |
| 5212 do { | |
| 5213 ICHAR *dataPtr = (ICHAR *)dataBuf; | |
| 5214 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | |
| 5215 *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
|
5216 defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); |
| 21930 | 5217 *eventPP = s; |
| 5218 } while (s != end); | |
| 5219 } | |
| 5220 else | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5221 defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 5222 } |
| 5223 | |
| 5224 | |
| 5225 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5226 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
|
5227 XML_Bool isId, const XML_Char *value, XML_Parser parser) |
| 21930 | 5228 { |
| 5229 DEFAULT_ATTRIBUTE *att; | |
| 5230 if (value || isId) { | |
| 5231 /* The handling of default attributes gets messed up if we have | |
| 5232 a default which duplicates a non-default. */ | |
| 5233 int i; | |
| 5234 for (i = 0; i < type->nDefaultAtts; i++) | |
| 5235 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
|
5236 return 1; |
| 21930 | 5237 if (isId && !type->idAtt && !attId->xmlns) |
| 5238 type->idAtt = attId; | |
| 5239 } | |
| 5240 if (type->nDefaultAtts == type->allocDefaultAtts) { | |
| 5241 if (type->allocDefaultAtts == 0) { | |
| 5242 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
|
5243 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
|
5244 * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5245 if (!type->defaultAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5246 return 0; |
| 21930 | 5247 } |
| 5248 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5249 DEFAULT_ATTRIBUTE *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5250 int count = type->allocDefaultAtts * 2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5251 temp = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5252 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
|
5253 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5254 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5255 type->allocDefaultAtts = count; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5256 type->defaultAtts = temp; |
| 21930 | 5257 } |
| 5258 } | |
| 5259 att = type->defaultAtts + type->nDefaultAtts; | |
| 5260 att->id = attId; | |
| 5261 att->value = value; | |
| 5262 att->isCdata = isCdata; | |
| 5263 if (!isCdata) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5264 attId->maybeTokenized = XML_TRUE; |
| 21930 | 5265 type->nDefaultAtts += 1; |
| 5266 return 1; | |
| 5267 } | |
| 5268 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5269 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5270 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) |
| 21930 | 5271 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5272 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5273 const XML_Char *name; |
| 5274 for (name = elementType->name; *name; name++) { | |
| 5275 if (*name == XML_T(':')) { | |
| 5276 PREFIX *prefix; | |
| 5277 const XML_Char *s; | |
| 5278 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
|
5279 if (!poolAppendChar(&dtd->pool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5280 return 0; |
| 21930 | 5281 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5282 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
|
5283 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5284 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
|
5285 sizeof(PREFIX)); |
| 21930 | 5286 if (!prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5287 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5288 if (prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5289 poolFinish(&dtd->pool); |
| 21930 | 5290 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5291 poolDiscard(&dtd->pool); |
| 21930 | 5292 elementType->prefix = prefix; |
| 5293 | |
| 5294 } | |
| 5295 } | |
| 5296 return 1; | |
| 5297 } | |
| 5298 | |
| 5299 static ATTRIBUTE_ID * | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5300 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
|
5301 const char *start, const char *end) |
| 21930 | 5302 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5303 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5304 ATTRIBUTE_ID *id; |
| 5305 const XML_Char *name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5306 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
|
5307 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5308 name = poolStoreString(&dtd->pool, enc, start, end); |
| 21930 | 5309 if (!name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5310 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
|
5311 /* skip quotation mark - its storage will be re-used (like in name[-1]) */ |
| 21930 | 5312 ++name; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5313 id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); |
| 21930 | 5314 if (!id) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5315 return NULL; |
| 21930 | 5316 if (id->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5317 poolDiscard(&dtd->pool); |
| 21930 | 5318 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5319 poolFinish(&dtd->pool); |
| 21930 | 5320 if (!ns) |
| 5321 ; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5322 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
|
5323 && name[1] == XML_T('m') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5324 && name[2] == XML_T('l') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5325 && name[3] == XML_T('n') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5326 && name[4] == XML_T('s') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5327 && (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
|
5328 if (name[5] == XML_T('\0')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5329 id->prefix = &dtd->defaultPrefix; |
| 21930 | 5330 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5331 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
|
5332 id->xmlns = XML_TRUE; |
| 21930 | 5333 } |
| 5334 else { | |
| 5335 int i; | |
| 5336 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
|
5337 /* 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
|
5338 if (name[i] == XML_T(':')) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5339 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5340 for (j = 0; j < i; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5341 if (!poolAppendChar(&dtd->pool, name[j])) |
|
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 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5344 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
|
5345 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5346 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
|
5347 sizeof(PREFIX)); |
|
39473
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
5348 if (!id->prefix) |
|
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
5349 return NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5350 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
|
5351 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5352 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5353 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5354 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5355 } |
| 21930 | 5356 } |
| 5357 } | |
| 5358 } | |
| 5359 return id; | |
| 5360 } | |
| 5361 | |
| 5362 #define CONTEXT_SEP XML_T('\f') | |
| 5363 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5364 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5365 getContext(XML_Parser parser) |
| 21930 | 5366 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5367 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5368 HASH_TABLE_ITER iter; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5369 XML_Bool needSep = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5370 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5371 if (dtd->defaultPrefix.binding) { |
| 21930 | 5372 int i; |
| 5373 int len; | |
| 5374 if (!poolAppendChar(&tempPool, XML_T('='))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5375 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5376 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
|
5377 if (namespaceSeparator) |
| 21930 | 5378 len--; |
| 5379 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
|
5380 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
|
5381 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5382 needSep = XML_TRUE; |
| 21930 | 5383 } |
| 5384 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5385 hashTableIterInit(&iter, &(dtd->prefixes)); |
| 21930 | 5386 for (;;) { |
| 5387 int i; | |
| 5388 int len; | |
| 5389 const XML_Char *s; | |
| 5390 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); | |
| 5391 if (!prefix) | |
| 5392 break; | |
| 5393 if (!prefix->binding) | |
| 5394 continue; | |
| 5395 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
|
5396 return NULL; |
| 21930 | 5397 for (s = prefix->name; *s; s++) |
| 5398 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5399 return NULL; |
| 21930 | 5400 if (!poolAppendChar(&tempPool, XML_T('='))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5401 return NULL; |
| 21930 | 5402 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
|
5403 if (namespaceSeparator) |
| 21930 | 5404 len--; |
| 5405 for (i = 0; i < len; i++) | |
| 5406 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
|
5407 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5408 needSep = XML_TRUE; |
| 21930 | 5409 } |
| 5410 | |
| 5411 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5412 hashTableIterInit(&iter, &(dtd->generalEntities)); |
| 21930 | 5413 for (;;) { |
| 5414 const XML_Char *s; | |
| 5415 ENTITY *e = (ENTITY *)hashTableIterNext(&iter); | |
| 5416 if (!e) | |
| 5417 break; | |
| 5418 if (!e->open) | |
| 5419 continue; | |
| 5420 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
|
5421 return NULL; |
| 21930 | 5422 for (s = e->name; *s; s++) |
| 5423 if (!poolAppendChar(&tempPool, *s)) | |
| 5424 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5425 needSep = XML_TRUE; |
| 21930 | 5426 } |
| 5427 | |
| 5428 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
|
5429 return NULL; |
| 21930 | 5430 return tempPool.start; |
| 5431 } | |
| 5432 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5433 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5434 setContext(XML_Parser parser, const XML_Char *context) |
| 21930 | 5435 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5436 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5437 const XML_Char *s = context; |
| 5438 | |
| 5439 while (*context != XML_T('\0')) { | |
| 5440 if (*s == CONTEXT_SEP || *s == XML_T('\0')) { | |
| 5441 ENTITY *e; | |
| 5442 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
|
5443 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5444 e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); |
| 21930 | 5445 if (e) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5446 e->open = XML_TRUE; |
| 21930 | 5447 if (*s != XML_T('\0')) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5448 s++; |
| 21930 | 5449 context = s; |
| 5450 poolDiscard(&tempPool); | |
| 5451 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5452 else if (*s == XML_T('=')) { |
| 21930 | 5453 PREFIX *prefix; |
| 5454 if (poolLength(&tempPool) == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5455 prefix = &dtd->defaultPrefix; |
| 21930 | 5456 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5457 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5458 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5459 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
|
5460 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5461 if (!prefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5462 return XML_FALSE; |
| 21930 | 5463 if (prefix->name == poolStart(&tempPool)) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5464 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
|
5465 if (!prefix->name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5466 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5467 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5468 poolDiscard(&tempPool); |
| 21930 | 5469 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5470 for (context = s + 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5471 *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
|
5472 context++) |
| 21930 | 5473 if (!poolAppendChar(&tempPool, *context)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5474 return XML_FALSE; |
| 21930 | 5475 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
|
5476 return XML_FALSE; |
| 32911 | 5477 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
|
5478 &inheritedBindings) != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5479 return XML_FALSE; |
| 21930 | 5480 poolDiscard(&tempPool); |
| 5481 if (*context != XML_T('\0')) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5482 ++context; |
| 21930 | 5483 s = context; |
| 5484 } | |
| 5485 else { | |
| 5486 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5487 return XML_FALSE; |
| 21930 | 5488 s++; |
| 5489 } | |
| 5490 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5491 return XML_TRUE; |
| 21930 | 5492 } |
| 5493 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5494 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5495 normalizePublicId(XML_Char *publicId) |
| 21930 | 5496 { |
| 5497 XML_Char *p = publicId; | |
| 5498 XML_Char *s; | |
| 5499 for (s = publicId; *s; s++) { | |
| 5500 switch (*s) { | |
| 5501 case 0x20: | |
| 5502 case 0xD: | |
| 5503 case 0xA: | |
| 5504 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
|
5505 *p++ = 0x20; |
| 21930 | 5506 break; |
| 5507 default: | |
| 5508 *p++ = *s; | |
| 5509 } | |
| 5510 } | |
| 5511 if (p != publicId && p[-1] == 0x20) | |
| 5512 --p; | |
| 5513 *p = XML_T('\0'); | |
| 5514 } | |
| 5515 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5516 static DTD * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5517 dtdCreate(const XML_Memory_Handling_Suite *ms) |
| 21930 | 5518 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5519 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
|
5520 if (p == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5521 return p; |
| 21930 | 5522 poolInit(&(p->pool), ms); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5523 poolInit(&(p->entityValuePool), ms); |
| 21930 | 5524 hashTableInit(&(p->generalEntities), ms); |
| 5525 hashTableInit(&(p->elementTypes), ms); | |
| 5526 hashTableInit(&(p->attributeIds), ms); | |
| 5527 hashTableInit(&(p->prefixes), ms); | |
| 5528 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5529 p->paramEntityRead = XML_FALSE; |
| 21930 | 5530 hashTableInit(&(p->paramEntities), ms); |
| 5531 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5532 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5533 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5534 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5535 p->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5536 p->scaffIndex = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5537 p->scaffold = NULL; |
| 21930 | 5538 p->scaffLevel = 0; |
| 5539 p->scaffSize = 0; | |
| 5540 p->scaffCount = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5541 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5542 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5543 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5544 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5545 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5546 return p; |
| 21930 | 5547 } |
| 5548 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5549 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5550 dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5551 { |
| 5552 HASH_TABLE_ITER iter; | |
| 5553 hashTableIterInit(&iter, &(p->elementTypes)); | |
| 5554 for (;;) { | |
| 5555 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5556 if (!e) | |
| 5557 break; | |
| 5558 if (e->allocDefaultAtts != 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5559 ms->free_fcn(e->defaultAtts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5560 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5561 hashTableClear(&(p->generalEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5562 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5563 p->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5564 hashTableClear(&(p->paramEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5565 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5566 hashTableClear(&(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5567 hashTableClear(&(p->attributeIds)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5568 hashTableClear(&(p->prefixes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5569 poolClear(&(p->pool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5570 poolClear(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5571 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5572 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5573 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5574 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
|
5575 |
|
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 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
|
5577 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
|
5578 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
|
5579 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
|
5580 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5581 p->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5582 p->scaffSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5583 p->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5584 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5585 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5586 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5587 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5588 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5589 } |
|
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 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5592 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
|
5593 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5594 HASH_TABLE_ITER iter; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5595 hashTableIterInit(&iter, &(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5596 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5597 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
|
5598 if (!e) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5599 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5600 if (e->allocDefaultAtts != 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5601 ms->free_fcn(e->defaultAtts); |
| 21930 | 5602 } |
| 5603 hashTableDestroy(&(p->generalEntities)); | |
| 5604 #ifdef XML_DTD | |
| 5605 hashTableDestroy(&(p->paramEntities)); | |
| 5606 #endif /* XML_DTD */ | |
| 5607 hashTableDestroy(&(p->elementTypes)); | |
| 5608 hashTableDestroy(&(p->attributeIds)); | |
| 5609 hashTableDestroy(&(p->prefixes)); | |
| 5610 poolDestroy(&(p->pool)); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5611 poolDestroy(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5612 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
|
5613 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
|
5614 ms->free_fcn(p->scaffold); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5615 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5616 ms->free_fcn(p); |
| 21930 | 5617 } |
| 5618 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5619 /* 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
|
5620 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
|
5621 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5622 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5623 dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5624 { |
| 5625 HASH_TABLE_ITER iter; | |
| 5626 | |
| 5627 /* Copy the prefix table. */ | |
| 5628 | |
| 5629 hashTableIterInit(&iter, &(oldDtd->prefixes)); | |
| 5630 for (;;) { | |
| 5631 const XML_Char *name; | |
| 5632 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); | |
| 5633 if (!oldP) | |
| 5634 break; | |
| 5635 name = poolCopyString(&(newDtd->pool), oldP->name); | |
| 5636 if (!name) | |
| 5637 return 0; | |
| 5638 if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX))) | |
| 5639 return 0; | |
| 5640 } | |
| 5641 | |
| 5642 hashTableIterInit(&iter, &(oldDtd->attributeIds)); | |
| 5643 | |
| 5644 /* Copy the attribute id table. */ | |
| 5645 | |
| 5646 for (;;) { | |
| 5647 ATTRIBUTE_ID *newA; | |
| 5648 const XML_Char *name; | |
| 5649 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); | |
| 5650 | |
| 5651 if (!oldA) | |
| 5652 break; | |
| 5653 /* Remember to allocate the scratch byte before the name. */ | |
| 5654 if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) | |
| 5655 return 0; | |
| 5656 name = poolCopyString(&(newDtd->pool), oldA->name); | |
| 5657 if (!name) | |
| 5658 return 0; | |
| 5659 ++name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5660 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
|
5661 sizeof(ATTRIBUTE_ID)); |
| 21930 | 5662 if (!newA) |
| 5663 return 0; | |
| 5664 newA->maybeTokenized = oldA->maybeTokenized; | |
| 5665 if (oldA->prefix) { | |
| 5666 newA->xmlns = oldA->xmlns; | |
| 5667 if (oldA->prefix == &oldDtd->defaultPrefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5668 newA->prefix = &newDtd->defaultPrefix; |
| 21930 | 5669 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5670 newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5671 oldA->prefix->name, 0); |
| 21930 | 5672 } |
| 5673 } | |
| 5674 | |
| 5675 /* Copy the element type table. */ | |
| 5676 | |
| 5677 hashTableIterInit(&iter, &(oldDtd->elementTypes)); | |
| 5678 | |
| 5679 for (;;) { | |
| 5680 int i; | |
| 5681 ELEMENT_TYPE *newE; | |
| 5682 const XML_Char *name; | |
| 5683 const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5684 if (!oldE) | |
| 5685 break; | |
| 5686 name = poolCopyString(&(newDtd->pool), oldE->name); | |
| 5687 if (!name) | |
| 5688 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5689 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
|
5690 sizeof(ELEMENT_TYPE)); |
| 21930 | 5691 if (!newE) |
| 5692 return 0; | |
| 5693 if (oldE->nDefaultAtts) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5694 newE->defaultAtts = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5695 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
|
5696 if (!newE->defaultAtts) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5697 ms->free_fcn(newE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5698 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5699 } |
| 21930 | 5700 } |
| 5701 if (oldE->idAtt) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5702 newE->idAtt = (ATTRIBUTE_ID *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5703 lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0); |
| 21930 | 5704 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; |
| 5705 if (oldE->prefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5706 newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5707 oldE->prefix->name, 0); |
| 21930 | 5708 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
|
5709 newE->defaultAtts[i].id = (ATTRIBUTE_ID *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5710 lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); |
| 21930 | 5711 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; |
| 5712 if (oldE->defaultAtts[i].value) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5713 newE->defaultAtts[i].value |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5714 = 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
|
5715 if (!newE->defaultAtts[i].value) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5716 return 0; |
| 21930 | 5717 } |
| 5718 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5719 newE->defaultAtts[i].value = NULL; |
| 21930 | 5720 } |
| 5721 } | |
| 5722 | |
| 5723 /* Copy the entity tables. */ | |
| 5724 if (!copyEntityTable(&(newDtd->generalEntities), | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5725 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5726 &(oldDtd->generalEntities))) |
| 21930 | 5727 return 0; |
| 5728 | |
| 5729 #ifdef XML_DTD | |
| 5730 if (!copyEntityTable(&(newDtd->paramEntities), | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5731 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5732 &(oldDtd->paramEntities))) |
| 21930 | 5733 return 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5734 newDtd->paramEntityRead = oldDtd->paramEntityRead; |
| 21930 | 5735 #endif /* XML_DTD */ |
| 5736 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5737 newDtd->keepProcessing = oldDtd->keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5738 newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; |
| 21930 | 5739 newDtd->standalone = oldDtd->standalone; |
| 5740 | |
| 5741 /* Don't want deep copying for scaffolding */ | |
| 5742 newDtd->in_eldecl = oldDtd->in_eldecl; | |
| 5743 newDtd->scaffold = oldDtd->scaffold; | |
| 5744 newDtd->contentStringLen = oldDtd->contentStringLen; | |
| 5745 newDtd->scaffSize = oldDtd->scaffSize; | |
| 5746 newDtd->scaffLevel = oldDtd->scaffLevel; | |
| 5747 newDtd->scaffIndex = oldDtd->scaffIndex; | |
| 5748 | |
| 5749 return 1; | |
| 5750 } /* End dtdCopy */ | |
| 5751 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5752 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5753 copyEntityTable(HASH_TABLE *newTable, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5754 STRING_POOL *newPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5755 const HASH_TABLE *oldTable) |
| 21930 | 5756 { |
| 5757 HASH_TABLE_ITER iter; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5758 const XML_Char *cachedOldBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5759 const XML_Char *cachedNewBase = NULL; |
| 21930 | 5760 |
| 5761 hashTableIterInit(&iter, oldTable); | |
| 5762 | |
| 5763 for (;;) { | |
| 5764 ENTITY *newE; | |
| 5765 const XML_Char *name; | |
| 5766 const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); | |
| 5767 if (!oldE) | |
| 5768 break; | |
| 5769 name = poolCopyString(newPool, oldE->name); | |
| 5770 if (!name) | |
| 5771 return 0; | |
| 5772 newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY)); | |
| 5773 if (!newE) | |
| 5774 return 0; | |
| 5775 if (oldE->systemId) { | |
| 5776 const XML_Char *tem = poolCopyString(newPool, oldE->systemId); | |
| 5777 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5778 return 0; |
| 21930 | 5779 newE->systemId = tem; |
| 5780 if (oldE->base) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5781 if (oldE->base == cachedOldBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5782 newE->base = cachedNewBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5783 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5784 cachedOldBase = oldE->base; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5785 tem = poolCopyString(newPool, cachedOldBase); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5786 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5787 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5788 cachedNewBase = newE->base = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5789 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5790 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5791 if (oldE->publicId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5792 tem = poolCopyString(newPool, oldE->publicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5793 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5794 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5795 newE->publicId = tem; |
| 21930 | 5796 } |
| 5797 } | |
| 5798 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5799 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
|
5800 oldE->textLen); |
| 21930 | 5801 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5802 return 0; |
| 21930 | 5803 newE->textPtr = tem; |
| 5804 newE->textLen = oldE->textLen; | |
| 5805 } | |
| 5806 if (oldE->notation) { | |
| 5807 const XML_Char *tem = poolCopyString(newPool, oldE->notation); | |
| 5808 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5809 return 0; |
| 21930 | 5810 newE->notation = tem; |
| 5811 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5812 newE->is_param = oldE->is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5813 newE->is_internal = oldE->is_internal; |
| 21930 | 5814 } |
| 5815 return 1; | |
| 5816 } | |
| 5817 | |
|
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
|
5818 #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
|
5819 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5820 static XML_Bool FASTCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5821 keyeq(KEY s1, KEY s2) |
| 21930 | 5822 { |
| 5823 for (; *s1 == *s2; s1++, s2++) | |
| 5824 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
|
5825 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
|
5826 return XML_FALSE; |
| 21930 | 5827 } |
| 5828 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5829 static unsigned long FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5830 hash(KEY s) |
| 21930 | 5831 { |
| 5832 unsigned long h = 0; | |
| 5833 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
|
5834 h = CHAR_HASH(h, *s++); |
| 21930 | 5835 return h; |
| 5836 } | |
| 5837 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5838 static NAMED * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5839 lookup(HASH_TABLE *table, KEY name, size_t createSize) |
| 21930 | 5840 { |
| 5841 size_t i; | |
| 5842 if (table->size == 0) { | |
| 5843 size_t tsize; | |
| 5844 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5845 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
|
5846 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
|
5847 /* 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
|
5848 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
|
5849 tsize = table->size * sizeof(NAMED *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5850 table->v = (NAMED **)table->mem->malloc_fcn(tsize); |
| 32911 | 5851 if (!table->v) { |
| 5852 table->size = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5853 return NULL; |
| 32911 | 5854 } |
| 21930 | 5855 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
|
5856 i = hash(name) & ((unsigned long)table->size - 1); |
| 21930 | 5857 } |
| 5858 else { | |
| 5859 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
|
5860 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
|
5861 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
|
5862 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
|
5863 while (table->v[i]) { |
| 21930 | 5864 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
|
5865 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
|
5866 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
|
5867 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
|
5868 i < step ? (i += table->size - step) : (i -= step); |
| 21930 | 5869 } |
| 5870 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5871 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
|
5872 |
|
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 /* 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
|
5874 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
|
5875 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
|
5876 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
|
5877 unsigned long newMask = (unsigned long)newSize - 1; |
| 21930 | 5878 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
|
5879 NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); |
| 21930 | 5880 if (!newV) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5881 return NULL; |
| 21930 | 5882 memset(newV, 0, tsize); |
| 5883 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
|
5884 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
|
5885 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
|
5886 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
|
5887 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
|
5888 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
|
5889 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
|
5890 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
|
5891 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
|
5892 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5893 newV[j] = table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5894 } |
| 21930 | 5895 table->mem->free_fcn(table->v); |
| 5896 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
|
5897 table->power = newPower; |
| 21930 | 5898 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
|
5899 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
|
5900 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
|
5901 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
|
5902 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
|
5903 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
|
5904 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
|
5905 } |
| 21930 | 5906 } |
| 5907 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5908 table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); |
| 21930 | 5909 if (!table->v[i]) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5910 return NULL; |
| 21930 | 5911 memset(table->v[i], 0, createSize); |
| 5912 table->v[i]->name = name; | |
| 5913 (table->used)++; | |
| 5914 return table->v[i]; | |
| 5915 } | |
| 5916 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5917 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5918 hashTableClear(HASH_TABLE *table) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5919 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5920 size_t i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5921 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
|
5922 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
|
5923 table->v[i] = NULL; |
|
27384
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 table->used = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5926 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5927 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5928 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5929 hashTableDestroy(HASH_TABLE *table) |
| 21930 | 5930 { |
| 5931 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
|
5932 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
|
5933 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
|
5934 table->mem->free_fcn(table->v); |
| 21930 | 5935 } |
| 5936 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5937 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5938 hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5939 { |
|
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
|
5940 p->power = 0; |
| 21930 | 5941 p->size = 0; |
| 5942 p->used = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5943 p->v = NULL; |
| 21930 | 5944 p->mem = ms; |
| 5945 } | |
| 5946 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5947 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5948 hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) |
| 21930 | 5949 { |
| 5950 iter->p = table->v; | |
| 5951 iter->end = iter->p + table->size; | |
| 5952 } | |
| 5953 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5954 static NAMED * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5955 hashTableIterNext(HASH_TABLE_ITER *iter) |
| 21930 | 5956 { |
| 5957 while (iter->p != iter->end) { | |
| 5958 NAMED *tem = *(iter->p)++; | |
| 5959 if (tem) | |
| 5960 return tem; | |
| 5961 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5962 return NULL; |
| 21930 | 5963 } |
| 5964 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5965 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5966 poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5967 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5968 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5969 pool->freeBlocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5970 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5971 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5972 pool->end = NULL; |
| 21930 | 5973 pool->mem = ms; |
| 5974 } | |
| 5975 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5976 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5977 poolClear(STRING_POOL *pool) |
| 21930 | 5978 { |
| 5979 if (!pool->freeBlocks) | |
| 5980 pool->freeBlocks = pool->blocks; | |
| 5981 else { | |
| 5982 BLOCK *p = pool->blocks; | |
| 5983 while (p) { | |
| 5984 BLOCK *tem = p->next; | |
| 5985 p->next = pool->freeBlocks; | |
| 5986 pool->freeBlocks = p; | |
| 5987 p = tem; | |
| 5988 } | |
| 5989 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5990 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5991 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5992 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5993 pool->end = NULL; |
| 21930 | 5994 } |
| 5995 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5996 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5997 poolDestroy(STRING_POOL *pool) |
| 21930 | 5998 { |
| 5999 BLOCK *p = pool->blocks; | |
| 6000 while (p) { | |
| 6001 BLOCK *tem = p->next; | |
| 6002 pool->mem->free_fcn(p); | |
| 6003 p = tem; | |
| 6004 } | |
| 6005 p = pool->freeBlocks; | |
| 6006 while (p) { | |
| 6007 BLOCK *tem = p->next; | |
| 6008 pool->mem->free_fcn(p); | |
| 6009 p = tem; | |
| 6010 } | |
| 6011 } | |
| 6012 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6013 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6014 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
|
6015 const char *ptr, const char *end) |
| 21930 | 6016 { |
| 6017 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6018 return NULL; |
| 21930 | 6019 for (;;) { |
| 6020 XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); | |
| 6021 if (ptr == end) | |
| 6022 break; | |
| 6023 if (!poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6024 return NULL; |
| 21930 | 6025 } |
| 6026 return pool->start; | |
| 6027 } | |
| 6028 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6029 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6030 poolCopyString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6031 { |
| 6032 do { | |
| 6033 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6034 return NULL; |
| 21930 | 6035 } while (*s++); |
| 6036 s = pool->start; | |
| 6037 poolFinish(pool); | |
| 6038 return s; | |
| 6039 } | |
| 6040 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6041 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6042 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) |
| 21930 | 6043 { |
| 6044 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6045 return NULL; |
| 21930 | 6046 for (; n > 0; --n, s++) { |
| 6047 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6048 return NULL; |
| 21930 | 6049 } |
| 6050 s = pool->start; | |
| 6051 poolFinish(pool); | |
| 6052 return s; | |
| 6053 } | |
| 6054 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6055 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6056 poolAppendString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6057 { |
| 6058 while (*s) { | |
| 6059 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6060 return NULL; |
| 21930 | 6061 s++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6062 } |
| 21930 | 6063 return pool->start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6064 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6065 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6066 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6067 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
|
6068 const char *ptr, const char *end) |
| 21930 | 6069 { |
| 6070 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
|
6071 return NULL; |
| 21930 | 6072 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
|
6073 return NULL; |
| 21930 | 6074 *(pool->ptr)++ = 0; |
| 6075 return pool->start; | |
| 6076 } | |
| 6077 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6078 static XML_Bool FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6079 poolGrow(STRING_POOL *pool) |
| 21930 | 6080 { |
| 6081 if (pool->freeBlocks) { | |
| 6082 if (pool->start == 0) { | |
| 6083 pool->blocks = pool->freeBlocks; | |
| 6084 pool->freeBlocks = pool->freeBlocks->next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6085 pool->blocks->next = NULL; |
| 21930 | 6086 pool->start = pool->blocks->s; |
| 6087 pool->end = pool->start + pool->blocks->size; | |
| 6088 pool->ptr = pool->start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6089 return XML_TRUE; |
| 21930 | 6090 } |
| 6091 if (pool->end - pool->start < pool->freeBlocks->size) { | |
| 6092 BLOCK *tem = pool->freeBlocks->next; | |
| 6093 pool->freeBlocks->next = pool->blocks; | |
| 6094 pool->blocks = pool->freeBlocks; | |
| 6095 pool->freeBlocks = tem; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6096 memcpy(pool->blocks->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6097 (pool->end - pool->start) * sizeof(XML_Char)); |
| 21930 | 6098 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); |
| 6099 pool->start = pool->blocks->s; | |
| 6100 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
|
6101 return XML_TRUE; |
| 21930 | 6102 } |
| 6103 } | |
| 6104 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
|
6105 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
|
6106 pool->blocks = (BLOCK *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6107 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
|
6108 (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
|
6109 + blockSize * sizeof(XML_Char))); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6110 if (pool->blocks == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6111 return XML_FALSE; |
| 21930 | 6112 pool->blocks->size = blockSize; |
| 6113 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); | |
| 6114 pool->start = pool->blocks->s; | |
| 6115 pool->end = pool->start + blockSize; | |
| 6116 } | |
| 6117 else { | |
| 6118 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
|
6119 int blockSize = (int)(pool->end - pool->start); |
| 21930 | 6120 if (blockSize < INIT_BLOCK_SIZE) |
| 6121 blockSize = INIT_BLOCK_SIZE; | |
| 6122 else | |
| 6123 blockSize *= 2; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6124 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
|
6125 + blockSize * sizeof(XML_Char)); |
| 21930 | 6126 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6127 return XML_FALSE; |
| 21930 | 6128 tem->size = blockSize; |
| 6129 tem->next = pool->blocks; | |
| 6130 pool->blocks = tem; | |
| 6131 if (pool->ptr != pool->start) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6132 memcpy(tem->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6133 (pool->ptr - pool->start) * sizeof(XML_Char)); |
| 21930 | 6134 pool->ptr = tem->s + (pool->ptr - pool->start); |
| 6135 pool->start = tem->s; | |
| 6136 pool->end = tem->s + blockSize; | |
| 6137 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6138 return XML_TRUE; |
| 21930 | 6139 } |
| 6140 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6141 static int FASTCALL |
| 21930 | 6142 nextScaffoldPart(XML_Parser parser) |
| 6143 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6144 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6145 CONTENT_SCAFFOLD * me; |
| 6146 int next; | |
| 6147 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6148 if (!dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6149 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
|
6150 if (!dtd->scaffIndex) |
| 21930 | 6151 return -1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6152 dtd->scaffIndex[0] = 0; |
| 21930 | 6153 } |
| 6154 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6155 if (dtd->scaffCount >= dtd->scaffSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6156 CONTENT_SCAFFOLD *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6157 if (dtd->scaffold) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6158 temp = (CONTENT_SCAFFOLD *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6159 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
|
6160 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6161 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6162 dtd->scaffSize *= 2; |
| 21930 | 6163 } |
| 6164 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6165 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
|
6166 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6167 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6168 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6169 dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; |
| 21930 | 6170 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6171 dtd->scaffold = temp; |
| 21930 | 6172 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6173 next = dtd->scaffCount++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6174 me = &dtd->scaffold[next]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6175 if (dtd->scaffLevel) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6176 CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; |
| 21930 | 6177 if (parent->lastchild) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6178 dtd->scaffold[parent->lastchild].nextsib = next; |
| 21930 | 6179 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6180 if (!parent->childcnt) |
| 21930 | 6181 parent->firstchild = next; |
| 6182 parent->lastchild = next; | |
| 6183 parent->childcnt++; | |
| 6184 } | |
| 6185 me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; | |
| 6186 return next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6187 } |
| 21930 | 6188 |
| 6189 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6190 build_node(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6191 int src_node, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6192 XML_Content *dest, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6193 XML_Content **contpos, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6194 XML_Char **strpos) |
| 21930 | 6195 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6196 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
|
6197 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
|
6198 dest->quant = dtd->scaffold[src_node].quant; |
| 21930 | 6199 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
|
6200 const XML_Char *src; |
| 21930 | 6201 dest->name = *strpos; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6202 src = dtd->scaffold[src_node].name; |
| 21930 | 6203 for (;;) { |
| 6204 *(*strpos)++ = *src; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6205 if (!*src) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6206 break; |
| 21930 | 6207 src++; |
| 6208 } | |
| 6209 dest->numchildren = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6210 dest->children = NULL; |
| 21930 | 6211 } |
| 6212 else { | |
| 6213 unsigned int i; | |
| 6214 int cn; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6215 dest->numchildren = dtd->scaffold[src_node].childcnt; |
| 21930 | 6216 dest->children = *contpos; |
| 6217 *contpos += dest->numchildren; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6218 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
|
6219 i < dest->numchildren; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6220 i++, cn = dtd->scaffold[cn].nextsib) { |
| 21930 | 6221 build_node(parser, cn, &(dest->children[i]), contpos, strpos); |
| 6222 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6223 dest->name = NULL; |
| 21930 | 6224 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6225 } |
| 21930 | 6226 |
| 6227 static XML_Content * | |
| 6228 build_model (XML_Parser parser) | |
| 6229 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6230 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6231 XML_Content *ret; |
| 6232 XML_Content *cpos; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6233 XML_Char * str; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6234 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
|
6235 + (dtd->contentStringLen * sizeof(XML_Char))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6236 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6237 ret = (XML_Content *)MALLOC(allocsize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6238 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6239 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6240 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6241 str = (XML_Char *) (&ret[dtd->scaffCount]); |
| 21930 | 6242 cpos = &ret[1]; |
| 6243 | |
| 6244 build_node(parser, 0, ret, &cpos, &str); | |
| 6245 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6246 } |
| 21930 | 6247 |
| 6248 static ELEMENT_TYPE * | |
| 6249 getElementType(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6250 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6251 const char *ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6252 const char *end) |
| 21930 | 6253 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6254 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
|
6255 const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); |
| 21930 | 6256 ELEMENT_TYPE *ret; |
| 6257 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6258 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6259 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6260 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
|
6261 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6262 return NULL; |
| 21930 | 6263 if (ret->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6264 poolDiscard(&dtd->pool); |
| 21930 | 6265 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6266 poolFinish(&dtd->pool); |
| 21930 | 6267 if (!setElementTypePrefix(parser, ret)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6268 return NULL; |
| 21930 | 6269 } |
| 6270 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6271 } |
