ObjFW  Diff

Differences From Artifact [d31ec13d9e]:

To Artifact [2e55f69888]:


378
379
380
381
382
383
384
385

386
387
388
389
390
391
392
378
379
380
381
382
383
384

385
386
387
388
389
390
391
392







-
+







	memmove(string + idx + [str cStringLength], string + idx, length - idx);
	memcpy(string + idx, [str cString], [str cStringLength]);
	string[nlen] = '\0';

	length = nlen;
}

- (void)removeCharactersFromIndex: (size_t)start
- (void)deleteCharactersFromIndex: (size_t)start
			  toIndex: (size_t)end
{
	if (isUTF8) {
		start = of_string_index_to_position(string, start, length);
		end = of_string_index_to_position(string, end, length);
	}

406
407
408
409
410
411
412
413

414
415

416
417
418
419
420
421
422
406
407
408
409
410
411
412

413
414

415
416
417
418
419
420
421
422







-
+

-
+







				     toSize: length + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeCharactersInRange: (of_range_t)range
- (void)deleteCharactersInRange: (of_range_t)range
{
	[self removeCharactersFromIndex: range.start
	[self deleteCharactersFromIndex: range.start
				toIndex: range.start + range.length];
}

- (void)replaceCharactersFromIndex: (size_t)start
			   toIndex: (size_t)end
			withString: (OFString*)repl
{
501
502
503
504
505
506
507
508

509
510
511
512
513
514
515
501
502
503
504
505
506
507

508
509
510
511
512
513
514
515







-
+







	tmp[tmp_len] = 0;

	[self freeMemory: string];
	string = tmp;
	length = tmp_len;
}

- (void)removeLeadingWhitespaces
- (void)deleteLeadingWhitespaces
{
	size_t i;

	for (i = 0; i < length; i++)
		if (string[i] != ' '  && string[i] != '\t' &&
		    string[i] != '\n' && string[i] != '\r')
			break;
523
524
525
526
527
528
529
530

531
532
533
534
535
536
537
523
524
525
526
527
528
529

530
531
532
533
534
535
536
537







-
+







				     toSize: length + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeTrailingWhitespaces
- (void)deleteTrailingWhitespaces
{
	size_t d;
	char *p;

	d = 0;
	for (p = string + length - 1; p >= string; p--) {
		if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
548
549
550
551
552
553
554
555

556
557
558
559
560
561
562
548
549
550
551
552
553
554

555
556
557
558
559
560
561
562







-
+







				     toSize: length + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeLeadingAndTrailingWhitespaces
- (void)deleteLeadingAndTrailingWhitespaces
{
	size_t d, i;
	char *p;

	d = 0;
	for (p = string + length - 1; p >= string; p--) {
		if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')