529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
}
- (void)deleteCharactersInRange: (of_range_t)range
{
size_t start = range.location;
size_t end = range.location + range.length;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
s->hashed = NO;
s->length -= end - start;
if (s->isUTF8) {
start = of_string_utf8_get_position(s->cString, start,
|
|
|
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
}
- (void)deleteCharactersInRange: (of_range_t)range
{
size_t start = range.location;
size_t end = range.location + range.length;
if (range.length > SIZE_MAX - range.location || end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
s->hashed = NO;
s->length -= end - start;
if (s->isUTF8) {
start = of_string_utf8_get_position(s->cString, start,
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
|
- (void)replaceCharactersInRange: (of_range_t)range
withString: (OFString*)replacement
{
size_t start = range.location;
size_t end = range.location + range.length;
size_t newCStringLength, newLength;
if (end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
newLength = s->length - (end - start) + [replacement length];
if (s->isUTF8) {
start = of_string_utf8_get_position(s->cString, start,
s->cStringLength);
|
|
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
|
- (void)replaceCharactersInRange: (of_range_t)range
withString: (OFString*)replacement
{
size_t start = range.location;
size_t end = range.location + range.length;
size_t newCStringLength, newLength;
if (range.length > SIZE_MAX - range.location || end > s->length)
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
newLength = s->length - (end - start) + [replacement length];
if (s->isUTF8) {
start = of_string_utf8_get_position(s->cString, start,
s->cStringLength);
|
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
|
const char *searchString = [string UTF8String];
const char *replacementString = [replacement UTF8String];
size_t searchLength = [string UTF8StringLength];
size_t replacementLength = [replacement UTF8StringLength];
size_t i, last, newCStringLength, newLength;
char *newCString;
if (s->isUTF8) {
range.location = of_string_utf8_get_position(s->cString,
range.location, s->cStringLength);
range.length = of_string_utf8_get_position(
s->cString + range.location, range.length,
s->cStringLength - range.location);
}
if (range.location + range.length > [self UTF8StringLength])
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if ([string UTF8StringLength] > range.length)
return;
newCString = NULL;
newCStringLength = 0;
newLength = s->length;
|
>
>
>
>
<
<
<
|
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
|
const char *searchString = [string UTF8String];
const char *replacementString = [replacement UTF8String];
size_t searchLength = [string UTF8StringLength];
size_t replacementLength = [replacement UTF8StringLength];
size_t i, last, newCStringLength, newLength;
char *newCString;
if (range.length > SIZE_MAX - range.location ||
range.location + range.length > [self length])
@throw [OFOutOfRangeException exceptionWithClass: [self class]];
if (s->isUTF8) {
range.location = of_string_utf8_get_position(s->cString,
range.location, s->cStringLength);
range.length = of_string_utf8_get_position(
s->cString + range.location, range.length,
s->cStringLength - range.location);
}
if ([string UTF8StringLength] > range.length)
return;
newCString = NULL;
newCStringLength = 0;
newLength = s->length;
|