Overview
Comment: | Get rid of appendCStringWithoutUTF8Checking:encoding:length:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1eedeefc721923b603919f25aea7f646 |
User & Date: | js on 2011-05-08 17:33:29 |
Other Links: | manifest | tags |
Context
2011-05-08
| ||
18:32 | OFNumber: Explicitly use signed and improve documentation. check-in: eb2402a77a user: js tags: trunk | |
17:33 | Get rid of appendCStringWithoutUTF8Checking:encoding:length:]. check-in: 1eedeefc72 user: js tags: trunk | |
17:19 | More documentation improvements. check-in: 242b1ccd71 user: js tags: trunk | |
Changes
Modified src/OFMutableString.h from [02e4c6ad2f] to [a158f1d48a].
︙ | ︙ | |||
79 80 81 82 83 84 85 | * * \param string A UTF-8 encoded C string to append * \param length The length of the UTF-8 encoded C string */ - (void)appendCStringWithoutUTF8Checking: (const char*)string length: (size_t)length; | < < < < < < < < < < < < < < < < | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | * * \param string A UTF-8 encoded C string to append * \param length The length of the UTF-8 encoded C string */ - (void)appendCStringWithoutUTF8Checking: (const char*)string length: (size_t)length; /** * Appends another OFString to the OFMutableString. * * \param string An OFString to append */ - (void)appendString: (OFString*)string; |
︙ | ︙ |
Modified src/OFMutableString.m from [0eff2f55bc] to [a73fb6b373].
︙ | ︙ | |||
244 245 246 247 248 249 250 | string = [self resizeMemory: string toSize: length + length_ + 1]; memcpy(string + length, string_, length_); length += length_; string[length] = 0; } | < < < < < < < < < < < < < < < < | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | string = [self resizeMemory: string toSize: length + length_ + 1]; memcpy(string + length, string_, length_); length += length_; string[length] = 0; } - (void)appendString: (OFString*)string_ { if (string_ == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; [self appendCString: [string_ cString]]; |
︙ | ︙ |
Modified src/OFXMLParser.m from [b060def371] to [c68cb5d129].
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #import "OFUnboundNamespaceException.h" #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]; static OFString* transform_string(OFMutableString *cache, size_t cut, BOOL unescape, OFObject <OFStringXMLUnescapingDelegate> *delegate) { [cache replaceOccurrencesOfString: @"\r\n" withString: @"\n"]; | > > > > > > > > > > > > > > > > | 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 | #import "OFUnboundNamespaceException.h" #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]; static void cache_append(OFMutableString *cache, const char *string, of_string_encoding_t encoding, size_t length) { if (OF_LIKELY(encoding == OF_STRING_ENCODING_UTF_8)) [cache appendCStringWithoutUTF8Checking: string length: length]; else { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [cache appendString: [OFString stringWithCString: string encoding: encoding length: length]]; [pool release]; } } static OFString* transform_string(OFMutableString *cache, size_t cut, BOOL unescape, OFObject <OFStringXMLUnescapingDelegate> *delegate) { [cache replaceOccurrencesOfString: @"\r\n" withString: @"\n"]; |
︙ | ︙ | |||
212 213 214 215 216 217 218 | } - (void)setDelegate: (id <OFXMLParserDelegate>)delegate_ { OF_SETTER(delegate, delegate_, YES, NO) } | | | > | | < < | | 228 229 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 260 261 262 263 264 265 | } - (void)setDelegate: (id <OFXMLParserDelegate>)delegate_ { OF_SETTER(delegate, delegate_, YES, NO) } - (void)parseBuffer: (const char*)buffer withLength: (size_t)length { size_t i, last = 0; for (i = 0; i < length; i++) { size_t j = i; lookupTable[state](self, selectors[state], buffer, &i, &last); /* Ensure we don't count this character twice */ if (i != j) continue; if (buffer[i] == '\r' || (buffer[i] == '\n' && !lastCarriageReturn)) lineNumber++; lastCarriageReturn = (buffer[i] == '\r'); } /* In OF_XMLPARSER_IN_TAG, there can be only spaces */ if (length - last > 0 && state != OF_XMLPARSER_IN_TAG) cache_append(cache, buffer + last, encoding, length - last); } - (void)parseString: (OFString*)string { [self parseBuffer: [string cString] withLength: [string cStringLength]]; } |
︙ | ︙ | |||
297 298 299 300 301 302 303 | @throw [OFMalformedXMLException newWithClass: isa parser: self]; if (buffer[*i] != '<') return; if ((length = *i - *last) > 0) | | < < | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | @throw [OFMalformedXMLException newWithClass: isa parser: self]; if (buffer[*i] != '<') return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); if ([cache cStringLength] > 0) { OFString *characters; OFAutoreleasePool *pool; pool = [[OFAutoreleasePool alloc] init]; characters = transform_string(cache, 0, YES, self); |
︙ | ︙ | |||
465 466 467 468 469 470 471 | { if (buffer[*i] == '?') level = 1; else if (level == 1 && buffer[*i] == '>') { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *pi; | | < < | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | { if (buffer[*i] == '?') level = 1; else if (level == 1 && buffer[*i] == '>') { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *pi; cache_append(cache, buffer + *last, encoding, *i - *last); pi = transform_string(cache, 1, NO, nil); if ([pi isEqual: @"xml"] || [pi hasPrefix: @"xml "] || [pi hasPrefix: @"xml\t"] || [pi hasPrefix: @"xml\r"] || [pi hasPrefix: @"xml\n"]) if (![self _parseXMLProcessingInstructions: pi]) @throw [OFMalformedXMLException |
︙ | ︙ | |||
504 505 506 507 508 509 510 | size_t length, cacheLength; if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '>' && buffer[*i] != '/') return; if ((length = *i - *last) > 0) | | < < | 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | size_t length, cacheLength; if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '>' && buffer[*i] != '/') return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { name = [[OFString alloc] initWithCString: tmp + 1 length: cacheLength - |
︙ | ︙ | |||
599 600 601 602 603 604 605 | OFString *ns; if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '>') return; if ((length = *i - *last) > 0) | | < < | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | OFString *ns; if (buffer[*i] != ' ' && buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '>') return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { name = [[OFString alloc] initWithCString: tmp + 1 length: cacheLength - |
︙ | ︙ | |||
751 752 753 754 755 756 757 | const char *cacheCString, *tmp; size_t length, cacheLength; if (buffer[*i] != '=') return; if ((length = *i - *last) > 0) | | < < | 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | const char *cacheCString, *tmp; size_t length, cacheLength; if (buffer[*i] != '=') return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); [cache deleteLeadingAndTrailingWhitespaces]; cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { |
︙ | ︙ | |||
810 811 812 813 814 815 816 | OFString *attributeValue; size_t length; if (buffer[*i] != delimiter) return; if ((length = *i - *last) > 0) | | < < | 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | OFString *attributeValue; size_t length; if (buffer[*i] != delimiter) return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); pool = [[OFAutoreleasePool alloc] init]; attributeValue = transform_string(cache, 0, YES, self); if (attributePrefix == nil && [attributeName isEqual: @"xmlns"]) [[namespaces lastObject] setObject: attributeValue forKey: @""]; |
︙ | ︙ | |||
940 941 942 943 944 945 946 | level = (buffer[*i] == ']' ? 1 : 0); return; } pool = [[OFAutoreleasePool alloc] init]; | | < < | 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | level = (buffer[*i] == ']' ? 1 : 0); return; } pool = [[OFAutoreleasePool alloc] init]; cache_append(cache, buffer + *last, encoding, *i - *last); CDATA = transform_string(cache, 2, NO, nil); #if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) if (CDATAHandler != NULL) CDATAHandler(self, CDATA); else #endif |
︙ | ︙ | |||
1001 1002 1003 1004 1005 1006 1007 | if (buffer[*i] != '>') @throw [OFMalformedXMLException newWithClass: isa parser: self]; pool = [[OFAutoreleasePool alloc] init]; | | < < | 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 | if (buffer[*i] != '>') @throw [OFMalformedXMLException newWithClass: isa parser: self]; pool = [[OFAutoreleasePool alloc] init]; cache_append(cache, buffer + *last, encoding, *i - *last); comment = transform_string(cache, 2, NO, nil); #if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) if (commentHandler != NULL) commentHandler(self, comment); else #endif |
︙ | ︙ |