ObjFW  Diff

Differences From Artifact [34bbb5a839]:

To Artifact [b5e0c44310]:


526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
			s->isUTF8 = YES;
	} else
		s->isUTF8 = YES;
}

- (void)deleteCharactersInRange: (of_range_t)range
{
	size_t start = range.start;
	size_t end = range.start + range.length;

	if (end > s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	s->hashed = NO;
	s->length -= end - start;








|
|







526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
			s->isUTF8 = YES;
	} else
		s->isUTF8 = YES;
}

- (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;

557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
		/* We don't really care, as we only made it smaller */
	}
}

- (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 (end > s->length)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	newLength = s->length - (end - start) + [replacement length];








|
|







557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
		/* We don't really care, as we only made it smaller */
	}
}

- (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];

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
626
627
628
629
630
631
	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.start = of_string_utf8_get_position(s->cString,
		    range.start, s->cStringLength);
		range.length = of_string_utf8_get_position(s->cString,

		    range.start + range.length, s->cStringLength) - range.start;
	}

	if (range.start + range.length > [self UTF8StringLength])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if ([string UTF8StringLength] > range.length)
		return;

	newCString = NULL;
	newCStringLength = 0;
	newLength = s->length;


	for (i = range.start, last = 0; i <= range.length - searchLength; i++) {
		if (memcmp(s->cString + i, searchString, searchLength))
			continue;

		@try {
			newCString = [self
			    resizeMemory: newCString
				    size: newCStringLength + i - last +







|
|
|
>
|


|









>
|







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
626
627
628
629
630
631
632
633
	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;

	last = 0;
	for (i = range.location; i <= range.length - searchLength; i++) {
		if (memcmp(s->cString + i, searchString, searchLength))
			continue;

		@try {
			newCString = [self
			    resizeMemory: newCString
				    size: newCStringLength + i - last +