Overview
Comment: | OFXMLParser: Add support for different encodings and other improvements. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b2dd4f049bcfbd088f1796eac1e44eae |
User & Date: | js on 2011-04-25 16:57:55 |
Other Links: | manifest | tags |
Context
2011-04-25
| ||
17:14 | Skip possible BOMs in OFMutableString. check-in: 7aefcd5ede user: js tags: trunk | |
16:57 | OFXMLParser: Add support for different encodings and other improvements. check-in: b2dd4f049b user: js tags: trunk | |
14:14 | Fix a warning when sizeof(size_t) < sizeof(long long). check-in: e14961f94d user: js tags: trunk | |
Changes
Modified src/OFDataArray.m from [e4b0bd482e] to [738291762c].
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | - + | #import "base64.h" #import "macros.h" /* References for static linking */ void _references_to_categories_of_OFDataArray(void) { _OFDataArray_Hashing_reference = 1; |
︙ |
Modified src/OFMutableString.h from [960bff6aa8] to [02e4c6ad2f].
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | - + - + - + - + + + + + + + + + + + + + + - - + + - - + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + | #import "OFString.h" /** * \brief A class for storing and modifying strings. */ @interface OFMutableString: OFString /** |
︙ |
Modified src/OFMutableString.m from [fa9bcee55c] to [9261f4b9e0].
︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | + | #ifdef HAVE_MADVISE # include <sys/mman.h> #else # define madvise(addr, len, advise) #endif #import "OFString.h" #import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" |
︙ | |||
192 193 194 195 196 197 198 199 200 201 202 203 204 205 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | + + + + + + + + + + + + + + + + | string = [self resizeMemory: string toSize: length + length_ + 1]; memcpy(string + length, string_, length_); length += length_; string[length] = 0; } - (void)appendCString: (const char*)string_ withEncoding: (of_string_encoding_t)encoding length: (size_t)length_ { if (encoding == OF_STRING_ENCODING_UTF_8) [self appendCString: string_ withLength: length_]; else { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self appendString: [OFString stringWithCString: string_ encoding: encoding length: length_]]; [pool release]; } } - (void)appendCStringWithoutUTF8Checking: (const char*)string_ { size_t len; len = strlen(string_); string = [self resizeMemory: string |
︙ | |||
213 214 215 216 217 218 219 220 221 222 223 224 225 226 | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | + + + + + + + + + + + + + + + + | { string = [self resizeMemory: string toSize: length + length_ + 1]; memcpy(string + length, string_, length_); length += length_; string[length] = 0; } - (void)appendCStringWithoutUTF8Checking: (const char*)string_ encoding: (of_string_encoding_t)encoding length: (size_t)length_ { if (encoding == OF_STRING_ENCODING_UTF_8) [self appendCStringWithoutUTF8Checking: string_ length: length_]; else { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self appendString: [OFString stringWithCString: string_ encoding: encoding length: length_]]; [pool release]; } } - (void)appendString: (OFString*)string_ { if (string_ == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; |
︙ |
Modified src/OFXMLParser.h from [542d58ae0a] to [6fc60c0e72].
︙ | |||
180 181 182 183 184 185 186 187 188 189 190 191 192 193 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | + | of_xml_parser_unknown_entity_block_t unknownEntityHandler; #endif size_t level; BOOL acceptProlog; size_t lineNumber; BOOL lastCarriageReturn; BOOL finishedParsing; of_string_encoding_t encoding; } #ifdef OF_HAVE_PROPERTIES @property (retain) id <OFXMLParserDelegate> delegate; # ifdef OF_HAVE_BLOCKS @property (copy) of_xml_parser_processing_instructions_block_t processingInstructionsHandler; |
︙ |
Modified src/OFXMLParser.m from [267ee48789] to [852bd85a55].
︙ | |||
36 37 38 39 40 41 42 | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + | #import "macros.h" typedef void (*state_function)(id, SEL, const char*, size_t*, size_t*); static SEL selectors[OF_XMLPARSER_NUM_STATES]; static state_function lookupTable[OF_XMLPARSER_NUM_STATES]; |
︙ | |||
156 157 158 159 160 161 162 163 164 165 166 167 168 169 | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | + | dict = [OFMutableDictionary dictionaryWithKeysAndObjects: @"xml", @"http://www.w3.org/XML/1998/namespace", @"xmlns", @"http://www.w3.org/2000/xmlns/", nil]; [namespaces addObject: dict]; acceptProlog = YES; lineNumber = 1; encoding = OF_STRING_ENCODING_UTF_8; [pool release]; } @catch (id e) { [self release]; @throw e; } |
︙ | |||
223 224 225 226 227 228 229 230 231 232 233 234 235 236 | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | + | lastCarriageReturn = (buf[i] == '\r'); } /* In OF_XMLPARSER_IN_TAG, there can be only spaces */ if (length - last > 0 && state != OF_XMLPARSER_IN_TAG) [cache appendCStringWithoutUTF8Checking: buf + last encoding: encoding length: length - last]; } - (void)parseString: (OFString*)string { [self parseBuffer: [string cString] withLength: [string cStringLength]]; |
︙ | |||
285 286 287 288 289 290 291 292 293 294 295 296 297 298 | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | + - + | parser: self]; if (buffer[*i] != '<') return; if ((length = *i - *last) > 0) [cache appendCStringWithoutUTF8Checking: buffer + *last encoding: encoding length: length]; if ([cache cStringLength] > 0) { OFString *characters; OFAutoreleasePool *pool; pool = [[OFAutoreleasePool alloc] init]; |
︙ | |||
351 352 353 354 355 356 357 | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | - + | /* <?xml […]?> */ - (BOOL)_parseXMLProcessingInstructions: (OFString*)pi { const char *cString; size_t i, last, length; int piState = 0; OFString *attribute = nil; |
︙ | |||
401 402 403 404 405 406 407 | 436 437 438 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 | + - - + + - - - + + + + + + + + + + + + + + + + | piState = 3; break; case 3: if (cString[i] != piDelimiter) continue; value = [OFMutableString |
︙ | |||
435 436 437 438 439 440 441 | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | - + - + - - - + - - - - - - - - - | i: (size_t*)i last: (size_t*)last { if (buffer[*i] == '?') level = 1; else if (level == 1 && buffer[*i] == '>') { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; |
︙ | |||
488 489 490 491 492 493 494 495 496 497 498 499 500 501 | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | + | if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '>' && buffer[*i] != '/') return; if ((length = *i - *last) > 0) [cache appendCStringWithoutUTF8Checking: buffer + *last encoding: encoding length: length]; cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { name = [[OFString alloc] initWithCString: tmp + 1 |
︙ | |||
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | + + | if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '>') return; if ((length = *i - *last) > 0) [cache appendCStringWithoutUTF8Checking: buffer + *last encoding: encoding length: length]; cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { name = [[OFString alloc] initWithCString: tmp + 1 length: cacheLength - (tmp - cacheCString) - |
︙ | |||
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 | + + | size_t length, cacheLength; if (buffer[*i] != '=') return; if ((length = *i - *last) > 0) [cache appendCStringWithoutUTF8Checking: buffer + *last encoding: encoding length: length]; [cache deleteLeadingAndTrailingWhitespaces]; cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { attributeName = [[OFString alloc] initWithCString: tmp + 1 length: cacheLength - (tmp - cacheCString) - 1]; |
︙ | |||
789 790 791 792 793 794 795 796 797 798 | 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | + - + | size_t length; if (buffer[*i] != delimiter) return; if ((length = *i - *last) > 0) [cache appendCStringWithoutUTF8Checking: buffer + *last encoding: encoding length: length]; pool = [[OFAutoreleasePool alloc] init]; |
︙ | |||
906 907 908 909 910 911 912 | 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 | - + - + - - - + - - - - - - - - - | } - (void)_parseInCDATA2WithBuffer: (const char*)buffer i: (size_t*)i last: (size_t*)last { OFAutoreleasePool *pool; |
︙ | |||
981 982 983 984 985 986 987 | 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 | - + - + - - - + - - - - - - - - - | } - (void)_parseInComment2WithBuffer: (const char*)buffer i: (size_t*)i last: (size_t*)last { OFAutoreleasePool *pool; |
︙ |