Overview
Comment: | Get rid of -[*FromIndex:toIndex:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f977192a233e204da718f03e7f01b134 |
User & Date: | js on 2011-08-04 16:48:32 |
Other Links: | manifest | tags |
Context
2011-08-04
| ||
17:18 | Add a note about usage of super to OFMutableCArray. check-in: dc8b06a5aa user: js tags: trunk | |
16:48 | Get rid of -[*FromIndex:toIndex:]. check-in: f977192a23 user: js tags: trunk | |
2011-08-03
| ||
16:25 | Fix a few OFString tests. check-in: cc93f51348 user: js tags: trunk | |
Changes
Modified src/OFConstantString.m from [4fa86efffd] to [5745a4d78a].
︙ | ︙ | |||
465 466 467 468 469 470 471 | { if (initialized != SIZE_MAX) [self finishInitialization]; return [super containsString: string]; } | < < < < < < < < < < | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | { if (initialized != SIZE_MAX) [self finishInitialization]; return [super containsString: string]; } - (OFString*)substringWithRange: (of_range_t)range { if (initialized != SIZE_MAX) [self finishInitialization]; return [super substringWithRange: range]; } |
︙ | ︙ |
Modified src/OFHTTPRequest.m from [6cdf31afd0] to [205f214213].
︙ | ︙ | |||
280 281 282 283 284 285 286 | */ line = [sock readLine]; if (![line hasPrefix: @"HTTP/1.0 "] && ![line hasPrefix: @"HTTP/1.1 "]) @throw [OFInvalidServerReplyException newWithClass: isa]; | | | | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | */ line = [sock readLine]; if (![line hasPrefix: @"HTTP/1.0 "] && ![line hasPrefix: @"HTTP/1.1 "]) @throw [OFInvalidServerReplyException newWithClass: isa]; status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue]; serverHeaders = [OFMutableDictionary dictionary]; while ((line = [sock readLine]) != nil) { OFString *key, *value; const char *line_c = [line cString], *tmp; |
︙ | ︙ |
Modified src/OFMutableString.h from [903f2cd12d] to [7e1d229b63].
︙ | ︙ | |||
118 119 120 121 122 123 124 | */ - (void)insertString: (OFString*)string atIndex: (size_t)index; /** * \brief Deletes the characters at the specified range. * | < < < < < < < < < < < < < < < < < < < < < < | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | */ - (void)insertString: (OFString*)string atIndex: (size_t)index; /** * \brief Deletes the characters at the specified range. * * \param range The range of the characters which should be removed */ - (void)deleteCharactersInRange: (of_range_t)range; /** * \brief Replaces the characters at the specified range. * * \param range The range of the characters which should be replaced * \param replacement The string to the replace the characters with */ - (void)replaceCharactersInRange: (of_range_t)range |
︙ | ︙ |
Modified src/OFMutableString.m from [3c8f4c2bc5] to [f5b0d569c9].
︙ | ︙ | |||
429 430 431 432 433 434 435 | string->s->cStringLength); s->cString[newCStringLength] = '\0'; s->cStringLength = newCStringLength; s->length += string->s->length; } | | > | > | | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | string->s->cStringLength); s->cString[newCStringLength] = '\0'; s->cStringLength = newCStringLength; s->length += string->s->length; } - (void)deleteCharactersInRange: (of_range_t)range { size_t start = range.start; size_t end = range.start + range.length; if (start > end) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; if (end > s->length) @throw [OFOutOfRangeException newWithClass: isa]; |
︙ | ︙ | |||
461 462 463 464 465 466 467 | toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e release]; } } | < < < < < < | < | > > | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | toSize: s->cStringLength + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e release]; } } - (void)replaceCharactersInRange: (of_range_t)range withString: (OFString*)replacement { size_t start = range.start; size_t end = range.start + range.length; size_t newCStringLength, newLength; if (start > end) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; if (end > s->length) |
︙ | ︙ | |||
504 505 506 507 508 509 510 | replacement->s->cStringLength); s->cString[newCStringLength] = '\0'; s->cStringLength = newCStringLength; s->length = newLength; } | < < < < < < < < | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | replacement->s->cStringLength); s->cString[newCStringLength] = '\0'; s->cStringLength = newCStringLength; s->length = newLength; } - (void)replaceOccurrencesOfString: (OFString*)string withString: (OFString*)replacement { const char *cString = [string cString]; const char *replacementCString = [replacement cString]; size_t cStringLength = string->s->cStringLength; size_t replacementCStringLength = replacement->s->cStringLength; |
︙ | ︙ |
Modified src/OFString.h from [5a32f0ead2] to [f186440ce9].
︙ | ︙ | |||
570 571 572 573 574 575 576 | /** * \param string The string to search * \return Whether the string contains the specified string */ - (BOOL)containsString: (OFString*)string; | < < < < < < < < < | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | /** * \param string The string to search * \return Whether the string contains the specified string */ - (BOOL)containsString: (OFString*)string; /** * \param range The range of the substring * \return The substring as a new autoreleased OFString */ - (OFString*)substringWithRange: (of_range_t)range; /** |
︙ | ︙ |
Modified src/OFString.m from [9e62f802e4] to [e16259c02d].
︙ | ︙ | |||
1394 1395 1396 1397 1398 1399 1400 | for (i = 0; i <= s->cStringLength - cStringLength; i++) if (!memcmp(s->cString + i, cString, cStringLength)) return YES; return NO; } | | < | < < > < < < < < < | 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 | for (i = 0; i <= s->cStringLength - cStringLength; i++) if (!memcmp(s->cString + i, cString, cStringLength)) return YES; return NO; } - (OFString*)substringWithRange: (of_range_t)range { size_t start = range.start; size_t end = range.start + range.length; if (end > s->length) @throw [OFOutOfRangeException newWithClass: isa]; if (s->isUTF8) { start = of_string_index_to_position(s->cString, start, s->cStringLength); end = of_string_index_to_position(s->cString, end, s->cStringLength); } return [OFString stringWithCString: s->cString + start length: end - start]; } - (OFString*)stringByAppendingString: (OFString*)string { OFMutableString *new; new = [OFMutableString stringWithString: self]; [new appendString: string]; |
︙ | ︙ |
Modified src/OFXMLParser.m from [b84b15abc4] to [a92b6c9809].
︙ | ︙ | |||
72 73 74 75 76 77 78 | withString: @"\n"]; [ret replaceOccurrencesOfString: @"\r" withString: @"\n"]; if (cut > 0) { size_t length = [ret length]; | | < | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | withString: @"\n"]; [ret replaceOccurrencesOfString: @"\r" withString: @"\n"]; if (cut > 0) { size_t length = [ret length]; [ret deleteCharactersInRange: of_range(length - cut, cut)]; } if (unescape) return [ret stringByXMLUnescapingWithDelegate: delegate]; ret->isa = [OFString class]; return ret; |
︙ | ︙ | |||
395 396 397 398 399 400 401 | char piDelimiter = 0; if (!acceptProlog) return NO; acceptProlog = NO; | | < | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | char piDelimiter = 0; if (!acceptProlog) return NO; acceptProlog = NO; pi = [pi substringWithRange: of_range(3, [pi length] - 3)]; pi = [pi stringByDeletingEnclosingWhitespaces]; cString = [pi cString]; length = [pi cStringLength]; for (i = last = 0; i < length; i++) { switch (piState) { |
︙ | ︙ |
Modified tests/OFStringTests.m from [eb8775f0d6] to [570caa0b7f].
︙ | ︙ | |||
216 217 218 219 220 221 222 | TEST(@"-[indexOfLastOccurrenceOfString:]", [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆΓΆ"] == 1 && [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆ"] == 2 && [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"π"] == 0 && [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == OF_INVALID_INDEX) | | | < | < | < | < | < | < < < < < < | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | TEST(@"-[indexOfLastOccurrenceOfString:]", [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆΓΆ"] == 1 && [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"ΓΆ"] == 2 && [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"π"] == 0 && [@"πΓΆΓΆ" indexOfLastOccurrenceOfString: @"x"] == OF_INVALID_INDEX) TEST(@"-[substringWithRange:]", [[@"πΓΆΓΆ" substringWithRange: of_range(1, 1)] isEqual: @"ΓΆ"] && [[@"πΓΆΓΆ" substringWithRange: of_range(3, 0)] isEqual: @""]) EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #1", OFOutOfRangeException, [@"πΓΆΓΆ" substringWithRange: of_range(2, 2)]) EXPECT_EXCEPTION(@"Detect out of range in -[substringWithRange:] #2", OFOutOfRangeException, [@"πΓΆΓΆ" substringWithRange: of_range(4, 0)]) TEST(@"-[stringByAppendingString:]", [[@"foo" stringByAppendingString: @"bar"] isEqual: @"foobar"]) TEST(@"-[stringByPrependingString:]", [[@"foo" stringByPrependingString: @"bar"] isEqual: @"barfoo"]) |
︙ | ︙ | |||
410 411 412 413 414 415 416 | EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding]) EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#2", OFInvalidEncodingException, [@"foo%FFbar" stringByURLDecoding]) | | | < | < | | < | | < | | | | < | | | < | < | < < < < < | < | | < | < | < < < < < < | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding]) EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#2", OFInvalidEncodingException, [@"foo%FFbar" stringByURLDecoding]) TEST(@"-[deleteCharactersInRange:]", (s[0] = [OFMutableString stringWithString: @"πΓΆΓΆΓΆbΓ€β¬"]) && R([s[0] deleteCharactersInRange: of_range(1, 3)]) && [s[0] isEqual: @"πbΓ€β¬"] && R([s[0] deleteCharactersInRange: of_range(0, 4)]) && [s[0] isEqual: @""]) TEST(@"-[replaceCharactersInRange:withString:]", (s[0] = [OFMutableString stringWithString: @"πΓΆΓΆΓΆbΓ€β¬"]) && R([s[0] replaceCharactersInRange: of_range(1, 3) withString: @"Àâü"]) && [s[0] isEqual: @"πÀâübΓ€β¬"] && R([s[0] replaceCharactersInRange: of_range(0, 7) withString: @""]) && [s[0] isEqual: @""]) EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #1", OFOutOfRangeException, { s[0] = [OFMutableString stringWithString: @"πΓΆΓΆ"]; [s[0] deleteCharactersInRange: of_range(2, 2)]; }) EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2", OFOutOfRangeException, [s[0] deleteCharactersInRange: of_range(4, 0)]) EXPECT_EXCEPTION(@"Detect OoR in -[replaceCharactersInRange:withString:] #1", OFOutOfRangeException, [s[0] replaceCharactersInRange: of_range(2, 2) withString: @""]) EXPECT_EXCEPTION(@"Detect OoR in -[replaceCharactersInRange:withString:] #2", OFOutOfRangeException, [s[0] replaceCharactersInRange: of_range(4, 0) withString: @""]) TEST(@"-[replaceOccurrencesOfString:withString:]", (s[0] = [OFMutableString stringWithString: @"asd fo asd fofo asd"]) && R([s[0] replaceOccurrencesOfString: @"fo" withString: @"foo"]) && [s[0] isEqual: @"asd foo asd foofoo asd"] && |
︙ | ︙ |