Overview
Comment: | Clean up OFXMLParser a little. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
568ec65e80ab9b5bc2efd1979c653318 |
User & Date: | js on 2013-06-14 22:59:15 |
Other Links: | manifest | tags |
Context
2013-06-15
| ||
18:56 | configure: Improve --with-wii option. check-in: 14e7c3481f user: js tags: trunk | |
2013-06-14
| ||
22:59 | Clean up OFXMLParser a little. check-in: 568ec65e80 user: js tags: trunk | |
2013-06-13
| ||
02:03 | Don't bind to port 0 on the Wii. check-in: ca113e0145 user: js tags: trunk | |
Changes
Modified src/OFXMLParser.h from [947e0975da] to [cb1201f0a4].
︙ | ︙ | |||
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | OF_XMLPARSER_IN_CDATA_2, OF_XMLPARSER_IN_COMMENT_OPENING, OF_XMLPARSER_IN_COMMENT_1, OF_XMLPARSER_IN_COMMENT_2, OF_XMLPARSER_IN_DOCTYPE, OF_XMLPARSER_NUM_STATES } _state; OFDataArray *_buffer; OFString *_name, *_prefix; OFMutableArray *_namespaces, *_attributes; OFString *_attributeName, *_attributePrefix; char _delimiter; OFMutableArray *_previous; size_t _level; | > > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | OF_XMLPARSER_IN_CDATA_2, OF_XMLPARSER_IN_COMMENT_OPENING, OF_XMLPARSER_IN_COMMENT_1, OF_XMLPARSER_IN_COMMENT_2, OF_XMLPARSER_IN_DOCTYPE, OF_XMLPARSER_NUM_STATES } _state; size_t _i, _last; const char *_data; OFDataArray *_buffer; OFString *_name, *_prefix; OFMutableArray *_namespaces, *_attributes; OFString *_attributeName, *_attributePrefix; char _delimiter; OFMutableArray *_previous; size_t _level; |
︙ | ︙ |
Modified src/OFXMLParser.m from [3bb79c6f6f] to [bf41f38598].
︙ | ︙ | |||
33 34 35 36 37 38 39 | #import "OFInitializationFailedException.h" #import "OFMalformedXMLException.h" #import "OFUnboundNamespaceException.h" #import "autorelease.h" #import "macros.h" | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "OFInitializationFailedException.h" #import "OFMalformedXMLException.h" #import "OFUnboundNamespaceException.h" #import "autorelease.h" #import "macros.h" typedef void (*state_function)(id, SEL); static SEL selectors[OF_XMLPARSER_NUM_STATES]; static state_function lookupTable[OF_XMLPARSER_NUM_STATES]; static OF_INLINE void buffer_append(OFDataArray *buffer, const char *string, of_string_encoding_t encoding, size_t length) { |
︙ | ︙ | |||
136 137 138 139 140 141 142 | @implementation OFXMLParser + (void)initialize { size_t i; const SEL selectors_[OF_XMLPARSER_NUM_STATES] = { | | | | | | | | | | | | | | | | | | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | @implementation OFXMLParser + (void)initialize { size_t i; const SEL selectors_[OF_XMLPARSER_NUM_STATES] = { @selector(OF_inByteOrderMarkState), @selector(OF_outsideTagState), @selector(OF_tagOpenedState), @selector(OF_inProcessingInstructionsState), @selector(OF_inTagNameState), @selector(OF_inCloseTagNameState), @selector(OF_inTagState), @selector(OF_inAttributeNameState), @selector(OF_expectDelimiterState), @selector(OF_inAttributeValueState), @selector(OF_expectCloseState), @selector(OF_expectSpaceOrCloseState), @selector(OF_inExclamationMarkState), @selector(OF_inCDATAOpeningState), @selector(OF_inCDATAState1), @selector(OF_inCDATAState2), @selector(OF_inCommentOpeningState), @selector(OF_inCommentState1), @selector(OF_inCommentState2), @selector(OF_inDOCTYPEState) }; memcpy(selectors, selectors_, sizeof(selectors_)); for (i = 0; i < OF_XMLPARSER_NUM_STATES; i++) { if (![self instancesRespondToSelector: selectors[i]]) @throw [OFInitializationFailedException exceptionWithClass: self]; |
︙ | ︙ | |||
244 245 246 247 248 249 250 | { _depthLimit = depthLimit; } - (void)parseBuffer: (const char*)buffer length: (size_t)length { | | | | | | | | | | > | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | { _depthLimit = depthLimit; } - (void)parseBuffer: (const char*)buffer length: (size_t)length { _data = buffer; for (_i = _last = 0; _i < length; _i++) { size_t j = _i; lookupTable[_state](self, selectors[_state]); /* Ensure we don't count this character twice */ if (_i != j) continue; if (_data[_i] == '\r' || (_data[_i] == '\n' && !_lastCarriageReturn)) _lineNumber++; _lastCarriageReturn = (_data[_i] == '\r'); } /* In OF_XMLPARSER_IN_TAG, there can be only spaces */ if (length - _last > 0 && _state != OF_XMLPARSER_IN_TAG) buffer_append(_buffer, _data + _last, _encoding, length - _last); } - (void)parseString: (OFString*)string { [self parseBuffer: [string UTF8String] length: [string UTF8StringLength]]; } |
︙ | ︙ | |||
309 310 311 312 313 314 315 | /* * The following methods handle the different states of the parser. They are * looked up in +[initialize] and put in a lookup table to speed things up. * One dispatch for every character would be way too slow! */ | | < < | | | | < < | | | | | | | | < < | | | | | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | /* * The following methods handle the different states of the parser. They are * looked up in +[initialize] and put in a lookup table to speed things up. * One dispatch for every character would be way too slow! */ - (void)OF_inByteOrderMarkState { if (_data[_i] != "\xEF\xBB\xBF"[_level]) { if (_level == 0) { _state = OF_XMLPARSER_OUTSIDE_TAG; _i--; return; } @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; } if (_level++ == 2) _state = OF_XMLPARSER_OUTSIDE_TAG; _last = _i + 1; } /* Not in a tag */ - (void)OF_outsideTagState { size_t length; if ((_finishedParsing || [_previous count] < 1) && _data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' && _data[_i] != '<') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; if (_data[_i] != '<') return; if ((length = _i - _last) > 0) buffer_append(_buffer, _data + _last, _encoding, length); if ([_buffer count] > 0) { void *pool = objc_autoreleasePoolPush(); OFString *characters = transform_string(_buffer, 0, true, self); if ([_delegate respondsToSelector: @selector(parser:foundCharacters:)]) [_delegate parser: self foundCharacters: characters]; objc_autoreleasePoolPop(pool); } [_buffer removeAllItems]; _last = _i + 1; _state = OF_XMLPARSER_TAG_OPENED; } /* Tag was just opened */ - (void)OF_tagOpenedState { if (_finishedParsing && _data[_i] != '!' && _data[_i] != '?') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; switch (_data[_i]) { case '?': _last = _i + 1; _state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS; _level = 0; break; case '/': _last = _i + 1; _state = OF_XMLPARSER_IN_CLOSE_TAG_NAME; _acceptProlog = false; break; case '!': _last = _i + 1; _state = OF_XMLPARSER_IN_EXCLAMATIONMARK; _acceptProlog = false; break; default: if (_depthLimit > 0 && [_previous count] >= _depthLimit) @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; _state = OF_XMLPARSER_IN_TAG_NAME; _acceptProlog = false; _i--; break; } } /* <?xml […]?> */ - (bool)OF_parseXMLProcessingInstructions: (OFString*)pi { |
︙ | ︙ | |||
444 445 446 447 448 449 450 | break; case 1: if (cString[i] != '=') continue; attribute = [OFString | | > | > | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | break; case 1: if (cString[i] != '=') continue; attribute = [OFString stringWithCString: cString + last encoding: _encoding length: i - last]; last = i + 1; PIState = 2; break; case 2: if (cString[i] != '\'' && cString[i] != '"') return false; piDelimiter = cString[i]; last = i + 1; PIState = 3; break; case 3: if (cString[i] != piDelimiter) continue; value = [OFMutableString stringWithCString: cString + last encoding: _encoding length: i - last]; if ([attribute isEqual: @"version"]) { if (![value hasPrefix: @"1."]) return false; hasVersion = true; |
︙ | ︙ | |||
506 507 508 509 510 511 512 | if (PIState != 0 || !hasVersion) return false; return true; } /* Inside processing instructions */ | | < < | | | | | < < | | | | | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | if (PIState != 0 || !hasVersion) return false; return true; } /* Inside processing instructions */ - (void)OF_inProcessingInstructionsState { if (_data[_i] == '?') _level = 1; else if (_level == 1 && _data[_i] == '>') { void *pool = objc_autoreleasePoolPush(); OFString *PI; buffer_append(_buffer, _data + _last, _encoding, _i - _last); PI = transform_string(_buffer, 1, false, nil); if ([PI isEqual: @"xml"] || [PI hasPrefix: @"xml "] || [PI hasPrefix: @"xml\t"] || [PI hasPrefix: @"xml\r"] || [PI hasPrefix: @"xml\n"]) if (![self OF_parseXMLProcessingInstructions: PI]) @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; if ([_delegate respondsToSelector: @selector(parser:foundProcessingInstructions:)]) [_delegate parser: self foundProcessingInstructions: PI]; objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } else _level = 0; } /* Inside a tag, no name yet */ - (void)OF_inTagNameState { void *pool; const char *bufferCString, *tmp; size_t length, bufferLength; OFString *bufferString; if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' && _data[_i] != '>' && _data[_i] != '/') return; if ((length = _i - _last) > 0) buffer_append(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); bufferCString = [_buffer items]; bufferLength = [_buffer count]; bufferString = [OFString stringWithUTF8String: bufferCString length: bufferLength]; |
︙ | ︙ | |||
579 580 581 582 583 584 585 | initWithUTF8String: bufferCString length: tmp - bufferCString]; } else { _name = [bufferString copy]; _prefix = nil; } | | | | | | | < < | | | | | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | initWithUTF8String: bufferCString length: tmp - bufferCString]; } else { _name = [bufferString copy]; _prefix = nil; } if (_data[_i] == '>' || _data[_i] == '/') { OFString *namespace; namespace = namespace_for_prefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) @throw [OFUnboundNamespaceException exceptionWithClass: [self class] prefix: _prefix]; if ([_delegate respondsToSelector: @selector(parser: didStartElement:prefix:namespace:attributes:)]) [_delegate parser: self didStartElement: _name prefix: _prefix namespace: namespace attributes: nil]; if (_data[_i] == '/') { if ([_delegate respondsToSelector: @selector(parser:didEndElement:prefix:namespace:)]) [_delegate parser: self didEndElement: _name prefix: _prefix namespace: namespace]; if ([_previous count] == 0) _finishedParsing = true; } else [_previous addObject: bufferString]; [_name release]; [_prefix release]; _name = _prefix = nil; _state = (_data[_i] == '/' ? OF_XMLPARSER_EXPECT_CLOSE : OF_XMLPARSER_OUTSIDE_TAG); } else _state = OF_XMLPARSER_IN_TAG; if (_data[_i] != '/') [_namespaces addObject: [OFMutableDictionary dictionary]]; objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; _last = _i + 1; } /* Inside a close tag, no name yet */ - (void)OF_inCloseTagNameState { void *pool; const char *bufferCString, *tmp; size_t length, bufferLength; OFString *bufferString, *namespace; if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' && _data[_i] != '>') return; if ((length = _i - _last) > 0) buffer_append(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); bufferCString = [_buffer items]; bufferLength = [_buffer count]; bufferString = [OFString stringWithUTF8String: bufferCString length: bufferLength]; |
︙ | ︙ | |||
694 695 696 697 698 699 700 | objc_autoreleasePoolPop(pool); [_namespaces removeLastObject]; [_name release]; [_prefix release]; _name = _prefix = nil; | | | | < < | | | | | | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | objc_autoreleasePoolPop(pool); [_namespaces removeLastObject]; [_name release]; [_prefix release]; _name = _prefix = nil; _last = _i + 1; _state = (_data[_i] == '>' ? OF_XMLPARSER_OUTSIDE_TAG : OF_XMLPARSER_EXPECT_SPACE_OR_CLOSE); if ([_previous count] == 0) _finishedParsing = true; } /* Inside a tag, name found */ - (void)OF_inTagState { void *pool; OFString *namespace; OFXMLAttribute **attributesObjects; size_t j, attributesCount; if (_data[_i] != '>' && _data[_i] != '/') { if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r') { _last = _i; _state = OF_XMLPARSER_IN_ATTR_NAME; _i--; } return; } attributesObjects = [_attributes objects]; attributesCount = [_attributes count]; |
︙ | ︙ | |||
748 749 750 751 752 753 754 | @selector(parser:didStartElement:prefix:namespace:attributes:)]) [_delegate parser: self didStartElement: _name prefix: _prefix namespace: namespace attributes: _attributes]; | | | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | @selector(parser:didStartElement:prefix:namespace:attributes:)]) [_delegate parser: self didStartElement: _name prefix: _prefix namespace: namespace attributes: _attributes]; if (_data[_i] == '/') { if ([_delegate respondsToSelector: @selector(parser:didEndElement:prefix:namespace:)]) [_delegate parser: self didEndElement: _name prefix: _prefix namespace: namespace]; |
︙ | ︙ | |||
774 775 776 777 778 779 780 | objc_autoreleasePoolPop(pool); [_name release]; [_prefix release]; [_attributes removeAllObjects]; _name = _prefix = nil; | | | | < < | | | | 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | objc_autoreleasePoolPop(pool); [_name release]; [_prefix release]; [_attributes removeAllObjects]; _name = _prefix = nil; _last = _i + 1; _state = (_data[_i] == '/' ? OF_XMLPARSER_EXPECT_CLOSE : OF_XMLPARSER_OUTSIDE_TAG); } /* Looking for attribute name */ - (void)OF_inAttributeNameState { void *pool; OFMutableString *bufferString; const char *bufferCString, *tmp; size_t length, bufferLength; if (_data[_i] != '=') return; if ((length = _i - _last) > 0) buffer_append(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); bufferString = [OFMutableString stringWithUTF8String: [_buffer items] length: [_buffer count]]; [bufferString deleteEnclosingWhitespaces]; /* Prevent a useless copy later */ |
︙ | ︙ | |||
824 825 826 827 828 829 830 | _attributePrefix = nil; } objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; | | | < < | | | | | | < < | | | | 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 | _attributePrefix = nil; } objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; _last = _i + 1; _state = OF_XMLPARSER_EXPECT_DELIMITER; } /* Expecting delimiter */ - (void)OF_expectDelimiterState { _last = _i + 1; if (_data[_i] == ' ' || _data[_i] == '\t' || _data[_i] == '\n' || _data[_i] == '\r') return; if (_data[_i] != '\'' && _data[_i] != '"') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; _delimiter = _data[_i]; _state = OF_XMLPARSER_IN_ATTR_VALUE; } /* Looking for attribute value */ - (void)OF_inAttributeValueState { void *pool; OFString *attributeValue; size_t length; if (_data[_i] != _delimiter) return; if ((length = _i - _last) > 0) buffer_append(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); attributeValue = transform_string(_buffer, 0, true, self); if (_attributePrefix == nil && [_attributeName isEqual: @"xmlns"]) [[_namespaces lastObject] setObject: attributeValue forKey: @""]; |
︙ | ︙ | |||
884 885 886 887 888 889 890 | objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; [_attributeName release]; [_attributePrefix release]; _attributeName = _attributePrefix = nil; | | | < < | | | < < | | | | | < < | | | | | | < < | | | < < | | < < | | | | | < < | | | < < | | < < | | | | < < | | | < < | < < | < | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; [_attributeName release]; [_attributePrefix release]; _attributeName = _attributePrefix = nil; _last = _i + 1; _state = OF_XMLPARSER_IN_TAG; } /* Expecting closing '>' */ - (void)OF_expectCloseState { if (_data[_i] == '>') { _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } else @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; } /* Expecting closing '>' or space */ - (void)OF_expectSpaceOrCloseState { if (_data[_i] == '>') { _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } else if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; } /* In <! */ - (void)OF_inExclamationMarkState { if (_finishedParsing && _data[_i] != '-') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; if (_data[_i] == '-') _state = OF_XMLPARSER_IN_COMMENT_OPENING; else if (_data[_i] == '[') { _state = OF_XMLPARSER_IN_CDATA_OPENING; _level = 0; } else if (_data[_i] == 'D') { _state = OF_XMLPARSER_IN_DOCTYPE; _level = 0; } else @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; _last = _i + 1; } /* CDATA */ - (void)OF_inCDATAOpeningState { if (_data[_i] != "CDATA["[_level]) @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; if (++_level == 6) { _state = OF_XMLPARSER_IN_CDATA_1; _level = 0; } _last = _i + 1; } - (void)OF_inCDATAState1 { if (_data[_i] == ']') _level++; else _level = 0; if (_level == 2) _state = OF_XMLPARSER_IN_CDATA_2; } - (void)OF_inCDATAState2 { void *pool; OFString *CDATA; if (_data[_i] != '>') { _state = OF_XMLPARSER_IN_CDATA_1; _level = (_data[_i] == ']' ? 1 : 0); return; } pool = objc_autoreleasePoolPush(); buffer_append(_buffer, _data + _last, _encoding, _i - _last); CDATA = transform_string(_buffer, 2, false, nil); if ([_delegate respondsToSelector: @selector(parser:foundCDATA:)]) [_delegate parser: self foundCDATA: CDATA]; objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } /* Comment */ - (void)OF_inCommentOpeningState { if (_data[_i] != '-') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; _last = _i + 1; _state = OF_XMLPARSER_IN_COMMENT_1; _level = 0; } - (void)OF_inCommentState1 { if (_data[_i] == '-') _level++; else _level = 0; if (_level == 2) _state = OF_XMLPARSER_IN_COMMENT_2; } - (void)OF_inCommentState2 { void *pool; OFString *comment; if (_data[_i] != '>') @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; pool = objc_autoreleasePoolPush(); buffer_append(_buffer, _data + _last, _encoding, _i - _last); comment = transform_string(_buffer, 2, false, nil); if ([_delegate respondsToSelector: @selector(parser:foundComment:)]) [_delegate parser: self foundComment: comment]; objc_autoreleasePoolPop(pool); [_buffer removeAllItems]; _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } /* In <!DOCTYPE ...> */ - (void)OF_inDOCTYPEState { if ((_level < 6 && _data[_i] != "OCTYPE"[_level]) || (_level == 6 && _data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r')) @throw [OFMalformedXMLException exceptionWithClass: [self class] parser: self]; _level++; if (_level > 6 && _data[_i] == '>') _state = OF_XMLPARSER_OUTSIDE_TAG; _last = _i + 1; } - (size_t)lineNumber { return _lineNumber; } |
︙ | ︙ |
Modified tests/OFXMLParserTests.m from [4892d444ce] to [5633d6614b].
︙ | ︙ | |||
320 321 322 323 324 325 326 | return nil; } - (void)XMLParserTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; const char *str = "\xEF\xBB\xBF<?xml version='1.0'?><?p?i?>" | | | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | return nil; } - (void)XMLParserTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; const char *str = "\xEF\xBB\xBF<?xml version='1.0'?><?p?i?>" "<!DOCTYPE foo><root>\r\r" " <![CDATA[f<]]]oo]]><bar/>\n" " <foobar xmlns='urn:objfw:test:foobar'>\r\n" " <qux xmlns:foo='urn:objfw:test:foo'>\n" " <foo:bla foo:bla = 'bla' blafoo='foo'>\n" " <blup foo:qux='asd' quxqux='test'/>\n" " <bla:bla\r\rxmlns:bla\r=\t\"urn:objfw:test:bla\" qux='qux'\r\n" " bla:foo='blafoo'/>\n" |
︙ | ︙ |