Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/xml/sax/qxml.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | namespace { | - | ||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | template <typename Container> | - | ||||||||||||
7 | void clear(Container &c) { c = Container(); } executed 2261 times by 6 tests: end of block Executed by:
| 2261 | ||||||||||||
8 | - | |||||||||||||
9 | } | - | ||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | static const signed char cltWS = 0; | - | ||||||||||||
13 | static const signed char cltPer = 1; | - | ||||||||||||
14 | static const signed char cltAmp = 2; | - | ||||||||||||
15 | static const signed char cltGt = 3; | - | ||||||||||||
16 | static const signed char cltLt = 4; | - | ||||||||||||
17 | static const signed char cltSlash = 5; | - | ||||||||||||
18 | static const signed char cltQm = 6; | - | ||||||||||||
19 | static const signed char cltEm = 7; | - | ||||||||||||
20 | static const signed char cltDash = 8; | - | ||||||||||||
21 | static const signed char cltCB = 9; | - | ||||||||||||
22 | static const signed char cltOB = 10; | - | ||||||||||||
23 | static const signed char cltEq = 11; | - | ||||||||||||
24 | static const signed char cltDq = 12; | - | ||||||||||||
25 | static const signed char cltSq = 13; | - | ||||||||||||
26 | static const signed char cltUnknown = 14; | - | ||||||||||||
27 | - | |||||||||||||
28 | - | |||||||||||||
29 | static const signed char charLookupTable[256]={ | - | ||||||||||||
30 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
31 | cltUnknown, | - | ||||||||||||
32 | cltWS, | - | ||||||||||||
33 | cltWS, | - | ||||||||||||
34 | cltUnknown, | - | ||||||||||||
35 | cltUnknown, | - | ||||||||||||
36 | cltWS, | - | ||||||||||||
37 | cltUnknown, | - | ||||||||||||
38 | cltUnknown, | - | ||||||||||||
39 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
40 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
41 | cltWS, | - | ||||||||||||
42 | cltEm, | - | ||||||||||||
43 | cltDq, | - | ||||||||||||
44 | cltUnknown, | - | ||||||||||||
45 | cltUnknown, | - | ||||||||||||
46 | cltPer, | - | ||||||||||||
47 | cltAmp, | - | ||||||||||||
48 | cltSq, | - | ||||||||||||
49 | cltUnknown, | - | ||||||||||||
50 | cltUnknown, | - | ||||||||||||
51 | cltUnknown, | - | ||||||||||||
52 | cltUnknown, | - | ||||||||||||
53 | cltUnknown, | - | ||||||||||||
54 | cltDash, | - | ||||||||||||
55 | cltUnknown, | - | ||||||||||||
56 | cltSlash, | - | ||||||||||||
57 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
58 | cltUnknown, | - | ||||||||||||
59 | cltUnknown, | - | ||||||||||||
60 | cltUnknown, | - | ||||||||||||
61 | cltUnknown, | - | ||||||||||||
62 | cltLt, | - | ||||||||||||
63 | cltEq, | - | ||||||||||||
64 | cltGt, | - | ||||||||||||
65 | cltQm, | - | ||||||||||||
66 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
67 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
68 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
69 | cltUnknown, | - | ||||||||||||
70 | cltUnknown, | - | ||||||||||||
71 | cltUnknown, | - | ||||||||||||
72 | cltOB, | - | ||||||||||||
73 | cltUnknown, | - | ||||||||||||
74 | cltCB, | - | ||||||||||||
75 | cltUnknown, | - | ||||||||||||
76 | cltUnknown, | - | ||||||||||||
77 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
78 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
79 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
80 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
81 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
82 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
83 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
84 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
85 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
86 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
87 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
88 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
89 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
90 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
91 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
92 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
93 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
94 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
95 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, | - | ||||||||||||
96 | cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown, cltUnknown | - | ||||||||||||
97 | }; | - | ||||||||||||
98 | static bool stripTextDecl(QString& str) | - | ||||||||||||
99 | { | - | ||||||||||||
100 | QString textDeclStart(QLatin1String("<?xml")); | - | ||||||||||||
101 | if (str.startsWith(textDeclStart)) { | - | ||||||||||||
102 | QRegExp textDecl(QString::fromLatin1( | - | ||||||||||||
103 | "^<\\?xml\\s+" | - | ||||||||||||
104 | "(version\\s*=\\s*((['\"])[-a-zA-Z0-9_.:]+\\3))?" | - | ||||||||||||
105 | "\\s*" | - | ||||||||||||
106 | "(encoding\\s*=\\s*((['\"])[A-Za-z][-a-zA-Z0-9_.]*\\6))?" | - | ||||||||||||
107 | "\\s*\\?>" | - | ||||||||||||
108 | )); | - | ||||||||||||
109 | QString strTmp = str.replace(textDecl, QLatin1String("")); | - | ||||||||||||
110 | if (strTmp.length() != str.length()) | - | ||||||||||||
111 | return false; | - | ||||||||||||
112 | str = strTmp; | - | ||||||||||||
113 | } | - | ||||||||||||
114 | return true; | - | ||||||||||||
115 | } | - | ||||||||||||
116 | - | |||||||||||||
117 | - | |||||||||||||
118 | class QXmlAttributesPrivate | - | ||||||||||||
119 | { | - | ||||||||||||
120 | }; | - | ||||||||||||
121 | class QXmlInputSourcePrivate | - | ||||||||||||
122 | { | - | ||||||||||||
123 | public: | - | ||||||||||||
124 | QIODevice *inputDevice; | - | ||||||||||||
125 | QTextStream *inputStream; | - | ||||||||||||
126 | - | |||||||||||||
127 | QString str; | - | ||||||||||||
128 | const QChar *unicode; | - | ||||||||||||
129 | int pos; | - | ||||||||||||
130 | int length; | - | ||||||||||||
131 | bool nextReturnedEndOfData; | - | ||||||||||||
132 | - | |||||||||||||
133 | QTextDecoder *encMapper; | - | ||||||||||||
134 | - | |||||||||||||
135 | - | |||||||||||||
136 | QByteArray encodingDeclBytes; | - | ||||||||||||
137 | QString encodingDeclChars; | - | ||||||||||||
138 | bool lookingForEncodingDecl; | - | ||||||||||||
139 | }; | - | ||||||||||||
140 | class QXmlParseExceptionPrivate | - | ||||||||||||
141 | { | - | ||||||||||||
142 | public: | - | ||||||||||||
143 | QXmlParseExceptionPrivate() | - | ||||||||||||
144 | : column(-1), line(-1) | - | ||||||||||||
145 | { | - | ||||||||||||
146 | } | - | ||||||||||||
147 | QXmlParseExceptionPrivate(const QXmlParseExceptionPrivate &other) | - | ||||||||||||
148 | : msg(other.msg), column(other.column), line(other.line), | - | ||||||||||||
149 | pub(other.pub), sys(other.sys) | - | ||||||||||||
150 | { | - | ||||||||||||
151 | } | - | ||||||||||||
152 | - | |||||||||||||
153 | QString msg; | - | ||||||||||||
154 | int column; | - | ||||||||||||
155 | int line; | - | ||||||||||||
156 | QString pub; | - | ||||||||||||
157 | QString sys; | - | ||||||||||||
158 | - | |||||||||||||
159 | }; | - | ||||||||||||
160 | - | |||||||||||||
161 | class QXmlLocatorPrivate | - | ||||||||||||
162 | { | - | ||||||||||||
163 | }; | - | ||||||||||||
164 | - | |||||||||||||
165 | class QXmlDefaultHandlerPrivate | - | ||||||||||||
166 | { | - | ||||||||||||
167 | }; | - | ||||||||||||
168 | QXmlParseException::QXmlParseException(const QString& name, int c, int l, | - | ||||||||||||
169 | const QString& p, const QString& s) | - | ||||||||||||
170 | : d(new QXmlParseExceptionPrivate) | - | ||||||||||||
171 | { | - | ||||||||||||
172 | d->msg = name; | - | ||||||||||||
173 | d->column = c; | - | ||||||||||||
174 | d->line = l; | - | ||||||||||||
175 | d->pub = p; | - | ||||||||||||
176 | d->sys = s; | - | ||||||||||||
177 | } | - | ||||||||||||
178 | - | |||||||||||||
179 | - | |||||||||||||
180 | - | |||||||||||||
181 | - | |||||||||||||
182 | QXmlParseException::QXmlParseException(const QXmlParseException& other) : | - | ||||||||||||
183 | d(new QXmlParseExceptionPrivate(*other.d)) | - | ||||||||||||
184 | { | - | ||||||||||||
185 | - | |||||||||||||
186 | } | - | ||||||||||||
187 | - | |||||||||||||
188 | - | |||||||||||||
189 | - | |||||||||||||
190 | - | |||||||||||||
191 | QXmlParseException::~QXmlParseException() | - | ||||||||||||
192 | { | - | ||||||||||||
193 | } | - | ||||||||||||
194 | - | |||||||||||||
195 | - | |||||||||||||
196 | - | |||||||||||||
197 | - | |||||||||||||
198 | QString QXmlParseException::message() const | - | ||||||||||||
199 | { | - | ||||||||||||
200 | return d->msg; | - | ||||||||||||
201 | } | - | ||||||||||||
202 | - | |||||||||||||
203 | - | |||||||||||||
204 | - | |||||||||||||
205 | int QXmlParseException::columnNumber() const | - | ||||||||||||
206 | { | - | ||||||||||||
207 | return d->column; | - | ||||||||||||
208 | } | - | ||||||||||||
209 | - | |||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | int QXmlParseException::lineNumber() const | - | ||||||||||||
213 | { | - | ||||||||||||
214 | return d->line; | - | ||||||||||||
215 | } | - | ||||||||||||
216 | - | |||||||||||||
217 | - | |||||||||||||
218 | - | |||||||||||||
219 | QString QXmlParseException::publicId() const | - | ||||||||||||
220 | { | - | ||||||||||||
221 | return d->pub; | - | ||||||||||||
222 | } | - | ||||||||||||
223 | - | |||||||||||||
224 | - | |||||||||||||
225 | - | |||||||||||||
226 | QString QXmlParseException::systemId() const | - | ||||||||||||
227 | { | - | ||||||||||||
228 | return d->sys; | - | ||||||||||||
229 | } | - | ||||||||||||
230 | QXmlLocator::QXmlLocator() | - | ||||||||||||
231 | { | - | ||||||||||||
232 | } | - | ||||||||||||
233 | - | |||||||||||||
234 | - | |||||||||||||
235 | - | |||||||||||||
236 | - | |||||||||||||
237 | QXmlLocator::~QXmlLocator() | - | ||||||||||||
238 | { | - | ||||||||||||
239 | } | - | ||||||||||||
240 | class QXmlSimpleReaderLocator : public QXmlLocator | - | ||||||||||||
241 | { | - | ||||||||||||
242 | public: | - | ||||||||||||
243 | QXmlSimpleReaderLocator(QXmlSimpleReader* parent) | - | ||||||||||||
244 | { | - | ||||||||||||
245 | reader = parent; | - | ||||||||||||
246 | } | - | ||||||||||||
247 | ~QXmlSimpleReaderLocator() | - | ||||||||||||
248 | { | - | ||||||||||||
249 | } | - | ||||||||||||
250 | - | |||||||||||||
251 | int columnNumber() const override | - | ||||||||||||
252 | { | - | ||||||||||||
253 | return (reader->d_ptr->columnNr == -1 ? -1 : reader->d_ptr->columnNr + 1); | - | ||||||||||||
254 | } | - | ||||||||||||
255 | int lineNumber() const override | - | ||||||||||||
256 | { | - | ||||||||||||
257 | return (reader->d_ptr->lineNr == -1 ? -1 : reader->d_ptr->lineNr + 1); | - | ||||||||||||
258 | } | - | ||||||||||||
259 | - | |||||||||||||
260 | - | |||||||||||||
261 | - | |||||||||||||
262 | private: | - | ||||||||||||
263 | QXmlSimpleReader *reader; | - | ||||||||||||
264 | }; | - | ||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | - | |||||||||||||
268 | - | |||||||||||||
269 | - | |||||||||||||
270 | - | |||||||||||||
271 | - | |||||||||||||
272 | typedef QMap<QString, QString> NamespaceMap; | - | ||||||||||||
273 | - | |||||||||||||
274 | class QXmlNamespaceSupportPrivate | - | ||||||||||||
275 | { | - | ||||||||||||
276 | public: | - | ||||||||||||
277 | QXmlNamespaceSupportPrivate() | - | ||||||||||||
278 | { | - | ||||||||||||
279 | ns.insert(QLatin1String("xml"), QLatin1String("http://www.w3.org/XML/1998/namespace")); | - | ||||||||||||
280 | } | - | ||||||||||||
281 | - | |||||||||||||
282 | ~QXmlNamespaceSupportPrivate() | - | ||||||||||||
283 | { | - | ||||||||||||
284 | } | - | ||||||||||||
285 | - | |||||||||||||
286 | QStack<NamespaceMap> nsStack; | - | ||||||||||||
287 | NamespaceMap ns; | - | ||||||||||||
288 | }; | - | ||||||||||||
289 | QXmlNamespaceSupport::QXmlNamespaceSupport() | - | ||||||||||||
290 | { | - | ||||||||||||
291 | d = new QXmlNamespaceSupportPrivate; | - | ||||||||||||
292 | } | - | ||||||||||||
293 | - | |||||||||||||
294 | - | |||||||||||||
295 | - | |||||||||||||
296 | - | |||||||||||||
297 | QXmlNamespaceSupport::~QXmlNamespaceSupport() | - | ||||||||||||
298 | { | - | ||||||||||||
299 | delete d; | - | ||||||||||||
300 | } | - | ||||||||||||
301 | void QXmlNamespaceSupport::setPrefix(const QString& pre, const QString& uri) | - | ||||||||||||
302 | { | - | ||||||||||||
303 | if(pre.isNull()) { | - | ||||||||||||
304 | d->ns.insert(QLatin1String(""), uri); | - | ||||||||||||
305 | } else { | - | ||||||||||||
306 | d->ns.insert(pre, uri); | - | ||||||||||||
307 | } | - | ||||||||||||
308 | } | - | ||||||||||||
309 | QString QXmlNamespaceSupport::prefix(const QString& uri) const | - | ||||||||||||
310 | { | - | ||||||||||||
311 | NamespaceMap::const_iterator itc, it = d->ns.constBegin(); | - | ||||||||||||
312 | while ((itc=it) != d->ns.constEnd()) { | - | ||||||||||||
313 | ++it; | - | ||||||||||||
314 | if (*itc == uri && !itc.key().isEmpty()) | - | ||||||||||||
315 | return itc.key(); | - | ||||||||||||
316 | } | - | ||||||||||||
317 | return QLatin1String(""); | - | ||||||||||||
318 | } | - | ||||||||||||
319 | - | |||||||||||||
320 | - | |||||||||||||
321 | - | |||||||||||||
322 | - | |||||||||||||
323 | - | |||||||||||||
324 | - | |||||||||||||
325 | QString QXmlNamespaceSupport::uri(const QString& prefix) const | - | ||||||||||||
326 | { | - | ||||||||||||
327 | return d->ns[prefix]; | - | ||||||||||||
328 | } | - | ||||||||||||
329 | - | |||||||||||||
330 | - | |||||||||||||
331 | - | |||||||||||||
332 | - | |||||||||||||
333 | - | |||||||||||||
334 | - | |||||||||||||
335 | - | |||||||||||||
336 | void QXmlNamespaceSupport::splitName(const QString& qname, QString& prefix, | - | ||||||||||||
337 | QString& localname) const | - | ||||||||||||
338 | { | - | ||||||||||||
339 | int pos = qname.indexOf(QLatin1Char(':')); | - | ||||||||||||
340 | if (pos == -1) | - | ||||||||||||
341 | pos = qname.size(); | - | ||||||||||||
342 | - | |||||||||||||
343 | prefix = qname.left(pos); | - | ||||||||||||
344 | localname = qname.mid(pos+1); | - | ||||||||||||
345 | } | - | ||||||||||||
346 | void QXmlNamespaceSupport::processName(const QString& qname, | - | ||||||||||||
347 | bool isAttribute, | - | ||||||||||||
348 | QString& nsuri, QString& localname) const | - | ||||||||||||
349 | { | - | ||||||||||||
350 | int len = qname.size(); | - | ||||||||||||
351 | const QChar *data = qname.constData(); | - | ||||||||||||
352 | for (int pos = 0; pos < len; ++pos) { | - | ||||||||||||
353 | if (data[pos] == QLatin1Char(':')) { | - | ||||||||||||
354 | nsuri = uri(qname.left(pos)); | - | ||||||||||||
355 | localname = qname.mid(pos + 1); | - | ||||||||||||
356 | return; | - | ||||||||||||
357 | } | - | ||||||||||||
358 | } | - | ||||||||||||
359 | - | |||||||||||||
360 | - | |||||||||||||
361 | nsuri.clear(); | - | ||||||||||||
362 | - | |||||||||||||
363 | if (!isAttribute && !d->ns.isEmpty()) { | - | ||||||||||||
364 | - | |||||||||||||
365 | - | |||||||||||||
366 | - | |||||||||||||
367 | - | |||||||||||||
368 | - | |||||||||||||
369 | NamespaceMap::const_iterator first = d->ns.constBegin(); | - | ||||||||||||
370 | if (first.key().isEmpty()) | - | ||||||||||||
371 | nsuri = first.value(); | - | ||||||||||||
372 | } | - | ||||||||||||
373 | localname = qname; | - | ||||||||||||
374 | } | - | ||||||||||||
375 | QStringList QXmlNamespaceSupport::prefixes() const | - | ||||||||||||
376 | { | - | ||||||||||||
377 | QStringList list; | - | ||||||||||||
378 | - | |||||||||||||
379 | NamespaceMap::const_iterator itc, it = d->ns.constBegin(); | - | ||||||||||||
380 | while ((itc=it) != d->ns.constEnd()) { | - | ||||||||||||
381 | ++it; | - | ||||||||||||
382 | if (!itc.key().isEmpty()) | - | ||||||||||||
383 | list.append(itc.key()); | - | ||||||||||||
384 | } | - | ||||||||||||
385 | return list; | - | ||||||||||||
386 | } | - | ||||||||||||
387 | QStringList QXmlNamespaceSupport::prefixes(const QString& uri) const | - | ||||||||||||
388 | { | - | ||||||||||||
389 | QStringList list; | - | ||||||||||||
390 | - | |||||||||||||
391 | NamespaceMap::const_iterator itc, it = d->ns.constBegin(); | - | ||||||||||||
392 | while ((itc=it) != d->ns.constEnd()) { | - | ||||||||||||
393 | ++it; | - | ||||||||||||
394 | if (*itc == uri && !itc.key().isEmpty()) | - | ||||||||||||
395 | list.append(itc.key()); | - | ||||||||||||
396 | } | - | ||||||||||||
397 | return list; | - | ||||||||||||
398 | } | - | ||||||||||||
399 | void QXmlNamespaceSupport::pushContext() | - | ||||||||||||
400 | { | - | ||||||||||||
401 | d->nsStack.push(d->ns); | - | ||||||||||||
402 | } | - | ||||||||||||
403 | void QXmlNamespaceSupport::popContext() | - | ||||||||||||
404 | { | - | ||||||||||||
405 | d->ns.clear(); | - | ||||||||||||
406 | if(!d->nsStack.isEmpty()) | - | ||||||||||||
407 | d->ns = d->nsStack.pop(); | - | ||||||||||||
408 | } | - | ||||||||||||
409 | - | |||||||||||||
410 | - | |||||||||||||
411 | - | |||||||||||||
412 | - | |||||||||||||
413 | void QXmlNamespaceSupport::reset() | - | ||||||||||||
414 | { | - | ||||||||||||
415 | QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate; | - | ||||||||||||
416 | delete d; | - | ||||||||||||
417 | d = newD; | - | ||||||||||||
418 | } | - | ||||||||||||
419 | QXmlAttributes::QXmlAttributes() | - | ||||||||||||
420 | { | - | ||||||||||||
421 | - | |||||||||||||
422 | - | |||||||||||||
423 | (void)d;; | - | ||||||||||||
424 | } | - | ||||||||||||
425 | - | |||||||||||||
426 | - | |||||||||||||
427 | - | |||||||||||||
428 | - | |||||||||||||
429 | - | |||||||||||||
430 | - | |||||||||||||
431 | QXmlAttributes::~QXmlAttributes() | - | ||||||||||||
432 | { | - | ||||||||||||
433 | } | - | ||||||||||||
434 | int QXmlAttributes::index(const QString& qName) const | - | ||||||||||||
435 | { | - | ||||||||||||
436 | for (int i = 0; i < attList.size(); ++i) { | - | ||||||||||||
437 | if (attList.at(i).qname == qName) | - | ||||||||||||
438 | return i; | - | ||||||||||||
439 | } | - | ||||||||||||
440 | return -1; | - | ||||||||||||
441 | } | - | ||||||||||||
442 | - | |||||||||||||
443 | - | |||||||||||||
444 | - | |||||||||||||
445 | int QXmlAttributes::index(QLatin1String qName) const | - | ||||||||||||
446 | { | - | ||||||||||||
447 | for (int i = 0; i < attList.size(); ++i) { | - | ||||||||||||
448 | if (attList.at(i).qname == qName) | - | ||||||||||||
449 | return i; | - | ||||||||||||
450 | } | - | ||||||||||||
451 | return -1; | - | ||||||||||||
452 | } | - | ||||||||||||
453 | int QXmlAttributes::index(const QString& uri, const QString& localPart) const | - | ||||||||||||
454 | { | - | ||||||||||||
455 | for (int i = 0; i < attList.size(); ++i) { | - | ||||||||||||
456 | const Attribute &att = attList.at(i); | - | ||||||||||||
457 | if (att.uri == uri && att.localname == localPart) | - | ||||||||||||
458 | return i; | - | ||||||||||||
459 | } | - | ||||||||||||
460 | return -1; | - | ||||||||||||
461 | } | - | ||||||||||||
462 | - | |||||||||||||
463 | - | |||||||||||||
464 | - | |||||||||||||
465 | - | |||||||||||||
466 | - | |||||||||||||
467 | - | |||||||||||||
468 | int QXmlAttributes::length() const | - | ||||||||||||
469 | { | - | ||||||||||||
470 | return attList.count(); | - | ||||||||||||
471 | } | - | ||||||||||||
472 | QString QXmlAttributes::localName(int index) const | - | ||||||||||||
473 | { | - | ||||||||||||
474 | return attList.at(index).localname; | - | ||||||||||||
475 | } | - | ||||||||||||
476 | - | |||||||||||||
477 | - | |||||||||||||
478 | - | |||||||||||||
479 | - | |||||||||||||
480 | - | |||||||||||||
481 | - | |||||||||||||
482 | - | |||||||||||||
483 | QString QXmlAttributes::qName(int index) const | - | ||||||||||||
484 | { | - | ||||||||||||
485 | return attList.at(index).qname; | - | ||||||||||||
486 | } | - | ||||||||||||
487 | QString QXmlAttributes::uri(int index) const | - | ||||||||||||
488 | { | - | ||||||||||||
489 | return attList.at(index).uri; | - | ||||||||||||
490 | } | - | ||||||||||||
491 | - | |||||||||||||
492 | - | |||||||||||||
493 | - | |||||||||||||
494 | - | |||||||||||||
495 | - | |||||||||||||
496 | - | |||||||||||||
497 | - | |||||||||||||
498 | QString QXmlAttributes::type(int) const | - | ||||||||||||
499 | { | - | ||||||||||||
500 | return QLatin1String("CDATA"); | - | ||||||||||||
501 | } | - | ||||||||||||
502 | QString QXmlAttributes::type(const QString&) const | - | ||||||||||||
503 | { | - | ||||||||||||
504 | return QLatin1String("CDATA"); | - | ||||||||||||
505 | } | - | ||||||||||||
506 | QString QXmlAttributes::type(const QString&, const QString&) const | - | ||||||||||||
507 | { | - | ||||||||||||
508 | return QLatin1String("CDATA"); | - | ||||||||||||
509 | } | - | ||||||||||||
510 | - | |||||||||||||
511 | - | |||||||||||||
512 | - | |||||||||||||
513 | - | |||||||||||||
514 | - | |||||||||||||
515 | - | |||||||||||||
516 | QString QXmlAttributes::value(int index) const | - | ||||||||||||
517 | { | - | ||||||||||||
518 | return attList.at(index).value; | - | ||||||||||||
519 | } | - | ||||||||||||
520 | QString QXmlAttributes::value(const QString& qName) const | - | ||||||||||||
521 | { | - | ||||||||||||
522 | int i = index(qName); | - | ||||||||||||
523 | if (i == -1) | - | ||||||||||||
524 | return QString(); | - | ||||||||||||
525 | return attList.at(i).value; | - | ||||||||||||
526 | } | - | ||||||||||||
527 | QString QXmlAttributes::value(QLatin1String qName) const | - | ||||||||||||
528 | { | - | ||||||||||||
529 | int i = index(qName); | - | ||||||||||||
530 | if (i == -1) | - | ||||||||||||
531 | return QString(); | - | ||||||||||||
532 | return attList.at(i).value; | - | ||||||||||||
533 | } | - | ||||||||||||
534 | QString QXmlAttributes::value(const QString& uri, const QString& localName) const | - | ||||||||||||
535 | { | - | ||||||||||||
536 | int i = index(uri, localName); | - | ||||||||||||
537 | if (i == -1) | - | ||||||||||||
538 | return QString(); | - | ||||||||||||
539 | return attList.at(i).value; | - | ||||||||||||
540 | } | - | ||||||||||||
541 | - | |||||||||||||
542 | - | |||||||||||||
543 | - | |||||||||||||
544 | - | |||||||||||||
545 | - | |||||||||||||
546 | - | |||||||||||||
547 | void QXmlAttributes::clear() | - | ||||||||||||
548 | { | - | ||||||||||||
549 | attList.clear(); | - | ||||||||||||
550 | } | - | ||||||||||||
551 | void QXmlAttributes::append(const QString &qName, const QString &uri, const QString &localPart, const QString &value) | - | ||||||||||||
552 | { | - | ||||||||||||
553 | Attribute att; | - | ||||||||||||
554 | att.qname = qName; | - | ||||||||||||
555 | att.uri = uri; | - | ||||||||||||
556 | att.localname = localPart; | - | ||||||||||||
557 | att.value = value; | - | ||||||||||||
558 | - | |||||||||||||
559 | attList.append(att); | - | ||||||||||||
560 | } | - | ||||||||||||
561 | const ushort QXmlInputSource::EndOfData = 0xfffe; | - | ||||||||||||
562 | const ushort QXmlInputSource::EndOfDocument = 0xffff; | - | ||||||||||||
563 | - | |||||||||||||
564 | - | |||||||||||||
565 | - | |||||||||||||
566 | - | |||||||||||||
567 | void QXmlInputSource::init() | - | ||||||||||||
568 | { | - | ||||||||||||
569 | d = new QXmlInputSourcePrivate; | - | ||||||||||||
570 | - | |||||||||||||
571 | if (true) { | - | ||||||||||||
572 | d->inputDevice = 0; | - | ||||||||||||
573 | d->inputStream = 0; | - | ||||||||||||
574 | - | |||||||||||||
575 | setData(QString()); | - | ||||||||||||
576 | - | |||||||||||||
577 | d->encMapper = 0; | - | ||||||||||||
578 | - | |||||||||||||
579 | d->nextReturnedEndOfData = true; | - | ||||||||||||
580 | - | |||||||||||||
581 | d->encodingDeclBytes.clear(); | - | ||||||||||||
582 | d->encodingDeclChars.clear(); | - | ||||||||||||
583 | d->lookingForEncodingDecl = true; | - | ||||||||||||
584 | } else { dead code: { delete(d); qt_noop(); } | - | ||||||||||||
585 | delete(d); dead code: { delete(d); qt_noop(); } | - | ||||||||||||
586 | qt_noop(); dead code: { delete(d); qt_noop(); } | - | ||||||||||||
587 | } dead code: { delete(d); qt_noop(); } | - | ||||||||||||
588 | } | - | ||||||||||||
589 | - | |||||||||||||
590 | - | |||||||||||||
591 | - | |||||||||||||
592 | - | |||||||||||||
593 | - | |||||||||||||
594 | - | |||||||||||||
595 | QXmlInputSource::QXmlInputSource() | - | ||||||||||||
596 | { | - | ||||||||||||
597 | init(); | - | ||||||||||||
598 | } | - | ||||||||||||
599 | QXmlInputSource::QXmlInputSource(QIODevice *dev) | - | ||||||||||||
600 | { | - | ||||||||||||
601 | init(); | - | ||||||||||||
602 | d->inputDevice = dev; | - | ||||||||||||
603 | if (dev->isOpen()) | - | ||||||||||||
604 | d->inputDevice->setTextModeEnabled(false); | - | ||||||||||||
605 | } | - | ||||||||||||
606 | - | |||||||||||||
607 | - | |||||||||||||
608 | - | |||||||||||||
609 | - | |||||||||||||
610 | QXmlInputSource::~QXmlInputSource() | - | ||||||||||||
611 | { | - | ||||||||||||
612 | - | |||||||||||||
613 | - | |||||||||||||
614 | delete d->encMapper; | - | ||||||||||||
615 | - | |||||||||||||
616 | delete d; | - | ||||||||||||
617 | } | - | ||||||||||||
618 | QChar QXmlInputSource::next() | - | ||||||||||||
619 | { | - | ||||||||||||
620 | if (d->pos >= d->length) { | - | ||||||||||||
621 | if (d->nextReturnedEndOfData) { | - | ||||||||||||
622 | d->nextReturnedEndOfData = false; | - | ||||||||||||
623 | fetchData(); | - | ||||||||||||
624 | if (d->pos >= d->length) { | - | ||||||||||||
625 | return EndOfDocument; | - | ||||||||||||
626 | } | - | ||||||||||||
627 | return next(); | - | ||||||||||||
628 | } | - | ||||||||||||
629 | d->nextReturnedEndOfData = true; | - | ||||||||||||
630 | return EndOfData; | - | ||||||||||||
631 | } | - | ||||||||||||
632 | - | |||||||||||||
633 | - | |||||||||||||
634 | - | |||||||||||||
635 | - | |||||||||||||
636 | QChar c = d->unicode[d->pos++]; | - | ||||||||||||
637 | if (c.unicode() == EndOfData) | - | ||||||||||||
638 | c = EndOfDocument; | - | ||||||||||||
639 | return c; | - | ||||||||||||
640 | } | - | ||||||||||||
641 | void QXmlInputSource::reset() | - | ||||||||||||
642 | { | - | ||||||||||||
643 | d->nextReturnedEndOfData = false; | - | ||||||||||||
644 | d->pos = 0; | - | ||||||||||||
645 | } | - | ||||||||||||
646 | - | |||||||||||||
647 | - | |||||||||||||
648 | - | |||||||||||||
649 | - | |||||||||||||
650 | - | |||||||||||||
651 | - | |||||||||||||
652 | - | |||||||||||||
653 | QString QXmlInputSource::data() const | - | ||||||||||||
654 | { | - | ||||||||||||
655 | if (d->nextReturnedEndOfData) { | - | ||||||||||||
656 | QXmlInputSource *that = const_cast<QXmlInputSource*>(this); | - | ||||||||||||
657 | that->d->nextReturnedEndOfData = false; | - | ||||||||||||
658 | that->fetchData(); | - | ||||||||||||
659 | } | - | ||||||||||||
660 | return d->str; | - | ||||||||||||
661 | } | - | ||||||||||||
662 | void QXmlInputSource::setData(const QString& dat) | - | ||||||||||||
663 | { | - | ||||||||||||
664 | d->str = dat; | - | ||||||||||||
665 | d->unicode = dat.unicode(); | - | ||||||||||||
666 | d->pos = 0; | - | ||||||||||||
667 | d->length = d->str.length(); | - | ||||||||||||
668 | d->nextReturnedEndOfData = false; | - | ||||||||||||
669 | } | - | ||||||||||||
670 | - | |||||||||||||
671 | - | |||||||||||||
672 | - | |||||||||||||
673 | - | |||||||||||||
674 | - | |||||||||||||
675 | - | |||||||||||||
676 | - | |||||||||||||
677 | void QXmlInputSource::setData(const QByteArray& dat) | - | ||||||||||||
678 | { | - | ||||||||||||
679 | setData(fromRawData(dat)); | - | ||||||||||||
680 | } | - | ||||||||||||
681 | void QXmlInputSource::fetchData() | - | ||||||||||||
682 | { | - | ||||||||||||
683 | enum | - | ||||||||||||
684 | { | - | ||||||||||||
685 | BufferSize = 1024 | - | ||||||||||||
686 | }; | - | ||||||||||||
687 | - | |||||||||||||
688 | QByteArray rawData; | - | ||||||||||||
689 | - | |||||||||||||
690 | if (d->inputDevice || d->inputStream) { | - | ||||||||||||
691 | QIODevice *device = d->inputDevice ? d->inputDevice : d->inputStream->device(); | - | ||||||||||||
692 | - | |||||||||||||
693 | if (!device) { | - | ||||||||||||
694 | if (d->inputStream && d->inputStream->string()) { | - | ||||||||||||
695 | QString *s = d->inputStream->string(); | - | ||||||||||||
696 | rawData = QByteArray((const char *) s->constData(), s->size() * sizeof(QChar)); | - | ||||||||||||
697 | } | - | ||||||||||||
698 | } else if (device->isOpen() || device->open(QIODevice::ReadOnly)) { | - | ||||||||||||
699 | rawData.resize(BufferSize); | - | ||||||||||||
700 | qint64 size = device->read(rawData.data(), BufferSize); | - | ||||||||||||
701 | - | |||||||||||||
702 | if (size != -1) { | - | ||||||||||||
703 | - | |||||||||||||
704 | while (size < 4) { | - | ||||||||||||
705 | if (!device->waitForReadyRead(-1)) | - | ||||||||||||
706 | break; | - | ||||||||||||
707 | int ret = device->read(rawData.data() + size, BufferSize - size); | - | ||||||||||||
708 | if (ret <= 0) | - | ||||||||||||
709 | break; | - | ||||||||||||
710 | size += ret; | - | ||||||||||||
711 | } | - | ||||||||||||
712 | } | - | ||||||||||||
713 | - | |||||||||||||
714 | rawData.resize(qMax(qint64(0), size)); | - | ||||||||||||
715 | } | - | ||||||||||||
716 | - | |||||||||||||
717 | - | |||||||||||||
718 | - | |||||||||||||
719 | - | |||||||||||||
720 | - | |||||||||||||
721 | setData(fromRawData(rawData)); | - | ||||||||||||
722 | } | - | ||||||||||||
723 | } | - | ||||||||||||
724 | - | |||||||||||||
725 | - | |||||||||||||
726 | static QString extractEncodingDecl(const QString &text, bool *needMoreText) | - | ||||||||||||
727 | { | - | ||||||||||||
728 | *needMoreText = false; | - | ||||||||||||
729 | - | |||||||||||||
730 | int l = text.length(); | - | ||||||||||||
731 | QStringconst QLatin1String snip= QString::fromLatin1("<?xml").left, std::min(l);, 5)); | - | ||||||||||||
732 | if (l > 0
| 6-3097 | ||||||||||||
733 | return executed 1742 times by 2 tests: QString();return QString(); Executed by:
executed 1742 times by 2 tests: return QString(); Executed by:
| 1742 | ||||||||||||
734 | - | |||||||||||||
735 | int endPos = text.indexOf(QLatin1Char('>')); | - | ||||||||||||
736 | if (endPos == -1
| 119-1242 | ||||||||||||
737 | *needMoreText = l < 255; | - | ||||||||||||
738 | return executed 1242 times by 1 test: QString();return QString(); Executed by:
executed 1242 times by 1 test: return QString(); Executed by:
| 1242 | ||||||||||||
739 | } | - | ||||||||||||
740 | - | |||||||||||||
741 | int pos = text.indexOf(QLatin1String("encoding")); | - | ||||||||||||
742 | if (pos == -1
| 0-67 | ||||||||||||
743 | return executed 52 times by 1 test: QString();return QString(); Executed by:
executed 52 times by 1 test: return QString(); Executed by:
| 52 | ||||||||||||
744 | - | |||||||||||||
745 | while (pos < endPos
| 0-670 | ||||||||||||
746 | ushort uc = text.at(pos).unicode(); | - | ||||||||||||
747 | if (uc == '\''
| 0-670 | ||||||||||||
748 | break; executed 67 times by 2 tests: break; Executed by:
| 67 | ||||||||||||
749 | ++pos; | - | ||||||||||||
750 | } executed 603 times by 2 tests: end of block Executed by:
| 603 | ||||||||||||
751 | - | |||||||||||||
752 | if (pos == endPos
| 0-67 | ||||||||||||
753 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||
754 | - | |||||||||||||
755 | QString encoding; | - | ||||||||||||
756 | ++pos; | - | ||||||||||||
757 | while (pos < endPos
| 0-404 | ||||||||||||
758 | ushort uc = text.at(pos).unicode(); | - | ||||||||||||
759 | if (uc == '\''
| 0-404 | ||||||||||||
760 | break; executed 67 times by 2 tests: break; Executed by:
| 67 | ||||||||||||
761 | encoding.append(uc); | - | ||||||||||||
762 | ++pos; | - | ||||||||||||
763 | } executed 337 times by 2 tests: end of block Executed by:
| 337 | ||||||||||||
764 | - | |||||||||||||
765 | return executed 67 times by 2 tests: encoding;return encoding; Executed by:
executed 67 times by 2 tests: return encoding; Executed by:
| 67 | ||||||||||||
766 | } | - | ||||||||||||
767 | QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) | - | ||||||||||||
768 | { | - | ||||||||||||
769 | - | |||||||||||||
770 | - | |||||||||||||
771 | - | |||||||||||||
772 | - | |||||||||||||
773 | if (data.size() == 0) | - | ||||||||||||
774 | return QString(); | - | ||||||||||||
775 | if (beginning) { | - | ||||||||||||
776 | delete d->encMapper; | - | ||||||||||||
777 | d->encMapper = 0; | - | ||||||||||||
778 | } | - | ||||||||||||
779 | - | |||||||||||||
780 | int mib = 106; | - | ||||||||||||
781 | - | |||||||||||||
782 | - | |||||||||||||
783 | if (d->encMapper == 0) { | - | ||||||||||||
784 | d->encodingDeclBytes.clear(); | - | ||||||||||||
785 | d->encodingDeclChars.clear(); | - | ||||||||||||
786 | d->lookingForEncodingDecl = true; | - | ||||||||||||
787 | - | |||||||||||||
788 | - | |||||||||||||
789 | if (data.size() >= 4) { | - | ||||||||||||
790 | uchar ch1 = data.at(0); | - | ||||||||||||
791 | uchar ch2 = data.at(1); | - | ||||||||||||
792 | uchar ch3 = data.at(2); | - | ||||||||||||
793 | uchar ch4 = data.at(3); | - | ||||||||||||
794 | - | |||||||||||||
795 | if ((ch1 == 0 && ch2 == 0 && ch3 == 0xfe && ch4 == 0xff) || | - | ||||||||||||
796 | (ch1 == 0xff && ch2 == 0xfe && ch3 == 0 && ch4 == 0)) | - | ||||||||||||
797 | mib = 1017; | - | ||||||||||||
798 | else if (ch1 == 0x3c && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x00) | - | ||||||||||||
799 | mib = 1019; | - | ||||||||||||
800 | else if (ch1 == 0x00 && ch2 == 0x00 && ch3 == 0x00 && ch4 == 0x3c) | - | ||||||||||||
801 | mib = 1018; | - | ||||||||||||
802 | } | - | ||||||||||||
803 | if (mib == 106 && data.size() >= 2) { | - | ||||||||||||
804 | uchar ch1 = data.at(0); | - | ||||||||||||
805 | uchar ch2 = data.at(1); | - | ||||||||||||
806 | - | |||||||||||||
807 | if ((ch1 == 0xfe && ch2 == 0xff) || (ch1 == 0xff && ch2 == 0xfe)) | - | ||||||||||||
808 | mib = 1015; | - | ||||||||||||
809 | else if (ch1 == 0x3c && ch2 == 0x00) | - | ||||||||||||
810 | mib = 1014; | - | ||||||||||||
811 | else if (ch1 == 0x00 && ch2 == 0x3c) | - | ||||||||||||
812 | mib = 1013; | - | ||||||||||||
813 | } | - | ||||||||||||
814 | - | |||||||||||||
815 | QTextCodec *codec = QTextCodec::codecForMib(mib); | - | ||||||||||||
816 | ((!(codec)) ? qt_assert("codec",__FILE__,13821396) : qt_noop()); | - | ||||||||||||
817 | - | |||||||||||||
818 | d->encMapper = codec->makeDecoder(); | - | ||||||||||||
819 | } | - | ||||||||||||
820 | - | |||||||||||||
821 | QString input = d->encMapper->toUnicode(data.constData(), data.size()); | - | ||||||||||||
822 | - | |||||||||||||
823 | if (d->lookingForEncodingDecl) { | - | ||||||||||||
824 | d->encodingDeclChars += input; | - | ||||||||||||
825 | - | |||||||||||||
826 | bool needMoreText; | - | ||||||||||||
827 | QString encoding = extractEncodingDecl(d->encodingDeclChars, &needMoreText); | - | ||||||||||||
828 | - | |||||||||||||
829 | if (!encoding.isEmpty()) { | - | ||||||||||||
830 | if (QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1())) { | - | ||||||||||||
831 | - | |||||||||||||
832 | if(codec->mibEnum() != mib) { | - | ||||||||||||
833 | delete d->encMapper; | - | ||||||||||||
834 | d->encMapper = codec->makeDecoder(); | - | ||||||||||||
835 | - | |||||||||||||
836 | - | |||||||||||||
837 | - | |||||||||||||
838 | - | |||||||||||||
839 | input.clear(); | - | ||||||||||||
840 | - | |||||||||||||
841 | - | |||||||||||||
842 | d->encMapper->toUnicode(d->encodingDeclBytes.constData(), d->encodingDeclBytes.size()); | - | ||||||||||||
843 | - | |||||||||||||
844 | input = d->encMapper->toUnicode(data.constData(), data.size()); | - | ||||||||||||
845 | } | - | ||||||||||||
846 | } | - | ||||||||||||
847 | } | - | ||||||||||||
848 | - | |||||||||||||
849 | d->encodingDeclBytes += data; | - | ||||||||||||
850 | d->lookingForEncodingDecl = needMoreText; | - | ||||||||||||
851 | } | - | ||||||||||||
852 | - | |||||||||||||
853 | return input; | - | ||||||||||||
854 | - | |||||||||||||
855 | } | - | ||||||||||||
856 | QXmlDefaultHandler::QXmlDefaultHandler() | - | ||||||||||||
857 | { | - | ||||||||||||
858 | - | |||||||||||||
859 | - | |||||||||||||
860 | (void)d;; | - | ||||||||||||
861 | } | - | ||||||||||||
862 | - | |||||||||||||
863 | - | |||||||||||||
864 | - | |||||||||||||
865 | - | |||||||||||||
866 | - | |||||||||||||
867 | - | |||||||||||||
868 | QXmlDefaultHandler::~QXmlDefaultHandler() | - | ||||||||||||
869 | { | - | ||||||||||||
870 | } | - | ||||||||||||
871 | - | |||||||||||||
872 | - | |||||||||||||
873 | - | |||||||||||||
874 | - | |||||||||||||
875 | - | |||||||||||||
876 | - | |||||||||||||
877 | void QXmlDefaultHandler::setDocumentLocator(QXmlLocator*) | - | ||||||||||||
878 | { | - | ||||||||||||
879 | } | - | ||||||||||||
880 | - | |||||||||||||
881 | - | |||||||||||||
882 | - | |||||||||||||
883 | - | |||||||||||||
884 | - | |||||||||||||
885 | - | |||||||||||||
886 | bool QXmlDefaultHandler::startDocument() | - | ||||||||||||
887 | { | - | ||||||||||||
888 | return true; | - | ||||||||||||
889 | } | - | ||||||||||||
890 | - | |||||||||||||
891 | - | |||||||||||||
892 | - | |||||||||||||
893 | - | |||||||||||||
894 | - | |||||||||||||
895 | - | |||||||||||||
896 | bool QXmlDefaultHandler::endDocument() | - | ||||||||||||
897 | { | - | ||||||||||||
898 | return true; | - | ||||||||||||
899 | } | - | ||||||||||||
900 | - | |||||||||||||
901 | - | |||||||||||||
902 | - | |||||||||||||
903 | - | |||||||||||||
904 | - | |||||||||||||
905 | - | |||||||||||||
906 | bool QXmlDefaultHandler::startPrefixMapping(const QString&, const QString&) | - | ||||||||||||
907 | { | - | ||||||||||||
908 | return true; | - | ||||||||||||
909 | } | - | ||||||||||||
910 | - | |||||||||||||
911 | - | |||||||||||||
912 | - | |||||||||||||
913 | - | |||||||||||||
914 | - | |||||||||||||
915 | - | |||||||||||||
916 | bool QXmlDefaultHandler::endPrefixMapping(const QString&) | - | ||||||||||||
917 | { | - | ||||||||||||
918 | return true; | - | ||||||||||||
919 | } | - | ||||||||||||
920 | - | |||||||||||||
921 | - | |||||||||||||
922 | - | |||||||||||||
923 | - | |||||||||||||
924 | - | |||||||||||||
925 | - | |||||||||||||
926 | bool QXmlDefaultHandler::startElement(const QString&, const QString&, | - | ||||||||||||
927 | const QString&, const QXmlAttributes&) | - | ||||||||||||
928 | { | - | ||||||||||||
929 | return true; | - | ||||||||||||
930 | } | - | ||||||||||||
931 | - | |||||||||||||
932 | - | |||||||||||||
933 | - | |||||||||||||
934 | - | |||||||||||||
935 | - | |||||||||||||
936 | - | |||||||||||||
937 | bool QXmlDefaultHandler::endElement(const QString&, const QString&, | - | ||||||||||||
938 | const QString&) | - | ||||||||||||
939 | { | - | ||||||||||||
940 | return true; | - | ||||||||||||
941 | } | - | ||||||||||||
942 | - | |||||||||||||
943 | - | |||||||||||||
944 | - | |||||||||||||
945 | - | |||||||||||||
946 | - | |||||||||||||
947 | - | |||||||||||||
948 | bool QXmlDefaultHandler::characters(const QString&) | - | ||||||||||||
949 | { | - | ||||||||||||
950 | return true; | - | ||||||||||||
951 | } | - | ||||||||||||
952 | - | |||||||||||||
953 | - | |||||||||||||
954 | - | |||||||||||||
955 | - | |||||||||||||
956 | - | |||||||||||||
957 | - | |||||||||||||
958 | bool QXmlDefaultHandler::ignorableWhitespace(const QString&) | - | ||||||||||||
959 | { | - | ||||||||||||
960 | return true; | - | ||||||||||||
961 | } | - | ||||||||||||
962 | - | |||||||||||||
963 | - | |||||||||||||
964 | - | |||||||||||||
965 | - | |||||||||||||
966 | - | |||||||||||||
967 | - | |||||||||||||
968 | bool QXmlDefaultHandler::processingInstruction(const QString&, | - | ||||||||||||
969 | const QString&) | - | ||||||||||||
970 | { | - | ||||||||||||
971 | return true; | - | ||||||||||||
972 | } | - | ||||||||||||
973 | - | |||||||||||||
974 | - | |||||||||||||
975 | - | |||||||||||||
976 | - | |||||||||||||
977 | - | |||||||||||||
978 | - | |||||||||||||
979 | bool QXmlDefaultHandler::skippedEntity(const QString&) | - | ||||||||||||
980 | { | - | ||||||||||||
981 | return true; | - | ||||||||||||
982 | } | - | ||||||||||||
983 | - | |||||||||||||
984 | - | |||||||||||||
985 | - | |||||||||||||
986 | - | |||||||||||||
987 | - | |||||||||||||
988 | - | |||||||||||||
989 | bool QXmlDefaultHandler::warning(const QXmlParseException&) | - | ||||||||||||
990 | { | - | ||||||||||||
991 | return true; | - | ||||||||||||
992 | } | - | ||||||||||||
993 | - | |||||||||||||
994 | - | |||||||||||||
995 | - | |||||||||||||
996 | - | |||||||||||||
997 | - | |||||||||||||
998 | - | |||||||||||||
999 | bool QXmlDefaultHandler::error(const QXmlParseException&) | - | ||||||||||||
1000 | { | - | ||||||||||||
1001 | return true; | - | ||||||||||||
1002 | } | - | ||||||||||||
1003 | - | |||||||||||||
1004 | - | |||||||||||||
1005 | - | |||||||||||||
1006 | - | |||||||||||||
1007 | - | |||||||||||||
1008 | - | |||||||||||||
1009 | bool QXmlDefaultHandler::fatalError(const QXmlParseException&) | - | ||||||||||||
1010 | { | - | ||||||||||||
1011 | return true; | - | ||||||||||||
1012 | } | - | ||||||||||||
1013 | - | |||||||||||||
1014 | - | |||||||||||||
1015 | - | |||||||||||||
1016 | - | |||||||||||||
1017 | - | |||||||||||||
1018 | - | |||||||||||||
1019 | bool QXmlDefaultHandler::notationDecl(const QString&, const QString&, | - | ||||||||||||
1020 | const QString&) | - | ||||||||||||
1021 | { | - | ||||||||||||
1022 | return true; | - | ||||||||||||
1023 | } | - | ||||||||||||
1024 | - | |||||||||||||
1025 | - | |||||||||||||
1026 | - | |||||||||||||
1027 | - | |||||||||||||
1028 | - | |||||||||||||
1029 | - | |||||||||||||
1030 | bool QXmlDefaultHandler::unparsedEntityDecl(const QString&, const QString&, | - | ||||||||||||
1031 | const QString&, const QString&) | - | ||||||||||||
1032 | { | - | ||||||||||||
1033 | return true; | - | ||||||||||||
1034 | } | - | ||||||||||||
1035 | - | |||||||||||||
1036 | - | |||||||||||||
1037 | - | |||||||||||||
1038 | - | |||||||||||||
1039 | - | |||||||||||||
1040 | - | |||||||||||||
1041 | - | |||||||||||||
1042 | bool QXmlDefaultHandler::resolveEntity(const QString&, const QString&, | - | ||||||||||||
1043 | QXmlInputSource*& ret) | - | ||||||||||||
1044 | { | - | ||||||||||||
1045 | ret = 0; | - | ||||||||||||
1046 | return true; | - | ||||||||||||
1047 | } | - | ||||||||||||
1048 | - | |||||||||||||
1049 | - | |||||||||||||
1050 | - | |||||||||||||
1051 | - | |||||||||||||
1052 | - | |||||||||||||
1053 | - | |||||||||||||
1054 | QString QXmlDefaultHandler::errorString() const | - | ||||||||||||
1055 | { | - | ||||||||||||
1056 | return QString::fromLatin1("error triggered by consumer"); | - | ||||||||||||
1057 | } | - | ||||||||||||
1058 | - | |||||||||||||
1059 | - | |||||||||||||
1060 | - | |||||||||||||
1061 | - | |||||||||||||
1062 | - | |||||||||||||
1063 | - | |||||||||||||
1064 | bool QXmlDefaultHandler::startDTD(const QString&, const QString&, const QString&) | - | ||||||||||||
1065 | { | - | ||||||||||||
1066 | return true; | - | ||||||||||||
1067 | } | - | ||||||||||||
1068 | - | |||||||||||||
1069 | - | |||||||||||||
1070 | - | |||||||||||||
1071 | - | |||||||||||||
1072 | - | |||||||||||||
1073 | - | |||||||||||||
1074 | bool QXmlDefaultHandler::endDTD() | - | ||||||||||||
1075 | { | - | ||||||||||||
1076 | return true; | - | ||||||||||||
1077 | } | - | ||||||||||||
1078 | - | |||||||||||||
1079 | - | |||||||||||||
1080 | - | |||||||||||||
1081 | - | |||||||||||||
1082 | - | |||||||||||||
1083 | - | |||||||||||||
1084 | bool QXmlDefaultHandler::startEntity(const QString&) | - | ||||||||||||
1085 | { | - | ||||||||||||
1086 | return true; | - | ||||||||||||
1087 | } | - | ||||||||||||
1088 | - | |||||||||||||
1089 | - | |||||||||||||
1090 | - | |||||||||||||
1091 | - | |||||||||||||
1092 | - | |||||||||||||
1093 | - | |||||||||||||
1094 | bool QXmlDefaultHandler::endEntity(const QString&) | - | ||||||||||||
1095 | { | - | ||||||||||||
1096 | return true; | - | ||||||||||||
1097 | } | - | ||||||||||||
1098 | - | |||||||||||||
1099 | - | |||||||||||||
1100 | - | |||||||||||||
1101 | - | |||||||||||||
1102 | - | |||||||||||||
1103 | - | |||||||||||||
1104 | bool QXmlDefaultHandler::startCDATA() | - | ||||||||||||
1105 | { | - | ||||||||||||
1106 | return true; | - | ||||||||||||
1107 | } | - | ||||||||||||
1108 | - | |||||||||||||
1109 | - | |||||||||||||
1110 | - | |||||||||||||
1111 | - | |||||||||||||
1112 | - | |||||||||||||
1113 | - | |||||||||||||
1114 | bool QXmlDefaultHandler::endCDATA() | - | ||||||||||||
1115 | { | - | ||||||||||||
1116 | return true; | - | ||||||||||||
1117 | } | - | ||||||||||||
1118 | - | |||||||||||||
1119 | - | |||||||||||||
1120 | - | |||||||||||||
1121 | - | |||||||||||||
1122 | - | |||||||||||||
1123 | - | |||||||||||||
1124 | bool QXmlDefaultHandler::comment(const QString&) | - | ||||||||||||
1125 | { | - | ||||||||||||
1126 | return true; | - | ||||||||||||
1127 | } | - | ||||||||||||
1128 | - | |||||||||||||
1129 | - | |||||||||||||
1130 | - | |||||||||||||
1131 | - | |||||||||||||
1132 | - | |||||||||||||
1133 | - | |||||||||||||
1134 | bool QXmlDefaultHandler::attributeDecl(const QString&, const QString&, const QString&, const QString&, const QString&) | - | ||||||||||||
1135 | { | - | ||||||||||||
1136 | return true; | - | ||||||||||||
1137 | } | - | ||||||||||||
1138 | - | |||||||||||||
1139 | - | |||||||||||||
1140 | - | |||||||||||||
1141 | - | |||||||||||||
1142 | - | |||||||||||||
1143 | - | |||||||||||||
1144 | bool QXmlDefaultHandler::internalEntityDecl(const QString&, const QString&) | - | ||||||||||||
1145 | { | - | ||||||||||||
1146 | return true; | - | ||||||||||||
1147 | } | - | ||||||||||||
1148 | - | |||||||||||||
1149 | - | |||||||||||||
1150 | - | |||||||||||||
1151 | - | |||||||||||||
1152 | - | |||||||||||||
1153 | - | |||||||||||||
1154 | bool QXmlDefaultHandler::externalEntityDecl(const QString&, const QString&, const QString&) | - | ||||||||||||
1155 | { | - | ||||||||||||
1156 | return true; | - | ||||||||||||
1157 | } | - | ||||||||||||
1158 | inline bool QXmlSimpleReaderPrivate::atEnd() | - | ||||||||||||
1159 | { | - | ||||||||||||
1160 | return (c.unicode()|0x0001) == 0xffff; | - | ||||||||||||
1161 | } | - | ||||||||||||
1162 | - | |||||||||||||
1163 | inline void QXmlSimpleReaderPrivate::stringClear() | - | ||||||||||||
1164 | { | - | ||||||||||||
1165 | stringValueLen = 0; stringArrayPos = 0; | - | ||||||||||||
1166 | } | - | ||||||||||||
1167 | inline void QXmlSimpleReaderPrivate::nameClear() | - | ||||||||||||
1168 | { | - | ||||||||||||
1169 | nameValueLen = 0; nameArrayPos = 0; | - | ||||||||||||
1170 | } | - | ||||||||||||
1171 | - | |||||||||||||
1172 | inline void QXmlSimpleReaderPrivate::refClear() | - | ||||||||||||
1173 | { | - | ||||||||||||
1174 | refValueLen = 0; refArrayPos = 0; | - | ||||||||||||
1175 | } | - | ||||||||||||
1176 | - | |||||||||||||
1177 | QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader) | - | ||||||||||||
1178 | { | - | ||||||||||||
1179 | q_ptr = reader; | - | ||||||||||||
1180 | parseStack = 0; | - | ||||||||||||
1181 | - | |||||||||||||
1182 | locator.reset(new QXmlSimpleReaderLocator(reader)); | - | ||||||||||||
1183 | entityRes = 0; | - | ||||||||||||
1184 | dtdHnd = 0; | - | ||||||||||||
1185 | contentHnd = 0; | - | ||||||||||||
1186 | errorHnd = 0; | - | ||||||||||||
1187 | lexicalHnd = 0; | - | ||||||||||||
1188 | declHnd = 0; | - | ||||||||||||
1189 | - | |||||||||||||
1190 | - | |||||||||||||
1191 | useNamespaces = true; | - | ||||||||||||
1192 | useNamespacePrefixes = false; | - | ||||||||||||
1193 | reportWhitespaceCharData = true; | - | ||||||||||||
1194 | reportEntities = false; | - | ||||||||||||
1195 | } | - | ||||||||||||
1196 | - | |||||||||||||
1197 | QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate() | - | ||||||||||||
1198 | { | - | ||||||||||||
1199 | delete parseStack; | - | ||||||||||||
1200 | } | - | ||||||||||||
1201 | - | |||||||||||||
1202 | void QXmlSimpleReaderPrivate::initIncrementalParsing() | - | ||||||||||||
1203 | { | - | ||||||||||||
1204 | if(parseStack) | - | ||||||||||||
1205 | parseStack->clear(); | - | ||||||||||||
1206 | else | - | ||||||||||||
1207 | parseStack = new QStack<ParseState>; | - | ||||||||||||
1208 | } | - | ||||||||||||
1209 | static inline bool is_S(QChar ch) | - | ||||||||||||
1210 | { | - | ||||||||||||
1211 | ushort uc = ch.unicode(); | - | ||||||||||||
1212 | return (uc == ' ' || uc == '\t' || uc == '\n' || uc == '\r'); | - | ||||||||||||
1213 | } | - | ||||||||||||
1214 | - | |||||||||||||
1215 | enum NameChar { NameBeginning, NameNotBeginning, NotName }; | - | ||||||||||||
1216 | - | |||||||||||||
1217 | static const char Begi = (char)NameBeginning; | - | ||||||||||||
1218 | static const char NtBg = (char)NameNotBeginning; | - | ||||||||||||
1219 | static const char NotN = (char)NotName; | - | ||||||||||||
1220 | - | |||||||||||||
1221 | static const char nameCharTable[128] = | - | ||||||||||||
1222 | { | - | ||||||||||||
1223 | - | |||||||||||||
1224 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||
1225 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||
1226 | - | |||||||||||||
1227 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||
1228 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||
1229 | - | |||||||||||||
1230 | NotN, NotN, NotN, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||
1231 | NotN, NotN, NotN, NotN, NotN, NtBg, NtBg, NotN, | - | ||||||||||||
1232 | - | |||||||||||||
1233 | NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, NtBg, | - | ||||||||||||
1234 | NtBg, NtBg, Begi, NotN, NotN, NotN, NotN, NotN, | - | ||||||||||||
1235 | - | |||||||||||||
1236 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||
1237 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||
1238 | - | |||||||||||||
1239 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||
1240 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, Begi, | - | ||||||||||||
1241 | - | |||||||||||||
1242 | NotN, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||
1243 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||
1244 | - | |||||||||||||
1245 | Begi, Begi, Begi, Begi, Begi, Begi, Begi, Begi, | - | ||||||||||||
1246 | Begi, Begi, Begi, NotN, NotN, NotN, NotN, NotN | - | ||||||||||||
1247 | }; | - | ||||||||||||
1248 | - | |||||||||||||
1249 | static inline NameChar fastDetermineNameChar(QChar ch) | - | ||||||||||||
1250 | { | - | ||||||||||||
1251 | ushort uc = ch.unicode(); | - | ||||||||||||
1252 | if (!(uc & ~0x7f)) | - | ||||||||||||
1253 | return (NameChar)nameCharTable[uc]; | - | ||||||||||||
1254 | - | |||||||||||||
1255 | QChar::Category cat = ch.category(); | - | ||||||||||||
1256 | - | |||||||||||||
1257 | if ((cat >= QChar::Letter_Uppercase && cat <= QChar::Letter_Other) | - | ||||||||||||
1258 | || cat == QChar::Number_Letter) | - | ||||||||||||
1259 | return NameBeginning; | - | ||||||||||||
1260 | if ((cat >= QChar::Number_DecimalDigit && cat <= QChar::Number_Other) | - | ||||||||||||
1261 | || (cat >= QChar::Mark_NonSpacing && cat <= QChar::Mark_Enclosing)) | - | ||||||||||||
1262 | return NameNotBeginning; | - | ||||||||||||
1263 | return NotName; | - | ||||||||||||
1264 | } | - | ||||||||||||
1265 | - | |||||||||||||
1266 | static NameChar determineNameChar(QChar ch) | - | ||||||||||||
1267 | { | - | ||||||||||||
1268 | return fastDetermineNameChar(ch); | - | ||||||||||||
1269 | } | - | ||||||||||||
1270 | - | |||||||||||||
1271 | - | |||||||||||||
1272 | - | |||||||||||||
1273 | - | |||||||||||||
1274 | - | |||||||||||||
1275 | QXmlSimpleReader::QXmlSimpleReader() | - | ||||||||||||
1276 | : d_ptr(new QXmlSimpleReaderPrivate(this)) | - | ||||||||||||
1277 | { | - | ||||||||||||
1278 | } | - | ||||||||||||
1279 | - | |||||||||||||
1280 | - | |||||||||||||
1281 | - | |||||||||||||
1282 | - | |||||||||||||
1283 | QXmlSimpleReader::~QXmlSimpleReader() | - | ||||||||||||
1284 | { | - | ||||||||||||
1285 | } | - | ||||||||||||
1286 | - | |||||||||||||
1287 | - | |||||||||||||
1288 | - | |||||||||||||
1289 | - | |||||||||||||
1290 | bool QXmlSimpleReader::feature(const QString& name, bool *ok) const | - | ||||||||||||
1291 | { | - | ||||||||||||
1292 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1293 | - | |||||||||||||
1294 | if (ok != 0) | - | ||||||||||||
1295 | *ok = true; | - | ||||||||||||
1296 | if (name == QLatin1String("http://xml.org/sax/features/namespaces")) { | - | ||||||||||||
1297 | return d->useNamespaces; | - | ||||||||||||
1298 | } else if (name == QLatin1String("http://xml.org/sax/features/namespace-prefixes")) { | - | ||||||||||||
1299 | return d->useNamespacePrefixes; | - | ||||||||||||
1300 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData") | - | ||||||||||||
1301 | || name == QLatin1String("http://qt-project.org/xml/features/report-whitespace-only-CharData")) { | - | ||||||||||||
1302 | return d->reportWhitespaceCharData; | - | ||||||||||||
1303 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-start-end-entity") | - | ||||||||||||
1304 | || name == QLatin1String("http://qt-project.org/xml/features/report-start-end-entity")) { | - | ||||||||||||
1305 | return d->reportEntities; | - | ||||||||||||
1306 | } else { | - | ||||||||||||
1307 | QMessageLogger(__FILE__, 29302944, __PRETTY_FUNCTION__).warning("Unknown feature %s", name.toLatin1().data()); | - | ||||||||||||
1308 | if (ok != 0) | - | ||||||||||||
1309 | *ok = false; | - | ||||||||||||
1310 | } | - | ||||||||||||
1311 | return false; | - | ||||||||||||
1312 | } | - | ||||||||||||
1313 | void QXmlSimpleReader::setFeature(const QString& name, bool enable) | - | ||||||||||||
1314 | { | - | ||||||||||||
1315 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1316 | if (name == QLatin1String("http://xml.org/sax/features/namespaces")) { | - | ||||||||||||
1317 | d->useNamespaces = enable; | - | ||||||||||||
1318 | } else if (name == QLatin1String("http://xml.org/sax/features/namespace-prefixes")) { | - | ||||||||||||
1319 | d->useNamespacePrefixes = enable; | - | ||||||||||||
1320 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData") | - | ||||||||||||
1321 | || name == QLatin1String("http://qt-project.org/xml/features/report-whitespace-only-CharData")) { | - | ||||||||||||
1322 | d->reportWhitespaceCharData = enable; | - | ||||||||||||
1323 | } else if (name == QLatin1String("http://trolltech.com/xml/features/report-start-end-entity") | - | ||||||||||||
1324 | || name == QLatin1String("http://qt-project.org/xml/features/report-start-end-entity")) { | - | ||||||||||||
1325 | d->reportEntities = enable; | - | ||||||||||||
1326 | } else { | - | ||||||||||||
1327 | QMessageLogger(__FILE__, 29842998, __PRETTY_FUNCTION__).warning("Unknown feature %s", name.toLatin1().data()); | - | ||||||||||||
1328 | } | - | ||||||||||||
1329 | } | - | ||||||||||||
1330 | - | |||||||||||||
1331 | - | |||||||||||||
1332 | - | |||||||||||||
1333 | bool QXmlSimpleReader::hasFeature(const QString& name) const | - | ||||||||||||
1334 | { | - | ||||||||||||
1335 | if (name == QLatin1String("http://xml.org/sax/features/namespaces") | - | ||||||||||||
1336 | || name == QLatin1String("http://xml.org/sax/features/namespace-prefixes") | - | ||||||||||||
1337 | || name == QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData") | - | ||||||||||||
1338 | || name == QLatin1String("http://qt-project.org/xml/features/report-whitespace-only-CharData") | - | ||||||||||||
1339 | || name == QLatin1String("http://trolltech.com/xml/features/report-start-end-entity") | - | ||||||||||||
1340 | || name == QLatin1String("http://qt-project.org/xml/features/report-start-end-entity")) { | - | ||||||||||||
1341 | return true; | - | ||||||||||||
1342 | } else { | - | ||||||||||||
1343 | return false; | - | ||||||||||||
1344 | } | - | ||||||||||||
1345 | } | - | ||||||||||||
1346 | - | |||||||||||||
1347 | - | |||||||||||||
1348 | - | |||||||||||||
1349 | void* QXmlSimpleReader::property(const QString&, bool *ok) const | - | ||||||||||||
1350 | { | - | ||||||||||||
1351 | if (ok != 0) | - | ||||||||||||
1352 | *ok = false; | - | ||||||||||||
1353 | return 0; | - | ||||||||||||
1354 | } | - | ||||||||||||
1355 | - | |||||||||||||
1356 | - | |||||||||||||
1357 | - | |||||||||||||
1358 | void QXmlSimpleReader::setProperty(const QString&, void*) | - | ||||||||||||
1359 | { | - | ||||||||||||
1360 | } | - | ||||||||||||
1361 | - | |||||||||||||
1362 | - | |||||||||||||
1363 | - | |||||||||||||
1364 | - | |||||||||||||
1365 | bool QXmlSimpleReader::hasProperty(const QString&) const | - | ||||||||||||
1366 | { | - | ||||||||||||
1367 | return false; | - | ||||||||||||
1368 | } | - | ||||||||||||
1369 | - | |||||||||||||
1370 | - | |||||||||||||
1371 | - | |||||||||||||
1372 | - | |||||||||||||
1373 | void QXmlSimpleReader::setEntityResolver(QXmlEntityResolver* handler) | - | ||||||||||||
1374 | { | - | ||||||||||||
1375 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1376 | d->entityRes = handler; | - | ||||||||||||
1377 | } | - | ||||||||||||
1378 | - | |||||||||||||
1379 | - | |||||||||||||
1380 | - | |||||||||||||
1381 | - | |||||||||||||
1382 | QXmlEntityResolver* QXmlSimpleReader::entityResolver() const | - | ||||||||||||
1383 | { | - | ||||||||||||
1384 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1385 | return d->entityRes; | - | ||||||||||||
1386 | } | - | ||||||||||||
1387 | - | |||||||||||||
1388 | - | |||||||||||||
1389 | - | |||||||||||||
1390 | - | |||||||||||||
1391 | void QXmlSimpleReader::setDTDHandler(QXmlDTDHandler* handler) | - | ||||||||||||
1392 | { | - | ||||||||||||
1393 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1394 | d->dtdHnd = handler; | - | ||||||||||||
1395 | } | - | ||||||||||||
1396 | - | |||||||||||||
1397 | - | |||||||||||||
1398 | - | |||||||||||||
1399 | - | |||||||||||||
1400 | QXmlDTDHandler* QXmlSimpleReader::DTDHandler() const | - | ||||||||||||
1401 | { | - | ||||||||||||
1402 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1403 | return d->dtdHnd; | - | ||||||||||||
1404 | } | - | ||||||||||||
1405 | - | |||||||||||||
1406 | - | |||||||||||||
1407 | - | |||||||||||||
1408 | - | |||||||||||||
1409 | void QXmlSimpleReader::setContentHandler(QXmlContentHandler* handler) | - | ||||||||||||
1410 | { | - | ||||||||||||
1411 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1412 | d->contentHnd = handler; | - | ||||||||||||
1413 | } | - | ||||||||||||
1414 | - | |||||||||||||
1415 | - | |||||||||||||
1416 | - | |||||||||||||
1417 | - | |||||||||||||
1418 | QXmlContentHandler* QXmlSimpleReader::contentHandler() const | - | ||||||||||||
1419 | { | - | ||||||||||||
1420 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1421 | return d->contentHnd; | - | ||||||||||||
1422 | } | - | ||||||||||||
1423 | - | |||||||||||||
1424 | - | |||||||||||||
1425 | - | |||||||||||||
1426 | - | |||||||||||||
1427 | void QXmlSimpleReader::setErrorHandler(QXmlErrorHandler* handler) | - | ||||||||||||
1428 | { | - | ||||||||||||
1429 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1430 | d->errorHnd = handler; | - | ||||||||||||
1431 | } | - | ||||||||||||
1432 | - | |||||||||||||
1433 | - | |||||||||||||
1434 | - | |||||||||||||
1435 | - | |||||||||||||
1436 | QXmlErrorHandler* QXmlSimpleReader::errorHandler() const | - | ||||||||||||
1437 | { | - | ||||||||||||
1438 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1439 | return d->errorHnd; | - | ||||||||||||
1440 | } | - | ||||||||||||
1441 | - | |||||||||||||
1442 | - | |||||||||||||
1443 | - | |||||||||||||
1444 | - | |||||||||||||
1445 | void QXmlSimpleReader::setLexicalHandler(QXmlLexicalHandler* handler) | - | ||||||||||||
1446 | { | - | ||||||||||||
1447 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1448 | d->lexicalHnd = handler; | - | ||||||||||||
1449 | } | - | ||||||||||||
1450 | - | |||||||||||||
1451 | - | |||||||||||||
1452 | - | |||||||||||||
1453 | - | |||||||||||||
1454 | QXmlLexicalHandler* QXmlSimpleReader::lexicalHandler() const | - | ||||||||||||
1455 | { | - | ||||||||||||
1456 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1457 | return d->lexicalHnd; | - | ||||||||||||
1458 | } | - | ||||||||||||
1459 | - | |||||||||||||
1460 | - | |||||||||||||
1461 | - | |||||||||||||
1462 | - | |||||||||||||
1463 | void QXmlSimpleReader::setDeclHandler(QXmlDeclHandler* handler) | - | ||||||||||||
1464 | { | - | ||||||||||||
1465 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1466 | d->declHnd = handler; | - | ||||||||||||
1467 | } | - | ||||||||||||
1468 | - | |||||||||||||
1469 | - | |||||||||||||
1470 | - | |||||||||||||
1471 | - | |||||||||||||
1472 | QXmlDeclHandler* QXmlSimpleReader::declHandler() const | - | ||||||||||||
1473 | { | - | ||||||||||||
1474 | const QXmlSimpleReaderPrivate *d = d_func(); | - | ||||||||||||
1475 | return d->declHnd; | - | ||||||||||||
1476 | } | - | ||||||||||||
1477 | - | |||||||||||||
1478 | - | |||||||||||||
1479 | - | |||||||||||||
1480 | - | |||||||||||||
1481 | - | |||||||||||||
1482 | - | |||||||||||||
1483 | bool QXmlSimpleReader::parse(const QXmlInputSource& input) | - | ||||||||||||
1484 | { | - | ||||||||||||
1485 | return parse(&input, false); | - | ||||||||||||
1486 | } | - | ||||||||||||
1487 | - | |||||||||||||
1488 | - | |||||||||||||
1489 | - | |||||||||||||
1490 | - | |||||||||||||
1491 | - | |||||||||||||
1492 | bool QXmlSimpleReader::parse(const QXmlInputSource* input) | - | ||||||||||||
1493 | { | - | ||||||||||||
1494 | return parse(input, false); | - | ||||||||||||
1495 | } | - | ||||||||||||
1496 | bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental) | - | ||||||||||||
1497 | { | - | ||||||||||||
1498 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1499 | - | |||||||||||||
1500 | d->literalEntitySizes.clear(); | - | ||||||||||||
1501 | d->referencesToOtherEntities.clear(); | - | ||||||||||||
1502 | d->expandedSizes.clear(); | - | ||||||||||||
1503 | - | |||||||||||||
1504 | if (incremental
| 616-1490 | ||||||||||||
1505 | d->initIncrementalParsing(); | - | ||||||||||||
1506 | } executed 1490 times by 1 test: else {end of block Executed by:
| 1490 | ||||||||||||
1507 | delete d->parseStack; | - | ||||||||||||
1508 | d->parseStack = 0; | - | ||||||||||||
1509 | } executed 616 times by 6 tests: end of block Executed by:
| 616 | ||||||||||||
1510 | d->init(input); | - | ||||||||||||
1511 | - | |||||||||||||
1512 | - | |||||||||||||
1513 | if (d->contentHnd
| 6-2100 | ||||||||||||
1514 | d->contentHnd->setDocumentLocator(d->locator.data()); | - | ||||||||||||
1515 | if (!d->contentHnd->startDocument()
| 0-2100 | ||||||||||||
1516 | d->reportParseError(d->contentHnd->errorString()); | - | ||||||||||||
1517 | clear(d->tags.clear();); | - | ||||||||||||
1518 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1519 | } | - | ||||||||||||
1520 | } executed 2100 times by 6 tests: end of block Executed by:
| 2100 | ||||||||||||
1521 | d->skipped_entity_in_content = false; | - | ||||||||||||
1522 | return executed 2106 times by 6 tests: d->parseBeginOrContinue(0, incremental);return d->parseBeginOrContinue(0, incremental); Executed by:
executed 2106 times by 6 tests: return d->parseBeginOrContinue(0, incremental); Executed by:
| 2106 | ||||||||||||
1523 | } | - | ||||||||||||
1524 | bool QXmlSimpleReader::parseContinue() | - | ||||||||||||
1525 | { | - | ||||||||||||
1526 | QXmlSimpleReaderPrivate * const d = d_func(); | - | ||||||||||||
1527 | if (d->parseStack == 0 || d->parseStack->isEmpty()) | - | ||||||||||||
1528 | return false; | - | ||||||||||||
1529 | d->initData(); | - | ||||||||||||
1530 | int state = d->parseStack->pop().state; | - | ||||||||||||
1531 | return d->parseBeginOrContinue(state, true); | - | ||||||||||||
1532 | } | - | ||||||||||||
1533 | - | |||||||||||||
1534 | - | |||||||||||||
1535 | - | |||||||||||||
1536 | - | |||||||||||||
1537 | bool QXmlSimpleReaderPrivate::parseBeginOrContinue(int state, bool incremental) | - | ||||||||||||
1538 | { | - | ||||||||||||
1539 | bool atEndOrig = atEnd(); | - | ||||||||||||
1540 | - | |||||||||||||
1541 | if (state==0
| 10967-36047 | ||||||||||||
1542 | if (!parseProlog()
| 2029-34018 | ||||||||||||
1543 | if (incremental
| 0-33941 | ||||||||||||
1544 | pushParseState(0, 0); | - | ||||||||||||
1545 | return executed 33941 times by 1 test: true;return true; Executed by:
executed 33941 times by 1 test: return true; Executed by:
| 33941 | ||||||||||||
1546 | } else { | - | ||||||||||||
1547 | tags.clear();(tags); | - | ||||||||||||
1548 | return executed 77 times by 1 test: false;return false; Executed by:
executed 77 times by 1 test: return false; Executed by:
| 77 | ||||||||||||
1549 | } | - | ||||||||||||
1550 | } | - | ||||||||||||
1551 | state = 1; | - | ||||||||||||
1552 | } executed 2029 times by 6 tests: end of block Executed by:
| 2029 | ||||||||||||
1553 | if (state==1
| 2514-10482 | ||||||||||||
1554 | if (!parseElement()
| 1961-8521 | ||||||||||||
1555 | if (incremental
| 0-8453 | ||||||||||||
1556 | pushParseState(0, 1); | - | ||||||||||||
1557 | return executed 8453 times by 1 test: true;return true; Executed by:
executed 8453 times by 1 test: return true; Executed by:
| 8453 | ||||||||||||
1558 | } else { | - | ||||||||||||
1559 | tags.clear();(tags); | - | ||||||||||||
1560 | return executed 68 times by 1 test: false;return false; Executed by:
executed 68 times by 1 test: return false; Executed by:
| 68 | ||||||||||||
1561 | } | - | ||||||||||||
1562 | } | - | ||||||||||||
1563 | state = 2; | - | ||||||||||||
1564 | } executed 1961 times by 6 tests: end of block Executed by:
| 1961 | ||||||||||||
1565 | - | |||||||||||||
1566 | while (!atEnd()
| 2340-2392 | ||||||||||||
1567 | if (!parseMisc()
| 257-2083 | ||||||||||||
1568 | if (incremental
| 0-2073 | ||||||||||||
1569 | pushParseState(0, 2); | - | ||||||||||||
1570 | return executed 2073 times by 1 test: true;return true; Executed by:
executed 2073 times by 1 test: return true; Executed by:
| 2073 | ||||||||||||
1571 | } else { | - | ||||||||||||
1572 | tags.clear();(tags); | - | ||||||||||||
1573 | return executed 10 times by 1 test: false;return false; Executed by:
executed 10 times by 1 test: return false; Executed by:
| 10 | ||||||||||||
1574 | } | - | ||||||||||||
1575 | } | - | ||||||||||||
1576 | } executed 257 times by 2 tests: end of block Executed by:
| 257 | ||||||||||||
1577 | if (!atEndOrig
| 441-1490 | ||||||||||||
1578 | - | |||||||||||||
1579 | pushParseState(0, 2); | - | ||||||||||||
1580 | return executed 441 times by 1 test: true;return true; Executed by:
executed 441 times by 1 test: return true; Executed by:
| 441 | ||||||||||||
1581 | } | - | ||||||||||||
1582 | - | |||||||||||||
1583 | if (!tags.isEmptyempty()
| 0-1951 | ||||||||||||
1584 | reportParseError(QLatin1String("unexpected end of file")); | - | ||||||||||||
1585 | tags.clear();(tags); | - | ||||||||||||
1586 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1587 | } | - | ||||||||||||
1588 | - | |||||||||||||
1589 | if (contentHnd
| 1-1950 | ||||||||||||
1590 | delete parseStack; | - | ||||||||||||
1591 | parseStack = 0; | - | ||||||||||||
1592 | if (!contentHnd->endDocument()
| 0-1950 | ||||||||||||
1593 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1594 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1595 | } | - | ||||||||||||
1596 | } executed 1950 times by 6 tests: end of block Executed by:
| 1950 | ||||||||||||
1597 | return executed 1951 times by 6 tests: true;return true; Executed by:
executed 1951 times by 6 tests: return true; Executed by:
| 1951 | ||||||||||||
1598 | } | - | ||||||||||||
1599 | bool QXmlSimpleReaderPrivate::parseProlog() | - | ||||||||||||
1600 | { | - | ||||||||||||
1601 | const signed char Init = 0; | - | ||||||||||||
1602 | const signed char EatWS = 1; | - | ||||||||||||
1603 | const signed char Lt = 2; | - | ||||||||||||
1604 | const signed char Em = 3; | - | ||||||||||||
1605 | const signed char DocType = 4; | - | ||||||||||||
1606 | const signed char Comment = 5; | - | ||||||||||||
1607 | const signed char CommentR = 6; | - | ||||||||||||
1608 | const signed char PInstr = 7; | - | ||||||||||||
1609 | const signed char PInstrR = 8; | - | ||||||||||||
1610 | const signed char Done = 9; | - | ||||||||||||
1611 | - | |||||||||||||
1612 | const signed char InpWs = 0; | - | ||||||||||||
1613 | const signed char InpLt = 1; | - | ||||||||||||
1614 | const signed char InpQm = 2; | - | ||||||||||||
1615 | const signed char InpEm = 3; | - | ||||||||||||
1616 | const signed char InpD = 4; | - | ||||||||||||
1617 | const signed char InpDash = 5; | - | ||||||||||||
1618 | const signed char InpUnknown = 6; | - | ||||||||||||
1619 | - | |||||||||||||
1620 | static const signed char table[9][7] = { | - | ||||||||||||
1621 | - | |||||||||||||
1622 | { EatWS, Lt, -1, -1, -1, -1, -1 }, | - | ||||||||||||
1623 | { -1, Lt, -1, -1, -1, -1, -1 }, | - | ||||||||||||
1624 | { -1, -1, PInstr,Em, Done, -1, Done }, | - | ||||||||||||
1625 | { -1, -1, -1, -1, DocType, Comment, -1 }, | - | ||||||||||||
1626 | { EatWS, Lt, -1, -1, -1, -1, -1 }, | - | ||||||||||||
1627 | { EatWS, Lt, -1, -1, -1, -1, -1 }, | - | ||||||||||||
1628 | { EatWS, Lt, -1, -1, -1, -1, -1 }, | - | ||||||||||||
1629 | { EatWS, Lt, -1, -1, -1, -1, -1 }, | - | ||||||||||||
1630 | { EatWS, Lt, -1, -1, -1, -1, -1 } | - | ||||||||||||
1631 | }; | - | ||||||||||||
1632 | signed char state; | - | ||||||||||||
1633 | signed char input; | - | ||||||||||||
1634 | - | |||||||||||||
1635 | if (parseStack == 0 || parseStack->isEmpty()) { | - | ||||||||||||
1636 | xmldecl_possible = true; | - | ||||||||||||
1637 | doctype_read = false; | - | ||||||||||||
1638 | state = Init; | - | ||||||||||||
1639 | } else { | - | ||||||||||||
1640 | state = parseStack->pop().state; | - | ||||||||||||
1641 | - | |||||||||||||
1642 | - | |||||||||||||
1643 | - | |||||||||||||
1644 | if (!parseStack->isEmpty()) { | - | ||||||||||||
1645 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
1646 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
1647 | parseStack->pop(); | - | ||||||||||||
1648 | - | |||||||||||||
1649 | - | |||||||||||||
1650 | - | |||||||||||||
1651 | } | - | ||||||||||||
1652 | if (!(this->*function)()) { | - | ||||||||||||
1653 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||
1654 | return false; | - | ||||||||||||
1655 | } | - | ||||||||||||
1656 | } | - | ||||||||||||
1657 | } | - | ||||||||||||
1658 | - | |||||||||||||
1659 | for (;;) { | - | ||||||||||||
1660 | switch (state) { | - | ||||||||||||
1661 | case DocType: | - | ||||||||||||
1662 | if (doctype_read) { | - | ||||||||||||
1663 | reportParseError(QLatin1String("more than one document type definition")); | - | ||||||||||||
1664 | return false; | - | ||||||||||||
1665 | } else { | - | ||||||||||||
1666 | doctype_read = false; | - | ||||||||||||
1667 | } | - | ||||||||||||
1668 | break; | - | ||||||||||||
1669 | case Comment: | - | ||||||||||||
1670 | if (lexicalHnd) { | - | ||||||||||||
1671 | if (!lexicalHnd->comment(string())) { | - | ||||||||||||
1672 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
1673 | return false; | - | ||||||||||||
1674 | } | - | ||||||||||||
1675 | } | - | ||||||||||||
1676 | state = CommentR; | - | ||||||||||||
1677 | break; | - | ||||||||||||
1678 | case PInstr: | - | ||||||||||||
1679 | - | |||||||||||||
1680 | if (contentHnd) { | - | ||||||||||||
1681 | if (xmldecl_possible && !xmlVersion.isEmpty()) { | - | ||||||||||||
1682 | QString value(QLatin1String("version='")); | - | ||||||||||||
1683 | value += xmlVersion; | - | ||||||||||||
1684 | value += QLatin1Char('\''); | - | ||||||||||||
1685 | if (!encoding.isEmpty()) { | - | ||||||||||||
1686 | value += QLatin1String(" encoding='"); | - | ||||||||||||
1687 | value += encoding; | - | ||||||||||||
1688 | value += QLatin1Char('\''); | - | ||||||||||||
1689 | } | - | ||||||||||||
1690 | if (standalone == QXmlSimpleReaderPrivate::Yes) { | - | ||||||||||||
1691 | value += QLatin1String(" standalone='yes'"); | - | ||||||||||||
1692 | } else if (standalone == QXmlSimpleReaderPrivate::No) { | - | ||||||||||||
1693 | value += QLatin1String(" standalone='no'"); | - | ||||||||||||
1694 | } | - | ||||||||||||
1695 | if (!contentHnd->processingInstruction(QLatin1String("xml"), value)) { | - | ||||||||||||
1696 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1697 | return false; | - | ||||||||||||
1698 | } | - | ||||||||||||
1699 | } else { | - | ||||||||||||
1700 | if (!contentHnd->processingInstruction(name(), string())) { | - | ||||||||||||
1701 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1702 | return false; | - | ||||||||||||
1703 | } | - | ||||||||||||
1704 | } | - | ||||||||||||
1705 | } | - | ||||||||||||
1706 | - | |||||||||||||
1707 | xmldecl_possible = false; | - | ||||||||||||
1708 | state = PInstrR; | - | ||||||||||||
1709 | break; | - | ||||||||||||
1710 | case Done: | - | ||||||||||||
1711 | return true; | - | ||||||||||||
1712 | case -1: | - | ||||||||||||
1713 | reportParseError(QLatin1String("error occurred while parsing element")); | - | ||||||||||||
1714 | return false; | - | ||||||||||||
1715 | } | - | ||||||||||||
1716 | - | |||||||||||||
1717 | if (atEnd()) { | - | ||||||||||||
1718 | unexpectedEof(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||
1719 | return false; | - | ||||||||||||
1720 | } | - | ||||||||||||
1721 | if (is_S(c)) { | - | ||||||||||||
1722 | input = InpWs; | - | ||||||||||||
1723 | } else if (c == QLatin1Char('<')) { | - | ||||||||||||
1724 | input = InpLt; | - | ||||||||||||
1725 | } else if (c == QLatin1Char('?')) { | - | ||||||||||||
1726 | input = InpQm; | - | ||||||||||||
1727 | } else if (c == QLatin1Char('!')) { | - | ||||||||||||
1728 | input = InpEm; | - | ||||||||||||
1729 | } else if (c == QLatin1Char('D')) { | - | ||||||||||||
1730 | input = InpD; | - | ||||||||||||
1731 | } else if (c == QLatin1Char('-')) { | - | ||||||||||||
1732 | input = InpDash; | - | ||||||||||||
1733 | } else { | - | ||||||||||||
1734 | input = InpUnknown; | - | ||||||||||||
1735 | } | - | ||||||||||||
1736 | state = table[state][input]; | - | ||||||||||||
1737 | - | |||||||||||||
1738 | switch (state) { | - | ||||||||||||
1739 | case EatWS: | - | ||||||||||||
1740 | - | |||||||||||||
1741 | xmldecl_possible = false; | - | ||||||||||||
1742 | if (!eat_ws()) { | - | ||||||||||||
1743 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||
1744 | return false; | - | ||||||||||||
1745 | } | - | ||||||||||||
1746 | break; | - | ||||||||||||
1747 | case Lt: | - | ||||||||||||
1748 | next(); | - | ||||||||||||
1749 | break; | - | ||||||||||||
1750 | case Em: | - | ||||||||||||
1751 | - | |||||||||||||
1752 | xmldecl_possible = false; | - | ||||||||||||
1753 | next(); | - | ||||||||||||
1754 | break; | - | ||||||||||||
1755 | case DocType: | - | ||||||||||||
1756 | if (!parseDoctype()) { | - | ||||||||||||
1757 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||
1758 | return false; | - | ||||||||||||
1759 | } | - | ||||||||||||
1760 | break; | - | ||||||||||||
1761 | case Comment: | - | ||||||||||||
1762 | case CommentR: | - | ||||||||||||
1763 | if (!parseComment()) { | - | ||||||||||||
1764 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||
1765 | return false; | - | ||||||||||||
1766 | } | - | ||||||||||||
1767 | break; | - | ||||||||||||
1768 | case PInstr: | - | ||||||||||||
1769 | case PInstrR: | - | ||||||||||||
1770 | parsePI_xmldecl = xmldecl_possible; | - | ||||||||||||
1771 | if (!parsePI()) { | - | ||||||||||||
1772 | parseFailed(&QXmlSimpleReaderPrivate::parseProlog, state); | - | ||||||||||||
1773 | return false; | - | ||||||||||||
1774 | } | - | ||||||||||||
1775 | break; | - | ||||||||||||
1776 | } | - | ||||||||||||
1777 | } | - | ||||||||||||
1778 | return false; | - | ||||||||||||
1779 | } | - | ||||||||||||
1780 | - | |||||||||||||
1781 | - | |||||||||||||
1782 | - | |||||||||||||
1783 | - | |||||||||||||
1784 | - | |||||||||||||
1785 | - | |||||||||||||
1786 | bool QXmlSimpleReaderPrivate::parseElement() | - | ||||||||||||
1787 | { | - | ||||||||||||
1788 | const int Init = 0; | - | ||||||||||||
1789 | const int ReadName = 1; | - | ||||||||||||
1790 | const int Ws1 = 2; | - | ||||||||||||
1791 | const int STagEnd = 3; | - | ||||||||||||
1792 | const int STagEnd2 = 4; | - | ||||||||||||
1793 | const int ETagBegin = 5; | - | ||||||||||||
1794 | const int ETagBegin2 = 6; | - | ||||||||||||
1795 | const int Ws2 = 7; | - | ||||||||||||
1796 | const int EmptyTag = 8; | - | ||||||||||||
1797 | const int Attrib = 9; | - | ||||||||||||
1798 | const int AttribPro = 10; | - | ||||||||||||
1799 | const int Ws3 = 11; | - | ||||||||||||
1800 | const int Done = 12; | - | ||||||||||||
1801 | - | |||||||||||||
1802 | const int InpWs = 0; | - | ||||||||||||
1803 | const int InpNameBe = 1; | - | ||||||||||||
1804 | const int InpGt = 2; | - | ||||||||||||
1805 | const int InpSlash = 3; | - | ||||||||||||
1806 | const int InpUnknown = 4; | - | ||||||||||||
1807 | - | |||||||||||||
1808 | static const int table[12][5] = { | - | ||||||||||||
1809 | - | |||||||||||||
1810 | { -1, ReadName, -1, -1, -1 }, | - | ||||||||||||
1811 | { Ws1, Attrib, STagEnd, EmptyTag, -1 }, | - | ||||||||||||
1812 | { -1, Attrib, STagEnd, EmptyTag, -1 }, | - | ||||||||||||
1813 | { STagEnd2, STagEnd2, STagEnd2, STagEnd2, STagEnd2 }, | - | ||||||||||||
1814 | { -1, -1, -1, ETagBegin, -1 }, | - | ||||||||||||
1815 | { -1, ETagBegin2, -1, -1, -1 }, | - | ||||||||||||
1816 | { Ws2, -1, Done, -1, -1 }, | - | ||||||||||||
1817 | { -1, -1, Done, -1, -1 }, | - | ||||||||||||
1818 | { -1, -1, Done, -1, -1 }, | - | ||||||||||||
1819 | { Ws3, Attrib, STagEnd, EmptyTag, -1 }, | - | ||||||||||||
1820 | { Ws3, Attrib, STagEnd, EmptyTag, -1 }, | - | ||||||||||||
1821 | { -1, Attrib, STagEnd, EmptyTag, -1 } | - | ||||||||||||
1822 | }; | - | ||||||||||||
1823 | int state; | - | ||||||||||||
1824 | int input; | - | ||||||||||||
1825 | - | |||||||||||||
1826 | if (parseStack == 0
| 1814-11462 | ||||||||||||
1827 | state = Init; | - | ||||||||||||
1828 | } executed 5806 times by 6 tests: else {end of block Executed by:
| 5806 | ||||||||||||
1829 | state = parseStack->pop().state; | - | ||||||||||||
1830 | - | |||||||||||||
1831 | - | |||||||||||||
1832 | - | |||||||||||||
1833 | if (!parseStack->isEmpty()
| 1223-8425 | ||||||||||||
1834 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
1835 | if (function == &QXmlSimpleReaderPrivate::eat_ws
| 136-8289 | ||||||||||||
1836 | parseStack->pop(); | - | ||||||||||||
1837 | - | |||||||||||||
1838 | - | |||||||||||||
1839 | - | |||||||||||||
1840 | } executed 136 times by 1 test: end of block Executed by:
| 136 | ||||||||||||
1841 | if (!(this->*function)()
| 3566-4859 | ||||||||||||
1842 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1843 | return executed 4859 times by 1 test: false;return false; Executed by:
executed 4859 times by 1 test: return false; Executed by:
| 4859 | ||||||||||||
1844 | } | - | ||||||||||||
1845 | } executed 3566 times by 1 test: end of block Executed by:
| 3566 | ||||||||||||
1846 | } executed 4789 times by 1 test: end of block Executed by:
| 4789 | ||||||||||||
1847 | - | |||||||||||||
1848 | for (;;) { | - | ||||||||||||
1849 | switch (state) { | - | ||||||||||||
1850 | case executed 5802 times by 6 tests: ReadName:case ReadName: Executed by:
executed 5802 times by 6 tests: case ReadName: Executed by:
| 5802 | ||||||||||||
1851 | - | |||||||||||||
1852 | tags.push(name()); | - | ||||||||||||
1853 | - | |||||||||||||
1854 | attList.clear(); | - | ||||||||||||
1855 | if (useNamespaces
| 1021-4781 | ||||||||||||
1856 | namespaceSupport.pushContext(); executed 4781 times by 3 tests: namespaceSupport.pushContext(); Executed by:
| 4781 | ||||||||||||
1857 | break; executed 5802 times by 6 tests: break; Executed by:
| 5802 | ||||||||||||
1858 | case executed 5180 times by 6 tests: ETagBegin2:case ETagBegin2: Executed by:
executed 5180 times by 6 tests: case ETagBegin2: Executed by:
| 5180 | ||||||||||||
1859 | if (!processElementETagBegin2()
| 4-5176 | ||||||||||||
1860 | return executed 4 times by 1 test: false;return false; Executed by:
executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||
1861 | break; executed 5176 times by 6 tests: break; Executed by:
| 5176 | ||||||||||||
1862 | case executed 12894 times by 6 tests: Attrib:case Attrib: Executed by:
executed 12894 times by 6 tests: case Attrib: Executed by:
| 12894 | ||||||||||||
1863 | if (!processElementAttribute()
| 0-12894 | ||||||||||||
1864 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1865 | state = AttribPro; | - | ||||||||||||
1866 | break; executed 12894 times by 6 tests: break; Executed by:
| 12894 | ||||||||||||
1867 | case executed 5723 times by 6 tests: Done:case Done: Executed by:
executed 5723 times by 6 tests: case Done: Executed by:
| 5723 | ||||||||||||
1868 | return executed 5723 times by 6 tests: true;return true; Executed by:
executed 5723 times by 6 tests: return true; Executed by:
| 5723 | ||||||||||||
1869 | case executed 14 times by 1 test: -1:case -1: Executed by:
executed 14 times by 1 test: case -1: Executed by:
| 14 | ||||||||||||
1870 | reportParseError(QLatin1String("error occurred while parsing element")); | - | ||||||||||||
1871 | return executed 14 times by 1 test: false;return false; Executed by:
executed 14 times by 1 test: return false; Executed by:
| 14 | ||||||||||||
1872 | } | - | ||||||||||||
1873 | - | |||||||||||||
1874 | if (atEnd()
| 1225-58942 | ||||||||||||
1875 | unexpectedEof(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1876 | return executed 1225 times by 1 test: false;return false; Executed by:
executed 1225 times by 1 test: return false; Executed by:
| 1225 | ||||||||||||
1877 | } | - | ||||||||||||
1878 | if (fastDetermineNameChar(c) == NameBeginning
| 24149-34793 | ||||||||||||
1879 | input = InpNameBe; | - | ||||||||||||
1880 | } executed 24149 times by 6 tests: else if (c == QLatin1Char('>')end of block Executed by:
| 10954-24149 | ||||||||||||
1881 | input = InpGt; | - | ||||||||||||
1882 | } executed 10954 times by 6 tests: else if (is_S(c)end of block Executed by:
| 7870-15969 | ||||||||||||
1883 | input = InpWs; | - | ||||||||||||
1884 | } executed 15969 times by 6 tests: else if (c == QLatin1Char('/')end of block Executed by:
| 2139-15969 | ||||||||||||
1885 | input = InpSlash; | - | ||||||||||||
1886 | } executed 5731 times by 6 tests: else {end of block Executed by:
| 5731 | ||||||||||||
1887 | input = InpUnknown; | - | ||||||||||||
1888 | } executed 2139 times by 5 tests: end of block Executed by:
| 2139 | ||||||||||||
1889 | state = table[state][input]; | - | ||||||||||||
1890 | - | |||||||||||||
1891 | switch (state) { | - | ||||||||||||
1892 | case executed 5802 times by 6 tests: ReadName:case ReadName: Executed by:
executed 5802 times by 6 tests: case ReadName: Executed by:
| 5802 | ||||||||||||
1893 | parseName_useRef = false; | - | ||||||||||||
1894 | if (!parseName()
| 1145-4657 | ||||||||||||
1895 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1896 | return executed 1145 times by 1 test: false;return false; Executed by:
executed 1145 times by 1 test: return false; Executed by:
| 1145 | ||||||||||||
1897 | } | - | ||||||||||||
1898 | break; executed 4657 times by 6 tests: break; Executed by:
| 4657 | ||||||||||||
1899 | case executed 3442 times by 6 tests: Ws1:case Ws1: Executed by:
executed 3442 times by 6 tests: case Ws1: Executed by:
| 3442 | ||||||||||||
1900 | case executed 20 times by 1 test: Ws2:case Ws2: Executed by:
executed 20 times by 1 test: case Ws2: Executed by:
| 20 | ||||||||||||
1901 | case executed 9662 times by 6 tests: Ws3:case Ws3: Executed by:
executed 9662 times by 6 tests: case Ws3: Executed by:
| 9662 | ||||||||||||
1902 | if (!eat_ws()
| 134-12990 | ||||||||||||
1903 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1904 | return executed 134 times by 1 test: false;return false; Executed by:
executed 134 times by 1 test: return false; Executed by:
| 134 | ||||||||||||
1905 | } | - | ||||||||||||
1906 | break; executed 12990 times by 6 tests: break; Executed by:
| 12990 | ||||||||||||
1907 | case executed 5230 times by 6 tests: STagEnd:case STagEnd: Executed by:
executed 5230 times by 6 tests: case STagEnd: Executed by:
| 5230 | ||||||||||||
1908 | - | |||||||||||||
1909 | if (contentHnd
| 4-5226 | ||||||||||||
1910 | const QString &tagsTop = tags.top();if (useNamespaces
| 697-4529 | ||||||||||||
1911 | QString uri, lname; | - | ||||||||||||
1912 | namespaceSupport.processName(tagsTop,tags.top(), false, uri, lname); | - | ||||||||||||
1913 | if (!contentHnd->startElement(uri, lname, tagsTop, tags.top(), attList)
| 0-4529 | ||||||||||||
1914 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1915 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1916 | } | - | ||||||||||||
1917 | } executed 4529 times by 2 tests: else {end of block Executed by:
| 4529 | ||||||||||||
1918 | if (!contentHnd->startElement(QString(), QString(), tagsTop,tags.top(), attList)
| 0-697 | ||||||||||||
1919 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1920 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1921 | } | - | ||||||||||||
1922 | } executed 697 times by 4 tests: end of block Executed by:
| 697 | ||||||||||||
1923 | } | - | ||||||||||||
1924 | next(); | - | ||||||||||||
1925 | break; executed 5230 times by 6 tests: break; Executed by:
| 5230 | ||||||||||||
1926 | case executed 5228 times by 6 tests: STagEnd2:case STagEnd2: Executed by:
executed 5228 times by 6 tests: case STagEnd2: Executed by:
| 5228 | ||||||||||||
1927 | if (!parseContent()
| 921-4307 | ||||||||||||
1928 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1929 | return executed 921 times by 1 test: false;return false; Executed by:
executed 921 times by 1 test: return false; Executed by:
| 921 | ||||||||||||
1930 | } | - | ||||||||||||
1931 | break; executed 4307 times by 6 tests: break; Executed by:
| 4307 | ||||||||||||
1932 | case executed 5181 times by 6 tests: ETagBegin:case ETagBegin: Executed by:
executed 5181 times by 6 tests: case ETagBegin: Executed by:
| 5181 | ||||||||||||
1933 | next(); | - | ||||||||||||
1934 | break; executed 5181 times by 6 tests: break; Executed by:
| 5181 | ||||||||||||
1935 | case executed 5180 times by 6 tests: ETagBegin2:case ETagBegin2: Executed by:
executed 5180 times by 6 tests: case ETagBegin2: Executed by:
| 5180 | ||||||||||||
1936 | - | |||||||||||||
1937 | parseName_useRef = false; | - | ||||||||||||
1938 | if (!parseName()
| 1072-4108 | ||||||||||||
1939 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1940 | return executed 1072 times by 1 test: false;return false; Executed by:
executed 1072 times by 1 test: return false; Executed by:
| 1072 | ||||||||||||
1941 | } | - | ||||||||||||
1942 | break; executed 4108 times by 6 tests: break; Executed by:
| 4108 | ||||||||||||
1943 | case executed 550 times by 5 tests: EmptyTag:case EmptyTag: Executed by:
executed 550 times by 5 tests: case EmptyTag: Executed by:
| 550 | ||||||||||||
1944 | if (tags.isEmptyempty()
| 0-550 | ||||||||||||
1945 | reportParseError(QLatin1String("tag mismatch")); | - | ||||||||||||
1946 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1947 | } | - | ||||||||||||
1948 | if (!processElementEmptyTag()
| 0-550 | ||||||||||||
1949 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1950 | next(); | - | ||||||||||||
1951 | break; executed 550 times by 5 tests: break; Executed by:
| 550 | ||||||||||||
1952 | case executed 12910 times by 6 tests: Attrib:case Attrib: Executed by:
executed 12910 times by 6 tests: case Attrib: Executed by:
| 12910 | ||||||||||||
1953 | case never executed: AttribPro:case AttribPro: never executed: case AttribPro: | 0 | ||||||||||||
1954 | - | |||||||||||||
1955 | if (!parseAttribute()
| 357-12553 | ||||||||||||
1956 | parseFailed(&QXmlSimpleReaderPrivate::parseElement, state); | - | ||||||||||||
1957 | return executed 357 times by 1 test: false;return false; Executed by:
executed 357 times by 1 test: return false; Executed by:
| 357 | ||||||||||||
1958 | } | - | ||||||||||||
1959 | break; executed 12553 times by 6 tests: break; Executed by:
| 12553 | ||||||||||||
1960 | case executed 5723 times by 6 tests: Done:case Done: Executed by:
executed 5723 times by 6 tests: case Done: Executed by:
| 5723 | ||||||||||||
1961 | next(); | - | ||||||||||||
1962 | break; executed 5723 times by 6 tests: break; Executed by:
| 5723 | ||||||||||||
1963 | } | - | ||||||||||||
1964 | } executed 55313 times by 6 tests: end of block Executed by:
| 55313 | ||||||||||||
1965 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1966 | } | - | ||||||||||||
1967 | - | |||||||||||||
1968 | - | |||||||||||||
1969 | - | |||||||||||||
1970 | - | |||||||||||||
1971 | - | |||||||||||||
1972 | bool QXmlSimpleReaderPrivate::processElementEmptyTag() | - | ||||||||||||
1973 | { | - | ||||||||||||
1974 | QString uri, lname; | - | ||||||||||||
1975 | - | |||||||||||||
1976 | if (contentHnd
| 9-541 | ||||||||||||
1977 | if (useNamespaces
| 217-324 | ||||||||||||
1978 | - | |||||||||||||
1979 | namespaceSupport.processName(tags.top(), false, uri, lname); | - | ||||||||||||
1980 | if (!contentHnd->startElement(uri, lname, tags.top(), attList)
| 0-217 | ||||||||||||
1981 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1982 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1983 | } | - | ||||||||||||
1984 | - | |||||||||||||
1985 | if (!const bool endElementReturnedFalse = !contentHnd->endElement(uri, lname, tags.top()); | - | ||||||||||||
1986 | tags.pop()))(); | - | ||||||||||||
1987 | if (endElementReturnedFalse
| 0-217 | ||||||||||||
1988 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
1989 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
1990 | } | - | ||||||||||||
1991 | - | |||||||||||||
1992 | QStringList prefixesBefore, prefixesAfter; | - | ||||||||||||
1993 | if (contentHnd
| 0-217 | ||||||||||||
1994 | prefixesBefore = namespaceSupport.prefixes(); | - | ||||||||||||
1995 | } executed 217 times by 2 tests: end of block Executed by:
| 217 | ||||||||||||
1996 | namespaceSupport.popContext(); | - | ||||||||||||
1997 | - | |||||||||||||
1998 | prefixesAfter = namespaceSupport.prefixes(); | - | ||||||||||||
1999 | for (QStringList::Iterator it = prefixesBefore.begin(); it != prefixesBefore.end()
| 217-221 | ||||||||||||
2000 | if (!prefixesAfter.contains(*it)
| 4-217 | ||||||||||||
2001 | if (!contentHnd->endPrefixMapping(*it)
| 0-4 | ||||||||||||
2002 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2003 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
2004 | } | - | ||||||||||||
2005 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
2006 | } executed 221 times by 2 tests: end of block Executed by:
| 221 | ||||||||||||
2007 | } executed 217 times by 2 tests: else {end of block Executed by:
| 217 | ||||||||||||
2008 | - | |||||||||||||
2009 | if (!contentHnd->startElement(QString(), QString(), tags.top(), attList)
| 0-324 | ||||||||||||
2010 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2011 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
2012 | } | - | ||||||||||||
2013 | - | |||||||||||||
2014 | if (!const bool endElementReturnedFalse = !contentHnd->endElement(QString(), QString(), tags.top()); | - | ||||||||||||
2015 | tags.pop()))(); | - | ||||||||||||
2016 | if (endElementReturnedFalse
| 0-324 | ||||||||||||
2017 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2018 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
2019 | } | - | ||||||||||||
2020 | } executed 324 times by 4 tests: end of block Executed by:
| 324 | ||||||||||||
2021 | } else { | - | ||||||||||||
2022 | tags.pop_backpop(); | - | ||||||||||||
2023 | namespaceSupport.popContext(); | - | ||||||||||||
2024 | } executed 9 times by 2 tests: end of block Executed by:
| 9 | ||||||||||||
2025 | return executed 550 times by 5 tests: true;return true; Executed by:
executed 550 times by 5 tests: return true; Executed by:
| 550 | ||||||||||||
2026 | } | - | ||||||||||||
2027 | - | |||||||||||||
2028 | - | |||||||||||||
2029 | - | |||||||||||||
2030 | - | |||||||||||||
2031 | bool QXmlSimpleReaderPrivate::processElementETagBegin2() | - | ||||||||||||
2032 | { | - | ||||||||||||
2033 | const QString &name = QXmlSimpleReaderPrivate::name(); | - | ||||||||||||
2034 | - | |||||||||||||
2035 | - | |||||||||||||
2036 | if (const bool nameIsTagsTop = tags.poptop() !=== name; | - | ||||||||||||
2037 | tags.pop(); | - | ||||||||||||
2038 | if (!nameIsTagsTop
| 4-5176 | ||||||||||||
2039 | reportParseError(QLatin1String("tag mismatch")); | - | ||||||||||||
2040 | return executed 4 times by 1 test: false;return false; Executed by:
executed 4 times by 1 test: return false; Executed by:
| 4 | ||||||||||||
2041 | } | - | ||||||||||||
2042 | - | |||||||||||||
2043 | if (contentHnd
| 0-5176 | ||||||||||||
2044 | QString uri, lname; | - | ||||||||||||
2045 | - | |||||||||||||
2046 | if (useNamespaces
| 697-4479 | ||||||||||||
2047 | namespaceSupport.processName(name, false, uri, lname); executed 4479 times by 2 tests: namespaceSupport.processName(name, false, uri, lname); Executed by:
| 4479 | ||||||||||||
2048 | if (!contentHnd->endElement(uri, lname, name)
| 0-5176 | ||||||||||||
2049 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2050 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
2051 | } | - | ||||||||||||
2052 | } executed 5176 times by 6 tests: end of block Executed by:
| 5176 | ||||||||||||
2053 | if (useNamespaces
| 697-4479 | ||||||||||||
2054 | NamespaceMap prefixesBefore, prefixesAfter; | - | ||||||||||||
2055 | if (contentHnd
| 0-4479 | ||||||||||||
2056 | prefixesBefore = namespaceSupport.d->ns; executed 4479 times by 2 tests: prefixesBefore = namespaceSupport.d->ns; Executed by:
| 4479 | ||||||||||||
2057 | - | |||||||||||||
2058 | namespaceSupport.popContext(); | - | ||||||||||||
2059 | - | |||||||||||||
2060 | if (contentHnd
| 0-4479 | ||||||||||||
2061 | prefixesAfter = namespaceSupport.d->ns; | - | ||||||||||||
2062 | if (prefixesBefore.size() != prefixesAfter.size()
| 10-4469 | ||||||||||||
2063 | for (NamespaceMap::const_iterator it = prefixesBefore.constBegin(); it != prefixesBefore.constEnd()
| 10-20 | ||||||||||||
2064 | if (!it.key().isEmpty()
| 0-10 | ||||||||||||
2065 | if (!contentHnd->endPrefixMapping(it.key())
| 0 | ||||||||||||
2066 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2067 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
2068 | } | - | ||||||||||||
2069 | } never executed: end of block | 0 | ||||||||||||
2070 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||
2071 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||
2072 | } executed 4479 times by 2 tests: end of block Executed by:
| 4479 | ||||||||||||
2073 | } executed 4479 times by 2 tests: end of block Executed by:
| 4479 | ||||||||||||
2074 | return executed 5176 times by 6 tests: true;return true; Executed by:
executed 5176 times by 6 tests: return true; Executed by:
| 5176 | ||||||||||||
2075 | } | - | ||||||||||||
2076 | - | |||||||||||||
2077 | - | |||||||||||||
2078 | - | |||||||||||||
2079 | - | |||||||||||||
2080 | bool QXmlSimpleReaderPrivate::processElementAttribute() | - | ||||||||||||
2081 | { | - | ||||||||||||
2082 | QString uri, lname, prefix; | - | ||||||||||||
2083 | const QString &name = QXmlSimpleReaderPrivate::name(); | - | ||||||||||||
2084 | const QString &string = QXmlSimpleReaderPrivate::string(); | - | ||||||||||||
2085 | - | |||||||||||||
2086 | - | |||||||||||||
2087 | if (useNamespaces) { | - | ||||||||||||
2088 | - | |||||||||||||
2089 | namespaceSupport.splitName(name, prefix, lname); | - | ||||||||||||
2090 | if (prefix == QLatin1String("xmlns")) { | - | ||||||||||||
2091 | - | |||||||||||||
2092 | namespaceSupport.setPrefix(lname, string); | - | ||||||||||||
2093 | if (useNamespacePrefixes) { | - | ||||||||||||
2094 | - | |||||||||||||
2095 | - | |||||||||||||
2096 | - | |||||||||||||
2097 | attList.append(name, QLatin1String("http://www.w3.org/2000/xmlns/"), lname, string); | - | ||||||||||||
2098 | } | - | ||||||||||||
2099 | - | |||||||||||||
2100 | if (contentHnd) { | - | ||||||||||||
2101 | if (!contentHnd->startPrefixMapping(lname, string)) { | - | ||||||||||||
2102 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2103 | return false; | - | ||||||||||||
2104 | } | - | ||||||||||||
2105 | } | - | ||||||||||||
2106 | } else { | - | ||||||||||||
2107 | - | |||||||||||||
2108 | namespaceSupport.processName(name, true, uri, lname); | - | ||||||||||||
2109 | attList.append(name, uri, lname, string); | - | ||||||||||||
2110 | } | - | ||||||||||||
2111 | } else { | - | ||||||||||||
2112 | - | |||||||||||||
2113 | attList.append(name, uri, lname, string); | - | ||||||||||||
2114 | } | - | ||||||||||||
2115 | return true; | - | ||||||||||||
2116 | } | - | ||||||||||||
2117 | - | |||||||||||||
2118 | - | |||||||||||||
2119 | - | |||||||||||||
2120 | - | |||||||||||||
2121 | - | |||||||||||||
2122 | - | |||||||||||||
2123 | - | |||||||||||||
2124 | bool QXmlSimpleReaderPrivate::parseContent() | - | ||||||||||||
2125 | { | - | ||||||||||||
2126 | const signed char Init = 0; | - | ||||||||||||
2127 | const signed char ChD = 1; | - | ||||||||||||
2128 | const signed char ChD1 = 2; | - | ||||||||||||
2129 | const signed char ChD2 = 3; | - | ||||||||||||
2130 | const signed char Ref = 4; | - | ||||||||||||
2131 | const signed char Lt = 5; | - | ||||||||||||
2132 | const signed char PInstr = 6; | - | ||||||||||||
2133 | const signed char PInstrR = 7; | - | ||||||||||||
2134 | const signed char Elem = 8; | - | ||||||||||||
2135 | const signed char Em = 9; | - | ||||||||||||
2136 | const signed char Com = 10; | - | ||||||||||||
2137 | const signed char ComR = 11; | - | ||||||||||||
2138 | const signed char CDS = 12; | - | ||||||||||||
2139 | const signed char CDS1 = 13; | - | ||||||||||||
2140 | const signed char CDS2 = 14; | - | ||||||||||||
2141 | const signed char CDS3 = 15; | - | ||||||||||||
2142 | const signed char Done = 16; | - | ||||||||||||
2143 | - | |||||||||||||
2144 | const signed char InpLt = 0; | - | ||||||||||||
2145 | const signed char InpGt = 1; | - | ||||||||||||
2146 | const signed char InpSlash = 2; | - | ||||||||||||
2147 | const signed char InpQMark = 3; | - | ||||||||||||
2148 | const signed char InpEMark = 4; | - | ||||||||||||
2149 | const signed char InpAmp = 5; | - | ||||||||||||
2150 | const signed char InpDash = 6; | - | ||||||||||||
2151 | const signed char InpOpenB = 7; | - | ||||||||||||
2152 | const signed char InpCloseB = 8; | - | ||||||||||||
2153 | const signed char InpUnknown = 9; | - | ||||||||||||
2154 | - | |||||||||||||
2155 | static const signed char mapCLT2FSMChar[] = { | - | ||||||||||||
2156 | InpUnknown, | - | ||||||||||||
2157 | InpUnknown, | - | ||||||||||||
2158 | InpAmp, | - | ||||||||||||
2159 | InpGt, | - | ||||||||||||
2160 | InpLt, | - | ||||||||||||
2161 | InpSlash, | - | ||||||||||||
2162 | InpQMark, | - | ||||||||||||
2163 | InpEMark, | - | ||||||||||||
2164 | InpDash, | - | ||||||||||||
2165 | InpCloseB, | - | ||||||||||||
2166 | InpOpenB, | - | ||||||||||||
2167 | InpUnknown, | - | ||||||||||||
2168 | InpUnknown, | - | ||||||||||||
2169 | InpUnknown, | - | ||||||||||||
2170 | InpUnknown | - | ||||||||||||
2171 | }; | - | ||||||||||||
2172 | - | |||||||||||||
2173 | static const signed char table[16][10] = { | - | ||||||||||||
2174 | - | |||||||||||||
2175 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, | - | ||||||||||||
2176 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD1, ChD }, | - | ||||||||||||
2177 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, | - | ||||||||||||
2178 | { Lt, -1, ChD, ChD, ChD, Ref, ChD, ChD, ChD2, ChD }, | - | ||||||||||||
2179 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, | - | ||||||||||||
2180 | { -1, -1, Done, PInstr, Em, -1, -1, -1, -1, Elem }, | - | ||||||||||||
2181 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, | - | ||||||||||||
2182 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, | - | ||||||||||||
2183 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, | - | ||||||||||||
2184 | { -1, -1, -1, -1, -1, -1, Com, CDS, -1, -1 }, | - | ||||||||||||
2185 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, | - | ||||||||||||
2186 | { Lt, ChD, ChD, ChD, ChD, Ref, ChD, ChD, ChD, ChD }, | - | ||||||||||||
2187 | { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, | - | ||||||||||||
2188 | { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS2, CDS1 }, | - | ||||||||||||
2189 | { CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 }, | - | ||||||||||||
2190 | { CDS1, Init, CDS1, CDS1, CDS1, CDS1, CDS1, CDS1, CDS3, CDS1 } | - | ||||||||||||
2191 | }; | - | ||||||||||||
2192 | signed char state; | - | ||||||||||||
2193 | signed char input; | - | ||||||||||||
2194 | - | |||||||||||||
2195 | if (parseStack == 0 || parseStack->isEmpty()) { | - | ||||||||||||
2196 | contentCharDataRead = false; | - | ||||||||||||
2197 | state = Init; | - | ||||||||||||
2198 | } else { | - | ||||||||||||
2199 | state = parseStack->pop().state; | - | ||||||||||||
2200 | - | |||||||||||||
2201 | - | |||||||||||||
2202 | - | |||||||||||||
2203 | if (!parseStack->isEmpty()) { | - | ||||||||||||
2204 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
2205 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
2206 | parseStack->pop(); | - | ||||||||||||
2207 | - | |||||||||||||
2208 | - | |||||||||||||
2209 | - | |||||||||||||
2210 | } | - | ||||||||||||
2211 | if (!(this->*function)()) { | - | ||||||||||||
2212 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2213 | return false; | - | ||||||||||||
2214 | } | - | ||||||||||||
2215 | } | - | ||||||||||||
2216 | } | - | ||||||||||||
2217 | - | |||||||||||||
2218 | for (;;) { | - | ||||||||||||
2219 | switch (state) { | - | ||||||||||||
2220 | case Ref: | - | ||||||||||||
2221 | if (!contentCharDataRead) | - | ||||||||||||
2222 | contentCharDataRead = parseReference_charDataRead; | - | ||||||||||||
2223 | break; | - | ||||||||||||
2224 | case PInstr: | - | ||||||||||||
2225 | if (contentHnd) { | - | ||||||||||||
2226 | if (!contentHnd->processingInstruction(name(),string())) { | - | ||||||||||||
2227 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2228 | return false; | - | ||||||||||||
2229 | } | - | ||||||||||||
2230 | } | - | ||||||||||||
2231 | state = PInstrR; | - | ||||||||||||
2232 | break; | - | ||||||||||||
2233 | case Com: | - | ||||||||||||
2234 | if (lexicalHnd) { | - | ||||||||||||
2235 | if (!lexicalHnd->comment(string())) { | - | ||||||||||||
2236 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
2237 | return false; | - | ||||||||||||
2238 | } | - | ||||||||||||
2239 | } | - | ||||||||||||
2240 | state = ComR; | - | ||||||||||||
2241 | break; | - | ||||||||||||
2242 | case CDS: | - | ||||||||||||
2243 | stringClear(); | - | ||||||||||||
2244 | break; | - | ||||||||||||
2245 | case CDS2: | - | ||||||||||||
2246 | if (!atEnd() && c != QLatin1Char(']')) | - | ||||||||||||
2247 | stringAddC(QLatin1Char(']')); | - | ||||||||||||
2248 | break; | - | ||||||||||||
2249 | case CDS3: | - | ||||||||||||
2250 | - | |||||||||||||
2251 | if (!atEnd()) { | - | ||||||||||||
2252 | if (c == QLatin1Char('>')) { | - | ||||||||||||
2253 | - | |||||||||||||
2254 | if (lexicalHnd) { | - | ||||||||||||
2255 | if (!lexicalHnd->startCDATA()) { | - | ||||||||||||
2256 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
2257 | return false; | - | ||||||||||||
2258 | } | - | ||||||||||||
2259 | } | - | ||||||||||||
2260 | if (contentHnd) { | - | ||||||||||||
2261 | if (!contentHnd->characters(string())) { | - | ||||||||||||
2262 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2263 | return false; | - | ||||||||||||
2264 | } | - | ||||||||||||
2265 | } | - | ||||||||||||
2266 | if (lexicalHnd) { | - | ||||||||||||
2267 | if (!lexicalHnd->endCDATA()) { | - | ||||||||||||
2268 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
2269 | return false; | - | ||||||||||||
2270 | } | - | ||||||||||||
2271 | } | - | ||||||||||||
2272 | } else if (c == QLatin1Char(']')) { | - | ||||||||||||
2273 | - | |||||||||||||
2274 | stringAddC(QLatin1Char(']')); | - | ||||||||||||
2275 | } else { | - | ||||||||||||
2276 | - | |||||||||||||
2277 | stringAddC(QLatin1Char(']')); | - | ||||||||||||
2278 | stringAddC(QLatin1Char(']')); | - | ||||||||||||
2279 | } | - | ||||||||||||
2280 | } | - | ||||||||||||
2281 | break; | - | ||||||||||||
2282 | case Done: | - | ||||||||||||
2283 | - | |||||||||||||
2284 | if (contentHnd) { | - | ||||||||||||
2285 | if (contentCharDataRead) { | - | ||||||||||||
2286 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) { | - | ||||||||||||
2287 | if (!contentHnd->characters(string())) { | - | ||||||||||||
2288 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2289 | return false; | - | ||||||||||||
2290 | } | - | ||||||||||||
2291 | } | - | ||||||||||||
2292 | } | - | ||||||||||||
2293 | } | - | ||||||||||||
2294 | - | |||||||||||||
2295 | return true; | - | ||||||||||||
2296 | case -1: | - | ||||||||||||
2297 | - | |||||||||||||
2298 | reportParseError(QLatin1String("error occurred while parsing content")); | - | ||||||||||||
2299 | return false; | - | ||||||||||||
2300 | } | - | ||||||||||||
2301 | - | |||||||||||||
2302 | - | |||||||||||||
2303 | - | |||||||||||||
2304 | if (atEnd()) { | - | ||||||||||||
2305 | unexpectedEof(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2306 | return false; | - | ||||||||||||
2307 | } | - | ||||||||||||
2308 | if (c.row()) { | - | ||||||||||||
2309 | input = InpUnknown; | - | ||||||||||||
2310 | } else { | - | ||||||||||||
2311 | input = mapCLT2FSMChar[charLookupTable[c.cell()]]; | - | ||||||||||||
2312 | } | - | ||||||||||||
2313 | state = table[state][input]; | - | ||||||||||||
2314 | - | |||||||||||||
2315 | switch (state) { | - | ||||||||||||
2316 | case Init: | - | ||||||||||||
2317 | - | |||||||||||||
2318 | next(); | - | ||||||||||||
2319 | break; | - | ||||||||||||
2320 | case ChD: | - | ||||||||||||
2321 | - | |||||||||||||
2322 | if (!contentCharDataRead) { | - | ||||||||||||
2323 | contentCharDataRead = true; | - | ||||||||||||
2324 | stringClear(); | - | ||||||||||||
2325 | } | - | ||||||||||||
2326 | stringAddC(); | - | ||||||||||||
2327 | if (reportEntities) { | - | ||||||||||||
2328 | if (!reportEndEntities()) | - | ||||||||||||
2329 | return false; | - | ||||||||||||
2330 | } | - | ||||||||||||
2331 | next(); | - | ||||||||||||
2332 | break; | - | ||||||||||||
2333 | case ChD1: | - | ||||||||||||
2334 | - | |||||||||||||
2335 | if (!contentCharDataRead) { | - | ||||||||||||
2336 | contentCharDataRead = true; | - | ||||||||||||
2337 | stringClear(); | - | ||||||||||||
2338 | } | - | ||||||||||||
2339 | stringAddC(); | - | ||||||||||||
2340 | if (reportEntities) { | - | ||||||||||||
2341 | if (!reportEndEntities()) | - | ||||||||||||
2342 | return false; | - | ||||||||||||
2343 | } | - | ||||||||||||
2344 | next(); | - | ||||||||||||
2345 | break; | - | ||||||||||||
2346 | case ChD2: | - | ||||||||||||
2347 | stringAddC(); | - | ||||||||||||
2348 | if (reportEntities) { | - | ||||||||||||
2349 | if (!reportEndEntities()) | - | ||||||||||||
2350 | return false; | - | ||||||||||||
2351 | } | - | ||||||||||||
2352 | next(); | - | ||||||||||||
2353 | break; | - | ||||||||||||
2354 | case Ref: | - | ||||||||||||
2355 | if (!contentCharDataRead) { | - | ||||||||||||
2356 | - | |||||||||||||
2357 | stringClear(); | - | ||||||||||||
2358 | parseReference_context = InContent; | - | ||||||||||||
2359 | if (!parseReference()) { | - | ||||||||||||
2360 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2361 | return false; | - | ||||||||||||
2362 | } | - | ||||||||||||
2363 | } else { | - | ||||||||||||
2364 | if (reportEntities) { | - | ||||||||||||
2365 | - | |||||||||||||
2366 | if (contentHnd) { | - | ||||||||||||
2367 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) { | - | ||||||||||||
2368 | if (!contentHnd->characters(string())) { | - | ||||||||||||
2369 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2370 | return false; | - | ||||||||||||
2371 | } | - | ||||||||||||
2372 | } | - | ||||||||||||
2373 | } | - | ||||||||||||
2374 | stringClear(); | - | ||||||||||||
2375 | } | - | ||||||||||||
2376 | parseReference_context = InContent; | - | ||||||||||||
2377 | if (!parseReference()) { | - | ||||||||||||
2378 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2379 | return false; | - | ||||||||||||
2380 | } | - | ||||||||||||
2381 | } | - | ||||||||||||
2382 | break; | - | ||||||||||||
2383 | case Lt: | - | ||||||||||||
2384 | - | |||||||||||||
2385 | if (contentHnd) { | - | ||||||||||||
2386 | if (contentCharDataRead) { | - | ||||||||||||
2387 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) { | - | ||||||||||||
2388 | if (!contentHnd->characters(string())) { | - | ||||||||||||
2389 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2390 | return false; | - | ||||||||||||
2391 | } | - | ||||||||||||
2392 | } | - | ||||||||||||
2393 | } | - | ||||||||||||
2394 | } | - | ||||||||||||
2395 | contentCharDataRead = false; | - | ||||||||||||
2396 | next(); | - | ||||||||||||
2397 | break; | - | ||||||||||||
2398 | case PInstr: | - | ||||||||||||
2399 | case PInstrR: | - | ||||||||||||
2400 | parsePI_xmldecl = false; | - | ||||||||||||
2401 | if (!parsePI()) { | - | ||||||||||||
2402 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2403 | return false; | - | ||||||||||||
2404 | } | - | ||||||||||||
2405 | break; | - | ||||||||||||
2406 | case Elem: | - | ||||||||||||
2407 | if (!parseElement()) { | - | ||||||||||||
2408 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2409 | return false; | - | ||||||||||||
2410 | } | - | ||||||||||||
2411 | break; | - | ||||||||||||
2412 | case Em: | - | ||||||||||||
2413 | next(); | - | ||||||||||||
2414 | break; | - | ||||||||||||
2415 | case Com: | - | ||||||||||||
2416 | case ComR: | - | ||||||||||||
2417 | if (!parseComment()) { | - | ||||||||||||
2418 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2419 | return false; | - | ||||||||||||
2420 | } | - | ||||||||||||
2421 | break; | - | ||||||||||||
2422 | case CDS: | - | ||||||||||||
2423 | parseString_s = QLatin1String("[CDATA["); | - | ||||||||||||
2424 | if (!parseString()) { | - | ||||||||||||
2425 | parseFailed(&QXmlSimpleReaderPrivate::parseContent, state); | - | ||||||||||||
2426 | return false; | - | ||||||||||||
2427 | } | - | ||||||||||||
2428 | break; | - | ||||||||||||
2429 | case CDS1: | - | ||||||||||||
2430 | stringAddC(); | - | ||||||||||||
2431 | next(); | - | ||||||||||||
2432 | break; | - | ||||||||||||
2433 | case CDS2: | - | ||||||||||||
2434 | - | |||||||||||||
2435 | next(); | - | ||||||||||||
2436 | break; | - | ||||||||||||
2437 | case CDS3: | - | ||||||||||||
2438 | - | |||||||||||||
2439 | next(); | - | ||||||||||||
2440 | break; | - | ||||||||||||
2441 | } | - | ||||||||||||
2442 | } | - | ||||||||||||
2443 | return false; | - | ||||||||||||
2444 | } | - | ||||||||||||
2445 | - | |||||||||||||
2446 | bool QXmlSimpleReaderPrivate::reportEndEntities() | - | ||||||||||||
2447 | { | - | ||||||||||||
2448 | int count = (int)xmlRefStack.count(); | - | ||||||||||||
2449 | while (count != 0 && xmlRefStack.top().isEmpty()) { | - | ||||||||||||
2450 | if (contentHnd) { | - | ||||||||||||
2451 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) { | - | ||||||||||||
2452 | if (!contentHnd->characters(string())) { | - | ||||||||||||
2453 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2454 | return false; | - | ||||||||||||
2455 | } | - | ||||||||||||
2456 | } | - | ||||||||||||
2457 | } | - | ||||||||||||
2458 | stringClear(); | - | ||||||||||||
2459 | if (lexicalHnd) { | - | ||||||||||||
2460 | if (!lexicalHnd->endEntity(xmlRefStack.top().name)) { | - | ||||||||||||
2461 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
2462 | return false; | - | ||||||||||||
2463 | } | - | ||||||||||||
2464 | } | - | ||||||||||||
2465 | xmlRefStack.pop_back(); | - | ||||||||||||
2466 | count--; | - | ||||||||||||
2467 | } | - | ||||||||||||
2468 | return true; | - | ||||||||||||
2469 | } | - | ||||||||||||
2470 | - | |||||||||||||
2471 | - | |||||||||||||
2472 | - | |||||||||||||
2473 | - | |||||||||||||
2474 | bool QXmlSimpleReaderPrivate::parseMisc() | - | ||||||||||||
2475 | { | - | ||||||||||||
2476 | const signed char Init = 0; | - | ||||||||||||
2477 | const signed char Lt = 1; | - | ||||||||||||
2478 | const signed char Comment = 2; | - | ||||||||||||
2479 | const signed char eatWS = 3; | - | ||||||||||||
2480 | const signed char PInstr = 4; | - | ||||||||||||
2481 | const signed char Comment2 = 5; | - | ||||||||||||
2482 | - | |||||||||||||
2483 | const signed char InpWs = 0; | - | ||||||||||||
2484 | const signed char InpLt = 1; | - | ||||||||||||
2485 | const signed char InpQm = 2; | - | ||||||||||||
2486 | const signed char InpEm = 3; | - | ||||||||||||
2487 | const signed char InpUnknown = 4; | - | ||||||||||||
2488 | - | |||||||||||||
2489 | static const signed char table[3][5] = { | - | ||||||||||||
2490 | - | |||||||||||||
2491 | { eatWS, Lt, -1, -1, -1 }, | - | ||||||||||||
2492 | { -1, -1, PInstr,Comment, -1 }, | - | ||||||||||||
2493 | { -1, -1, -1, -1, Comment2 } | - | ||||||||||||
2494 | }; | - | ||||||||||||
2495 | signed char state; | - | ||||||||||||
2496 | signed char input; | - | ||||||||||||
2497 | - | |||||||||||||
2498 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
2499 | state = Init; | - | ||||||||||||
2500 | } else { | - | ||||||||||||
2501 | state = parseStack->pop().state; | - | ||||||||||||
2502 | - | |||||||||||||
2503 | - | |||||||||||||
2504 | - | |||||||||||||
2505 | if (!parseStack->isEmpty()) { | - | ||||||||||||
2506 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
2507 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
2508 | parseStack->pop(); | - | ||||||||||||
2509 | - | |||||||||||||
2510 | - | |||||||||||||
2511 | - | |||||||||||||
2512 | } | - | ||||||||||||
2513 | if (!(this->*function)()) { | - | ||||||||||||
2514 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||
2515 | return false; | - | ||||||||||||
2516 | } | - | ||||||||||||
2517 | } | - | ||||||||||||
2518 | } | - | ||||||||||||
2519 | - | |||||||||||||
2520 | for (;;) { | - | ||||||||||||
2521 | switch (state) { | - | ||||||||||||
2522 | case eatWS: | - | ||||||||||||
2523 | return true; | - | ||||||||||||
2524 | case PInstr: | - | ||||||||||||
2525 | if (contentHnd) { | - | ||||||||||||
2526 | if (!contentHnd->processingInstruction(name(),string())) { | - | ||||||||||||
2527 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
2528 | return false; | - | ||||||||||||
2529 | } | - | ||||||||||||
2530 | } | - | ||||||||||||
2531 | return true; | - | ||||||||||||
2532 | case Comment2: | - | ||||||||||||
2533 | if (lexicalHnd) { | - | ||||||||||||
2534 | if (!lexicalHnd->comment(string())) { | - | ||||||||||||
2535 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
2536 | return false; | - | ||||||||||||
2537 | } | - | ||||||||||||
2538 | } | - | ||||||||||||
2539 | return true; | - | ||||||||||||
2540 | case -1: | - | ||||||||||||
2541 | - | |||||||||||||
2542 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
2543 | return false; | - | ||||||||||||
2544 | } | - | ||||||||||||
2545 | - | |||||||||||||
2546 | if (atEnd()) { | - | ||||||||||||
2547 | unexpectedEof(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||
2548 | return false; | - | ||||||||||||
2549 | } | - | ||||||||||||
2550 | if (is_S(c)) { | - | ||||||||||||
2551 | input = InpWs; | - | ||||||||||||
2552 | } else if (c == QLatin1Char('<')) { | - | ||||||||||||
2553 | input = InpLt; | - | ||||||||||||
2554 | } else if (c == QLatin1Char('?')) { | - | ||||||||||||
2555 | input = InpQm; | - | ||||||||||||
2556 | } else if (c == QLatin1Char('!')) { | - | ||||||||||||
2557 | input = InpEm; | - | ||||||||||||
2558 | } else { | - | ||||||||||||
2559 | input = InpUnknown; | - | ||||||||||||
2560 | } | - | ||||||||||||
2561 | state = table[state][input]; | - | ||||||||||||
2562 | - | |||||||||||||
2563 | switch (state) { | - | ||||||||||||
2564 | case eatWS: | - | ||||||||||||
2565 | if (!eat_ws()) { | - | ||||||||||||
2566 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||
2567 | return false; | - | ||||||||||||
2568 | } | - | ||||||||||||
2569 | break; | - | ||||||||||||
2570 | case Lt: | - | ||||||||||||
2571 | next(); | - | ||||||||||||
2572 | break; | - | ||||||||||||
2573 | case PInstr: | - | ||||||||||||
2574 | parsePI_xmldecl = false; | - | ||||||||||||
2575 | if (!parsePI()) { | - | ||||||||||||
2576 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||
2577 | return false; | - | ||||||||||||
2578 | } | - | ||||||||||||
2579 | break; | - | ||||||||||||
2580 | case Comment: | - | ||||||||||||
2581 | next(); | - | ||||||||||||
2582 | break; | - | ||||||||||||
2583 | case Comment2: | - | ||||||||||||
2584 | if (!parseComment()) { | - | ||||||||||||
2585 | parseFailed(&QXmlSimpleReaderPrivate::parseMisc, state); | - | ||||||||||||
2586 | return false; | - | ||||||||||||
2587 | } | - | ||||||||||||
2588 | break; | - | ||||||||||||
2589 | } | - | ||||||||||||
2590 | } | - | ||||||||||||
2591 | return false; | - | ||||||||||||
2592 | } | - | ||||||||||||
2593 | bool QXmlSimpleReaderPrivate::parsePI() | - | ||||||||||||
2594 | { | - | ||||||||||||
2595 | const signed char Init = 0; | - | ||||||||||||
2596 | const signed char QmI = 1; | - | ||||||||||||
2597 | const signed char Name = 2; | - | ||||||||||||
2598 | const signed char XMLDecl = 3; | - | ||||||||||||
2599 | const signed char Ws1 = 4; | - | ||||||||||||
2600 | const signed char PInstr = 5; | - | ||||||||||||
2601 | const signed char Ws2 = 6; | - | ||||||||||||
2602 | const signed char Version = 7; | - | ||||||||||||
2603 | const signed char Ws3 = 8; | - | ||||||||||||
2604 | const signed char EorSD = 9; | - | ||||||||||||
2605 | const signed char Ws4 = 10; | - | ||||||||||||
2606 | const signed char SD = 11; | - | ||||||||||||
2607 | const signed char Ws5 = 12; | - | ||||||||||||
2608 | const signed char ADone = 13; | - | ||||||||||||
2609 | const signed char Char = 14; | - | ||||||||||||
2610 | const signed char Qm = 15; | - | ||||||||||||
2611 | const signed char Done = 16; | - | ||||||||||||
2612 | - | |||||||||||||
2613 | const signed char InpWs = 0; | - | ||||||||||||
2614 | const signed char InpNameBe = 1; | - | ||||||||||||
2615 | const signed char InpGt = 2; | - | ||||||||||||
2616 | const signed char InpQm = 3; | - | ||||||||||||
2617 | const signed char InpUnknown = 4; | - | ||||||||||||
2618 | - | |||||||||||||
2619 | static const signed char table[16][5] = { | - | ||||||||||||
2620 | - | |||||||||||||
2621 | { -1, -1, -1, QmI, -1 }, | - | ||||||||||||
2622 | { -1, Name, -1, -1, -1 }, | - | ||||||||||||
2623 | { -1, -1, -1, -1, -1 }, | - | ||||||||||||
2624 | { Ws1, -1, -1, -1, -1 }, | - | ||||||||||||
2625 | { -1, Version, -1, -1, -1 }, | - | ||||||||||||
2626 | { Ws2, -1, -1, Qm, -1 }, | - | ||||||||||||
2627 | { Char, Char, Char, Qm, Char }, | - | ||||||||||||
2628 | { Ws3, -1, -1, ADone, -1 }, | - | ||||||||||||
2629 | { -1, EorSD, -1, ADone, -1 }, | - | ||||||||||||
2630 | { Ws4, -1, -1, ADone, -1 }, | - | ||||||||||||
2631 | { -1, SD, -1, ADone, -1 }, | - | ||||||||||||
2632 | { Ws5, -1, -1, ADone, -1 }, | - | ||||||||||||
2633 | { -1, -1, -1, ADone, -1 }, | - | ||||||||||||
2634 | { -1, -1, Done, -1, -1 }, | - | ||||||||||||
2635 | { Char, Char, Char, Qm, Char }, | - | ||||||||||||
2636 | { Char, Char, Done, Qm, Char }, | - | ||||||||||||
2637 | }; | - | ||||||||||||
2638 | signed char state; | - | ||||||||||||
2639 | signed char input; | - | ||||||||||||
2640 | - | |||||||||||||
2641 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
2642 | state = Init; | - | ||||||||||||
2643 | } else { | - | ||||||||||||
2644 | state = parseStack->pop().state; | - | ||||||||||||
2645 | - | |||||||||||||
2646 | - | |||||||||||||
2647 | - | |||||||||||||
2648 | if (!parseStack->isEmpty()) { | - | ||||||||||||
2649 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
2650 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
2651 | parseStack->pop(); | - | ||||||||||||
2652 | - | |||||||||||||
2653 | - | |||||||||||||
2654 | - | |||||||||||||
2655 | } | - | ||||||||||||
2656 | if (!(this->*function)()) { | - | ||||||||||||
2657 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2658 | return false; | - | ||||||||||||
2659 | } | - | ||||||||||||
2660 | } | - | ||||||||||||
2661 | } | - | ||||||||||||
2662 | - | |||||||||||||
2663 | for (;;) { | - | ||||||||||||
2664 | switch (state) { | - | ||||||||||||
2665 | case Name: | - | ||||||||||||
2666 | - | |||||||||||||
2667 | - | |||||||||||||
2668 | if (name().toLower() == QLatin1String("xml")) { | - | ||||||||||||
2669 | if (parsePI_xmldecl && name() == QLatin1String("xml")) { | - | ||||||||||||
2670 | state = XMLDecl; | - | ||||||||||||
2671 | } else { | - | ||||||||||||
2672 | reportParseError(QLatin1String("invalid name for processing instruction")); | - | ||||||||||||
2673 | return false; | - | ||||||||||||
2674 | } | - | ||||||||||||
2675 | } else { | - | ||||||||||||
2676 | state = PInstr; | - | ||||||||||||
2677 | stringClear(); | - | ||||||||||||
2678 | } | - | ||||||||||||
2679 | break; | - | ||||||||||||
2680 | case Version: | - | ||||||||||||
2681 | - | |||||||||||||
2682 | if (name() != QLatin1String("version")) { | - | ||||||||||||
2683 | reportParseError(QLatin1String("version expected while reading the XML declaration")); | - | ||||||||||||
2684 | return false; | - | ||||||||||||
2685 | } | - | ||||||||||||
2686 | xmlVersion = string(); | - | ||||||||||||
2687 | break; | - | ||||||||||||
2688 | case EorSD: | - | ||||||||||||
2689 | - | |||||||||||||
2690 | if (name() == QLatin1String("standalone")) { | - | ||||||||||||
2691 | if (string()== QLatin1String("yes")) { | - | ||||||||||||
2692 | standalone = QXmlSimpleReaderPrivate::Yes; | - | ||||||||||||
2693 | } else if (string() == QLatin1String("no")) { | - | ||||||||||||
2694 | standalone = QXmlSimpleReaderPrivate::No; | - | ||||||||||||
2695 | } else { | - | ||||||||||||
2696 | reportParseError(QLatin1String("wrong value for standalone declaration")); | - | ||||||||||||
2697 | return false; | - | ||||||||||||
2698 | } | - | ||||||||||||
2699 | } else if (name() == QLatin1String("encoding")) { | - | ||||||||||||
2700 | encoding = string(); | - | ||||||||||||
2701 | } else { | - | ||||||||||||
2702 | reportParseError(QLatin1String("encoding declaration or standalone declaration expected while reading the XML declaration")); | - | ||||||||||||
2703 | return false; | - | ||||||||||||
2704 | } | - | ||||||||||||
2705 | break; | - | ||||||||||||
2706 | case SD: | - | ||||||||||||
2707 | if (name() != QLatin1String("standalone")) { | - | ||||||||||||
2708 | reportParseError(QLatin1String("standalone declaration expected while reading the XML declaration")); | - | ||||||||||||
2709 | return false; | - | ||||||||||||
2710 | } | - | ||||||||||||
2711 | if (string() == QLatin1String("yes")) { | - | ||||||||||||
2712 | standalone = QXmlSimpleReaderPrivate::Yes; | - | ||||||||||||
2713 | } else if (string() == QLatin1String("no")) { | - | ||||||||||||
2714 | standalone = QXmlSimpleReaderPrivate::No; | - | ||||||||||||
2715 | } else { | - | ||||||||||||
2716 | reportParseError(QLatin1String("wrong value for standalone declaration")); | - | ||||||||||||
2717 | return false; | - | ||||||||||||
2718 | } | - | ||||||||||||
2719 | break; | - | ||||||||||||
2720 | case Qm: | - | ||||||||||||
2721 | - | |||||||||||||
2722 | if (!atEnd() && c != QLatin1Char('>')) | - | ||||||||||||
2723 | stringAddC(QLatin1Char('?')); | - | ||||||||||||
2724 | break; | - | ||||||||||||
2725 | case Done: | - | ||||||||||||
2726 | return true; | - | ||||||||||||
2727 | case -1: | - | ||||||||||||
2728 | - | |||||||||||||
2729 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
2730 | return false; | - | ||||||||||||
2731 | } | - | ||||||||||||
2732 | - | |||||||||||||
2733 | if (atEnd()) { | - | ||||||||||||
2734 | unexpectedEof(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2735 | return false; | - | ||||||||||||
2736 | } | - | ||||||||||||
2737 | if (is_S(c)) { | - | ||||||||||||
2738 | input = InpWs; | - | ||||||||||||
2739 | } else if (determineNameChar(c) == NameBeginning) { | - | ||||||||||||
2740 | input = InpNameBe; | - | ||||||||||||
2741 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
2742 | input = InpGt; | - | ||||||||||||
2743 | } else if (c == QLatin1Char('?')) { | - | ||||||||||||
2744 | input = InpQm; | - | ||||||||||||
2745 | } else { | - | ||||||||||||
2746 | input = InpUnknown; | - | ||||||||||||
2747 | } | - | ||||||||||||
2748 | state = table[state][input]; | - | ||||||||||||
2749 | - | |||||||||||||
2750 | switch (state) { | - | ||||||||||||
2751 | case QmI: | - | ||||||||||||
2752 | next(); | - | ||||||||||||
2753 | break; | - | ||||||||||||
2754 | case Name: | - | ||||||||||||
2755 | parseName_useRef = false; | - | ||||||||||||
2756 | if (!parseName()) { | - | ||||||||||||
2757 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2758 | return false; | - | ||||||||||||
2759 | } | - | ||||||||||||
2760 | break; | - | ||||||||||||
2761 | case Ws1: | - | ||||||||||||
2762 | case Ws2: | - | ||||||||||||
2763 | case Ws3: | - | ||||||||||||
2764 | case Ws4: | - | ||||||||||||
2765 | case Ws5: | - | ||||||||||||
2766 | if (!eat_ws()) { | - | ||||||||||||
2767 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2768 | return false; | - | ||||||||||||
2769 | } | - | ||||||||||||
2770 | break; | - | ||||||||||||
2771 | case Version: | - | ||||||||||||
2772 | if (!parseAttribute()) { | - | ||||||||||||
2773 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2774 | return false; | - | ||||||||||||
2775 | } | - | ||||||||||||
2776 | break; | - | ||||||||||||
2777 | case EorSD: | - | ||||||||||||
2778 | if (!parseAttribute()) { | - | ||||||||||||
2779 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2780 | return false; | - | ||||||||||||
2781 | } | - | ||||||||||||
2782 | break; | - | ||||||||||||
2783 | case SD: | - | ||||||||||||
2784 | - | |||||||||||||
2785 | if (standalone != QXmlSimpleReaderPrivate::Unknown) { | - | ||||||||||||
2786 | - | |||||||||||||
2787 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
2788 | return false; | - | ||||||||||||
2789 | } | - | ||||||||||||
2790 | if (!parseAttribute()) { | - | ||||||||||||
2791 | parseFailed(&QXmlSimpleReaderPrivate::parsePI, state); | - | ||||||||||||
2792 | return false; | - | ||||||||||||
2793 | } | - | ||||||||||||
2794 | break; | - | ||||||||||||
2795 | case ADone: | - | ||||||||||||
2796 | next(); | - | ||||||||||||
2797 | break; | - | ||||||||||||
2798 | case Char: | - | ||||||||||||
2799 | stringAddC(); | - | ||||||||||||
2800 | next(); | - | ||||||||||||
2801 | break; | - | ||||||||||||
2802 | case Qm: | - | ||||||||||||
2803 | - | |||||||||||||
2804 | next(); | - | ||||||||||||
2805 | break; | - | ||||||||||||
2806 | case Done: | - | ||||||||||||
2807 | next(); | - | ||||||||||||
2808 | break; | - | ||||||||||||
2809 | } | - | ||||||||||||
2810 | } | - | ||||||||||||
2811 | return false; | - | ||||||||||||
2812 | } | - | ||||||||||||
2813 | bool QXmlSimpleReaderPrivate::parseDoctype() | - | ||||||||||||
2814 | { | - | ||||||||||||
2815 | const signed char Init = 0; | - | ||||||||||||
2816 | const signed char Doctype = 1; | - | ||||||||||||
2817 | const signed char Ws1 = 2; | - | ||||||||||||
2818 | const signed char Doctype2 = 3; | - | ||||||||||||
2819 | const signed char Ws2 = 4; | - | ||||||||||||
2820 | const signed char Sys = 5; | - | ||||||||||||
2821 | const signed char Ws3 = 6; | - | ||||||||||||
2822 | const signed char MP = 7; | - | ||||||||||||
2823 | const signed char MPR = 8; | - | ||||||||||||
2824 | const signed char PER = 9; | - | ||||||||||||
2825 | const signed char Mup = 10; | - | ||||||||||||
2826 | const signed char Ws4 = 11; | - | ||||||||||||
2827 | const signed char MPE = 12; | - | ||||||||||||
2828 | const signed char Done = 13; | - | ||||||||||||
2829 | - | |||||||||||||
2830 | const signed char InpWs = 0; | - | ||||||||||||
2831 | const signed char InpD = 1; | - | ||||||||||||
2832 | const signed char InpS = 2; | - | ||||||||||||
2833 | const signed char InpOB = 3; | - | ||||||||||||
2834 | const signed char InpCB = 4; | - | ||||||||||||
2835 | const signed char InpPer = 5; | - | ||||||||||||
2836 | const signed char InpGt = 6; | - | ||||||||||||
2837 | const signed char InpUnknown = 7; | - | ||||||||||||
2838 | - | |||||||||||||
2839 | static const signed char table[13][8] = { | - | ||||||||||||
2840 | - | |||||||||||||
2841 | { -1, Doctype, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
2842 | { Ws1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
2843 | { -1, Doctype2, Doctype2, -1, -1, -1, -1, Doctype2 }, | - | ||||||||||||
2844 | { Ws2, -1, Sys, MP, -1, -1, Done, -1 }, | - | ||||||||||||
2845 | { -1, -1, Sys, MP, -1, -1, Done, -1 }, | - | ||||||||||||
2846 | { Ws3, -1, -1, MP, -1, -1, Done, -1 }, | - | ||||||||||||
2847 | { -1, -1, -1, MP, -1, -1, Done, -1 }, | - | ||||||||||||
2848 | { -1, -1, -1, -1, MPE, PER, -1, Mup }, | - | ||||||||||||
2849 | { -1, -1, -1, -1, MPE, PER, -1, Mup }, | - | ||||||||||||
2850 | { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, | - | ||||||||||||
2851 | { Ws4, -1, -1, -1, MPE, PER, -1, Mup }, | - | ||||||||||||
2852 | { -1, -1, -1, -1, MPE, PER, -1, Mup }, | - | ||||||||||||
2853 | { -1, -1, -1, -1, -1, -1, Done, -1 } | - | ||||||||||||
2854 | }; | - | ||||||||||||
2855 | signed char state; | - | ||||||||||||
2856 | signed char input; | - | ||||||||||||
2857 | - | |||||||||||||
2858 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
2859 | startDTDwasReported = false; | - | ||||||||||||
2860 | systemId.clear(); | - | ||||||||||||
2861 | publicId.clear(); | - | ||||||||||||
2862 | state = Init; | - | ||||||||||||
2863 | } else { | - | ||||||||||||
2864 | state = parseStack->pop().state; | - | ||||||||||||
2865 | - | |||||||||||||
2866 | - | |||||||||||||
2867 | - | |||||||||||||
2868 | if (!parseStack->isEmpty()) { | - | ||||||||||||
2869 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
2870 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
2871 | parseStack->pop(); | - | ||||||||||||
2872 | - | |||||||||||||
2873 | - | |||||||||||||
2874 | - | |||||||||||||
2875 | } | - | ||||||||||||
2876 | if (!(this->*function)()) { | - | ||||||||||||
2877 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2878 | return false; | - | ||||||||||||
2879 | } | - | ||||||||||||
2880 | } | - | ||||||||||||
2881 | } | - | ||||||||||||
2882 | - | |||||||||||||
2883 | for (;;) { | - | ||||||||||||
2884 | switch (state) { | - | ||||||||||||
2885 | case Doctype2: | - | ||||||||||||
2886 | doctype = name(); | - | ||||||||||||
2887 | break; | - | ||||||||||||
2888 | case MP: | - | ||||||||||||
2889 | if (!startDTDwasReported && lexicalHnd ) { | - | ||||||||||||
2890 | startDTDwasReported = true; | - | ||||||||||||
2891 | if (!lexicalHnd->startDTD(doctype, publicId, systemId)) { | - | ||||||||||||
2892 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
2893 | return false; | - | ||||||||||||
2894 | } | - | ||||||||||||
2895 | } | - | ||||||||||||
2896 | state = MPR; | - | ||||||||||||
2897 | break; | - | ||||||||||||
2898 | case Done: | - | ||||||||||||
2899 | return true; | - | ||||||||||||
2900 | case -1: | - | ||||||||||||
2901 | - | |||||||||||||
2902 | reportParseError(QLatin1String("error occurred while parsing document type definition")); | - | ||||||||||||
2903 | return false; | - | ||||||||||||
2904 | } | - | ||||||||||||
2905 | - | |||||||||||||
2906 | if (atEnd()) { | - | ||||||||||||
2907 | unexpectedEof(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2908 | return false; | - | ||||||||||||
2909 | } | - | ||||||||||||
2910 | if (is_S(c)) { | - | ||||||||||||
2911 | input = InpWs; | - | ||||||||||||
2912 | } else if (c == QLatin1Char('D')) { | - | ||||||||||||
2913 | input = InpD; | - | ||||||||||||
2914 | } else if (c == QLatin1Char('S')) { | - | ||||||||||||
2915 | input = InpS; | - | ||||||||||||
2916 | } else if (c == QLatin1Char('P')) { | - | ||||||||||||
2917 | input = InpS; | - | ||||||||||||
2918 | } else if (c == QLatin1Char('[')) { | - | ||||||||||||
2919 | input = InpOB; | - | ||||||||||||
2920 | } else if (c == QLatin1Char(']')) { | - | ||||||||||||
2921 | input = InpCB; | - | ||||||||||||
2922 | } else if (c == QLatin1Char('%')) { | - | ||||||||||||
2923 | input = InpPer; | - | ||||||||||||
2924 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
2925 | input = InpGt; | - | ||||||||||||
2926 | } else { | - | ||||||||||||
2927 | input = InpUnknown; | - | ||||||||||||
2928 | } | - | ||||||||||||
2929 | state = table[state][input]; | - | ||||||||||||
2930 | - | |||||||||||||
2931 | switch (state) { | - | ||||||||||||
2932 | case Doctype: | - | ||||||||||||
2933 | parseString_s = QLatin1String("DOCTYPE"); | - | ||||||||||||
2934 | if (!parseString()) { | - | ||||||||||||
2935 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2936 | return false; | - | ||||||||||||
2937 | } | - | ||||||||||||
2938 | break; | - | ||||||||||||
2939 | case Ws1: | - | ||||||||||||
2940 | case Ws2: | - | ||||||||||||
2941 | case Ws3: | - | ||||||||||||
2942 | case Ws4: | - | ||||||||||||
2943 | if (!eat_ws()) { | - | ||||||||||||
2944 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2945 | return false; | - | ||||||||||||
2946 | } | - | ||||||||||||
2947 | break; | - | ||||||||||||
2948 | case Doctype2: | - | ||||||||||||
2949 | parseName_useRef = false; | - | ||||||||||||
2950 | if (!parseName()) { | - | ||||||||||||
2951 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2952 | return false; | - | ||||||||||||
2953 | } | - | ||||||||||||
2954 | break; | - | ||||||||||||
2955 | case Sys: | - | ||||||||||||
2956 | parseExternalID_allowPublicID = false; | - | ||||||||||||
2957 | if (!parseExternalID()) { | - | ||||||||||||
2958 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2959 | return false; | - | ||||||||||||
2960 | } | - | ||||||||||||
2961 | thisPublicId = publicId; | - | ||||||||||||
2962 | thisSystemId = systemId; | - | ||||||||||||
2963 | break; | - | ||||||||||||
2964 | case MP: | - | ||||||||||||
2965 | case MPR: | - | ||||||||||||
2966 | if (!next_eat_ws()) { | - | ||||||||||||
2967 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2968 | return false; | - | ||||||||||||
2969 | } | - | ||||||||||||
2970 | break; | - | ||||||||||||
2971 | case PER: | - | ||||||||||||
2972 | parsePEReference_context = InDTD; | - | ||||||||||||
2973 | if (!parsePEReference()) { | - | ||||||||||||
2974 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2975 | return false; | - | ||||||||||||
2976 | } | - | ||||||||||||
2977 | break; | - | ||||||||||||
2978 | case Mup: | - | ||||||||||||
2979 | if (dtdRecursionLimit > 0 && parameterEntities.size() > dtdRecursionLimit) { | - | ||||||||||||
2980 | reportParseError(QString::fromLatin1( | - | ||||||||||||
2981 | "DTD parsing exceeded recursion limit of %1.").arg(dtdRecursionLimit)); | - | ||||||||||||
2982 | return false; | - | ||||||||||||
2983 | } | - | ||||||||||||
2984 | if (!parseMarkupdecl()) { | - | ||||||||||||
2985 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2986 | return false; | - | ||||||||||||
2987 | } | - | ||||||||||||
2988 | break; | - | ||||||||||||
2989 | case MPE: | - | ||||||||||||
2990 | if (!next_eat_ws()) { | - | ||||||||||||
2991 | parseFailed(&QXmlSimpleReaderPrivate::parseDoctype, state); | - | ||||||||||||
2992 | return false; | - | ||||||||||||
2993 | } | - | ||||||||||||
2994 | break; | - | ||||||||||||
2995 | case Done: | - | ||||||||||||
2996 | if (lexicalHnd) { | - | ||||||||||||
2997 | if (!startDTDwasReported) { | - | ||||||||||||
2998 | startDTDwasReported = true; | - | ||||||||||||
2999 | if (!lexicalHnd->startDTD(doctype, publicId, systemId)) { | - | ||||||||||||
3000 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
3001 | return false; | - | ||||||||||||
3002 | } | - | ||||||||||||
3003 | } | - | ||||||||||||
3004 | if (!lexicalHnd->endDTD()) { | - | ||||||||||||
3005 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
3006 | return false; | - | ||||||||||||
3007 | } | - | ||||||||||||
3008 | } | - | ||||||||||||
3009 | next(); | - | ||||||||||||
3010 | break; | - | ||||||||||||
3011 | } | - | ||||||||||||
3012 | } | - | ||||||||||||
3013 | return false; | - | ||||||||||||
3014 | } | - | ||||||||||||
3015 | - | |||||||||||||
3016 | - | |||||||||||||
3017 | - | |||||||||||||
3018 | - | |||||||||||||
3019 | - | |||||||||||||
3020 | - | |||||||||||||
3021 | bool QXmlSimpleReaderPrivate::parseExternalID() | - | ||||||||||||
3022 | { | - | ||||||||||||
3023 | const signed char Init = 0; | - | ||||||||||||
3024 | const signed char Sys = 1; | - | ||||||||||||
3025 | const signed char SysWS = 2; | - | ||||||||||||
3026 | const signed char SysSQ = 3; | - | ||||||||||||
3027 | const signed char SysSQ2 = 4; | - | ||||||||||||
3028 | const signed char SysDQ = 5; | - | ||||||||||||
3029 | const signed char SysDQ2 = 6; | - | ||||||||||||
3030 | const signed char Pub = 7; | - | ||||||||||||
3031 | const signed char PubWS = 8; | - | ||||||||||||
3032 | const signed char PubSQ = 9; | - | ||||||||||||
3033 | const signed char PubSQ2 = 10; | - | ||||||||||||
3034 | const signed char PubDQ = 11; | - | ||||||||||||
3035 | const signed char PubDQ2 = 12; | - | ||||||||||||
3036 | const signed char PubE = 13; | - | ||||||||||||
3037 | const signed char PubWS2 = 14; | - | ||||||||||||
3038 | const signed char PDone = 15; | - | ||||||||||||
3039 | const signed char Done = 16; | - | ||||||||||||
3040 | - | |||||||||||||
3041 | const signed char InpSQ = 0; | - | ||||||||||||
3042 | const signed char InpDQ = 1; | - | ||||||||||||
3043 | const signed char InpS = 2; | - | ||||||||||||
3044 | const signed char InpP = 3; | - | ||||||||||||
3045 | const signed char InpWs = 4; | - | ||||||||||||
3046 | const signed char InpUnknown = 5; | - | ||||||||||||
3047 | - | |||||||||||||
3048 | static const signed char table[15][6] = { | - | ||||||||||||
3049 | - | |||||||||||||
3050 | { -1, -1, Sys, Pub, -1, -1 }, | - | ||||||||||||
3051 | { -1, -1, -1, -1, SysWS, -1 }, | - | ||||||||||||
3052 | { SysSQ, SysDQ, -1, -1, -1, -1 }, | - | ||||||||||||
3053 | { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, | - | ||||||||||||
3054 | { Done, SysSQ2, SysSQ2, SysSQ2, SysSQ2, SysSQ2 }, | - | ||||||||||||
3055 | { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, | - | ||||||||||||
3056 | { SysDQ2, Done, SysDQ2, SysDQ2, SysDQ2, SysDQ2 }, | - | ||||||||||||
3057 | { -1, -1, -1, -1, PubWS, -1 }, | - | ||||||||||||
3058 | { PubSQ, PubDQ, -1, -1, -1, -1 }, | - | ||||||||||||
3059 | { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, | - | ||||||||||||
3060 | { PubE, -1, PubSQ2, PubSQ2, PubSQ2, PubSQ2 }, | - | ||||||||||||
3061 | { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, | - | ||||||||||||
3062 | { -1, PubE, PubDQ2, PubDQ2, PubDQ2, PubDQ2 }, | - | ||||||||||||
3063 | { PDone, PDone, PDone, PDone, PubWS2, PDone }, | - | ||||||||||||
3064 | { SysSQ, SysDQ, PDone, PDone, PDone, PDone } | - | ||||||||||||
3065 | }; | - | ||||||||||||
3066 | signed char state; | - | ||||||||||||
3067 | signed char input; | - | ||||||||||||
3068 | - | |||||||||||||
3069 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
3070 | systemId.clear(); | - | ||||||||||||
3071 | publicId.clear(); | - | ||||||||||||
3072 | state = Init; | - | ||||||||||||
3073 | } else { | - | ||||||||||||
3074 | state = parseStack->pop().state; | - | ||||||||||||
3075 | - | |||||||||||||
3076 | - | |||||||||||||
3077 | - | |||||||||||||
3078 | if (!parseStack->isEmpty()) { | - | ||||||||||||
3079 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
3080 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
3081 | parseStack->pop(); | - | ||||||||||||
3082 | - | |||||||||||||
3083 | - | |||||||||||||
3084 | - | |||||||||||||
3085 | } | - | ||||||||||||
3086 | if (!(this->*function)()) { | - | ||||||||||||
3087 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3088 | return false; | - | ||||||||||||
3089 | } | - | ||||||||||||
3090 | } | - | ||||||||||||
3091 | } | - | ||||||||||||
3092 | - | |||||||||||||
3093 | for (;;) { | - | ||||||||||||
3094 | switch (state) { | - | ||||||||||||
3095 | case PDone: | - | ||||||||||||
3096 | if (parseExternalID_allowPublicID) { | - | ||||||||||||
3097 | publicId = string(); | - | ||||||||||||
3098 | return true; | - | ||||||||||||
3099 | } else { | - | ||||||||||||
3100 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
3101 | return false; | - | ||||||||||||
3102 | } | - | ||||||||||||
3103 | case Done: | - | ||||||||||||
3104 | return true; | - | ||||||||||||
3105 | case -1: | - | ||||||||||||
3106 | - | |||||||||||||
3107 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
3108 | return false; | - | ||||||||||||
3109 | } | - | ||||||||||||
3110 | - | |||||||||||||
3111 | if (atEnd()) { | - | ||||||||||||
3112 | unexpectedEof(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3113 | return false; | - | ||||||||||||
3114 | } | - | ||||||||||||
3115 | if (is_S(c)) { | - | ||||||||||||
3116 | input = InpWs; | - | ||||||||||||
3117 | } else if (c == QLatin1Char('\'')) { | - | ||||||||||||
3118 | input = InpSQ; | - | ||||||||||||
3119 | } else if (c == QLatin1Char('"')) { | - | ||||||||||||
3120 | input = InpDQ; | - | ||||||||||||
3121 | } else if (c == QLatin1Char('S')) { | - | ||||||||||||
3122 | input = InpS; | - | ||||||||||||
3123 | } else if (c == QLatin1Char('P')) { | - | ||||||||||||
3124 | input = InpP; | - | ||||||||||||
3125 | } else { | - | ||||||||||||
3126 | input = InpUnknown; | - | ||||||||||||
3127 | } | - | ||||||||||||
3128 | state = table[state][input]; | - | ||||||||||||
3129 | - | |||||||||||||
3130 | switch (state) { | - | ||||||||||||
3131 | case Sys: | - | ||||||||||||
3132 | parseString_s = QLatin1String("SYSTEM"); | - | ||||||||||||
3133 | if (!parseString()) { | - | ||||||||||||
3134 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3135 | return false; | - | ||||||||||||
3136 | } | - | ||||||||||||
3137 | break; | - | ||||||||||||
3138 | case SysWS: | - | ||||||||||||
3139 | if (!eat_ws()) { | - | ||||||||||||
3140 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3141 | return false; | - | ||||||||||||
3142 | } | - | ||||||||||||
3143 | break; | - | ||||||||||||
3144 | case SysSQ: | - | ||||||||||||
3145 | case SysDQ: | - | ||||||||||||
3146 | stringClear(); | - | ||||||||||||
3147 | next(); | - | ||||||||||||
3148 | break; | - | ||||||||||||
3149 | case SysSQ2: | - | ||||||||||||
3150 | case SysDQ2: | - | ||||||||||||
3151 | stringAddC(); | - | ||||||||||||
3152 | next(); | - | ||||||||||||
3153 | break; | - | ||||||||||||
3154 | case Pub: | - | ||||||||||||
3155 | parseString_s = QLatin1String("PUBLIC"); | - | ||||||||||||
3156 | if (!parseString()) { | - | ||||||||||||
3157 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3158 | return false; | - | ||||||||||||
3159 | } | - | ||||||||||||
3160 | break; | - | ||||||||||||
3161 | case PubWS: | - | ||||||||||||
3162 | if (!eat_ws()) { | - | ||||||||||||
3163 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3164 | return false; | - | ||||||||||||
3165 | } | - | ||||||||||||
3166 | break; | - | ||||||||||||
3167 | case PubSQ: | - | ||||||||||||
3168 | case PubDQ: | - | ||||||||||||
3169 | stringClear(); | - | ||||||||||||
3170 | next(); | - | ||||||||||||
3171 | break; | - | ||||||||||||
3172 | case PubSQ2: | - | ||||||||||||
3173 | case PubDQ2: | - | ||||||||||||
3174 | stringAddC(); | - | ||||||||||||
3175 | next(); | - | ||||||||||||
3176 | break; | - | ||||||||||||
3177 | case PubE: | - | ||||||||||||
3178 | next(); | - | ||||||||||||
3179 | break; | - | ||||||||||||
3180 | case PubWS2: | - | ||||||||||||
3181 | publicId = string(); | - | ||||||||||||
3182 | if (!eat_ws()) { | - | ||||||||||||
3183 | parseFailed(&QXmlSimpleReaderPrivate::parseExternalID, state); | - | ||||||||||||
3184 | return false; | - | ||||||||||||
3185 | } | - | ||||||||||||
3186 | break; | - | ||||||||||||
3187 | case Done: | - | ||||||||||||
3188 | systemId = string(); | - | ||||||||||||
3189 | next(); | - | ||||||||||||
3190 | break; | - | ||||||||||||
3191 | } | - | ||||||||||||
3192 | } | - | ||||||||||||
3193 | return false; | - | ||||||||||||
3194 | } | - | ||||||||||||
3195 | - | |||||||||||||
3196 | - | |||||||||||||
3197 | - | |||||||||||||
3198 | - | |||||||||||||
3199 | bool QXmlSimpleReaderPrivate::parseMarkupdecl() | - | ||||||||||||
3200 | { | - | ||||||||||||
3201 | const signed char Init = 0; | - | ||||||||||||
3202 | const signed char Lt = 1; | - | ||||||||||||
3203 | const signed char Em = 2; | - | ||||||||||||
3204 | const signed char CE = 3; | - | ||||||||||||
3205 | const signed char Qm = 4; | - | ||||||||||||
3206 | const signed char Dash = 5; | - | ||||||||||||
3207 | const signed char CA = 6; | - | ||||||||||||
3208 | const signed char CEL = 7; | - | ||||||||||||
3209 | const signed char CEN = 8; | - | ||||||||||||
3210 | const signed char CN = 9; | - | ||||||||||||
3211 | const signed char Done = 10; | - | ||||||||||||
3212 | - | |||||||||||||
3213 | const signed char InpLt = 0; | - | ||||||||||||
3214 | const signed char InpQm = 1; | - | ||||||||||||
3215 | const signed char InpEm = 2; | - | ||||||||||||
3216 | const signed char InpDash = 3; | - | ||||||||||||
3217 | const signed char InpA = 4; | - | ||||||||||||
3218 | const signed char InpE = 5; | - | ||||||||||||
3219 | const signed char InpL = 6; | - | ||||||||||||
3220 | const signed char InpN = 7; | - | ||||||||||||
3221 | const signed char InpUnknown = 8; | - | ||||||||||||
3222 | - | |||||||||||||
3223 | static const signed char table[4][9] = { | - | ||||||||||||
3224 | - | |||||||||||||
3225 | { Lt, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3226 | { -1, Qm, Em, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3227 | { -1, -1, -1, Dash, CA, CE, -1, CN, -1 }, | - | ||||||||||||
3228 | { -1, -1, -1, -1, -1, -1, CEL, CEN, -1 } | - | ||||||||||||
3229 | }; | - | ||||||||||||
3230 | signed char state; | - | ||||||||||||
3231 | signed char input; | - | ||||||||||||
3232 | - | |||||||||||||
3233 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
3234 | state = Init; | - | ||||||||||||
3235 | } else { | - | ||||||||||||
3236 | state = parseStack->pop().state; | - | ||||||||||||
3237 | - | |||||||||||||
3238 | - | |||||||||||||
3239 | - | |||||||||||||
3240 | if (!parseStack->isEmpty()) { | - | ||||||||||||
3241 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
3242 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
3243 | parseStack->pop(); | - | ||||||||||||
3244 | - | |||||||||||||
3245 | - | |||||||||||||
3246 | - | |||||||||||||
3247 | } | - | ||||||||||||
3248 | if (!(this->*function)()) { | - | ||||||||||||
3249 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3250 | return false; | - | ||||||||||||
3251 | } | - | ||||||||||||
3252 | } | - | ||||||||||||
3253 | } | - | ||||||||||||
3254 | - | |||||||||||||
3255 | for (;;) { | - | ||||||||||||
3256 | switch (state) { | - | ||||||||||||
3257 | case Qm: | - | ||||||||||||
3258 | if (contentHnd) { | - | ||||||||||||
3259 | if (!contentHnd->processingInstruction(name(),string())) { | - | ||||||||||||
3260 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
3261 | return false; | - | ||||||||||||
3262 | } | - | ||||||||||||
3263 | } | - | ||||||||||||
3264 | return true; | - | ||||||||||||
3265 | case Dash: | - | ||||||||||||
3266 | if (lexicalHnd) { | - | ||||||||||||
3267 | if (!lexicalHnd->comment(string())) { | - | ||||||||||||
3268 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
3269 | return false; | - | ||||||||||||
3270 | } | - | ||||||||||||
3271 | } | - | ||||||||||||
3272 | return true; | - | ||||||||||||
3273 | case CA: | - | ||||||||||||
3274 | return true; | - | ||||||||||||
3275 | case CEL: | - | ||||||||||||
3276 | return true; | - | ||||||||||||
3277 | case CEN: | - | ||||||||||||
3278 | return true; | - | ||||||||||||
3279 | case CN: | - | ||||||||||||
3280 | return true; | - | ||||||||||||
3281 | case Done: | - | ||||||||||||
3282 | return true; | - | ||||||||||||
3283 | case -1: | - | ||||||||||||
3284 | - | |||||||||||||
3285 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
3286 | return false; | - | ||||||||||||
3287 | } | - | ||||||||||||
3288 | - | |||||||||||||
3289 | if (atEnd()) { | - | ||||||||||||
3290 | unexpectedEof(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3291 | return false; | - | ||||||||||||
3292 | } | - | ||||||||||||
3293 | if (c == QLatin1Char('<')) { | - | ||||||||||||
3294 | input = InpLt; | - | ||||||||||||
3295 | } else if (c == QLatin1Char('?')) { | - | ||||||||||||
3296 | input = InpQm; | - | ||||||||||||
3297 | } else if (c == QLatin1Char('!')) { | - | ||||||||||||
3298 | input = InpEm; | - | ||||||||||||
3299 | } else if (c == QLatin1Char('-')) { | - | ||||||||||||
3300 | input = InpDash; | - | ||||||||||||
3301 | } else if (c == QLatin1Char('A')) { | - | ||||||||||||
3302 | input = InpA; | - | ||||||||||||
3303 | } else if (c == QLatin1Char('E')) { | - | ||||||||||||
3304 | input = InpE; | - | ||||||||||||
3305 | } else if (c == QLatin1Char('L')) { | - | ||||||||||||
3306 | input = InpL; | - | ||||||||||||
3307 | } else if (c == QLatin1Char('N')) { | - | ||||||||||||
3308 | input = InpN; | - | ||||||||||||
3309 | } else { | - | ||||||||||||
3310 | input = InpUnknown; | - | ||||||||||||
3311 | } | - | ||||||||||||
3312 | state = table[state][input]; | - | ||||||||||||
3313 | - | |||||||||||||
3314 | switch (state) { | - | ||||||||||||
3315 | case Lt: | - | ||||||||||||
3316 | next(); | - | ||||||||||||
3317 | break; | - | ||||||||||||
3318 | case Em: | - | ||||||||||||
3319 | next(); | - | ||||||||||||
3320 | break; | - | ||||||||||||
3321 | case CE: | - | ||||||||||||
3322 | next(); | - | ||||||||||||
3323 | break; | - | ||||||||||||
3324 | case Qm: | - | ||||||||||||
3325 | parsePI_xmldecl = false; | - | ||||||||||||
3326 | if (!parsePI()) { | - | ||||||||||||
3327 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3328 | return false; | - | ||||||||||||
3329 | } | - | ||||||||||||
3330 | break; | - | ||||||||||||
3331 | case Dash: | - | ||||||||||||
3332 | if (!parseComment()) { | - | ||||||||||||
3333 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3334 | return false; | - | ||||||||||||
3335 | } | - | ||||||||||||
3336 | break; | - | ||||||||||||
3337 | case CA: | - | ||||||||||||
3338 | if (!parseAttlistDecl()) { | - | ||||||||||||
3339 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3340 | return false; | - | ||||||||||||
3341 | } | - | ||||||||||||
3342 | break; | - | ||||||||||||
3343 | case CEL: | - | ||||||||||||
3344 | if (!parseElementDecl()) { | - | ||||||||||||
3345 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3346 | return false; | - | ||||||||||||
3347 | } | - | ||||||||||||
3348 | break; | - | ||||||||||||
3349 | case CEN: | - | ||||||||||||
3350 | if (!parseEntityDecl()) { | - | ||||||||||||
3351 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3352 | return false; | - | ||||||||||||
3353 | } | - | ||||||||||||
3354 | break; | - | ||||||||||||
3355 | case CN: | - | ||||||||||||
3356 | if (!parseNotationDecl()) { | - | ||||||||||||
3357 | parseFailed(&QXmlSimpleReaderPrivate::parseMarkupdecl, state); | - | ||||||||||||
3358 | return false; | - | ||||||||||||
3359 | } | - | ||||||||||||
3360 | break; | - | ||||||||||||
3361 | } | - | ||||||||||||
3362 | } | - | ||||||||||||
3363 | return false; | - | ||||||||||||
3364 | } | - | ||||||||||||
3365 | - | |||||||||||||
3366 | - | |||||||||||||
3367 | - | |||||||||||||
3368 | - | |||||||||||||
3369 | bool QXmlSimpleReaderPrivate::parsePEReference() | - | ||||||||||||
3370 | { | - | ||||||||||||
3371 | const signed char Init = 0; | - | ||||||||||||
3372 | const signed char Next = 1; | - | ||||||||||||
3373 | const signed char Name = 2; | - | ||||||||||||
3374 | const signed char NameR = 3; | - | ||||||||||||
3375 | const signed char Done = 4; | - | ||||||||||||
3376 | - | |||||||||||||
3377 | const signed char InpSemi = 0; | - | ||||||||||||
3378 | const signed char InpPer = 1; | - | ||||||||||||
3379 | const signed char InpUnknown = 2; | - | ||||||||||||
3380 | - | |||||||||||||
3381 | static const signed char table[4][3] = { | - | ||||||||||||
3382 | - | |||||||||||||
3383 | { -1, Next, -1 }, | - | ||||||||||||
3384 | { -1, -1, Name }, | - | ||||||||||||
3385 | { Done, -1, -1 }, | - | ||||||||||||
3386 | { Done, -1, -1 } | - | ||||||||||||
3387 | }; | - | ||||||||||||
3388 | signed char state; | - | ||||||||||||
3389 | signed char input; | - | ||||||||||||
3390 | - | |||||||||||||
3391 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
3392 | state = Init; | - | ||||||||||||
3393 | } else { | - | ||||||||||||
3394 | state = parseStack->pop().state; | - | ||||||||||||
3395 | - | |||||||||||||
3396 | - | |||||||||||||
3397 | - | |||||||||||||
3398 | if (!parseStack->isEmpty()) { | - | ||||||||||||
3399 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
3400 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
3401 | parseStack->pop(); | - | ||||||||||||
3402 | - | |||||||||||||
3403 | - | |||||||||||||
3404 | - | |||||||||||||
3405 | } | - | ||||||||||||
3406 | if (!(this->*function)()) { | - | ||||||||||||
3407 | parseFailed(&QXmlSimpleReaderPrivate::parsePEReference, state); | - | ||||||||||||
3408 | return false; | - | ||||||||||||
3409 | } | - | ||||||||||||
3410 | } | - | ||||||||||||
3411 | } | - | ||||||||||||
3412 | - | |||||||||||||
3413 | for (;;) { | - | ||||||||||||
3414 | switch (state) { | - | ||||||||||||
3415 | case Name: | - | ||||||||||||
3416 | { | - | ||||||||||||
3417 | bool skipIt = true; | - | ||||||||||||
3418 | QString xmlRefString; | - | ||||||||||||
3419 | - | |||||||||||||
3420 | QMap<QString,QString>::Iterator it; | - | ||||||||||||
3421 | it = parameterEntities.find(ref()); | - | ||||||||||||
3422 | if (it != parameterEntities.end()) { | - | ||||||||||||
3423 | skipIt = false; | - | ||||||||||||
3424 | xmlRefString = *it; | - | ||||||||||||
3425 | } else if (entityRes) { | - | ||||||||||||
3426 | QMap<QString,QXmlSimpleReaderPrivate::ExternParameterEntity>::Iterator it2; | - | ||||||||||||
3427 | it2 = externParameterEntities.find(ref()); | - | ||||||||||||
3428 | QXmlInputSource *ret = 0; | - | ||||||||||||
3429 | if (it2 != externParameterEntities.end()) { | - | ||||||||||||
3430 | if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) { | - | ||||||||||||
3431 | delete ret; | - | ||||||||||||
3432 | reportParseError(entityRes->errorString()); | - | ||||||||||||
3433 | return false; | - | ||||||||||||
3434 | } | - | ||||||||||||
3435 | if (ret) { | - | ||||||||||||
3436 | QString buffer = ret->data(); | - | ||||||||||||
3437 | while (!buffer.isEmpty()) { | - | ||||||||||||
3438 | xmlRefString += buffer; | - | ||||||||||||
3439 | ret->fetchData(); | - | ||||||||||||
3440 | buffer = ret->data(); | - | ||||||||||||
3441 | } | - | ||||||||||||
3442 | delete ret; | - | ||||||||||||
3443 | if (!stripTextDecl(xmlRefString)) { | - | ||||||||||||
3444 | reportParseError(QLatin1String("error in the text declaration of an external entity")); | - | ||||||||||||
3445 | return false; | - | ||||||||||||
3446 | } | - | ||||||||||||
3447 | skipIt = false; | - | ||||||||||||
3448 | } | - | ||||||||||||
3449 | } | - | ||||||||||||
3450 | } | - | ||||||||||||
3451 | - | |||||||||||||
3452 | if (skipIt) { | - | ||||||||||||
3453 | if (contentHnd) { | - | ||||||||||||
3454 | if (!contentHnd->skippedEntity(QLatin1Char('%') + ref())) { | - | ||||||||||||
3455 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
3456 | return false; | - | ||||||||||||
3457 | } | - | ||||||||||||
3458 | } | - | ||||||||||||
3459 | } else { | - | ||||||||||||
3460 | if (parsePEReference_context == InEntityValue) { | - | ||||||||||||
3461 | - | |||||||||||||
3462 | if (!insertXmlRef(xmlRefString, ref(), true)) | - | ||||||||||||
3463 | return false; | - | ||||||||||||
3464 | } else if (parsePEReference_context == InDTD) { | - | ||||||||||||
3465 | - | |||||||||||||
3466 | if (!insertXmlRef(QLatin1Char(' ') + xmlRefString + QLatin1Char(' '), ref(), false)) | - | ||||||||||||
3467 | return false; | - | ||||||||||||
3468 | } | - | ||||||||||||
3469 | } | - | ||||||||||||
3470 | } | - | ||||||||||||
3471 | state = NameR; | - | ||||||||||||
3472 | break; | - | ||||||||||||
3473 | case Done: | - | ||||||||||||
3474 | return true; | - | ||||||||||||
3475 | case -1: | - | ||||||||||||
3476 | - | |||||||||||||
3477 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
3478 | return false; | - | ||||||||||||
3479 | } | - | ||||||||||||
3480 | - | |||||||||||||
3481 | if (atEnd()) { | - | ||||||||||||
3482 | unexpectedEof(&QXmlSimpleReaderPrivate::parsePEReference, state); | - | ||||||||||||
3483 | return false; | - | ||||||||||||
3484 | } | - | ||||||||||||
3485 | if (c == QLatin1Char(';')) { | - | ||||||||||||
3486 | input = InpSemi; | - | ||||||||||||
3487 | } else if (c == QLatin1Char('%')) { | - | ||||||||||||
3488 | input = InpPer; | - | ||||||||||||
3489 | } else { | - | ||||||||||||
3490 | input = InpUnknown; | - | ||||||||||||
3491 | } | - | ||||||||||||
3492 | state = table[state][input]; | - | ||||||||||||
3493 | - | |||||||||||||
3494 | switch (state) { | - | ||||||||||||
3495 | case Next: | - | ||||||||||||
3496 | next(); | - | ||||||||||||
3497 | break; | - | ||||||||||||
3498 | case Name: | - | ||||||||||||
3499 | case NameR: | - | ||||||||||||
3500 | parseName_useRef = true; | - | ||||||||||||
3501 | if (!parseName()) { | - | ||||||||||||
3502 | parseFailed(&QXmlSimpleReaderPrivate::parsePEReference, state); | - | ||||||||||||
3503 | return false; | - | ||||||||||||
3504 | } | - | ||||||||||||
3505 | break; | - | ||||||||||||
3506 | case Done: | - | ||||||||||||
3507 | next(); | - | ||||||||||||
3508 | break; | - | ||||||||||||
3509 | } | - | ||||||||||||
3510 | } | - | ||||||||||||
3511 | return false; | - | ||||||||||||
3512 | } | - | ||||||||||||
3513 | - | |||||||||||||
3514 | - | |||||||||||||
3515 | - | |||||||||||||
3516 | - | |||||||||||||
3517 | - | |||||||||||||
3518 | - | |||||||||||||
3519 | - | |||||||||||||
3520 | bool QXmlSimpleReaderPrivate::parseAttlistDecl() | - | ||||||||||||
3521 | { | - | ||||||||||||
3522 | const signed char Init = 0; | - | ||||||||||||
3523 | const signed char Attlist = 1; | - | ||||||||||||
3524 | const signed char Ws = 2; | - | ||||||||||||
3525 | const signed char Name = 3; | - | ||||||||||||
3526 | const signed char Ws1 = 4; | - | ||||||||||||
3527 | const signed char Attdef = 5; | - | ||||||||||||
3528 | const signed char Ws2 = 6; | - | ||||||||||||
3529 | const signed char Atttype = 7; | - | ||||||||||||
3530 | const signed char Ws3 = 8; | - | ||||||||||||
3531 | const signed char DDecH = 9; | - | ||||||||||||
3532 | const signed char DefReq = 10; | - | ||||||||||||
3533 | const signed char DefImp = 11; | - | ||||||||||||
3534 | const signed char DefFix = 12; | - | ||||||||||||
3535 | const signed char Attval = 13; | - | ||||||||||||
3536 | const signed char Ws4 = 14; | - | ||||||||||||
3537 | const signed char Done = 15; | - | ||||||||||||
3538 | - | |||||||||||||
3539 | const signed char InpWs = 0; | - | ||||||||||||
3540 | const signed char InpGt = 1; | - | ||||||||||||
3541 | const signed char InpHash = 2; | - | ||||||||||||
3542 | const signed char InpA = 3; | - | ||||||||||||
3543 | const signed char InpI = 4; | - | ||||||||||||
3544 | const signed char InpF = 5; | - | ||||||||||||
3545 | const signed char InpR = 6; | - | ||||||||||||
3546 | const signed char InpUnknown = 7; | - | ||||||||||||
3547 | - | |||||||||||||
3548 | static const signed char table[15][8] = { | - | ||||||||||||
3549 | - | |||||||||||||
3550 | { -1, -1, -1, Attlist, -1, -1, -1, -1 }, | - | ||||||||||||
3551 | { Ws, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3552 | { -1, -1, -1, Name, Name, Name, Name, Name }, | - | ||||||||||||
3553 | { Ws1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, | - | ||||||||||||
3554 | { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef }, | - | ||||||||||||
3555 | { Ws2, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3556 | { -1, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype, Atttype }, | - | ||||||||||||
3557 | { Ws3, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3558 | { -1, Attval, DDecH, Attval, Attval, Attval, Attval, Attval }, | - | ||||||||||||
3559 | { -1, -1, -1, -1, DefImp, DefFix, DefReq, -1 }, | - | ||||||||||||
3560 | { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3561 | { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3562 | { Ws3, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3563 | { Ws4, Ws4, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3564 | { -1, Done, Attdef, Attdef, Attdef, Attdef, Attdef, Attdef } | - | ||||||||||||
3565 | }; | - | ||||||||||||
3566 | signed char state; | - | ||||||||||||
3567 | signed char input; | - | ||||||||||||
3568 | - | |||||||||||||
3569 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
3570 | state = Init; | - | ||||||||||||
3571 | } else { | - | ||||||||||||
3572 | state = parseStack->pop().state; | - | ||||||||||||
3573 | - | |||||||||||||
3574 | - | |||||||||||||
3575 | - | |||||||||||||
3576 | if (!parseStack->isEmpty()) { | - | ||||||||||||
3577 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
3578 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
3579 | parseStack->pop(); | - | ||||||||||||
3580 | - | |||||||||||||
3581 | - | |||||||||||||
3582 | - | |||||||||||||
3583 | } | - | ||||||||||||
3584 | if (!(this->*function)()) { | - | ||||||||||||
3585 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3586 | return false; | - | ||||||||||||
3587 | } | - | ||||||||||||
3588 | } | - | ||||||||||||
3589 | } | - | ||||||||||||
3590 | - | |||||||||||||
3591 | for (;;) { | - | ||||||||||||
3592 | switch (state) { | - | ||||||||||||
3593 | case Name: | - | ||||||||||||
3594 | attDeclEName = name(); | - | ||||||||||||
3595 | break; | - | ||||||||||||
3596 | case Attdef: | - | ||||||||||||
3597 | attDeclAName = name(); | - | ||||||||||||
3598 | break; | - | ||||||||||||
3599 | case Done: | - | ||||||||||||
3600 | return true; | - | ||||||||||||
3601 | case -1: | - | ||||||||||||
3602 | - | |||||||||||||
3603 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
3604 | return false; | - | ||||||||||||
3605 | } | - | ||||||||||||
3606 | - | |||||||||||||
3607 | if (atEnd()) { | - | ||||||||||||
3608 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3609 | return false; | - | ||||||||||||
3610 | } | - | ||||||||||||
3611 | if (is_S(c)) { | - | ||||||||||||
3612 | input = InpWs; | - | ||||||||||||
3613 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
3614 | input = InpGt; | - | ||||||||||||
3615 | } else if (c == QLatin1Char('#')) { | - | ||||||||||||
3616 | input = InpHash; | - | ||||||||||||
3617 | } else if (c == QLatin1Char('A')) { | - | ||||||||||||
3618 | input = InpA; | - | ||||||||||||
3619 | } else if (c == QLatin1Char('I')) { | - | ||||||||||||
3620 | input = InpI; | - | ||||||||||||
3621 | } else if (c == QLatin1Char('F')) { | - | ||||||||||||
3622 | input = InpF; | - | ||||||||||||
3623 | } else if (c == QLatin1Char('R')) { | - | ||||||||||||
3624 | input = InpR; | - | ||||||||||||
3625 | } else { | - | ||||||||||||
3626 | input = InpUnknown; | - | ||||||||||||
3627 | } | - | ||||||||||||
3628 | state = table[state][input]; | - | ||||||||||||
3629 | - | |||||||||||||
3630 | switch (state) { | - | ||||||||||||
3631 | case Attlist: | - | ||||||||||||
3632 | parseString_s = QLatin1String("ATTLIST"); | - | ||||||||||||
3633 | if (!parseString()) { | - | ||||||||||||
3634 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3635 | return false; | - | ||||||||||||
3636 | } | - | ||||||||||||
3637 | break; | - | ||||||||||||
3638 | case Ws: | - | ||||||||||||
3639 | case Ws1: | - | ||||||||||||
3640 | case Ws2: | - | ||||||||||||
3641 | case Ws3: | - | ||||||||||||
3642 | if (!eat_ws()) { | - | ||||||||||||
3643 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3644 | return false; | - | ||||||||||||
3645 | } | - | ||||||||||||
3646 | break; | - | ||||||||||||
3647 | case Name: | - | ||||||||||||
3648 | parseName_useRef = false; | - | ||||||||||||
3649 | if (!parseName()) { | - | ||||||||||||
3650 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3651 | return false; | - | ||||||||||||
3652 | } | - | ||||||||||||
3653 | break; | - | ||||||||||||
3654 | case Attdef: | - | ||||||||||||
3655 | parseName_useRef = false; | - | ||||||||||||
3656 | if (!parseName()) { | - | ||||||||||||
3657 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3658 | return false; | - | ||||||||||||
3659 | } | - | ||||||||||||
3660 | break; | - | ||||||||||||
3661 | case Atttype: | - | ||||||||||||
3662 | if (!parseAttType()) { | - | ||||||||||||
3663 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3664 | return false; | - | ||||||||||||
3665 | } | - | ||||||||||||
3666 | break; | - | ||||||||||||
3667 | case DDecH: | - | ||||||||||||
3668 | next(); | - | ||||||||||||
3669 | break; | - | ||||||||||||
3670 | case DefReq: | - | ||||||||||||
3671 | parseString_s = QLatin1String("REQUIRED"); | - | ||||||||||||
3672 | if (!parseString()) { | - | ||||||||||||
3673 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3674 | return false; | - | ||||||||||||
3675 | } | - | ||||||||||||
3676 | break; | - | ||||||||||||
3677 | case DefImp: | - | ||||||||||||
3678 | parseString_s = QLatin1String("IMPLIED"); | - | ||||||||||||
3679 | if (!parseString()) { | - | ||||||||||||
3680 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3681 | return false; | - | ||||||||||||
3682 | } | - | ||||||||||||
3683 | break; | - | ||||||||||||
3684 | case DefFix: | - | ||||||||||||
3685 | parseString_s = QLatin1String("FIXED"); | - | ||||||||||||
3686 | if (!parseString()) { | - | ||||||||||||
3687 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3688 | return false; | - | ||||||||||||
3689 | } | - | ||||||||||||
3690 | break; | - | ||||||||||||
3691 | case Attval: | - | ||||||||||||
3692 | if (!parseAttValue()) { | - | ||||||||||||
3693 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3694 | return false; | - | ||||||||||||
3695 | } | - | ||||||||||||
3696 | break; | - | ||||||||||||
3697 | case Ws4: | - | ||||||||||||
3698 | if (declHnd) { | - | ||||||||||||
3699 | - | |||||||||||||
3700 | if (!declHnd->attributeDecl(attDeclEName, attDeclAName, QLatin1String(""), QLatin1String(""), QLatin1String(""))) { | - | ||||||||||||
3701 | reportParseError(declHnd->errorString()); | - | ||||||||||||
3702 | return false; | - | ||||||||||||
3703 | } | - | ||||||||||||
3704 | } | - | ||||||||||||
3705 | if (!eat_ws()) { | - | ||||||||||||
3706 | parseFailed(&QXmlSimpleReaderPrivate::parseAttlistDecl, state); | - | ||||||||||||
3707 | return false; | - | ||||||||||||
3708 | } | - | ||||||||||||
3709 | break; | - | ||||||||||||
3710 | case Done: | - | ||||||||||||
3711 | next(); | - | ||||||||||||
3712 | break; | - | ||||||||||||
3713 | } | - | ||||||||||||
3714 | } | - | ||||||||||||
3715 | return false; | - | ||||||||||||
3716 | } | - | ||||||||||||
3717 | - | |||||||||||||
3718 | - | |||||||||||||
3719 | - | |||||||||||||
3720 | - | |||||||||||||
3721 | bool QXmlSimpleReaderPrivate::parseAttType() | - | ||||||||||||
3722 | { | - | ||||||||||||
3723 | const signed char Init = 0; | - | ||||||||||||
3724 | const signed char ST = 1; | - | ||||||||||||
3725 | const signed char TTI = 2; | - | ||||||||||||
3726 | const signed char TTI2 = 3; | - | ||||||||||||
3727 | const signed char TTI3 = 4; | - | ||||||||||||
3728 | const signed char TTE = 5; | - | ||||||||||||
3729 | const signed char TTEY = 6; | - | ||||||||||||
3730 | const signed char TTEI = 7; | - | ||||||||||||
3731 | const signed char N = 8; | - | ||||||||||||
3732 | const signed char TTNM = 9; | - | ||||||||||||
3733 | const signed char TTNM2 = 10; | - | ||||||||||||
3734 | const signed char NO = 11; | - | ||||||||||||
3735 | const signed char NO2 = 12; | - | ||||||||||||
3736 | const signed char NO3 = 13; | - | ||||||||||||
3737 | const signed char NOName = 14; | - | ||||||||||||
3738 | const signed char NO4 = 15; | - | ||||||||||||
3739 | const signed char EN = 16; | - | ||||||||||||
3740 | const signed char ENNmt = 17; | - | ||||||||||||
3741 | const signed char EN2 = 18; | - | ||||||||||||
3742 | const signed char ADone = 19; | - | ||||||||||||
3743 | const signed char Done = 20; | - | ||||||||||||
3744 | - | |||||||||||||
3745 | const signed char InpWs = 0; | - | ||||||||||||
3746 | const signed char InpOp = 1; | - | ||||||||||||
3747 | const signed char InpCp = 2; | - | ||||||||||||
3748 | const signed char InpPipe = 3; | - | ||||||||||||
3749 | const signed char InpC = 4; | - | ||||||||||||
3750 | const signed char InpE = 5; | - | ||||||||||||
3751 | const signed char InpI = 6; | - | ||||||||||||
3752 | const signed char InpM = 7; | - | ||||||||||||
3753 | const signed char InpN = 8; | - | ||||||||||||
3754 | const signed char InpO = 9; | - | ||||||||||||
3755 | const signed char InpR = 10; | - | ||||||||||||
3756 | const signed char InpS = 11; | - | ||||||||||||
3757 | const signed char InpY = 12; | - | ||||||||||||
3758 | const signed char InpUnknown = 13; | - | ||||||||||||
3759 | - | |||||||||||||
3760 | static const signed char table[19][14] = { | - | ||||||||||||
3761 | - | |||||||||||||
3762 | { -1, EN, -1, -1, ST, TTE, TTI, -1, N, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3763 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, | - | ||||||||||||
3764 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI2, Done, Done, Done }, | - | ||||||||||||
3765 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTI3, Done, Done }, | - | ||||||||||||
3766 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, | - | ||||||||||||
3767 | { -1, -1, -1, -1, -1, -1, TTEI, -1, -1, -1, -1, -1, TTEY, -1 }, | - | ||||||||||||
3768 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, | - | ||||||||||||
3769 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, | - | ||||||||||||
3770 | { -1, -1, -1, -1, -1, -1, -1, TTNM, -1, NO, -1, -1, -1, -1 }, | - | ||||||||||||
3771 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, TTNM2, Done, Done }, | - | ||||||||||||
3772 | { Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done, Done }, | - | ||||||||||||
3773 | { NO2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3774 | { -1, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3775 | { NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName, NOName }, | - | ||||||||||||
3776 | { NO4, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3777 | { -1, -1, ADone, NO3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3778 | { -1, -1, ENNmt, -1, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt, ENNmt }, | - | ||||||||||||
3779 | { EN2, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
3780 | { -1, -1, ADone, EN, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } | - | ||||||||||||
3781 | }; | - | ||||||||||||
3782 | signed char state; | - | ||||||||||||
3783 | signed char input; | - | ||||||||||||
3784 | - | |||||||||||||
3785 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
3786 | state = Init; | - | ||||||||||||
3787 | } else { | - | ||||||||||||
3788 | state = parseStack->pop().state; | - | ||||||||||||
3789 | - | |||||||||||||
3790 | - | |||||||||||||
3791 | - | |||||||||||||
3792 | if (!parseStack->isEmpty()) { | - | ||||||||||||
3793 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
3794 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
3795 | parseStack->pop(); | - | ||||||||||||
3796 | - | |||||||||||||
3797 | - | |||||||||||||
3798 | - | |||||||||||||
3799 | } | - | ||||||||||||
3800 | if (!(this->*function)()) { | - | ||||||||||||
3801 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3802 | return false; | - | ||||||||||||
3803 | } | - | ||||||||||||
3804 | } | - | ||||||||||||
3805 | } | - | ||||||||||||
3806 | - | |||||||||||||
3807 | for (;;) { | - | ||||||||||||
3808 | switch (state) { | - | ||||||||||||
3809 | case ADone: | - | ||||||||||||
3810 | return true; | - | ||||||||||||
3811 | case Done: | - | ||||||||||||
3812 | return true; | - | ||||||||||||
3813 | case -1: | - | ||||||||||||
3814 | - | |||||||||||||
3815 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
3816 | return false; | - | ||||||||||||
3817 | } | - | ||||||||||||
3818 | - | |||||||||||||
3819 | if (atEnd()) { | - | ||||||||||||
3820 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3821 | return false; | - | ||||||||||||
3822 | } | - | ||||||||||||
3823 | if (is_S(c)) { | - | ||||||||||||
3824 | input = InpWs; | - | ||||||||||||
3825 | } else if (c == QLatin1Char('(')) { | - | ||||||||||||
3826 | input = InpOp; | - | ||||||||||||
3827 | } else if (c == QLatin1Char(')')) { | - | ||||||||||||
3828 | input = InpCp; | - | ||||||||||||
3829 | } else if (c == QLatin1Char('|')) { | - | ||||||||||||
3830 | input = InpPipe; | - | ||||||||||||
3831 | } else if (c == QLatin1Char('C')) { | - | ||||||||||||
3832 | input = InpC; | - | ||||||||||||
3833 | } else if (c == QLatin1Char('E')) { | - | ||||||||||||
3834 | input = InpE; | - | ||||||||||||
3835 | } else if (c == QLatin1Char('I')) { | - | ||||||||||||
3836 | input = InpI; | - | ||||||||||||
3837 | } else if (c == QLatin1Char('M')) { | - | ||||||||||||
3838 | input = InpM; | - | ||||||||||||
3839 | } else if (c == QLatin1Char('N')) { | - | ||||||||||||
3840 | input = InpN; | - | ||||||||||||
3841 | } else if (c == QLatin1Char('O')) { | - | ||||||||||||
3842 | input = InpO; | - | ||||||||||||
3843 | } else if (c == QLatin1Char('R')) { | - | ||||||||||||
3844 | input = InpR; | - | ||||||||||||
3845 | } else if (c == QLatin1Char('S')) { | - | ||||||||||||
3846 | input = InpS; | - | ||||||||||||
3847 | } else if (c == QLatin1Char('Y')) { | - | ||||||||||||
3848 | input = InpY; | - | ||||||||||||
3849 | } else { | - | ||||||||||||
3850 | input = InpUnknown; | - | ||||||||||||
3851 | } | - | ||||||||||||
3852 | state = table[state][input]; | - | ||||||||||||
3853 | - | |||||||||||||
3854 | switch (state) { | - | ||||||||||||
3855 | case ST: | - | ||||||||||||
3856 | parseString_s = QLatin1String("CDATA"); | - | ||||||||||||
3857 | if (!parseString()) { | - | ||||||||||||
3858 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3859 | return false; | - | ||||||||||||
3860 | } | - | ||||||||||||
3861 | break; | - | ||||||||||||
3862 | case TTI: | - | ||||||||||||
3863 | parseString_s = QLatin1String("ID"); | - | ||||||||||||
3864 | if (!parseString()) { | - | ||||||||||||
3865 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3866 | return false; | - | ||||||||||||
3867 | } | - | ||||||||||||
3868 | break; | - | ||||||||||||
3869 | case TTI2: | - | ||||||||||||
3870 | parseString_s = QLatin1String("REF"); | - | ||||||||||||
3871 | if (!parseString()) { | - | ||||||||||||
3872 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3873 | return false; | - | ||||||||||||
3874 | } | - | ||||||||||||
3875 | break; | - | ||||||||||||
3876 | case TTI3: | - | ||||||||||||
3877 | next(); | - | ||||||||||||
3878 | break; | - | ||||||||||||
3879 | case TTE: | - | ||||||||||||
3880 | parseString_s = QLatin1String("ENTIT"); | - | ||||||||||||
3881 | if (!parseString()) { | - | ||||||||||||
3882 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3883 | return false; | - | ||||||||||||
3884 | } | - | ||||||||||||
3885 | break; | - | ||||||||||||
3886 | case TTEY: | - | ||||||||||||
3887 | next(); | - | ||||||||||||
3888 | break; | - | ||||||||||||
3889 | case TTEI: | - | ||||||||||||
3890 | parseString_s = QLatin1String("IES"); | - | ||||||||||||
3891 | if (!parseString()) { | - | ||||||||||||
3892 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3893 | return false; | - | ||||||||||||
3894 | } | - | ||||||||||||
3895 | break; | - | ||||||||||||
3896 | case N: | - | ||||||||||||
3897 | next(); | - | ||||||||||||
3898 | break; | - | ||||||||||||
3899 | case TTNM: | - | ||||||||||||
3900 | parseString_s = QLatin1String("MTOKEN"); | - | ||||||||||||
3901 | if (!parseString()) { | - | ||||||||||||
3902 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3903 | return false; | - | ||||||||||||
3904 | } | - | ||||||||||||
3905 | break; | - | ||||||||||||
3906 | case TTNM2: | - | ||||||||||||
3907 | next(); | - | ||||||||||||
3908 | break; | - | ||||||||||||
3909 | case NO: | - | ||||||||||||
3910 | parseString_s = QLatin1String("OTATION"); | - | ||||||||||||
3911 | if (!parseString()) { | - | ||||||||||||
3912 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3913 | return false; | - | ||||||||||||
3914 | } | - | ||||||||||||
3915 | break; | - | ||||||||||||
3916 | case NO2: | - | ||||||||||||
3917 | if (!eat_ws()) { | - | ||||||||||||
3918 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3919 | return false; | - | ||||||||||||
3920 | } | - | ||||||||||||
3921 | break; | - | ||||||||||||
3922 | case NO3: | - | ||||||||||||
3923 | if (!next_eat_ws()) { | - | ||||||||||||
3924 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3925 | return false; | - | ||||||||||||
3926 | } | - | ||||||||||||
3927 | break; | - | ||||||||||||
3928 | case NOName: | - | ||||||||||||
3929 | parseName_useRef = false; | - | ||||||||||||
3930 | if (!parseName()) { | - | ||||||||||||
3931 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3932 | return false; | - | ||||||||||||
3933 | } | - | ||||||||||||
3934 | break; | - | ||||||||||||
3935 | case NO4: | - | ||||||||||||
3936 | if (!eat_ws()) { | - | ||||||||||||
3937 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3938 | return false; | - | ||||||||||||
3939 | } | - | ||||||||||||
3940 | break; | - | ||||||||||||
3941 | case EN: | - | ||||||||||||
3942 | if (!next_eat_ws()) { | - | ||||||||||||
3943 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3944 | return false; | - | ||||||||||||
3945 | } | - | ||||||||||||
3946 | break; | - | ||||||||||||
3947 | case ENNmt: | - | ||||||||||||
3948 | if (!parseNmtoken()) { | - | ||||||||||||
3949 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3950 | return false; | - | ||||||||||||
3951 | } | - | ||||||||||||
3952 | break; | - | ||||||||||||
3953 | case EN2: | - | ||||||||||||
3954 | if (!eat_ws()) { | - | ||||||||||||
3955 | parseFailed(&QXmlSimpleReaderPrivate::parseAttType, state); | - | ||||||||||||
3956 | return false; | - | ||||||||||||
3957 | } | - | ||||||||||||
3958 | break; | - | ||||||||||||
3959 | case ADone: | - | ||||||||||||
3960 | next(); | - | ||||||||||||
3961 | break; | - | ||||||||||||
3962 | } | - | ||||||||||||
3963 | } | - | ||||||||||||
3964 | return false; | - | ||||||||||||
3965 | } | - | ||||||||||||
3966 | bool QXmlSimpleReaderPrivate::parseAttValue() | - | ||||||||||||
3967 | { | - | ||||||||||||
3968 | const signed char Init = 0; | - | ||||||||||||
3969 | const signed char Dq = 1; | - | ||||||||||||
3970 | const signed char DqRef = 2; | - | ||||||||||||
3971 | const signed char DqC = 3; | - | ||||||||||||
3972 | const signed char Sq = 4; | - | ||||||||||||
3973 | const signed char SqRef = 5; | - | ||||||||||||
3974 | const signed char SqC = 6; | - | ||||||||||||
3975 | const signed char Done = 7; | - | ||||||||||||
3976 | - | |||||||||||||
3977 | const signed char InpDq = 0; | - | ||||||||||||
3978 | const signed char InpSq = 1; | - | ||||||||||||
3979 | const signed char InpAmp = 2; | - | ||||||||||||
3980 | const signed char InpLt = 3; | - | ||||||||||||
3981 | const signed char InpUnknown = 4; | - | ||||||||||||
3982 | - | |||||||||||||
3983 | static const signed char table[7][5] = { | - | ||||||||||||
3984 | - | |||||||||||||
3985 | { Dq, Sq, -1, -1, -1 }, | - | ||||||||||||
3986 | { Done, DqC, DqRef, -1, DqC }, | - | ||||||||||||
3987 | { Done, DqC, DqRef, -1, DqC }, | - | ||||||||||||
3988 | { Done, DqC, DqRef, -1, DqC }, | - | ||||||||||||
3989 | { SqC, Done, SqRef, -1, SqC }, | - | ||||||||||||
3990 | { SqC, Done, SqRef, -1, SqC }, | - | ||||||||||||
3991 | { SqC, Done, SqRef, -1, SqC } | - | ||||||||||||
3992 | }; | - | ||||||||||||
3993 | signed char state; | - | ||||||||||||
3994 | signed char input; | - | ||||||||||||
3995 | - | |||||||||||||
3996 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
3997 | state = Init; | - | ||||||||||||
3998 | } else { | - | ||||||||||||
3999 | state = parseStack->pop().state; | - | ||||||||||||
4000 | - | |||||||||||||
4001 | - | |||||||||||||
4002 | - | |||||||||||||
4003 | if (!parseStack->isEmpty()) { | - | ||||||||||||
4004 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
4005 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
4006 | parseStack->pop(); | - | ||||||||||||
4007 | - | |||||||||||||
4008 | - | |||||||||||||
4009 | - | |||||||||||||
4010 | } | - | ||||||||||||
4011 | if (!(this->*function)()) { | - | ||||||||||||
4012 | parseFailed(&QXmlSimpleReaderPrivate::parseAttValue, state); | - | ||||||||||||
4013 | return false; | - | ||||||||||||
4014 | } | - | ||||||||||||
4015 | } | - | ||||||||||||
4016 | } | - | ||||||||||||
4017 | - | |||||||||||||
4018 | for (;;) { | - | ||||||||||||
4019 | switch (state) { | - | ||||||||||||
4020 | case Done: | - | ||||||||||||
4021 | return true; | - | ||||||||||||
4022 | case -1: | - | ||||||||||||
4023 | - | |||||||||||||
4024 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
4025 | return false; | - | ||||||||||||
4026 | } | - | ||||||||||||
4027 | - | |||||||||||||
4028 | if (atEnd()) { | - | ||||||||||||
4029 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttValue, state); | - | ||||||||||||
4030 | return false; | - | ||||||||||||
4031 | } | - | ||||||||||||
4032 | if (c == QLatin1Char('"')) { | - | ||||||||||||
4033 | input = InpDq; | - | ||||||||||||
4034 | } else if (c == QLatin1Char('\'')) { | - | ||||||||||||
4035 | input = InpSq; | - | ||||||||||||
4036 | } else if (c == QLatin1Char('&')) { | - | ||||||||||||
4037 | input = InpAmp; | - | ||||||||||||
4038 | } else if (c == QLatin1Char('<')) { | - | ||||||||||||
4039 | input = InpLt; | - | ||||||||||||
4040 | } else { | - | ||||||||||||
4041 | input = InpUnknown; | - | ||||||||||||
4042 | } | - | ||||||||||||
4043 | state = table[state][input]; | - | ||||||||||||
4044 | - | |||||||||||||
4045 | switch (state) { | - | ||||||||||||
4046 | case Dq: | - | ||||||||||||
4047 | case Sq: | - | ||||||||||||
4048 | stringClear(); | - | ||||||||||||
4049 | next(); | - | ||||||||||||
4050 | break; | - | ||||||||||||
4051 | case DqRef: | - | ||||||||||||
4052 | case SqRef: | - | ||||||||||||
4053 | parseReference_context = InAttributeValue; | - | ||||||||||||
4054 | if (!parseReference()) { | - | ||||||||||||
4055 | parseFailed(&QXmlSimpleReaderPrivate::parseAttValue, state); | - | ||||||||||||
4056 | return false; | - | ||||||||||||
4057 | } | - | ||||||||||||
4058 | break; | - | ||||||||||||
4059 | case DqC: | - | ||||||||||||
4060 | case SqC: | - | ||||||||||||
4061 | stringAddC(); | - | ||||||||||||
4062 | next(); | - | ||||||||||||
4063 | break; | - | ||||||||||||
4064 | case Done: | - | ||||||||||||
4065 | next(); | - | ||||||||||||
4066 | break; | - | ||||||||||||
4067 | } | - | ||||||||||||
4068 | } | - | ||||||||||||
4069 | return false; | - | ||||||||||||
4070 | } | - | ||||||||||||
4071 | - | |||||||||||||
4072 | - | |||||||||||||
4073 | - | |||||||||||||
4074 | - | |||||||||||||
4075 | - | |||||||||||||
4076 | - | |||||||||||||
4077 | - | |||||||||||||
4078 | bool QXmlSimpleReaderPrivate::parseElementDecl() | - | ||||||||||||
4079 | { | - | ||||||||||||
4080 | const signed char Init = 0; | - | ||||||||||||
4081 | const signed char Elem = 1; | - | ||||||||||||
4082 | const signed char Ws1 = 2; | - | ||||||||||||
4083 | const signed char Nam = 3; | - | ||||||||||||
4084 | const signed char Ws2 = 4; | - | ||||||||||||
4085 | const signed char Empty = 5; | - | ||||||||||||
4086 | const signed char Any = 6; | - | ||||||||||||
4087 | const signed char Cont = 7; | - | ||||||||||||
4088 | const signed char Mix = 8; | - | ||||||||||||
4089 | const signed char Mix2 = 9; | - | ||||||||||||
4090 | const signed char Mix3 = 10; | - | ||||||||||||
4091 | const signed char MixN1 = 11; | - | ||||||||||||
4092 | const signed char MixN2 = 12; | - | ||||||||||||
4093 | const signed char MixN3 = 13; | - | ||||||||||||
4094 | const signed char MixN4 = 14; | - | ||||||||||||
4095 | const signed char Cp = 15; | - | ||||||||||||
4096 | const signed char Cp2 = 16; | - | ||||||||||||
4097 | const signed char WsD = 17; | - | ||||||||||||
4098 | const signed char Done = 18; | - | ||||||||||||
4099 | - | |||||||||||||
4100 | const signed char InpWs = 0; | - | ||||||||||||
4101 | const signed char InpGt = 1; | - | ||||||||||||
4102 | const signed char InpPipe = 2; | - | ||||||||||||
4103 | const signed char InpOp = 3; | - | ||||||||||||
4104 | const signed char InpCp = 4; | - | ||||||||||||
4105 | const signed char InpHash = 5; | - | ||||||||||||
4106 | const signed char InpQm = 6; | - | ||||||||||||
4107 | const signed char InpAst = 7; | - | ||||||||||||
4108 | const signed char InpPlus = 8; | - | ||||||||||||
4109 | const signed char InpA = 9; | - | ||||||||||||
4110 | const signed char InpE = 10; | - | ||||||||||||
4111 | const signed char InpL = 11; | - | ||||||||||||
4112 | const signed char InpUnknown = 12; | - | ||||||||||||
4113 | - | |||||||||||||
4114 | static const signed char table[18][13] = { | - | ||||||||||||
4115 | - | |||||||||||||
4116 | { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, Elem, -1 }, | - | ||||||||||||
4117 | { Ws1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4118 | { -1, -1, -1, -1, -1, -1, -1, -1, -1, Nam, Nam, Nam, Nam }, | - | ||||||||||||
4119 | { Ws2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4120 | { -1, -1, -1, Cont, -1, -1, -1, -1, -1, Any, Empty, -1, -1 }, | - | ||||||||||||
4121 | { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4122 | { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4123 | { -1, -1, -1, Cp, Cp, Mix, -1, -1, -1, Cp, Cp, Cp, Cp }, | - | ||||||||||||
4124 | { Mix2, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4125 | { -1, -1, MixN1, -1, Mix3, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4126 | { WsD, Done, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4127 | { -1, -1, -1, -1, -1, -1, -1, -1, -1, MixN2, MixN2, MixN2, MixN2 }, | - | ||||||||||||
4128 | { MixN3, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4129 | { -1, -1, MixN1, -1, MixN4, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4130 | { -1, -1, -1, -1, -1, -1, -1, WsD, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4131 | { WsD, Done, -1, -1, -1, -1, Cp2, Cp2, Cp2, -1, -1, -1, -1 }, | - | ||||||||||||
4132 | { WsD, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4133 | { -1, Done, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } | - | ||||||||||||
4134 | }; | - | ||||||||||||
4135 | signed char state; | - | ||||||||||||
4136 | signed char input; | - | ||||||||||||
4137 | - | |||||||||||||
4138 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
4139 | state = Init; | - | ||||||||||||
4140 | } else { | - | ||||||||||||
4141 | state = parseStack->pop().state; | - | ||||||||||||
4142 | - | |||||||||||||
4143 | - | |||||||||||||
4144 | - | |||||||||||||
4145 | if (!parseStack->isEmpty()) { | - | ||||||||||||
4146 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
4147 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
4148 | parseStack->pop(); | - | ||||||||||||
4149 | - | |||||||||||||
4150 | - | |||||||||||||
4151 | - | |||||||||||||
4152 | } | - | ||||||||||||
4153 | if (!(this->*function)()) { | - | ||||||||||||
4154 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4155 | return false; | - | ||||||||||||
4156 | } | - | ||||||||||||
4157 | } | - | ||||||||||||
4158 | } | - | ||||||||||||
4159 | - | |||||||||||||
4160 | for (;;) { | - | ||||||||||||
4161 | switch (state) { | - | ||||||||||||
4162 | case Done: | - | ||||||||||||
4163 | return true; | - | ||||||||||||
4164 | case -1: | - | ||||||||||||
4165 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
4166 | return false; | - | ||||||||||||
4167 | } | - | ||||||||||||
4168 | - | |||||||||||||
4169 | if (atEnd()) { | - | ||||||||||||
4170 | unexpectedEof(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4171 | return false; | - | ||||||||||||
4172 | } | - | ||||||||||||
4173 | if (is_S(c)) { | - | ||||||||||||
4174 | input = InpWs; | - | ||||||||||||
4175 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
4176 | input = InpGt; | - | ||||||||||||
4177 | } else if (c == QLatin1Char('|')) { | - | ||||||||||||
4178 | input = InpPipe; | - | ||||||||||||
4179 | } else if (c == QLatin1Char('(')) { | - | ||||||||||||
4180 | input = InpOp; | - | ||||||||||||
4181 | } else if (c == QLatin1Char(')')) { | - | ||||||||||||
4182 | input = InpCp; | - | ||||||||||||
4183 | } else if (c == QLatin1Char('#')) { | - | ||||||||||||
4184 | input = InpHash; | - | ||||||||||||
4185 | } else if (c == QLatin1Char('?')) { | - | ||||||||||||
4186 | input = InpQm; | - | ||||||||||||
4187 | } else if (c == QLatin1Char('*')) { | - | ||||||||||||
4188 | input = InpAst; | - | ||||||||||||
4189 | } else if (c == QLatin1Char('+')) { | - | ||||||||||||
4190 | input = InpPlus; | - | ||||||||||||
4191 | } else if (c == QLatin1Char('A')) { | - | ||||||||||||
4192 | input = InpA; | - | ||||||||||||
4193 | } else if (c == QLatin1Char('E')) { | - | ||||||||||||
4194 | input = InpE; | - | ||||||||||||
4195 | } else if (c == QLatin1Char('L')) { | - | ||||||||||||
4196 | input = InpL; | - | ||||||||||||
4197 | } else { | - | ||||||||||||
4198 | input = InpUnknown; | - | ||||||||||||
4199 | } | - | ||||||||||||
4200 | state = table[state][input]; | - | ||||||||||||
4201 | - | |||||||||||||
4202 | switch (state) { | - | ||||||||||||
4203 | case Elem: | - | ||||||||||||
4204 | parseString_s = QLatin1String("LEMENT"); | - | ||||||||||||
4205 | if (!parseString()) { | - | ||||||||||||
4206 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4207 | return false; | - | ||||||||||||
4208 | } | - | ||||||||||||
4209 | break; | - | ||||||||||||
4210 | case Ws1: | - | ||||||||||||
4211 | if (!eat_ws()) { | - | ||||||||||||
4212 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4213 | return false; | - | ||||||||||||
4214 | } | - | ||||||||||||
4215 | break; | - | ||||||||||||
4216 | case Nam: | - | ||||||||||||
4217 | parseName_useRef = false; | - | ||||||||||||
4218 | if (!parseName()) { | - | ||||||||||||
4219 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4220 | return false; | - | ||||||||||||
4221 | } | - | ||||||||||||
4222 | break; | - | ||||||||||||
4223 | case Ws2: | - | ||||||||||||
4224 | if (!eat_ws()) { | - | ||||||||||||
4225 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4226 | return false; | - | ||||||||||||
4227 | } | - | ||||||||||||
4228 | break; | - | ||||||||||||
4229 | case Empty: | - | ||||||||||||
4230 | parseString_s = QLatin1String("EMPTY"); | - | ||||||||||||
4231 | if (!parseString()) { | - | ||||||||||||
4232 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4233 | return false; | - | ||||||||||||
4234 | } | - | ||||||||||||
4235 | break; | - | ||||||||||||
4236 | case Any: | - | ||||||||||||
4237 | parseString_s = QLatin1String("ANY"); | - | ||||||||||||
4238 | if (!parseString()) { | - | ||||||||||||
4239 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4240 | return false; | - | ||||||||||||
4241 | } | - | ||||||||||||
4242 | break; | - | ||||||||||||
4243 | case Cont: | - | ||||||||||||
4244 | if (!next_eat_ws()) { | - | ||||||||||||
4245 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4246 | return false; | - | ||||||||||||
4247 | } | - | ||||||||||||
4248 | break; | - | ||||||||||||
4249 | case Mix: | - | ||||||||||||
4250 | parseString_s = QLatin1String("#PCDATA"); | - | ||||||||||||
4251 | if (!parseString()) { | - | ||||||||||||
4252 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4253 | return false; | - | ||||||||||||
4254 | } | - | ||||||||||||
4255 | break; | - | ||||||||||||
4256 | case Mix2: | - | ||||||||||||
4257 | if (!eat_ws()) { | - | ||||||||||||
4258 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4259 | return false; | - | ||||||||||||
4260 | } | - | ||||||||||||
4261 | break; | - | ||||||||||||
4262 | case Mix3: | - | ||||||||||||
4263 | next(); | - | ||||||||||||
4264 | break; | - | ||||||||||||
4265 | case MixN1: | - | ||||||||||||
4266 | if (!next_eat_ws()) { | - | ||||||||||||
4267 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4268 | return false; | - | ||||||||||||
4269 | } | - | ||||||||||||
4270 | break; | - | ||||||||||||
4271 | case MixN2: | - | ||||||||||||
4272 | parseName_useRef = false; | - | ||||||||||||
4273 | if (!parseName()) { | - | ||||||||||||
4274 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4275 | return false; | - | ||||||||||||
4276 | } | - | ||||||||||||
4277 | break; | - | ||||||||||||
4278 | case MixN3: | - | ||||||||||||
4279 | if (!eat_ws()) { | - | ||||||||||||
4280 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4281 | return false; | - | ||||||||||||
4282 | } | - | ||||||||||||
4283 | break; | - | ||||||||||||
4284 | case MixN4: | - | ||||||||||||
4285 | next(); | - | ||||||||||||
4286 | break; | - | ||||||||||||
4287 | case Cp: | - | ||||||||||||
4288 | if (!parseChoiceSeq()) { | - | ||||||||||||
4289 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4290 | return false; | - | ||||||||||||
4291 | } | - | ||||||||||||
4292 | break; | - | ||||||||||||
4293 | case Cp2: | - | ||||||||||||
4294 | next(); | - | ||||||||||||
4295 | break; | - | ||||||||||||
4296 | case WsD: | - | ||||||||||||
4297 | if (!next_eat_ws()) { | - | ||||||||||||
4298 | parseFailed(&QXmlSimpleReaderPrivate::parseElementDecl, state); | - | ||||||||||||
4299 | return false; | - | ||||||||||||
4300 | } | - | ||||||||||||
4301 | break; | - | ||||||||||||
4302 | case Done: | - | ||||||||||||
4303 | next(); | - | ||||||||||||
4304 | break; | - | ||||||||||||
4305 | } | - | ||||||||||||
4306 | } | - | ||||||||||||
4307 | return false; | - | ||||||||||||
4308 | } | - | ||||||||||||
4309 | - | |||||||||||||
4310 | - | |||||||||||||
4311 | - | |||||||||||||
4312 | - | |||||||||||||
4313 | - | |||||||||||||
4314 | - | |||||||||||||
4315 | - | |||||||||||||
4316 | bool QXmlSimpleReaderPrivate::parseNotationDecl() | - | ||||||||||||
4317 | { | - | ||||||||||||
4318 | const signed char Init = 0; | - | ||||||||||||
4319 | const signed char Not = 1; | - | ||||||||||||
4320 | const signed char Ws1 = 2; | - | ||||||||||||
4321 | const signed char Nam = 3; | - | ||||||||||||
4322 | const signed char Ws2 = 4; | - | ||||||||||||
4323 | const signed char ExtID = 5; | - | ||||||||||||
4324 | const signed char ExtIDR = 6; | - | ||||||||||||
4325 | const signed char Ws3 = 7; | - | ||||||||||||
4326 | const signed char Done = 8; | - | ||||||||||||
4327 | - | |||||||||||||
4328 | const signed char InpWs = 0; | - | ||||||||||||
4329 | const signed char InpGt = 1; | - | ||||||||||||
4330 | const signed char InpN = 2; | - | ||||||||||||
4331 | const signed char InpUnknown = 3; | - | ||||||||||||
4332 | - | |||||||||||||
4333 | static const signed char table[8][4] = { | - | ||||||||||||
4334 | - | |||||||||||||
4335 | { -1, -1, Not, -1 }, | - | ||||||||||||
4336 | { Ws1, -1, -1, -1 }, | - | ||||||||||||
4337 | { -1, -1, Nam, Nam }, | - | ||||||||||||
4338 | { Ws2, Done, -1, -1 }, | - | ||||||||||||
4339 | { -1, Done, ExtID, ExtID }, | - | ||||||||||||
4340 | { Ws3, Done, -1, -1 }, | - | ||||||||||||
4341 | { Ws3, Done, -1, -1 }, | - | ||||||||||||
4342 | { -1, Done, -1, -1 } | - | ||||||||||||
4343 | }; | - | ||||||||||||
4344 | signed char state; | - | ||||||||||||
4345 | signed char input; | - | ||||||||||||
4346 | - | |||||||||||||
4347 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
4348 | state = Init; | - | ||||||||||||
4349 | } else { | - | ||||||||||||
4350 | state = parseStack->pop().state; | - | ||||||||||||
4351 | - | |||||||||||||
4352 | - | |||||||||||||
4353 | - | |||||||||||||
4354 | if (!parseStack->isEmpty()) { | - | ||||||||||||
4355 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
4356 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
4357 | parseStack->pop(); | - | ||||||||||||
4358 | - | |||||||||||||
4359 | - | |||||||||||||
4360 | - | |||||||||||||
4361 | } | - | ||||||||||||
4362 | if (!(this->*function)()) { | - | ||||||||||||
4363 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4364 | return false; | - | ||||||||||||
4365 | } | - | ||||||||||||
4366 | } | - | ||||||||||||
4367 | } | - | ||||||||||||
4368 | - | |||||||||||||
4369 | for (;;) { | - | ||||||||||||
4370 | switch (state) { | - | ||||||||||||
4371 | case ExtID: | - | ||||||||||||
4372 | - | |||||||||||||
4373 | if (dtdHnd) { | - | ||||||||||||
4374 | if (!dtdHnd->notationDecl(name(), publicId, systemId)) { | - | ||||||||||||
4375 | reportParseError(dtdHnd->errorString()); | - | ||||||||||||
4376 | return false; | - | ||||||||||||
4377 | } | - | ||||||||||||
4378 | } | - | ||||||||||||
4379 | state = ExtIDR; | - | ||||||||||||
4380 | break; | - | ||||||||||||
4381 | case Done: | - | ||||||||||||
4382 | return true; | - | ||||||||||||
4383 | case -1: | - | ||||||||||||
4384 | - | |||||||||||||
4385 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
4386 | return false; | - | ||||||||||||
4387 | } | - | ||||||||||||
4388 | - | |||||||||||||
4389 | if (atEnd()) { | - | ||||||||||||
4390 | unexpectedEof(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4391 | return false; | - | ||||||||||||
4392 | } | - | ||||||||||||
4393 | if (is_S(c)) { | - | ||||||||||||
4394 | input = InpWs; | - | ||||||||||||
4395 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
4396 | input = InpGt; | - | ||||||||||||
4397 | } else if (c == QLatin1Char('N')) { | - | ||||||||||||
4398 | input = InpN; | - | ||||||||||||
4399 | } else { | - | ||||||||||||
4400 | input = InpUnknown; | - | ||||||||||||
4401 | } | - | ||||||||||||
4402 | state = table[state][input]; | - | ||||||||||||
4403 | - | |||||||||||||
4404 | switch (state) { | - | ||||||||||||
4405 | case Not: | - | ||||||||||||
4406 | parseString_s = QLatin1String("NOTATION"); | - | ||||||||||||
4407 | if (!parseString()) { | - | ||||||||||||
4408 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4409 | return false; | - | ||||||||||||
4410 | } | - | ||||||||||||
4411 | break; | - | ||||||||||||
4412 | case Ws1: | - | ||||||||||||
4413 | if (!eat_ws()) { | - | ||||||||||||
4414 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4415 | return false; | - | ||||||||||||
4416 | } | - | ||||||||||||
4417 | break; | - | ||||||||||||
4418 | case Nam: | - | ||||||||||||
4419 | parseName_useRef = false; | - | ||||||||||||
4420 | if (!parseName()) { | - | ||||||||||||
4421 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4422 | return false; | - | ||||||||||||
4423 | } | - | ||||||||||||
4424 | break; | - | ||||||||||||
4425 | case Ws2: | - | ||||||||||||
4426 | if (!eat_ws()) { | - | ||||||||||||
4427 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4428 | return false; | - | ||||||||||||
4429 | } | - | ||||||||||||
4430 | break; | - | ||||||||||||
4431 | case ExtID: | - | ||||||||||||
4432 | case ExtIDR: | - | ||||||||||||
4433 | parseExternalID_allowPublicID = true; | - | ||||||||||||
4434 | if (!parseExternalID()) { | - | ||||||||||||
4435 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4436 | return false; | - | ||||||||||||
4437 | } | - | ||||||||||||
4438 | break; | - | ||||||||||||
4439 | case Ws3: | - | ||||||||||||
4440 | if (!eat_ws()) { | - | ||||||||||||
4441 | parseFailed(&QXmlSimpleReaderPrivate::parseNotationDecl, state); | - | ||||||||||||
4442 | return false; | - | ||||||||||||
4443 | } | - | ||||||||||||
4444 | break; | - | ||||||||||||
4445 | case Done: | - | ||||||||||||
4446 | next(); | - | ||||||||||||
4447 | break; | - | ||||||||||||
4448 | } | - | ||||||||||||
4449 | } | - | ||||||||||||
4450 | return false; | - | ||||||||||||
4451 | } | - | ||||||||||||
4452 | - | |||||||||||||
4453 | - | |||||||||||||
4454 | - | |||||||||||||
4455 | - | |||||||||||||
4456 | - | |||||||||||||
4457 | - | |||||||||||||
4458 | - | |||||||||||||
4459 | bool QXmlSimpleReaderPrivate::parseChoiceSeq() | - | ||||||||||||
4460 | { | - | ||||||||||||
4461 | const signed char Init = 0; | - | ||||||||||||
4462 | const signed char Ws1 = 1; | - | ||||||||||||
4463 | const signed char CoS = 2; | - | ||||||||||||
4464 | const signed char Ws2 = 3; | - | ||||||||||||
4465 | const signed char More = 4; | - | ||||||||||||
4466 | const signed char Name = 5; | - | ||||||||||||
4467 | const signed char Done = 6; | - | ||||||||||||
4468 | - | |||||||||||||
4469 | const signed char InpWs = 0; | - | ||||||||||||
4470 | const signed char InpOp = 1; | - | ||||||||||||
4471 | const signed char InpCp = 2; | - | ||||||||||||
4472 | const signed char InpQm = 3; | - | ||||||||||||
4473 | const signed char InpAst = 4; | - | ||||||||||||
4474 | const signed char InpPlus = 5; | - | ||||||||||||
4475 | const signed char InpPipe = 6; | - | ||||||||||||
4476 | const signed char InpComm = 7; | - | ||||||||||||
4477 | const signed char InpUnknown = 8; | - | ||||||||||||
4478 | - | |||||||||||||
4479 | static const signed char table[6][9] = { | - | ||||||||||||
4480 | - | |||||||||||||
4481 | { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, | - | ||||||||||||
4482 | { -1, CoS, -1, -1, -1, -1, -1, -1, CoS }, | - | ||||||||||||
4483 | { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 }, | - | ||||||||||||
4484 | { -1, -1, Done, -1, -1, -1, More, More, -1 }, | - | ||||||||||||
4485 | { -1, Ws1, -1, -1, -1, -1, -1, -1, Name }, | - | ||||||||||||
4486 | { Ws2, -1, Done, Ws2, Ws2, Ws2, More, More, -1 } | - | ||||||||||||
4487 | }; | - | ||||||||||||
4488 | signed char state; | - | ||||||||||||
4489 | signed char input; | - | ||||||||||||
4490 | - | |||||||||||||
4491 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
4492 | state = Init; | - | ||||||||||||
4493 | } else { | - | ||||||||||||
4494 | state = parseStack->pop().state; | - | ||||||||||||
4495 | - | |||||||||||||
4496 | - | |||||||||||||
4497 | - | |||||||||||||
4498 | if (!parseStack->isEmpty()) { | - | ||||||||||||
4499 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
4500 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
4501 | parseStack->pop(); | - | ||||||||||||
4502 | - | |||||||||||||
4503 | - | |||||||||||||
4504 | - | |||||||||||||
4505 | } | - | ||||||||||||
4506 | if (!(this->*function)()) { | - | ||||||||||||
4507 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4508 | return false; | - | ||||||||||||
4509 | } | - | ||||||||||||
4510 | } | - | ||||||||||||
4511 | } | - | ||||||||||||
4512 | - | |||||||||||||
4513 | for (;;) { | - | ||||||||||||
4514 | switch (state) { | - | ||||||||||||
4515 | case Done: | - | ||||||||||||
4516 | return true; | - | ||||||||||||
4517 | case -1: | - | ||||||||||||
4518 | - | |||||||||||||
4519 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
4520 | return false; | - | ||||||||||||
4521 | } | - | ||||||||||||
4522 | - | |||||||||||||
4523 | if (atEnd()) { | - | ||||||||||||
4524 | unexpectedEof(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4525 | return false; | - | ||||||||||||
4526 | } | - | ||||||||||||
4527 | if (is_S(c)) { | - | ||||||||||||
4528 | input = InpWs; | - | ||||||||||||
4529 | } else if (c == QLatin1Char('(')) { | - | ||||||||||||
4530 | input = InpOp; | - | ||||||||||||
4531 | } else if (c == QLatin1Char(')')) { | - | ||||||||||||
4532 | input = InpCp; | - | ||||||||||||
4533 | } else if (c == QLatin1Char('?')) { | - | ||||||||||||
4534 | input = InpQm; | - | ||||||||||||
4535 | } else if (c == QLatin1Char('*')) { | - | ||||||||||||
4536 | input = InpAst; | - | ||||||||||||
4537 | } else if (c == QLatin1Char('+')) { | - | ||||||||||||
4538 | input = InpPlus; | - | ||||||||||||
4539 | } else if (c == QLatin1Char('|')) { | - | ||||||||||||
4540 | input = InpPipe; | - | ||||||||||||
4541 | } else if (c == QLatin1Char(',')) { | - | ||||||||||||
4542 | input = InpComm; | - | ||||||||||||
4543 | } else { | - | ||||||||||||
4544 | input = InpUnknown; | - | ||||||||||||
4545 | } | - | ||||||||||||
4546 | state = table[state][input]; | - | ||||||||||||
4547 | - | |||||||||||||
4548 | switch (state) { | - | ||||||||||||
4549 | case Ws1: | - | ||||||||||||
4550 | if (!next_eat_ws()) { | - | ||||||||||||
4551 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4552 | return false; | - | ||||||||||||
4553 | } | - | ||||||||||||
4554 | break; | - | ||||||||||||
4555 | case CoS: | - | ||||||||||||
4556 | if (!parseChoiceSeq()) { | - | ||||||||||||
4557 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4558 | return false; | - | ||||||||||||
4559 | } | - | ||||||||||||
4560 | break; | - | ||||||||||||
4561 | case Ws2: | - | ||||||||||||
4562 | if (!next_eat_ws()) { | - | ||||||||||||
4563 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4564 | return false; | - | ||||||||||||
4565 | } | - | ||||||||||||
4566 | break; | - | ||||||||||||
4567 | case More: | - | ||||||||||||
4568 | if (!next_eat_ws()) { | - | ||||||||||||
4569 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4570 | return false; | - | ||||||||||||
4571 | } | - | ||||||||||||
4572 | break; | - | ||||||||||||
4573 | case Name: | - | ||||||||||||
4574 | parseName_useRef = false; | - | ||||||||||||
4575 | if (!parseName()) { | - | ||||||||||||
4576 | parseFailed(&QXmlSimpleReaderPrivate::parseChoiceSeq, state); | - | ||||||||||||
4577 | return false; | - | ||||||||||||
4578 | } | - | ||||||||||||
4579 | break; | - | ||||||||||||
4580 | case Done: | - | ||||||||||||
4581 | next(); | - | ||||||||||||
4582 | break; | - | ||||||||||||
4583 | } | - | ||||||||||||
4584 | } | - | ||||||||||||
4585 | return false; | - | ||||||||||||
4586 | } | - | ||||||||||||
4587 | - | |||||||||||||
4588 | bool QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(QString *errorMessage) | - | ||||||||||||
4589 | { | - | ||||||||||||
4590 | QString entityNameBuffer; | - | ||||||||||||
4591 | - | |||||||||||||
4592 | - | |||||||||||||
4593 | for (QMap<QString,QString>::const_iterator toSearchIt = entities.constBegin(); | - | ||||||||||||
4594 | toSearchIt != entities.constEnd(); | - | ||||||||||||
4595 | ++toSearchIt) { | - | ||||||||||||
4596 | const QString &toSearch = toSearchIt.key(); | - | ||||||||||||
4597 | - | |||||||||||||
4598 | - | |||||||||||||
4599 | if (!literalEntitySizes.contains(toSearch)) { | - | ||||||||||||
4600 | - | |||||||||||||
4601 | QString leftOvers = entities.value(toSearch); | - | ||||||||||||
4602 | - | |||||||||||||
4603 | for (QMap<QString,QString>::const_iterator referencedIt = entities.constBegin(); | - | ||||||||||||
4604 | referencedIt != entities.constEnd(); | - | ||||||||||||
4605 | ++referencedIt) { | - | ||||||||||||
4606 | const QString &entityName = referencedIt.key(); | - | ||||||||||||
4607 | - | |||||||||||||
4608 | for (int i = 0; i < leftOvers.size() && i != -1; ) { | - | ||||||||||||
4609 | entityNameBuffer = QLatin1Char('&') + entityName + QLatin1Char(';'); | - | ||||||||||||
4610 | - | |||||||||||||
4611 | i = leftOvers.indexOf(entityNameBuffer, i); | - | ||||||||||||
4612 | if (i != -1) { | - | ||||||||||||
4613 | leftOvers.remove(i, entityName.size() + 2); | - | ||||||||||||
4614 | - | |||||||||||||
4615 | ++referencesToOtherEntities[toSearch][entityName]; | - | ||||||||||||
4616 | } | - | ||||||||||||
4617 | } | - | ||||||||||||
4618 | } | - | ||||||||||||
4619 | literalEntitySizes[toSearch] = leftOvers.size(); | - | ||||||||||||
4620 | } | - | ||||||||||||
4621 | } | - | ||||||||||||
4622 | - | |||||||||||||
4623 | for (QHash<QString, QHash<QString, int> >::const_iterator entityIt = referencesToOtherEntities.constBegin(); | - | ||||||||||||
4624 | entityIt != referencesToOtherEntities.constEnd(); | - | ||||||||||||
4625 | ++entityIt) { | - | ||||||||||||
4626 | const QString &entity = entityIt.key(); | - | ||||||||||||
4627 | - | |||||||||||||
4628 | QHash<QString, int>::iterator expandedIt = expandedSizes.find(entity); | - | ||||||||||||
4629 | if (expandedIt == expandedSizes.end()) { | - | ||||||||||||
4630 | expandedIt = expandedSizes.insert(entity, literalEntitySizes.value(entity)); | - | ||||||||||||
4631 | for (QHash<QString, int>::const_iterator referenceIt = entityIt->constBegin(); | - | ||||||||||||
4632 | referenceIt != entityIt->constEnd(); | - | ||||||||||||
4633 | ++referenceIt) { | - | ||||||||||||
4634 | const QString &referenceTo = referenceIt.key(); | - | ||||||||||||
4635 | const int references = referencesToOtherEntities.value(entity).value(referenceTo); | - | ||||||||||||
4636 | - | |||||||||||||
4637 | *expandedIt += expandedSizes.value(referenceTo) * references + literalEntitySizes.value(referenceTo) * references; | - | ||||||||||||
4638 | } | - | ||||||||||||
4639 | - | |||||||||||||
4640 | if (*expandedIt > entityCharacterLimit) { | - | ||||||||||||
4641 | if (errorMessage) { | - | ||||||||||||
4642 | *errorMessage = QString::fromLatin1("The XML entity \"%1\" expands to a string that is too large to process (%2 characters > %3).") | - | ||||||||||||
4643 | .arg(entity, QString::number(*expandedIt), QString::number(entityCharacterLimit)); | - | ||||||||||||
4644 | } | - | ||||||||||||
4645 | return true; | - | ||||||||||||
4646 | } | - | ||||||||||||
4647 | } | - | ||||||||||||
4648 | } | - | ||||||||||||
4649 | return false; | - | ||||||||||||
4650 | } | - | ||||||||||||
4651 | - | |||||||||||||
4652 | - | |||||||||||||
4653 | - | |||||||||||||
4654 | - | |||||||||||||
4655 | - | |||||||||||||
4656 | - | |||||||||||||
4657 | - | |||||||||||||
4658 | bool QXmlSimpleReaderPrivate::parseEntityDecl() | - | ||||||||||||
4659 | { | - | ||||||||||||
4660 | const signed char Init = 0; | - | ||||||||||||
4661 | const signed char Ent = 1; | - | ||||||||||||
4662 | const signed char Ws1 = 2; | - | ||||||||||||
4663 | const signed char Name = 3; | - | ||||||||||||
4664 | const signed char Ws2 = 4; | - | ||||||||||||
4665 | const signed char EValue = 5; | - | ||||||||||||
4666 | const signed char EValueR = 6; | - | ||||||||||||
4667 | const signed char ExtID = 7; | - | ||||||||||||
4668 | const signed char Ws3 = 8; | - | ||||||||||||
4669 | const signed char Ndata = 9; | - | ||||||||||||
4670 | const signed char Ws4 = 10; | - | ||||||||||||
4671 | const signed char NNam = 11; | - | ||||||||||||
4672 | const signed char NNamR = 12; | - | ||||||||||||
4673 | const signed char PEDec = 13; | - | ||||||||||||
4674 | const signed char Ws6 = 14; | - | ||||||||||||
4675 | const signed char PENam = 15; | - | ||||||||||||
4676 | const signed char Ws7 = 16; | - | ||||||||||||
4677 | const signed char PEVal = 17; | - | ||||||||||||
4678 | const signed char PEValR = 18; | - | ||||||||||||
4679 | const signed char PEEID = 19; | - | ||||||||||||
4680 | const signed char PEEIDR = 20; | - | ||||||||||||
4681 | const signed char WsE = 21; | - | ||||||||||||
4682 | const signed char Done = 22; | - | ||||||||||||
4683 | const signed char EDDone = 23; | - | ||||||||||||
4684 | - | |||||||||||||
4685 | const signed char InpWs = 0; | - | ||||||||||||
4686 | const signed char InpPer = 1; | - | ||||||||||||
4687 | const signed char InpQuot = 2; | - | ||||||||||||
4688 | const signed char InpGt = 3; | - | ||||||||||||
4689 | const signed char InpN = 4; | - | ||||||||||||
4690 | const signed char InpUnknown = 5; | - | ||||||||||||
4691 | - | |||||||||||||
4692 | static const signed char table[22][6] = { | - | ||||||||||||
4693 | - | |||||||||||||
4694 | { -1, -1, -1, -1, Ent, -1 }, | - | ||||||||||||
4695 | { Ws1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4696 | { -1, PEDec, -1, -1, Name, Name }, | - | ||||||||||||
4697 | { Ws2, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4698 | { -1, -1, EValue, -1, -1, ExtID }, | - | ||||||||||||
4699 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4700 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4701 | { Ws3, -1, -1, EDDone,-1, -1 }, | - | ||||||||||||
4702 | { -1, -1, -1, EDDone,Ndata, -1 }, | - | ||||||||||||
4703 | { Ws4, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4704 | { -1, -1, -1, -1, NNam, NNam }, | - | ||||||||||||
4705 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4706 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4707 | { Ws6, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4708 | { -1, -1, -1, -1, PENam, PENam }, | - | ||||||||||||
4709 | { Ws7, -1, -1, -1, -1, -1 }, | - | ||||||||||||
4710 | { -1, -1, PEVal, -1, -1, PEEID }, | - | ||||||||||||
4711 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4712 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4713 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4714 | { WsE, -1, -1, Done, -1, -1 }, | - | ||||||||||||
4715 | { -1, -1, -1, Done, -1, -1 } | - | ||||||||||||
4716 | }; | - | ||||||||||||
4717 | signed char state; | - | ||||||||||||
4718 | signed char input; | - | ||||||||||||
4719 | - | |||||||||||||
4720 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
4721 | state = Init; | - | ||||||||||||
4722 | } else { | - | ||||||||||||
4723 | state = parseStack->pop().state; | - | ||||||||||||
4724 | - | |||||||||||||
4725 | - | |||||||||||||
4726 | - | |||||||||||||
4727 | if (!parseStack->isEmpty()) { | - | ||||||||||||
4728 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
4729 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
4730 | parseStack->pop(); | - | ||||||||||||
4731 | - | |||||||||||||
4732 | - | |||||||||||||
4733 | - | |||||||||||||
4734 | } | - | ||||||||||||
4735 | if (!(this->*function)()) { | - | ||||||||||||
4736 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4737 | return false; | - | ||||||||||||
4738 | } | - | ||||||||||||
4739 | } | - | ||||||||||||
4740 | } | - | ||||||||||||
4741 | - | |||||||||||||
4742 | for (;;) { | - | ||||||||||||
4743 | switch (state) { | - | ||||||||||||
4744 | case EValue: | - | ||||||||||||
4745 | if ( !entityExist(name())) { | - | ||||||||||||
4746 | QString errorMessage; | - | ||||||||||||
4747 | if (isExpandedEntityValueTooLarge(&errorMessage)) { | - | ||||||||||||
4748 | reportParseError(errorMessage); | - | ||||||||||||
4749 | return false; | - | ||||||||||||
4750 | } | - | ||||||||||||
4751 | - | |||||||||||||
4752 | entities.insert(name(), string()); | - | ||||||||||||
4753 | if (declHnd) { | - | ||||||||||||
4754 | if (!declHnd->internalEntityDecl(name(), string())) { | - | ||||||||||||
4755 | reportParseError(declHnd->errorString()); | - | ||||||||||||
4756 | return false; | - | ||||||||||||
4757 | } | - | ||||||||||||
4758 | } | - | ||||||||||||
4759 | } | - | ||||||||||||
4760 | state = EValueR; | - | ||||||||||||
4761 | break; | - | ||||||||||||
4762 | case NNam: | - | ||||||||||||
4763 | if ( !entityExist(name())) { | - | ||||||||||||
4764 | externEntities.insert(name(), QXmlSimpleReaderPrivate::ExternEntity(publicId, systemId, ref())); | - | ||||||||||||
4765 | if (dtdHnd) { | - | ||||||||||||
4766 | if (!dtdHnd->unparsedEntityDecl(name(), publicId, systemId, ref())) { | - | ||||||||||||
4767 | reportParseError(declHnd->errorString()); | - | ||||||||||||
4768 | return false; | - | ||||||||||||
4769 | } | - | ||||||||||||
4770 | } | - | ||||||||||||
4771 | } | - | ||||||||||||
4772 | state = NNamR; | - | ||||||||||||
4773 | break; | - | ||||||||||||
4774 | case PEVal: | - | ||||||||||||
4775 | if ( !entityExist(name())) { | - | ||||||||||||
4776 | parameterEntities.insert(name(), string()); | - | ||||||||||||
4777 | if (declHnd) { | - | ||||||||||||
4778 | if (!declHnd->internalEntityDecl(QLatin1Char('%') + name(), string())) { | - | ||||||||||||
4779 | reportParseError(declHnd->errorString()); | - | ||||||||||||
4780 | return false; | - | ||||||||||||
4781 | } | - | ||||||||||||
4782 | } | - | ||||||||||||
4783 | } | - | ||||||||||||
4784 | state = PEValR; | - | ||||||||||||
4785 | break; | - | ||||||||||||
4786 | case PEEID: | - | ||||||||||||
4787 | if ( !entityExist(name())) { | - | ||||||||||||
4788 | externParameterEntities.insert(name(), QXmlSimpleReaderPrivate::ExternParameterEntity(publicId, systemId)); | - | ||||||||||||
4789 | if (declHnd) { | - | ||||||||||||
4790 | if (!declHnd->externalEntityDecl(QLatin1Char('%') + name(), publicId, systemId)) { | - | ||||||||||||
4791 | reportParseError(declHnd->errorString()); | - | ||||||||||||
4792 | return false; | - | ||||||||||||
4793 | } | - | ||||||||||||
4794 | } | - | ||||||||||||
4795 | } | - | ||||||||||||
4796 | state = PEEIDR; | - | ||||||||||||
4797 | break; | - | ||||||||||||
4798 | case EDDone: | - | ||||||||||||
4799 | if ( !entityExist(name())) { | - | ||||||||||||
4800 | externEntities.insert(name(), QXmlSimpleReaderPrivate::ExternEntity(publicId, systemId, QString())); | - | ||||||||||||
4801 | if (declHnd) { | - | ||||||||||||
4802 | if (!declHnd->externalEntityDecl(name(), publicId, systemId)) { | - | ||||||||||||
4803 | reportParseError(declHnd->errorString()); | - | ||||||||||||
4804 | return false; | - | ||||||||||||
4805 | } | - | ||||||||||||
4806 | } | - | ||||||||||||
4807 | } | - | ||||||||||||
4808 | return true; | - | ||||||||||||
4809 | case Done: | - | ||||||||||||
4810 | return true; | - | ||||||||||||
4811 | case -1: | - | ||||||||||||
4812 | - | |||||||||||||
4813 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
4814 | return false; | - | ||||||||||||
4815 | } | - | ||||||||||||
4816 | - | |||||||||||||
4817 | if (atEnd()) { | - | ||||||||||||
4818 | unexpectedEof(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4819 | return false; | - | ||||||||||||
4820 | } | - | ||||||||||||
4821 | if (is_S(c)) { | - | ||||||||||||
4822 | input = InpWs; | - | ||||||||||||
4823 | } else if (c == QLatin1Char('%')) { | - | ||||||||||||
4824 | input = InpPer; | - | ||||||||||||
4825 | } else if (c == QLatin1Char('"') || c == QLatin1Char('\'')) { | - | ||||||||||||
4826 | input = InpQuot; | - | ||||||||||||
4827 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
4828 | input = InpGt; | - | ||||||||||||
4829 | } else if (c == QLatin1Char('N')) { | - | ||||||||||||
4830 | input = InpN; | - | ||||||||||||
4831 | } else { | - | ||||||||||||
4832 | input = InpUnknown; | - | ||||||||||||
4833 | } | - | ||||||||||||
4834 | state = table[state][input]; | - | ||||||||||||
4835 | - | |||||||||||||
4836 | switch (state) { | - | ||||||||||||
4837 | case Ent: | - | ||||||||||||
4838 | parseString_s = QLatin1String("NTITY"); | - | ||||||||||||
4839 | if (!parseString()) { | - | ||||||||||||
4840 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4841 | return false; | - | ||||||||||||
4842 | } | - | ||||||||||||
4843 | break; | - | ||||||||||||
4844 | case Ws1: | - | ||||||||||||
4845 | if (!eat_ws()) { | - | ||||||||||||
4846 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4847 | return false; | - | ||||||||||||
4848 | } | - | ||||||||||||
4849 | break; | - | ||||||||||||
4850 | case Name: | - | ||||||||||||
4851 | parseName_useRef = false; | - | ||||||||||||
4852 | if (!parseName()) { | - | ||||||||||||
4853 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4854 | return false; | - | ||||||||||||
4855 | } | - | ||||||||||||
4856 | break; | - | ||||||||||||
4857 | case Ws2: | - | ||||||||||||
4858 | if (!eat_ws()) { | - | ||||||||||||
4859 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4860 | return false; | - | ||||||||||||
4861 | } | - | ||||||||||||
4862 | break; | - | ||||||||||||
4863 | case EValue: | - | ||||||||||||
4864 | case EValueR: | - | ||||||||||||
4865 | if (!parseEntityValue()) { | - | ||||||||||||
4866 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4867 | return false; | - | ||||||||||||
4868 | } | - | ||||||||||||
4869 | break; | - | ||||||||||||
4870 | case ExtID: | - | ||||||||||||
4871 | parseExternalID_allowPublicID = false; | - | ||||||||||||
4872 | if (!parseExternalID()) { | - | ||||||||||||
4873 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4874 | return false; | - | ||||||||||||
4875 | } | - | ||||||||||||
4876 | break; | - | ||||||||||||
4877 | case Ws3: | - | ||||||||||||
4878 | if (!eat_ws()) { | - | ||||||||||||
4879 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4880 | return false; | - | ||||||||||||
4881 | } | - | ||||||||||||
4882 | break; | - | ||||||||||||
4883 | case Ndata: | - | ||||||||||||
4884 | parseString_s = QLatin1String("NDATA"); | - | ||||||||||||
4885 | if (!parseString()) { | - | ||||||||||||
4886 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4887 | return false; | - | ||||||||||||
4888 | } | - | ||||||||||||
4889 | break; | - | ||||||||||||
4890 | case Ws4: | - | ||||||||||||
4891 | if (!eat_ws()) { | - | ||||||||||||
4892 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4893 | return false; | - | ||||||||||||
4894 | } | - | ||||||||||||
4895 | break; | - | ||||||||||||
4896 | case NNam: | - | ||||||||||||
4897 | case NNamR: | - | ||||||||||||
4898 | parseName_useRef = true; | - | ||||||||||||
4899 | if (!parseName()) { | - | ||||||||||||
4900 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4901 | return false; | - | ||||||||||||
4902 | } | - | ||||||||||||
4903 | break; | - | ||||||||||||
4904 | case PEDec: | - | ||||||||||||
4905 | next(); | - | ||||||||||||
4906 | break; | - | ||||||||||||
4907 | case Ws6: | - | ||||||||||||
4908 | if (!eat_ws()) { | - | ||||||||||||
4909 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4910 | return false; | - | ||||||||||||
4911 | } | - | ||||||||||||
4912 | break; | - | ||||||||||||
4913 | case PENam: | - | ||||||||||||
4914 | parseName_useRef = false; | - | ||||||||||||
4915 | if (!parseName()) { | - | ||||||||||||
4916 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4917 | return false; | - | ||||||||||||
4918 | } | - | ||||||||||||
4919 | break; | - | ||||||||||||
4920 | case Ws7: | - | ||||||||||||
4921 | if (!eat_ws()) { | - | ||||||||||||
4922 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4923 | return false; | - | ||||||||||||
4924 | } | - | ||||||||||||
4925 | break; | - | ||||||||||||
4926 | case PEVal: | - | ||||||||||||
4927 | case PEValR: | - | ||||||||||||
4928 | if (!parseEntityValue()) { | - | ||||||||||||
4929 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4930 | return false; | - | ||||||||||||
4931 | } | - | ||||||||||||
4932 | break; | - | ||||||||||||
4933 | case PEEID: | - | ||||||||||||
4934 | case PEEIDR: | - | ||||||||||||
4935 | parseExternalID_allowPublicID = false; | - | ||||||||||||
4936 | if (!parseExternalID()) { | - | ||||||||||||
4937 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4938 | return false; | - | ||||||||||||
4939 | } | - | ||||||||||||
4940 | break; | - | ||||||||||||
4941 | case WsE: | - | ||||||||||||
4942 | if (!eat_ws()) { | - | ||||||||||||
4943 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityDecl, state); | - | ||||||||||||
4944 | return false; | - | ||||||||||||
4945 | } | - | ||||||||||||
4946 | break; | - | ||||||||||||
4947 | case EDDone: | - | ||||||||||||
4948 | next(); | - | ||||||||||||
4949 | break; | - | ||||||||||||
4950 | case Done: | - | ||||||||||||
4951 | next(); | - | ||||||||||||
4952 | break; | - | ||||||||||||
4953 | } | - | ||||||||||||
4954 | } | - | ||||||||||||
4955 | return false; | - | ||||||||||||
4956 | } | - | ||||||||||||
4957 | - | |||||||||||||
4958 | - | |||||||||||||
4959 | - | |||||||||||||
4960 | - | |||||||||||||
4961 | bool QXmlSimpleReaderPrivate::parseEntityValue() | - | ||||||||||||
4962 | { | - | ||||||||||||
4963 | const signed char Init = 0; | - | ||||||||||||
4964 | const signed char Dq = 1; | - | ||||||||||||
4965 | const signed char DqC = 2; | - | ||||||||||||
4966 | const signed char DqPER = 3; | - | ||||||||||||
4967 | const signed char DqRef = 4; | - | ||||||||||||
4968 | const signed char Sq = 5; | - | ||||||||||||
4969 | const signed char SqC = 6; | - | ||||||||||||
4970 | const signed char SqPER = 7; | - | ||||||||||||
4971 | const signed char SqRef = 8; | - | ||||||||||||
4972 | const signed char Done = 9; | - | ||||||||||||
4973 | - | |||||||||||||
4974 | const signed char InpDq = 0; | - | ||||||||||||
4975 | const signed char InpSq = 1; | - | ||||||||||||
4976 | const signed char InpAmp = 2; | - | ||||||||||||
4977 | const signed char InpPer = 3; | - | ||||||||||||
4978 | const signed char InpUnknown = 4; | - | ||||||||||||
4979 | - | |||||||||||||
4980 | static const signed char table[9][5] = { | - | ||||||||||||
4981 | - | |||||||||||||
4982 | { Dq, Sq, -1, -1, -1 }, | - | ||||||||||||
4983 | { Done, DqC, DqRef, DqPER, DqC }, | - | ||||||||||||
4984 | { Done, DqC, DqRef, DqPER, DqC }, | - | ||||||||||||
4985 | { Done, DqC, DqRef, DqPER, DqC }, | - | ||||||||||||
4986 | { Done, DqC, DqRef, DqPER, DqC }, | - | ||||||||||||
4987 | { SqC, Done, SqRef, SqPER, SqC }, | - | ||||||||||||
4988 | { SqC, Done, SqRef, SqPER, SqC }, | - | ||||||||||||
4989 | { SqC, Done, SqRef, SqPER, SqC }, | - | ||||||||||||
4990 | { SqC, Done, SqRef, SqPER, SqC } | - | ||||||||||||
4991 | }; | - | ||||||||||||
4992 | signed char state; | - | ||||||||||||
4993 | signed char input; | - | ||||||||||||
4994 | - | |||||||||||||
4995 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
4996 | state = Init; | - | ||||||||||||
4997 | } else { | - | ||||||||||||
4998 | state = parseStack->pop().state; | - | ||||||||||||
4999 | - | |||||||||||||
5000 | - | |||||||||||||
5001 | - | |||||||||||||
5002 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5003 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5004 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5005 | parseStack->pop(); | - | ||||||||||||
5006 | - | |||||||||||||
5007 | - | |||||||||||||
5008 | - | |||||||||||||
5009 | } | - | ||||||||||||
5010 | if (!(this->*function)()) { | - | ||||||||||||
5011 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||
5012 | return false; | - | ||||||||||||
5013 | } | - | ||||||||||||
5014 | } | - | ||||||||||||
5015 | } | - | ||||||||||||
5016 | - | |||||||||||||
5017 | for (;;) { | - | ||||||||||||
5018 | switch (state) { | - | ||||||||||||
5019 | case Done: | - | ||||||||||||
5020 | return true; | - | ||||||||||||
5021 | case -1: | - | ||||||||||||
5022 | - | |||||||||||||
5023 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
5024 | return false; | - | ||||||||||||
5025 | } | - | ||||||||||||
5026 | - | |||||||||||||
5027 | if (atEnd()) { | - | ||||||||||||
5028 | unexpectedEof(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||
5029 | return false; | - | ||||||||||||
5030 | } | - | ||||||||||||
5031 | if (c == QLatin1Char('"')) { | - | ||||||||||||
5032 | input = InpDq; | - | ||||||||||||
5033 | } else if (c == QLatin1Char('\'')) { | - | ||||||||||||
5034 | input = InpSq; | - | ||||||||||||
5035 | } else if (c == QLatin1Char('&')) { | - | ||||||||||||
5036 | input = InpAmp; | - | ||||||||||||
5037 | } else if (c == QLatin1Char('%')) { | - | ||||||||||||
5038 | input = InpPer; | - | ||||||||||||
5039 | } else { | - | ||||||||||||
5040 | input = InpUnknown; | - | ||||||||||||
5041 | } | - | ||||||||||||
5042 | state = table[state][input]; | - | ||||||||||||
5043 | - | |||||||||||||
5044 | switch (state) { | - | ||||||||||||
5045 | case Dq: | - | ||||||||||||
5046 | case Sq: | - | ||||||||||||
5047 | stringClear(); | - | ||||||||||||
5048 | next(); | - | ||||||||||||
5049 | break; | - | ||||||||||||
5050 | case DqC: | - | ||||||||||||
5051 | case SqC: | - | ||||||||||||
5052 | stringAddC(); | - | ||||||||||||
5053 | next(); | - | ||||||||||||
5054 | break; | - | ||||||||||||
5055 | case DqPER: | - | ||||||||||||
5056 | case SqPER: | - | ||||||||||||
5057 | parsePEReference_context = InEntityValue; | - | ||||||||||||
5058 | if (!parsePEReference()) { | - | ||||||||||||
5059 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||
5060 | return false; | - | ||||||||||||
5061 | } | - | ||||||||||||
5062 | break; | - | ||||||||||||
5063 | case DqRef: | - | ||||||||||||
5064 | case SqRef: | - | ||||||||||||
5065 | parseReference_context = InEntityValue; | - | ||||||||||||
5066 | if (!parseReference()) { | - | ||||||||||||
5067 | parseFailed(&QXmlSimpleReaderPrivate::parseEntityValue, state); | - | ||||||||||||
5068 | return false; | - | ||||||||||||
5069 | } | - | ||||||||||||
5070 | break; | - | ||||||||||||
5071 | case Done: | - | ||||||||||||
5072 | next(); | - | ||||||||||||
5073 | break; | - | ||||||||||||
5074 | } | - | ||||||||||||
5075 | } | - | ||||||||||||
5076 | return false; | - | ||||||||||||
5077 | } | - | ||||||||||||
5078 | bool QXmlSimpleReaderPrivate::parseComment() | - | ||||||||||||
5079 | { | - | ||||||||||||
5080 | const signed char Init = 0; | - | ||||||||||||
5081 | const signed char Dash1 = 1; | - | ||||||||||||
5082 | const signed char Dash2 = 2; | - | ||||||||||||
5083 | const signed char Com = 3; | - | ||||||||||||
5084 | const signed char Com2 = 4; | - | ||||||||||||
5085 | const signed char ComE = 5; | - | ||||||||||||
5086 | const signed char Done = 6; | - | ||||||||||||
5087 | - | |||||||||||||
5088 | const signed char InpDash = 0; | - | ||||||||||||
5089 | const signed char InpGt = 1; | - | ||||||||||||
5090 | const signed char InpUnknown = 2; | - | ||||||||||||
5091 | - | |||||||||||||
5092 | static const signed char table[6][3] = { | - | ||||||||||||
5093 | - | |||||||||||||
5094 | { Dash1, -1, -1 }, | - | ||||||||||||
5095 | { Dash2, -1, -1 }, | - | ||||||||||||
5096 | { Com2, Com, Com }, | - | ||||||||||||
5097 | { Com2, Com, Com }, | - | ||||||||||||
5098 | { ComE, Com, Com }, | - | ||||||||||||
5099 | { -1, Done, -1 } | - | ||||||||||||
5100 | }; | - | ||||||||||||
5101 | signed char state; | - | ||||||||||||
5102 | signed char input; | - | ||||||||||||
5103 | - | |||||||||||||
5104 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
5105 | state = Init; | - | ||||||||||||
5106 | } else { | - | ||||||||||||
5107 | state = parseStack->pop().state; | - | ||||||||||||
5108 | - | |||||||||||||
5109 | - | |||||||||||||
5110 | - | |||||||||||||
5111 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5112 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5113 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5114 | parseStack->pop(); | - | ||||||||||||
5115 | - | |||||||||||||
5116 | - | |||||||||||||
5117 | - | |||||||||||||
5118 | } | - | ||||||||||||
5119 | if (!(this->*function)()) { | - | ||||||||||||
5120 | parseFailed(&QXmlSimpleReaderPrivate::parseComment, state); | - | ||||||||||||
5121 | return false; | - | ||||||||||||
5122 | } | - | ||||||||||||
5123 | } | - | ||||||||||||
5124 | } | - | ||||||||||||
5125 | - | |||||||||||||
5126 | for (;;) { | - | ||||||||||||
5127 | switch (state) { | - | ||||||||||||
5128 | case Dash2: | - | ||||||||||||
5129 | stringClear(); | - | ||||||||||||
5130 | break; | - | ||||||||||||
5131 | case Com2: | - | ||||||||||||
5132 | - | |||||||||||||
5133 | if (!atEnd() && c != QLatin1Char('-')) | - | ||||||||||||
5134 | stringAddC(QLatin1Char('-')); | - | ||||||||||||
5135 | break; | - | ||||||||||||
5136 | case Done: | - | ||||||||||||
5137 | return true; | - | ||||||||||||
5138 | case -1: | - | ||||||||||||
5139 | - | |||||||||||||
5140 | reportParseError(QLatin1String("error occurred while parsing comment")); | - | ||||||||||||
5141 | return false; | - | ||||||||||||
5142 | } | - | ||||||||||||
5143 | - | |||||||||||||
5144 | if (atEnd()) { | - | ||||||||||||
5145 | unexpectedEof(&QXmlSimpleReaderPrivate::parseComment, state); | - | ||||||||||||
5146 | return false; | - | ||||||||||||
5147 | } | - | ||||||||||||
5148 | if (c == QLatin1Char('-')) { | - | ||||||||||||
5149 | input = InpDash; | - | ||||||||||||
5150 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||
5151 | input = InpGt; | - | ||||||||||||
5152 | } else { | - | ||||||||||||
5153 | input = InpUnknown; | - | ||||||||||||
5154 | } | - | ||||||||||||
5155 | state = table[state][input]; | - | ||||||||||||
5156 | - | |||||||||||||
5157 | switch (state) { | - | ||||||||||||
5158 | case Dash1: | - | ||||||||||||
5159 | next(); | - | ||||||||||||
5160 | break; | - | ||||||||||||
5161 | case Dash2: | - | ||||||||||||
5162 | next(); | - | ||||||||||||
5163 | break; | - | ||||||||||||
5164 | case Com: | - | ||||||||||||
5165 | stringAddC(); | - | ||||||||||||
5166 | next(); | - | ||||||||||||
5167 | break; | - | ||||||||||||
5168 | case Com2: | - | ||||||||||||
5169 | next(); | - | ||||||||||||
5170 | break; | - | ||||||||||||
5171 | case ComE: | - | ||||||||||||
5172 | next(); | - | ||||||||||||
5173 | break; | - | ||||||||||||
5174 | case Done: | - | ||||||||||||
5175 | next(); | - | ||||||||||||
5176 | break; | - | ||||||||||||
5177 | } | - | ||||||||||||
5178 | } | - | ||||||||||||
5179 | return false; | - | ||||||||||||
5180 | } | - | ||||||||||||
5181 | bool QXmlSimpleReaderPrivate::parseAttribute() | - | ||||||||||||
5182 | { | - | ||||||||||||
5183 | const int Init = 0; | - | ||||||||||||
5184 | const int PName = 1; | - | ||||||||||||
5185 | const int Ws = 2; | - | ||||||||||||
5186 | const int Eq = 3; | - | ||||||||||||
5187 | const int Quotes = 4; | - | ||||||||||||
5188 | - | |||||||||||||
5189 | const int InpNameBe = 0; | - | ||||||||||||
5190 | const int InpEq = 1; | - | ||||||||||||
5191 | const int InpDq = 2; | - | ||||||||||||
5192 | const int InpSq = 3; | - | ||||||||||||
5193 | const int InpUnknown = 4; | - | ||||||||||||
5194 | - | |||||||||||||
5195 | static const int table[4][5] = { | - | ||||||||||||
5196 | - | |||||||||||||
5197 | { PName, -1, -1, -1, -1 }, | - | ||||||||||||
5198 | { -1, Eq, -1, -1, Ws }, | - | ||||||||||||
5199 | { -1, Eq, -1, -1, -1 }, | - | ||||||||||||
5200 | { -1, -1, Quotes, Quotes, -1 } | - | ||||||||||||
5201 | }; | - | ||||||||||||
5202 | int state; | - | ||||||||||||
5203 | int input; | - | ||||||||||||
5204 | - | |||||||||||||
5205 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
5206 | state = Init; | - | ||||||||||||
5207 | } else { | - | ||||||||||||
5208 | state = parseStack->pop().state; | - | ||||||||||||
5209 | - | |||||||||||||
5210 | - | |||||||||||||
5211 | - | |||||||||||||
5212 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5213 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5214 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5215 | parseStack->pop(); | - | ||||||||||||
5216 | - | |||||||||||||
5217 | - | |||||||||||||
5218 | - | |||||||||||||
5219 | } | - | ||||||||||||
5220 | if (!(this->*function)()) { | - | ||||||||||||
5221 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||
5222 | return false; | - | ||||||||||||
5223 | } | - | ||||||||||||
5224 | } | - | ||||||||||||
5225 | } | - | ||||||||||||
5226 | - | |||||||||||||
5227 | for (;;) { | - | ||||||||||||
5228 | switch (state) { | - | ||||||||||||
5229 | case Quotes: | - | ||||||||||||
5230 | - | |||||||||||||
5231 | return true; | - | ||||||||||||
5232 | case -1: | - | ||||||||||||
5233 | - | |||||||||||||
5234 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
5235 | return false; | - | ||||||||||||
5236 | } | - | ||||||||||||
5237 | - | |||||||||||||
5238 | if (atEnd()) { | - | ||||||||||||
5239 | unexpectedEof(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||
5240 | return false; | - | ||||||||||||
5241 | } | - | ||||||||||||
5242 | if (determineNameChar(c) == NameBeginning) { | - | ||||||||||||
5243 | input = InpNameBe; | - | ||||||||||||
5244 | } else if (c == QLatin1Char('=')) { | - | ||||||||||||
5245 | input = InpEq; | - | ||||||||||||
5246 | } else if (c == QLatin1Char('"')) { | - | ||||||||||||
5247 | input = InpDq; | - | ||||||||||||
5248 | } else if (c == QLatin1Char('\'')) { | - | ||||||||||||
5249 | input = InpSq; | - | ||||||||||||
5250 | } else { | - | ||||||||||||
5251 | input = InpUnknown; | - | ||||||||||||
5252 | } | - | ||||||||||||
5253 | state = table[state][input]; | - | ||||||||||||
5254 | - | |||||||||||||
5255 | switch (state) { | - | ||||||||||||
5256 | case PName: | - | ||||||||||||
5257 | parseName_useRef = false; | - | ||||||||||||
5258 | if (!parseName()) { | - | ||||||||||||
5259 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||
5260 | return false; | - | ||||||||||||
5261 | } | - | ||||||||||||
5262 | break; | - | ||||||||||||
5263 | case Ws: | - | ||||||||||||
5264 | if (!eat_ws()) { | - | ||||||||||||
5265 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||
5266 | return false; | - | ||||||||||||
5267 | } | - | ||||||||||||
5268 | break; | - | ||||||||||||
5269 | case Eq: | - | ||||||||||||
5270 | if (!next_eat_ws()) { | - | ||||||||||||
5271 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||
5272 | return false; | - | ||||||||||||
5273 | } | - | ||||||||||||
5274 | break; | - | ||||||||||||
5275 | case Quotes: | - | ||||||||||||
5276 | if (!parseAttValue()) { | - | ||||||||||||
5277 | parseFailed(&QXmlSimpleReaderPrivate::parseAttribute, state); | - | ||||||||||||
5278 | return false; | - | ||||||||||||
5279 | } | - | ||||||||||||
5280 | break; | - | ||||||||||||
5281 | } | - | ||||||||||||
5282 | } | - | ||||||||||||
5283 | return false; | - | ||||||||||||
5284 | } | - | ||||||||||||
5285 | - | |||||||||||||
5286 | - | |||||||||||||
5287 | - | |||||||||||||
5288 | - | |||||||||||||
5289 | bool QXmlSimpleReaderPrivate::parseName() | - | ||||||||||||
5290 | { | - | ||||||||||||
5291 | const int Init = 0; | - | ||||||||||||
5292 | const int Name1 = 1; | - | ||||||||||||
5293 | const int Name = 2; | - | ||||||||||||
5294 | const int Done = 3; | - | ||||||||||||
5295 | - | |||||||||||||
5296 | static const int table[3][3] = { | - | ||||||||||||
5297 | - | |||||||||||||
5298 | { Name1, -1, -1 }, | - | ||||||||||||
5299 | { Name, Name, Done }, | - | ||||||||||||
5300 | { Name, Name, Done } | - | ||||||||||||
5301 | }; | - | ||||||||||||
5302 | int state; | - | ||||||||||||
5303 | - | |||||||||||||
5304 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
5305 | state = Init; | - | ||||||||||||
5306 | } else { | - | ||||||||||||
5307 | state = parseStack->pop().state; | - | ||||||||||||
5308 | - | |||||||||||||
5309 | - | |||||||||||||
5310 | - | |||||||||||||
5311 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5312 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5313 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5314 | parseStack->pop(); | - | ||||||||||||
5315 | - | |||||||||||||
5316 | - | |||||||||||||
5317 | - | |||||||||||||
5318 | } | - | ||||||||||||
5319 | if (!(this->*function)()) { | - | ||||||||||||
5320 | parseFailed(&QXmlSimpleReaderPrivate::parseName, state); | - | ||||||||||||
5321 | return false; | - | ||||||||||||
5322 | } | - | ||||||||||||
5323 | } | - | ||||||||||||
5324 | } | - | ||||||||||||
5325 | - | |||||||||||||
5326 | for (;;) { | - | ||||||||||||
5327 | switch (state) { | - | ||||||||||||
5328 | case Done: | - | ||||||||||||
5329 | return true; | - | ||||||||||||
5330 | case -1: | - | ||||||||||||
5331 | - | |||||||||||||
5332 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
5333 | return false; | - | ||||||||||||
5334 | } | - | ||||||||||||
5335 | - | |||||||||||||
5336 | if (atEnd()) { | - | ||||||||||||
5337 | unexpectedEof(&QXmlSimpleReaderPrivate::parseName, state); | - | ||||||||||||
5338 | return false; | - | ||||||||||||
5339 | } | - | ||||||||||||
5340 | - | |||||||||||||
5341 | - | |||||||||||||
5342 | state = table[state][(int)fastDetermineNameChar(c)]; | - | ||||||||||||
5343 | - | |||||||||||||
5344 | switch (state) { | - | ||||||||||||
5345 | case Name1: | - | ||||||||||||
5346 | if (parseName_useRef) { | - | ||||||||||||
5347 | refClear(); | - | ||||||||||||
5348 | refAddC(); | - | ||||||||||||
5349 | } else { | - | ||||||||||||
5350 | nameClear(); | - | ||||||||||||
5351 | nameAddC(); | - | ||||||||||||
5352 | } | - | ||||||||||||
5353 | next(); | - | ||||||||||||
5354 | break; | - | ||||||||||||
5355 | case Name: | - | ||||||||||||
5356 | if (parseName_useRef) { | - | ||||||||||||
5357 | refAddC(); | - | ||||||||||||
5358 | } else { | - | ||||||||||||
5359 | nameAddC(); | - | ||||||||||||
5360 | } | - | ||||||||||||
5361 | next(); | - | ||||||||||||
5362 | break; | - | ||||||||||||
5363 | } | - | ||||||||||||
5364 | } | - | ||||||||||||
5365 | return false; | - | ||||||||||||
5366 | } | - | ||||||||||||
5367 | - | |||||||||||||
5368 | - | |||||||||||||
5369 | - | |||||||||||||
5370 | - | |||||||||||||
5371 | bool QXmlSimpleReaderPrivate::parseNmtoken() | - | ||||||||||||
5372 | { | - | ||||||||||||
5373 | const signed char Init = 0; | - | ||||||||||||
5374 | const signed char NameF = 1; | - | ||||||||||||
5375 | const signed char Name = 2; | - | ||||||||||||
5376 | const signed char Done = 3; | - | ||||||||||||
5377 | - | |||||||||||||
5378 | const signed char InpNameCh = 0; | - | ||||||||||||
5379 | const signed char InpUnknown = 1; | - | ||||||||||||
5380 | - | |||||||||||||
5381 | static const signed char table[3][2] = { | - | ||||||||||||
5382 | - | |||||||||||||
5383 | { NameF, -1 }, | - | ||||||||||||
5384 | { Name, Done }, | - | ||||||||||||
5385 | { Name, Done } | - | ||||||||||||
5386 | }; | - | ||||||||||||
5387 | signed char state; | - | ||||||||||||
5388 | signed char input; | - | ||||||||||||
5389 | - | |||||||||||||
5390 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
5391 | state = Init; | - | ||||||||||||
5392 | } else { | - | ||||||||||||
5393 | state = parseStack->pop().state; | - | ||||||||||||
5394 | - | |||||||||||||
5395 | - | |||||||||||||
5396 | - | |||||||||||||
5397 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5398 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5399 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5400 | parseStack->pop(); | - | ||||||||||||
5401 | - | |||||||||||||
5402 | - | |||||||||||||
5403 | - | |||||||||||||
5404 | } | - | ||||||||||||
5405 | if (!(this->*function)()) { | - | ||||||||||||
5406 | parseFailed(&QXmlSimpleReaderPrivate::parseNmtoken, state); | - | ||||||||||||
5407 | return false; | - | ||||||||||||
5408 | } | - | ||||||||||||
5409 | } | - | ||||||||||||
5410 | } | - | ||||||||||||
5411 | - | |||||||||||||
5412 | for (;;) { | - | ||||||||||||
5413 | switch (state) { | - | ||||||||||||
5414 | case Done: | - | ||||||||||||
5415 | return true; | - | ||||||||||||
5416 | case -1: | - | ||||||||||||
5417 | - | |||||||||||||
5418 | reportParseError(QLatin1String("letter is expected")); | - | ||||||||||||
5419 | return false; | - | ||||||||||||
5420 | } | - | ||||||||||||
5421 | - | |||||||||||||
5422 | if (atEnd()) { | - | ||||||||||||
5423 | unexpectedEof(&QXmlSimpleReaderPrivate::parseNmtoken, state); | - | ||||||||||||
5424 | return false; | - | ||||||||||||
5425 | } | - | ||||||||||||
5426 | if (determineNameChar(c) == NotName) { | - | ||||||||||||
5427 | input = InpUnknown; | - | ||||||||||||
5428 | } else { | - | ||||||||||||
5429 | input = InpNameCh; | - | ||||||||||||
5430 | } | - | ||||||||||||
5431 | state = table[state][input]; | - | ||||||||||||
5432 | - | |||||||||||||
5433 | switch (state) { | - | ||||||||||||
5434 | case NameF: | - | ||||||||||||
5435 | nameClear(); | - | ||||||||||||
5436 | nameAddC(); | - | ||||||||||||
5437 | next(); | - | ||||||||||||
5438 | break; | - | ||||||||||||
5439 | case Name: | - | ||||||||||||
5440 | nameAddC(); | - | ||||||||||||
5441 | next(); | - | ||||||||||||
5442 | break; | - | ||||||||||||
5443 | } | - | ||||||||||||
5444 | } | - | ||||||||||||
5445 | return false; | - | ||||||||||||
5446 | } | - | ||||||||||||
5447 | bool QXmlSimpleReaderPrivate::parseReference() | - | ||||||||||||
5448 | { | - | ||||||||||||
5449 | - | |||||||||||||
5450 | - | |||||||||||||
5451 | uint tmp; | - | ||||||||||||
5452 | bool ok; | - | ||||||||||||
5453 | - | |||||||||||||
5454 | const signed char Init = 0; | - | ||||||||||||
5455 | const signed char SRef = 1; | - | ||||||||||||
5456 | const signed char ChRef = 2; | - | ||||||||||||
5457 | const signed char ChDec = 3; | - | ||||||||||||
5458 | const signed char ChHexS = 4; | - | ||||||||||||
5459 | const signed char ChHex = 5; | - | ||||||||||||
5460 | const signed char Name = 6; | - | ||||||||||||
5461 | const signed char DoneD = 7; | - | ||||||||||||
5462 | const signed char DoneH = 8; | - | ||||||||||||
5463 | const signed char DoneN = 9; | - | ||||||||||||
5464 | - | |||||||||||||
5465 | const signed char InpAmp = 0; | - | ||||||||||||
5466 | const signed char InpSemi = 1; | - | ||||||||||||
5467 | const signed char InpHash = 2; | - | ||||||||||||
5468 | const signed char InpX = 3; | - | ||||||||||||
5469 | const signed char InpNum = 4; | - | ||||||||||||
5470 | const signed char InpHex = 5; | - | ||||||||||||
5471 | const signed char InpUnknown = 6; | - | ||||||||||||
5472 | - | |||||||||||||
5473 | static const signed char table[8][7] = { | - | ||||||||||||
5474 | - | |||||||||||||
5475 | { SRef, -1, -1, -1, -1, -1, -1 }, | - | ||||||||||||
5476 | { -1, -1, ChRef, Name, Name, Name, Name }, | - | ||||||||||||
5477 | { -1, -1, -1, ChHexS, ChDec, -1, -1 }, | - | ||||||||||||
5478 | { -1, DoneD, -1, -1, ChDec, -1, -1 }, | - | ||||||||||||
5479 | { -1, -1, -1, -1, ChHex, ChHex, -1 }, | - | ||||||||||||
5480 | { -1, DoneH, -1, -1, ChHex, ChHex, -1 }, | - | ||||||||||||
5481 | { -1, DoneN, -1, -1, -1, -1, -1 } | - | ||||||||||||
5482 | }; | - | ||||||||||||
5483 | signed char state; | - | ||||||||||||
5484 | signed char input; | - | ||||||||||||
5485 | - | |||||||||||||
5486 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
5487 | parseReference_charDataRead = false; | - | ||||||||||||
5488 | state = Init; | - | ||||||||||||
5489 | } else { | - | ||||||||||||
5490 | state = parseStack->pop().state; | - | ||||||||||||
5491 | - | |||||||||||||
5492 | - | |||||||||||||
5493 | - | |||||||||||||
5494 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5495 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5496 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5497 | parseStack->pop(); | - | ||||||||||||
5498 | - | |||||||||||||
5499 | - | |||||||||||||
5500 | - | |||||||||||||
5501 | } | - | ||||||||||||
5502 | if (!(this->*function)()) { | - | ||||||||||||
5503 | parseFailed(&QXmlSimpleReaderPrivate::parseReference, state); | - | ||||||||||||
5504 | return false; | - | ||||||||||||
5505 | } | - | ||||||||||||
5506 | } | - | ||||||||||||
5507 | } | - | ||||||||||||
5508 | - | |||||||||||||
5509 | for (;;) { | - | ||||||||||||
5510 | switch (state) { | - | ||||||||||||
5511 | case DoneD: | - | ||||||||||||
5512 | return true; | - | ||||||||||||
5513 | case DoneH: | - | ||||||||||||
5514 | return true; | - | ||||||||||||
5515 | case DoneN: | - | ||||||||||||
5516 | return true; | - | ||||||||||||
5517 | case -1: | - | ||||||||||||
5518 | - | |||||||||||||
5519 | reportParseError(QLatin1String("error occurred while parsing reference")); | - | ||||||||||||
5520 | return false; | - | ||||||||||||
5521 | } | - | ||||||||||||
5522 | - | |||||||||||||
5523 | if (atEnd()) { | - | ||||||||||||
5524 | unexpectedEof(&QXmlSimpleReaderPrivate::parseReference, state); | - | ||||||||||||
5525 | return false; | - | ||||||||||||
5526 | } | - | ||||||||||||
5527 | if (c.row()) { | - | ||||||||||||
5528 | input = InpUnknown; | - | ||||||||||||
5529 | } else if (c.cell() == '&') { | - | ||||||||||||
5530 | input = InpAmp; | - | ||||||||||||
5531 | } else if (c.cell() == ';') { | - | ||||||||||||
5532 | input = InpSemi; | - | ||||||||||||
5533 | } else if (c.cell() == '#') { | - | ||||||||||||
5534 | input = InpHash; | - | ||||||||||||
5535 | } else if (c.cell() == 'x') { | - | ||||||||||||
5536 | input = InpX; | - | ||||||||||||
5537 | } else if ('0' <= c.cell() && c.cell() <= '9') { | - | ||||||||||||
5538 | input = InpNum; | - | ||||||||||||
5539 | } else if ('a' <= c.cell() && c.cell() <= 'f') { | - | ||||||||||||
5540 | input = InpHex; | - | ||||||||||||
5541 | } else if ('A' <= c.cell() && c.cell() <= 'F') { | - | ||||||||||||
5542 | input = InpHex; | - | ||||||||||||
5543 | } else { | - | ||||||||||||
5544 | input = InpUnknown; | - | ||||||||||||
5545 | } | - | ||||||||||||
5546 | state = table[state][input]; | - | ||||||||||||
5547 | - | |||||||||||||
5548 | switch (state) { | - | ||||||||||||
5549 | case SRef: | - | ||||||||||||
5550 | refClear(); | - | ||||||||||||
5551 | next(); | - | ||||||||||||
5552 | break; | - | ||||||||||||
5553 | case ChRef: | - | ||||||||||||
5554 | next(); | - | ||||||||||||
5555 | break; | - | ||||||||||||
5556 | case ChDec: | - | ||||||||||||
5557 | refAddC(); | - | ||||||||||||
5558 | next(); | - | ||||||||||||
5559 | break; | - | ||||||||||||
5560 | case ChHexS: | - | ||||||||||||
5561 | next(); | - | ||||||||||||
5562 | break; | - | ||||||||||||
5563 | case ChHex: | - | ||||||||||||
5564 | refAddC(); | - | ||||||||||||
5565 | next(); | - | ||||||||||||
5566 | break; | - | ||||||||||||
5567 | case Name: | - | ||||||||||||
5568 | - | |||||||||||||
5569 | parseName_useRef = true; | - | ||||||||||||
5570 | if (!parseName()) { | - | ||||||||||||
5571 | parseFailed(&QXmlSimpleReaderPrivate::parseReference, state); | - | ||||||||||||
5572 | return false; | - | ||||||||||||
5573 | } | - | ||||||||||||
5574 | break; | - | ||||||||||||
5575 | case DoneD: | - | ||||||||||||
5576 | tmp = ref().toUInt(&ok, 10); | - | ||||||||||||
5577 | if (ok) { | - | ||||||||||||
5578 | stringAddC(QChar(tmp)); | - | ||||||||||||
5579 | } else { | - | ||||||||||||
5580 | reportParseError(QLatin1String("error occurred while parsing reference")); | - | ||||||||||||
5581 | return false; | - | ||||||||||||
5582 | } | - | ||||||||||||
5583 | parseReference_charDataRead = true; | - | ||||||||||||
5584 | next(); | - | ||||||||||||
5585 | break; | - | ||||||||||||
5586 | case DoneH: | - | ||||||||||||
5587 | tmp = ref().toUInt(&ok, 16); | - | ||||||||||||
5588 | if (ok) { | - | ||||||||||||
5589 | stringAddC(QChar(tmp)); | - | ||||||||||||
5590 | } else { | - | ||||||||||||
5591 | reportParseError(QLatin1String("error occurred while parsing reference")); | - | ||||||||||||
5592 | return false; | - | ||||||||||||
5593 | } | - | ||||||||||||
5594 | parseReference_charDataRead = true; | - | ||||||||||||
5595 | next(); | - | ||||||||||||
5596 | break; | - | ||||||||||||
5597 | case DoneN: | - | ||||||||||||
5598 | if (!processReference()) | - | ||||||||||||
5599 | return false; | - | ||||||||||||
5600 | next(); | - | ||||||||||||
5601 | break; | - | ||||||||||||
5602 | } | - | ||||||||||||
5603 | } | - | ||||||||||||
5604 | return false; | - | ||||||||||||
5605 | } | - | ||||||||||||
5606 | - | |||||||||||||
5607 | - | |||||||||||||
5608 | - | |||||||||||||
5609 | - | |||||||||||||
5610 | bool QXmlSimpleReaderPrivate::processReference() | - | ||||||||||||
5611 | { | - | ||||||||||||
5612 | QString reference = ref(); | - | ||||||||||||
5613 | if (reference == QLatin1String("amp")) { | - | ||||||||||||
5614 | if (parseReference_context == InEntityValue) { | - | ||||||||||||
5615 | - | |||||||||||||
5616 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('a')); stringAddC(QLatin1Char('m')); stringAddC(QLatin1Char('p')); stringAddC(QLatin1Char(';')); | - | ||||||||||||
5617 | } else { | - | ||||||||||||
5618 | - | |||||||||||||
5619 | stringAddC(QLatin1Char('&')); | - | ||||||||||||
5620 | } | - | ||||||||||||
5621 | parseReference_charDataRead = true; | - | ||||||||||||
5622 | } else if (reference == QLatin1String("lt")) { | - | ||||||||||||
5623 | if (parseReference_context == InEntityValue) { | - | ||||||||||||
5624 | - | |||||||||||||
5625 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('l')); stringAddC(QLatin1Char('t')); stringAddC(QLatin1Char(';')); | - | ||||||||||||
5626 | } else { | - | ||||||||||||
5627 | - | |||||||||||||
5628 | stringAddC(QLatin1Char('<')); | - | ||||||||||||
5629 | } | - | ||||||||||||
5630 | parseReference_charDataRead = true; | - | ||||||||||||
5631 | } else if (reference == QLatin1String("gt")) { | - | ||||||||||||
5632 | if (parseReference_context == InEntityValue) { | - | ||||||||||||
5633 | - | |||||||||||||
5634 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('g')); stringAddC(QLatin1Char('t')); stringAddC(QLatin1Char(';')); | - | ||||||||||||
5635 | } else { | - | ||||||||||||
5636 | - | |||||||||||||
5637 | stringAddC(QLatin1Char('>')); | - | ||||||||||||
5638 | } | - | ||||||||||||
5639 | parseReference_charDataRead = true; | - | ||||||||||||
5640 | } else if (reference == QLatin1String("apos")) { | - | ||||||||||||
5641 | if (parseReference_context == InEntityValue) { | - | ||||||||||||
5642 | - | |||||||||||||
5643 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('a')); stringAddC(QLatin1Char('p')); stringAddC(QLatin1Char('o')); stringAddC(QLatin1Char('s')); stringAddC(QLatin1Char(';')); | - | ||||||||||||
5644 | } else { | - | ||||||||||||
5645 | - | |||||||||||||
5646 | stringAddC(QLatin1Char('\'')); | - | ||||||||||||
5647 | } | - | ||||||||||||
5648 | parseReference_charDataRead = true; | - | ||||||||||||
5649 | } else if (reference == QLatin1String("quot")) { | - | ||||||||||||
5650 | if (parseReference_context == InEntityValue) { | - | ||||||||||||
5651 | - | |||||||||||||
5652 | stringAddC(QLatin1Char('&')); stringAddC(QLatin1Char('q')); stringAddC(QLatin1Char('u')); stringAddC(QLatin1Char('o')); stringAddC(QLatin1Char('t')); stringAddC(QLatin1Char(';')); | - | ||||||||||||
5653 | } else { | - | ||||||||||||
5654 | - | |||||||||||||
5655 | stringAddC(QLatin1Char('"')); | - | ||||||||||||
5656 | } | - | ||||||||||||
5657 | parseReference_charDataRead = true; | - | ||||||||||||
5658 | } else { | - | ||||||||||||
5659 | QMap<QString,QString>::Iterator it; | - | ||||||||||||
5660 | it = entities.find(reference); | - | ||||||||||||
5661 | if (it != entities.end()) { | - | ||||||||||||
5662 | - | |||||||||||||
5663 | switch (parseReference_context) { | - | ||||||||||||
5664 | case InContent: | - | ||||||||||||
5665 | - | |||||||||||||
5666 | if (!insertXmlRef(*it, reference, false)) | - | ||||||||||||
5667 | return false; | - | ||||||||||||
5668 | parseReference_charDataRead = false; | - | ||||||||||||
5669 | break; | - | ||||||||||||
5670 | case InAttributeValue: | - | ||||||||||||
5671 | - | |||||||||||||
5672 | if (!insertXmlRef(*it, reference, true)) | - | ||||||||||||
5673 | return false; | - | ||||||||||||
5674 | parseReference_charDataRead = false; | - | ||||||||||||
5675 | break; | - | ||||||||||||
5676 | case InEntityValue: | - | ||||||||||||
5677 | { | - | ||||||||||||
5678 | - | |||||||||||||
5679 | stringAddC(QLatin1Char('&')); | - | ||||||||||||
5680 | for (int i=0; i<(int)reference.length(); i++) { | - | ||||||||||||
5681 | stringAddC(reference[i]); | - | ||||||||||||
5682 | } | - | ||||||||||||
5683 | stringAddC(QLatin1Char(';')); | - | ||||||||||||
5684 | parseReference_charDataRead = true; | - | ||||||||||||
5685 | } | - | ||||||||||||
5686 | break; | - | ||||||||||||
5687 | case InDTD: | - | ||||||||||||
5688 | - | |||||||||||||
5689 | parseReference_charDataRead = false; | - | ||||||||||||
5690 | reportParseError(QLatin1String("internal general entity reference not allowed in DTD")); | - | ||||||||||||
5691 | return false; | - | ||||||||||||
5692 | } | - | ||||||||||||
5693 | } else { | - | ||||||||||||
5694 | QMap<QString,QXmlSimpleReaderPrivate::ExternEntity>::Iterator itExtern; | - | ||||||||||||
5695 | itExtern = externEntities.find(reference); | - | ||||||||||||
5696 | if (itExtern == externEntities.end()) { | - | ||||||||||||
5697 | - | |||||||||||||
5698 | - | |||||||||||||
5699 | if (parseReference_context == InEntityValue) { | - | ||||||||||||
5700 | - | |||||||||||||
5701 | stringAddC(QLatin1Char('&')); | - | ||||||||||||
5702 | for (int i=0; i<(int)reference.length(); i++) { | - | ||||||||||||
5703 | stringAddC(reference[i]); | - | ||||||||||||
5704 | } | - | ||||||||||||
5705 | stringAddC(QLatin1Char(';')); | - | ||||||||||||
5706 | parseReference_charDataRead = true; | - | ||||||||||||
5707 | } else { | - | ||||||||||||
5708 | - | |||||||||||||
5709 | if (parseReference_context == InContent) { | - | ||||||||||||
5710 | if (contentCharDataRead) { | - | ||||||||||||
5711 | if (reportWhitespaceCharData || !string().simplified().isEmpty()) { | - | ||||||||||||
5712 | if (contentHnd != 0 && !contentHnd->characters(string())) { | - | ||||||||||||
5713 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
5714 | return false; | - | ||||||||||||
5715 | } | - | ||||||||||||
5716 | } | - | ||||||||||||
5717 | stringClear(); | - | ||||||||||||
5718 | contentCharDataRead = false; | - | ||||||||||||
5719 | } | - | ||||||||||||
5720 | } | - | ||||||||||||
5721 | - | |||||||||||||
5722 | if (contentHnd) { | - | ||||||||||||
5723 | skipped_entity_in_content = parseReference_context == InContent; | - | ||||||||||||
5724 | if (!contentHnd->skippedEntity(reference)) { | - | ||||||||||||
5725 | skipped_entity_in_content = false; | - | ||||||||||||
5726 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
5727 | return false; | - | ||||||||||||
5728 | } | - | ||||||||||||
5729 | skipped_entity_in_content = false; | - | ||||||||||||
5730 | } | - | ||||||||||||
5731 | } | - | ||||||||||||
5732 | } else if ((*itExtern).notation.isNull()) { | - | ||||||||||||
5733 | - | |||||||||||||
5734 | switch (parseReference_context) { | - | ||||||||||||
5735 | case InContent: | - | ||||||||||||
5736 | { | - | ||||||||||||
5737 | - | |||||||||||||
5738 | bool skipIt = true; | - | ||||||||||||
5739 | if (entityRes) { | - | ||||||||||||
5740 | QXmlInputSource *ret = 0; | - | ||||||||||||
5741 | if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) { | - | ||||||||||||
5742 | delete ret; | - | ||||||||||||
5743 | reportParseError(entityRes->errorString()); | - | ||||||||||||
5744 | return false; | - | ||||||||||||
5745 | } | - | ||||||||||||
5746 | if (ret) { | - | ||||||||||||
5747 | QString xmlRefString; | - | ||||||||||||
5748 | QString buffer = ret->data(); | - | ||||||||||||
5749 | while (!buffer.isEmpty()) { | - | ||||||||||||
5750 | xmlRefString += buffer; | - | ||||||||||||
5751 | ret->fetchData(); | - | ||||||||||||
5752 | buffer = ret->data(); | - | ||||||||||||
5753 | } | - | ||||||||||||
5754 | - | |||||||||||||
5755 | delete ret; | - | ||||||||||||
5756 | if (!stripTextDecl(xmlRefString)) { | - | ||||||||||||
5757 | reportParseError(QLatin1String("error in the text declaration of an external entity")); | - | ||||||||||||
5758 | return false; | - | ||||||||||||
5759 | } | - | ||||||||||||
5760 | if (!insertXmlRef(xmlRefString, reference, false)) | - | ||||||||||||
5761 | return false; | - | ||||||||||||
5762 | skipIt = false; | - | ||||||||||||
5763 | } | - | ||||||||||||
5764 | } | - | ||||||||||||
5765 | if (skipIt && contentHnd) { | - | ||||||||||||
5766 | skipped_entity_in_content = true; | - | ||||||||||||
5767 | if (!contentHnd->skippedEntity(reference)) { | - | ||||||||||||
5768 | skipped_entity_in_content = false; | - | ||||||||||||
5769 | reportParseError(contentHnd->errorString()); | - | ||||||||||||
5770 | return false; | - | ||||||||||||
5771 | } | - | ||||||||||||
5772 | skipped_entity_in_content = false; | - | ||||||||||||
5773 | } | - | ||||||||||||
5774 | parseReference_charDataRead = false; | - | ||||||||||||
5775 | } break; | - | ||||||||||||
5776 | case InAttributeValue: | - | ||||||||||||
5777 | - | |||||||||||||
5778 | parseReference_charDataRead = false; | - | ||||||||||||
5779 | reportParseError(QLatin1String("external parsed general entity reference not allowed in attribute value")); | - | ||||||||||||
5780 | return false; | - | ||||||||||||
5781 | case InEntityValue: | - | ||||||||||||
5782 | { | - | ||||||||||||
5783 | - | |||||||||||||
5784 | stringAddC(QLatin1Char('&')); | - | ||||||||||||
5785 | for (int i=0; i<(int)reference.length(); i++) { | - | ||||||||||||
5786 | stringAddC(reference[i]); | - | ||||||||||||
5787 | } | - | ||||||||||||
5788 | stringAddC(QLatin1Char(';')); | - | ||||||||||||
5789 | parseReference_charDataRead = true; | - | ||||||||||||
5790 | } | - | ||||||||||||
5791 | break; | - | ||||||||||||
5792 | case InDTD: | - | ||||||||||||
5793 | - | |||||||||||||
5794 | parseReference_charDataRead = false; | - | ||||||||||||
5795 | reportParseError(QLatin1String("external parsed general entity reference not allowed in DTD")); | - | ||||||||||||
5796 | return false; | - | ||||||||||||
5797 | } | - | ||||||||||||
5798 | } else { | - | ||||||||||||
5799 | - | |||||||||||||
5800 | - | |||||||||||||
5801 | - | |||||||||||||
5802 | parseReference_charDataRead = false; | - | ||||||||||||
5803 | reportParseError(QLatin1String("unparsed entity reference in wrong context")); | - | ||||||||||||
5804 | return false; | - | ||||||||||||
5805 | } | - | ||||||||||||
5806 | } | - | ||||||||||||
5807 | } | - | ||||||||||||
5808 | return true; | - | ||||||||||||
5809 | } | - | ||||||||||||
5810 | bool QXmlSimpleReaderPrivate::parseString() | - | ||||||||||||
5811 | { | - | ||||||||||||
5812 | const signed char InpCharExpected = 0; | - | ||||||||||||
5813 | const signed char InpUnknown = 1; | - | ||||||||||||
5814 | - | |||||||||||||
5815 | signed char state; | - | ||||||||||||
5816 | signed char input; | - | ||||||||||||
5817 | - | |||||||||||||
5818 | if (parseStack==0 || parseStack->isEmpty()) { | - | ||||||||||||
5819 | Done = parseString_s.length(); | - | ||||||||||||
5820 | state = 0; | - | ||||||||||||
5821 | } else { | - | ||||||||||||
5822 | state = parseStack->pop().state; | - | ||||||||||||
5823 | - | |||||||||||||
5824 | - | |||||||||||||
5825 | - | |||||||||||||
5826 | if (!parseStack->isEmpty()) { | - | ||||||||||||
5827 | ParseFunction function = parseStack->top().function; | - | ||||||||||||
5828 | if (function == &QXmlSimpleReaderPrivate::eat_ws) { | - | ||||||||||||
5829 | parseStack->pop(); | - | ||||||||||||
5830 | - | |||||||||||||
5831 | - | |||||||||||||
5832 | - | |||||||||||||
5833 | } | - | ||||||||||||
5834 | if (!(this->*function)()) { | - | ||||||||||||
5835 | parseFailed(&QXmlSimpleReaderPrivate::parseString, state); | - | ||||||||||||
5836 | return false; | - | ||||||||||||
5837 | } | - | ||||||||||||
5838 | } | - | ||||||||||||
5839 | } | - | ||||||||||||
5840 | - | |||||||||||||
5841 | for (;;) { | - | ||||||||||||
5842 | if (state == Done) { | - | ||||||||||||
5843 | return true; | - | ||||||||||||
5844 | } | - | ||||||||||||
5845 | - | |||||||||||||
5846 | if (atEnd()) { | - | ||||||||||||
5847 | unexpectedEof(&QXmlSimpleReaderPrivate::parseString, state); | - | ||||||||||||
5848 | return false; | - | ||||||||||||
5849 | } | - | ||||||||||||
5850 | if (c == parseString_s[(int)state]) { | - | ||||||||||||
5851 | input = InpCharExpected; | - | ||||||||||||
5852 | } else { | - | ||||||||||||
5853 | input = InpUnknown; | - | ||||||||||||
5854 | } | - | ||||||||||||
5855 | if (input == InpCharExpected) { | - | ||||||||||||
5856 | state++; | - | ||||||||||||
5857 | } else { | - | ||||||||||||
5858 | - | |||||||||||||
5859 | reportParseError(QLatin1String("unexpected character")); | - | ||||||||||||
5860 | return false; | - | ||||||||||||
5861 | } | - | ||||||||||||
5862 | - | |||||||||||||
5863 | next(); | - | ||||||||||||
5864 | } | - | ||||||||||||
5865 | return false; | - | ||||||||||||
5866 | } | - | ||||||||||||
5867 | bool QXmlSimpleReaderPrivate::insertXmlRef(const QString &data, const QString &name, bool inLiteral) | - | ||||||||||||
5868 | { | - | ||||||||||||
5869 | if (inLiteral) { | - | ||||||||||||
5870 | QString tmp = data; | - | ||||||||||||
5871 | xmlRefStack.push(XmlRef(name, tmp.replace(QLatin1Char('\"'), | - | ||||||||||||
5872 | QLatin1String(""")).replace(QLatin1Char('\''), QLatin1String("'")))); | - | ||||||||||||
5873 | } else { | - | ||||||||||||
5874 | xmlRefStack.push(XmlRef(name, data)); | - | ||||||||||||
5875 | } | - | ||||||||||||
5876 | int n = qMax(parameterEntities.count(), entities.count()); | - | ||||||||||||
5877 | if (xmlRefStack.count() > n+1) { | - | ||||||||||||
5878 | - | |||||||||||||
5879 | reportParseError(QLatin1String("recursive entities")); | - | ||||||||||||
5880 | return false; | - | ||||||||||||
5881 | } | - | ||||||||||||
5882 | if (reportEntities && lexicalHnd) { | - | ||||||||||||
5883 | if (!lexicalHnd->startEntity(name)) { | - | ||||||||||||
5884 | reportParseError(lexicalHnd->errorString()); | - | ||||||||||||
5885 | return false; | - | ||||||||||||
5886 | } | - | ||||||||||||
5887 | } | - | ||||||||||||
5888 | return true; | - | ||||||||||||
5889 | } | - | ||||||||||||
5890 | - | |||||||||||||
5891 | - | |||||||||||||
5892 | - | |||||||||||||
5893 | - | |||||||||||||
5894 | void QXmlSimpleReaderPrivate::next() | - | ||||||||||||
5895 | { | - | ||||||||||||
5896 | int count = xmlRefStack.size(); | - | ||||||||||||
5897 | while (count != 0) { | - | ||||||||||||
5898 | if (xmlRefStack.top().isEmpty()) { | - | ||||||||||||
5899 | xmlRefStack.pop_back(); | - | ||||||||||||
5900 | count--; | - | ||||||||||||
5901 | } else { | - | ||||||||||||
5902 | c = xmlRefStack.top().next(); | - | ||||||||||||
5903 | return; | - | ||||||||||||
5904 | } | - | ||||||||||||
5905 | } | - | ||||||||||||
5906 | - | |||||||||||||
5907 | - | |||||||||||||
5908 | - | |||||||||||||
5909 | ushort uc = c.unicode(); | - | ||||||||||||
5910 | c = inputSource->next(); | - | ||||||||||||
5911 | - | |||||||||||||
5912 | - | |||||||||||||
5913 | if (c == QXmlInputSource::EndOfData && parseStack == 0) | - | ||||||||||||
5914 | c = inputSource->next(); | - | ||||||||||||
5915 | if (uc == '\n') { | - | ||||||||||||
5916 | lineNr++; | - | ||||||||||||
5917 | columnNr = -1; | - | ||||||||||||
5918 | } else if (uc == '\r') { | - | ||||||||||||
5919 | if (c != QLatin1Char('\n')) { | - | ||||||||||||
5920 | lineNr++; | - | ||||||||||||
5921 | columnNr = -1; | - | ||||||||||||
5922 | } | - | ||||||||||||
5923 | } | - | ||||||||||||
5924 | ++columnNr; | - | ||||||||||||
5925 | } | - | ||||||||||||
5926 | bool QXmlSimpleReaderPrivate::eat_ws() | - | ||||||||||||
5927 | { | - | ||||||||||||
5928 | while (!atEnd()) { | - | ||||||||||||
5929 | if (!is_S(c)) { | - | ||||||||||||
5930 | return true; | - | ||||||||||||
5931 | } | - | ||||||||||||
5932 | next(); | - | ||||||||||||
5933 | } | - | ||||||||||||
5934 | if (parseStack != 0) { | - | ||||||||||||
5935 | unexpectedEof(&QXmlSimpleReaderPrivate::eat_ws, 0); | - | ||||||||||||
5936 | return false; | - | ||||||||||||
5937 | } | - | ||||||||||||
5938 | return true; | - | ||||||||||||
5939 | } | - | ||||||||||||
5940 | - | |||||||||||||
5941 | bool QXmlSimpleReaderPrivate::next_eat_ws() | - | ||||||||||||
5942 | { | - | ||||||||||||
5943 | next(); | - | ||||||||||||
5944 | return eat_ws(); | - | ||||||||||||
5945 | } | - | ||||||||||||
5946 | - | |||||||||||||
5947 | - | |||||||||||||
5948 | - | |||||||||||||
5949 | - | |||||||||||||
5950 | - | |||||||||||||
5951 | - | |||||||||||||
5952 | void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i) | - | ||||||||||||
5953 | { | - | ||||||||||||
5954 | lineNr = 0; | - | ||||||||||||
5955 | columnNr = -1; | - | ||||||||||||
5956 | inputSource = const_cast<QXmlInputSource *>(i); | - | ||||||||||||
5957 | initData(); | - | ||||||||||||
5958 | - | |||||||||||||
5959 | externParameterEntities.clear(); | - | ||||||||||||
5960 | parameterEntities.clear(); | - | ||||||||||||
5961 | externEntities.clear(); | - | ||||||||||||
5962 | entities.clear(); | - | ||||||||||||
5963 | - | |||||||||||||
5964 | tags.clear();(tags); | - | ||||||||||||
5965 | - | |||||||||||||
5966 | doctype.clear(); | - | ||||||||||||
5967 | xmlVersion.clear(); | - | ||||||||||||
5968 | encoding.clear(); | - | ||||||||||||
5969 | standalone = QXmlSimpleReaderPrivate::Unknown; | - | ||||||||||||
5970 | error.clear(); | - | ||||||||||||
5971 | } executed 2106 times by 6 tests: end of block Executed by:
| 2106 | ||||||||||||
5972 | - | |||||||||||||
5973 | - | |||||||||||||
5974 | - | |||||||||||||
5975 | - | |||||||||||||
5976 | - | |||||||||||||
5977 | void QXmlSimpleReaderPrivate::initData() | - | ||||||||||||
5978 | { | - | ||||||||||||
5979 | c = QXmlInputSource::EndOfData; | - | ||||||||||||
5980 | xmlRefStack.clear(); | - | ||||||||||||
5981 | next(); | - | ||||||||||||
5982 | } | - | ||||||||||||
5983 | - | |||||||||||||
5984 | - | |||||||||||||
5985 | - | |||||||||||||
5986 | - | |||||||||||||
5987 | - | |||||||||||||
5988 | bool QXmlSimpleReaderPrivate::entityExist(const QString& e) const | - | ||||||||||||
5989 | { | - | ||||||||||||
5990 | if ( parameterEntities.find(e) == parameterEntities.end() && | - | ||||||||||||
5991 | externParameterEntities.find(e) == externParameterEntities.end() && | - | ||||||||||||
5992 | externEntities.find(e) == externEntities.end() && | - | ||||||||||||
5993 | entities.find(e) == entities.end()) { | - | ||||||||||||
5994 | return false; | - | ||||||||||||
5995 | } else { | - | ||||||||||||
5996 | return true; | - | ||||||||||||
5997 | } | - | ||||||||||||
5998 | } | - | ||||||||||||
5999 | - | |||||||||||||
6000 | void QXmlSimpleReaderPrivate::reportParseError(const QString& error) | - | ||||||||||||
6001 | { | - | ||||||||||||
6002 | this->error = error; | - | ||||||||||||
6003 | if (errorHnd) { | - | ||||||||||||
6004 | if (this->error.isNull()) { | - | ||||||||||||
6005 | const QXmlParseException ex(QLatin1String("no error occurred"), columnNr+1, lineNr+1, | - | ||||||||||||
6006 | thisPublicId, thisSystemId); | - | ||||||||||||
6007 | errorHnd->fatalError(ex); | - | ||||||||||||
6008 | } else { | - | ||||||||||||
6009 | const QXmlParseException ex(this->error, columnNr+1, lineNr+1, | - | ||||||||||||
6010 | thisPublicId, thisSystemId); | - | ||||||||||||
6011 | errorHnd->fatalError(ex); | - | ||||||||||||
6012 | } | - | ||||||||||||
6013 | } | - | ||||||||||||
6014 | } | - | ||||||||||||
6015 | - | |||||||||||||
6016 | - | |||||||||||||
6017 | - | |||||||||||||
6018 | - | |||||||||||||
6019 | - | |||||||||||||
6020 | - | |||||||||||||
6021 | - | |||||||||||||
6022 | void QXmlSimpleReaderPrivate::unexpectedEof(ParseFunction where, int state) | - | ||||||||||||
6023 | { | - | ||||||||||||
6024 | if (parseStack == 0) { | - | ||||||||||||
6025 | reportParseError(QLatin1String("unexpected end of file")); | - | ||||||||||||
6026 | } else { | - | ||||||||||||
6027 | if (c == QXmlInputSource::EndOfDocument) { | - | ||||||||||||
6028 | reportParseError(QLatin1String("unexpected end of file")); | - | ||||||||||||
6029 | } else { | - | ||||||||||||
6030 | pushParseState(where, state); | - | ||||||||||||
6031 | } | - | ||||||||||||
6032 | } | - | ||||||||||||
6033 | } | - | ||||||||||||
6034 | void QXmlSimpleReaderPrivate::parseFailed(ParseFunction where, int state) | - | ||||||||||||
6035 | { | - | ||||||||||||
6036 | if (parseStack!=0 && error.isNull()) { | - | ||||||||||||
6037 | pushParseState(where, state); | - | ||||||||||||
6038 | } | - | ||||||||||||
6039 | } | - | ||||||||||||
6040 | void QXmlSimpleReaderPrivate::pushParseState(ParseFunction function, int state) | - | ||||||||||||
6041 | { | - | ||||||||||||
6042 | QXmlSimpleReaderPrivate::ParseState ps; | - | ||||||||||||
6043 | ps.function = function; | - | ||||||||||||
6044 | ps.state = state; | - | ||||||||||||
6045 | parseStack->push(ps); | - | ||||||||||||
6046 | } | - | ||||||||||||
6047 | - | |||||||||||||
6048 | inline static void updateValue(QString &value, const QChar *array, int &arrayPos, int &valueLen) | - | ||||||||||||
6049 | { | - | ||||||||||||
6050 | value.resize(valueLen + arrayPos); | - | ||||||||||||
6051 | memcpy(value.data() + valueLen, array, arrayPos * sizeof(QChar)); | - | ||||||||||||
6052 | valueLen += arrayPos; | - | ||||||||||||
6053 | arrayPos = 0; | - | ||||||||||||
6054 | } | - | ||||||||||||
6055 | - | |||||||||||||
6056 | - | |||||||||||||
6057 | const QString& QXmlSimpleReaderPrivate::string() | - | ||||||||||||
6058 | { | - | ||||||||||||
6059 | updateValue(stringValue, stringArray, stringArrayPos, stringValueLen); | - | ||||||||||||
6060 | return stringValue; | - | ||||||||||||
6061 | } | - | ||||||||||||
6062 | const QString& QXmlSimpleReaderPrivate::name() | - | ||||||||||||
6063 | { | - | ||||||||||||
6064 | updateValue(nameValue, nameArray, nameArrayPos, nameValueLen); | - | ||||||||||||
6065 | return nameValue; | - | ||||||||||||
6066 | } | - | ||||||||||||
6067 | const QString& QXmlSimpleReaderPrivate::ref() | - | ||||||||||||
6068 | { | - | ||||||||||||
6069 | updateValue(refValue, refArray, refArrayPos, refValueLen); | - | ||||||||||||
6070 | return refValue; | - | ||||||||||||
6071 | } | - | ||||||||||||
6072 | - | |||||||||||||
6073 | void QXmlSimpleReaderPrivate::stringAddC(QChar ch) | - | ||||||||||||
6074 | { | - | ||||||||||||
6075 | if (stringArrayPos == 256) | - | ||||||||||||
6076 | updateValue(stringValue, stringArray, stringArrayPos, stringValueLen); | - | ||||||||||||
6077 | stringArray[stringArrayPos++] = ch; | - | ||||||||||||
6078 | } | - | ||||||||||||
6079 | void QXmlSimpleReaderPrivate::nameAddC(QChar ch) | - | ||||||||||||
6080 | { | - | ||||||||||||
6081 | if (nameArrayPos == 256) | - | ||||||||||||
6082 | updateValue(nameValue, nameArray, nameArrayPos, nameValueLen); | - | ||||||||||||
6083 | nameArray[nameArrayPos++] = ch; | - | ||||||||||||
6084 | } | - | ||||||||||||
6085 | void QXmlSimpleReaderPrivate::refAddC(QChar ch) | - | ||||||||||||
6086 | { | - | ||||||||||||
6087 | if (refArrayPos == 256) | - | ||||||||||||
6088 | updateValue(refValue, refArray, refArrayPos, refValueLen); | - | ||||||||||||
6089 | refArray[refArrayPos++] = ch; | - | ||||||||||||
6090 | } | - | ||||||||||||
6091 | - | |||||||||||||
Switch to Source code | Preprocessed file |