Overview
Comment: | Rename -[deleteLeadingAndTrailingWhitespaces]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7c66260ead45212ff8d5adbcf3f05892 |
User & Date: | js on 2011-07-08 20:13:39 |
Other Links: | manifest | tags |
Context
2011-07-08
| ||
21:08 | Optimize +[stringWithString:] and -[appendString:]. check-in: e250800382 user: js tags: trunk | |
20:13 | Rename -[deleteLeadingAndTrailingWhitespaces]. check-in: 7c66260ead user: js tags: trunk | |
20:07 | Rename OF_PATH_DELIM to OF_PATH_DELIMITER. check-in: 7d9efc3924 user: js tags: trunk | |
Changes
Modified src/OFConstantString.m from [d4339ab533] to [c1cbc7f938].
︙ | ︙ | |||
530 531 532 533 534 535 536 | { if (initialized != SIZE_MAX) [self completeInitialization]; return [super stringByDeletingTrailingWhitespaces]; } | | | | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | { if (initialized != SIZE_MAX) [self completeInitialization]; return [super stringByDeletingTrailingWhitespaces]; } - (OFString*)stringByDeletingEnclosingWhitespaces { if (initialized != SIZE_MAX) [self completeInitialization]; return [super stringByDeletingEnclosingWhitespaces]; } - (BOOL)hasPrefix: (OFString*)prefix { if (initialized != SIZE_MAX) [self completeInitialization]; |
︙ | ︙ |
Modified src/OFMutableString.h from [f563238c97] to [b015e271e1].
︙ | ︙ | |||
199 200 201 202 203 204 205 | * \brief Deletes all whitespaces at the end of the string. */ - (void)deleteTrailingWhitespaces; /** * \brief Deletes all whitespaces at the beginning and the end of the string. */ | | | 199 200 201 202 203 204 205 206 207 | * \brief Deletes all whitespaces at the end of the string. */ - (void)deleteTrailingWhitespaces; /** * \brief Deletes all whitespaces at the beginning and the end of the string. */ - (void)deleteEnclosingWhitespaces; @end |
Modified src/OFMutableString.m from [34b8bce34b] to [736e731460].
︙ | ︙ | |||
598 599 600 601 602 603 604 | toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e release]; } } | | | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e release]; } } - (void)deleteEnclosingWhitespaces { size_t d, i; char *p; d = 0; for (p = s->cString + s->cStringLength - 1; p >= s->cString; p--) { if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') |
︙ | ︙ |
Modified src/OFString.h from [4d41d466d8] to [3fb5b4e15d].
︙ | ︙ | |||
622 623 624 625 626 627 628 | /** * Creates a new string by deleting leading and trailing whitespaces. * * \return A new autoreleased OFString with leading and trailing whitespaces * deleted */ | | | 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | /** * Creates a new string by deleting leading and trailing whitespaces. * * \return A new autoreleased OFString with leading and trailing whitespaces * deleted */ - (OFString*)stringByDeletingEnclosingWhitespaces; /** * Checks whether the string has the specified prefix. * * \param prefix The prefix to check for * \return A boolean whether the string has the specified prefix */ |
︙ | ︙ |
Modified src/OFString.m from [92607cf374] to [39b88703df].
︙ | ︙ | |||
1513 1514 1515 1516 1517 1518 1519 | * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ new->isa = [OFString class]; return new; } | | | | 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 | * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ new->isa = [OFString class]; return new; } - (OFString*)stringByDeletingEnclosingWhitespaces { OFMutableString *new = [[self mutableCopy] autorelease]; [new deleteEnclosingWhitespaces]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ new->isa = [OFString class]; |
︙ | ︙ |
Modified src/OFXMLParser.m from [c97fda3f99] to [d41280c3bf].
︙ | ︙ | |||
388 389 390 391 392 393 394 | if (!acceptProlog) return NO; acceptProlog = NO; pi = [pi substringFromIndex: 3 toIndex: [pi length]]; | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | if (!acceptProlog) return NO; acceptProlog = NO; pi = [pi substringFromIndex: 3 toIndex: [pi length]]; pi = [pi stringByDeletingEnclosingWhitespaces]; cString = [pi cString]; length = [pi cStringLength]; for (i = last = 0; i < length; i++) { switch (piState) { case 0: |
︙ | ︙ | |||
766 767 768 769 770 771 772 | if (buffer[*i] != '=') return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); | | | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | if (buffer[*i] != '=') return; if ((length = *i - *last) > 0) cache_append(cache, buffer + *last, encoding, length); [cache deleteEnclosingWhitespaces]; cacheCString = [cache cString]; cacheLength = [cache cStringLength]; if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) { attributeName = [[OFString alloc] initWithCString: tmp + 1 |
︙ | ︙ |
Modified tests/OFStringTests.m from [b6b68a3700] to [5ba4a302f9].
︙ | ︙ | |||
474 475 476 477 478 479 480 | TEST(@"-[deleteTrailingWhitespaces]", (s[0] = [OFMutableString stringWithString: whitespace[0]]) && R([s[0] deleteTrailingWhitespaces]) && [s[0] isEqual: @" \r \t\n\t \tasd"] && (s[0] = [OFMutableString stringWithString: whitespace[1]]) && R([s[0] deleteTrailingWhitespaces]) && [s[0] isEqual: @""]) | | < | | < | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | TEST(@"-[deleteTrailingWhitespaces]", (s[0] = [OFMutableString stringWithString: whitespace[0]]) && R([s[0] deleteTrailingWhitespaces]) && [s[0] isEqual: @" \r \t\n\t \tasd"] && (s[0] = [OFMutableString stringWithString: whitespace[1]]) && R([s[0] deleteTrailingWhitespaces]) && [s[0] isEqual: @""]) TEST(@"-[deleteEnclosingWhitespaces]", (s[0] = [OFMutableString stringWithString: whitespace[0]]) && R([s[0] deleteEnclosingWhitespaces]) && [s[0] isEqual: @"asd"] && (s[0] = [OFMutableString stringWithString: whitespace[1]]) && R([s[0] deleteEnclosingWhitespaces]) && [s[0] isEqual: @""]) TEST(@"-[stringByXMLEscaping]", (s[0] = (id)[@"<hello> &world'\"!&" stringByXMLEscaping]) && [s[0] isEqual: @"<hello> &world'"!&"]) TEST(@"-[stringByXMLUnescaping]", [[s[0] stringByXMLUnescaping] isEqual: @"<hello> &world'\"!&"] && |
︙ | ︙ |