 |
Changeset 3827
- Timestamp:
- 07/31/08 00:53:02
(4 months ago)
- Author:
- kris
- Message:
ignoring more garbage at eof
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3826 |
r3827 |
|
| 91 | 91 | while (*++p <= 32) |
|---|
| 92 | 92 | if (p >= text.end) |
|---|
| 93 | | return doEndOfStream; |
|---|
| | 93 | return endOfInput; |
|---|
| 94 | 94 | text.point = p; |
|---|
| 95 | 95 | } |
|---|
| … | … | |
| 135 | 135 | return type = XmlTokenType.Data; |
|---|
| 136 | 136 | } |
|---|
| 137 | | return XmlTokenType.Done; |
|---|
| | 137 | return endOfInput; |
|---|
| 138 | 138 | } |
|---|
| 139 | 139 | |
|---|
| … | … | |
| 148 | 148 | // check if we ran past the end |
|---|
| 149 | 149 | if (q >= e) |
|---|
| 150 | | return XmlTokenType.Done; |
|---|
| | 150 | return endOfInput; |
|---|
| 151 | 151 | |
|---|
| 152 | 152 | text.point = q; |
|---|
| … | … | |
| 181 | 181 | { |
|---|
| 182 | 182 | text.point += 4; |
|---|
| 183 | | return doComment(); |
|---|
| | 183 | return doComment; |
|---|
| 184 | 184 | } |
|---|
| 185 | 185 | else |
|---|
| … | … | |
| 187 | 187 | { |
|---|
| 188 | 188 | text.point += 9; |
|---|
| 189 | | return doCData(); |
|---|
| | 189 | return doCData; |
|---|
| 190 | 190 | } |
|---|
| 191 | 191 | else |
|---|
| … | … | |
| 193 | 193 | { |
|---|
| 194 | 194 | text.point += 9; |
|---|
| 195 | | return doDoctype(); |
|---|
| | 195 | return doDoctype; |
|---|
| 196 | 196 | } |
|---|
| 197 | | return doUnexpected("!"); |
|---|
| | 197 | return doUnexpected("!", p); |
|---|
| 198 | 198 | |
|---|
| 199 | 199 | case '\?': |
|---|
| 200 | 200 | text.point += 2; |
|---|
| 201 | | return doPI(); |
|---|
| | 201 | return doPI; |
|---|
| 202 | 202 | |
|---|
| 203 | 203 | case '/': |
|---|
| … | … | |
| 225 | 225 | ++q; |
|---|
| 226 | 226 | |
|---|
| 227 | | if (q >= text.end) |
|---|
| 228 | | return doUnexpectedEOF; |
|---|
| | 227 | if (q >= e) |
|---|
| | 228 | return endOfInput; |
|---|
| 229 | 229 | |
|---|
| 230 | 230 | if (*q is '>') |
|---|
| … | … | |
| 234 | 234 | return type = XmlTokenType.EndElement; |
|---|
| 235 | 235 | } |
|---|
| 236 | | return doUnexpected(">"); |
|---|
| | 236 | return doExpected(">", q); |
|---|
| 237 | 237 | } |
|---|
| 238 | 238 | |
|---|
| … | … | |
| 253 | 253 | ++q; |
|---|
| 254 | 254 | if (q >= e) |
|---|
| 255 | | return doUnexpectedEOF; |
|---|
| | 255 | return endOfInput; |
|---|
| 256 | 256 | |
|---|
| 257 | 257 | if (*q is ':') |
|---|
| … | … | |
| 262 | 262 | while (*q > 63 || text.attributeName[*q]) |
|---|
| 263 | 263 | ++q; |
|---|
| 264 | | if (q >= e) |
|---|
| 265 | | return doUnexpectedEOF; |
|---|
| 266 | 264 | |
|---|
| 267 | 265 | localName = p[0 .. q - p]; |
|---|
| … | … | |
| 277 | 275 | while (*++q <= 32) {} |
|---|
| 278 | 276 | if (q >= e) |
|---|
| 279 | | return doUnexpectedEOF; |
|---|
| | 277 | return endOfInput; |
|---|
| 280 | 278 | } |
|---|
| 281 | 279 | |
|---|
| … | … | |
| 284 | 282 | while (*++q <= 32) {} |
|---|
| 285 | 283 | if (q >= e) |
|---|
| 286 | | return doUnexpectedEOF; |
|---|
| | 284 | return endOfInput; |
|---|
| 287 | 285 | |
|---|
| 288 | 286 | auto quote = *q; |
|---|
| … | … | |
| 300 | 298 | return type = XmlTokenType.Attribute; |
|---|
| 301 | 299 | } |
|---|
| 302 | | return doUnexpectedEOF; |
|---|
| | 300 | return endOfInput; |
|---|
| 303 | 301 | |
|---|
| 304 | 302 | default: |
|---|
| 305 | | return doUnexpected("\' or \""); |
|---|
| | 303 | return doExpected("\' or \"", q); |
|---|
| 306 | 304 | } |
|---|
| 307 | 305 | } |
|---|
| 308 | 306 | |
|---|
| 309 | | return doUnexpected (q[0..1]); |
|---|
| | 307 | return doUnexpected (q[0..1], q); |
|---|
| 310 | 308 | } |
|---|
| 311 | 309 | |
|---|
| … | … | |
| 322 | 320 | return type = XmlTokenType.EndEmptyElement; |
|---|
| 323 | 321 | } |
|---|
| 324 | | return doUnexpected("/>"); |
|---|
| | 322 | return doExpected("/>", text.point); |
|---|
| 325 | 323 | } |
|---|
| 326 | 324 | |
|---|
| … | … | |
| 336 | 334 | { |
|---|
| 337 | 335 | if (! text.forwardLocate('-')) |
|---|
| 338 | | return doUnexpectedEOF; |
|---|
| | 336 | return endOfInput; |
|---|
| 339 | 337 | |
|---|
| 340 | 338 | if (text[0..3] == "-->") |
|---|
| … | … | |
| 348 | 346 | } |
|---|
| 349 | 347 | |
|---|
| 350 | | return doUnexpectedEOF; |
|---|
| | 348 | return endOfInput; |
|---|
| 351 | 349 | } |
|---|
| 352 | 350 | |
|---|
| … | … | |
| 362 | 360 | { |
|---|
| 363 | 361 | if (! text.forwardLocate(']')) |
|---|
| 364 | | return doUnexpectedEOF; |
|---|
| | 362 | return endOfInput; |
|---|
| 365 | 363 | |
|---|
| 366 | 364 | if (text[0..3] == "]]>") |
|---|
| … | … | |
| 374 | 372 | } |
|---|
| 375 | 373 | |
|---|
| 376 | | return doUnexpectedEOF; |
|---|
| | 374 | return endOfInput; |
|---|
| 377 | 375 | } |
|---|
| 378 | 376 | |
|---|
| … | … | |
| 390 | 388 | { |
|---|
| 391 | 389 | if (! text.forwardLocate('\?')) |
|---|
| 392 | | return doUnexpectedEOF; |
|---|
| | 390 | return endOfInput; |
|---|
| 393 | 391 | |
|---|
| 394 | 392 | if (text.point[1] == '>') |
|---|
| … | … | |
| 400 | 398 | ++text.point; |
|---|
| 401 | 399 | } |
|---|
| 402 | | return doUnexpectedEOF; |
|---|
| | 400 | return endOfInput; |
|---|
| 403 | 401 | } |
|---|
| 404 | 402 | |
|---|
| … | … | |
| 433 | 431 | |
|---|
| 434 | 432 | if (! text.good) |
|---|
| 435 | | return doUnexpectedEOF; |
|---|
| | 433 | return endOfInput; |
|---|
| 436 | 434 | return XmlTokenType.Doctype; |
|---|
| 437 | 435 | } |
|---|
| … | … | |
| 441 | 439 | ***********************************************************************/ |
|---|
| 442 | 440 | |
|---|
| 443 | | private XmlTokenType doUnexpectedEOF() |
|---|
| 444 | | { |
|---|
| 445 | | return error ("Unexpected EOF"); |
|---|
| 446 | | } |
|---|
| 447 | | |
|---|
| 448 | | /*********************************************************************** |
|---|
| 449 | | |
|---|
| 450 | | ***********************************************************************/ |
|---|
| 451 | | |
|---|
| 452 | | private XmlTokenType doUnexpected(char[] msg = null) |
|---|
| 453 | | { |
|---|
| 454 | | return error ("Unexpected event " ~ msg ~ " " ~ Integer.toString(type)); |
|---|
| 455 | | } |
|---|
| 456 | | |
|---|
| 457 | | /*********************************************************************** |
|---|
| 458 | | |
|---|
| 459 | | ***********************************************************************/ |
|---|
| 460 | | |
|---|
| 461 | | private XmlTokenType doEndOfStream() |
|---|
| 462 | | { |
|---|
| | 441 | private XmlTokenType endOfInput () |
|---|
| | 442 | { |
|---|
| | 443 | if (depth) |
|---|
| | 444 | error ("Unexpected EOF"); |
|---|
| | 445 | |
|---|
| 463 | 446 | return XmlTokenType.Done; |
|---|
| 464 | 447 | } |
|---|
| 465 | | |
|---|
| | 448 | |
|---|
| | 449 | /*********************************************************************** |
|---|
| | 450 | |
|---|
| | 451 | ***********************************************************************/ |
|---|
| | 452 | |
|---|
| | 453 | private XmlTokenType doUnexpected (char[] msg, Ch* p) |
|---|
| | 454 | { |
|---|
| | 455 | return position ("parse error :: unexpected " ~ msg, p); |
|---|
| | 456 | } |
|---|
| | 457 | |
|---|
| | 458 | /*********************************************************************** |
|---|
| | 459 | |
|---|
| | 460 | ***********************************************************************/ |
|---|
| | 461 | |
|---|
| | 462 | private XmlTokenType doExpected (char[] msg, Ch* p) |
|---|
| | 463 | { |
|---|
| | 464 | return position ("parse error :: expected " ~ msg ~ " instead of " ~ *p, p); |
|---|
| | 465 | } |
|---|
| | 466 | |
|---|
| | 467 | /*********************************************************************** |
|---|
| | 468 | |
|---|
| | 469 | ***********************************************************************/ |
|---|
| | 470 | |
|---|
| | 471 | private XmlTokenType position (char[] msg, Ch* p) |
|---|
| | 472 | { |
|---|
| | 473 | return error (msg ~ " at position " ~ Integer.toString(p-text.text.ptr)); |
|---|
| | 474 | } |
|---|
| | 475 | |
|---|
| 466 | 476 | /*********************************************************************** |
|---|
| 467 | 477 | |
|---|
| … | … | |
| 470 | 480 | private XmlTokenType error (char[] msg) |
|---|
| 471 | 481 | { |
|---|
| | 482 | err = true; |
|---|
| 472 | 483 | errMsg = msg; |
|---|
| 473 | | err = true; |
|---|
| 474 | 484 | throw new XmlException (msg); |
|---|
| 475 | 485 | } |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic