ObjFW  Diff

Differences From Artifact [bcea8a4ed5]:

To Artifact [788fd6f59d]:


1409
1410
1411
1412
1413
1414
1415





1416
1417
1418
1419
1420
1421
1422
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427







+
+
+
+
+







	new = [OFMutableString stringWithString: self];
	[new appendString: string];

	[new makeImmutable];

	return new;
}

- (OFString*)stringByAppendingPathComponent: (OFString*)component
{
	return [OFString stringWithPath: self, component, nil];
}

- (OFString*)stringByPrependingString: (OFString*)string
{
	OFMutableString *new = [[string mutableCopy] autorelease];

	[new appendString: self];

1514
1515
1516
1517
1518
1519
1520
1521
1522


1523
1524
1525
1526
1527
1528
1529
1519
1520
1521
1522
1523
1524
1525


1526
1527
1528
1529
1530
1531
1532
1533
1534







-
-
+
+







	const of_unichar_t *prefixString;
	size_t prefixLength;
	int compare;

	if ((prefixLength = [prefix length]) > [self length])
		return NO;

	tmp = [self allocMemoryForNItems: prefixLength
				  ofSize: sizeof(of_unichar_t)];
	tmp = [self allocMemoryWithItemSize: sizeof(of_unichar_t)
				      count: prefixLength];
	@try {
		OFAutoreleasePool *pool;

		[self getCharacters: tmp
			    inRange: of_range(0, prefixLength)];

		pool = [[OFAutoreleasePool alloc] init];
1548
1549
1550
1551
1552
1553
1554
1555
1556


1557
1558
1559
1560
1561
1562
1563
1553
1554
1555
1556
1557
1558
1559


1560
1561
1562
1563
1564
1565
1566
1567
1568







-
-
+
+







	int compare;

	if ((suffixLength = [suffix length]) > [self length])
		return NO;

	length = [self length];

	tmp = [self allocMemoryForNItems: suffixLength
				  ofSize: sizeof(of_unichar_t)];
	tmp = [self allocMemoryWithItemSize: sizeof(of_unichar_t)
				      count: suffixLength];
	@try {
		OFAutoreleasePool *pool;

		[self getCharacters: tmp
			    inRange: of_range(length - suffixLength,
					 suffixLength)];

1950
1951
1952
1953
1954
1955
1956
1957
1958


1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977


1978
1979
1980
1981
1982
1983
1984
1955
1956
1957
1958
1959
1960
1961


1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980


1981
1982
1983
1984
1985
1986
1987
1988
1989







-
-
+
+

















-
-
+
+








- (const of_unichar_t*)unicodeString
{
	OFObject *object = [[[OFObject alloc] init] autorelease];
	size_t length = [self length];
	of_unichar_t *ret;

	ret = [object allocMemoryForNItems: length + 1
				    ofSize: sizeof(of_unichar_t)];
	ret = [object allocMemoryWithItemSize: sizeof(of_unichar_t)
					count: length + 1];
	[self getCharacters: ret
		    inRange: of_range(0, length)];
	ret[length] = 0;

	return ret;
}

- (const uint16_t*)UTF16String
{
	OFObject *object = [[[OFObject alloc] init] autorelease];
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	const of_unichar_t *unicodeString = [self unicodeString];
	size_t length = [self length];
	uint16_t *ret;
	size_t i, j;

	/* Allocate memory for the worst case */
	ret = [object allocMemoryForNItems: length * 2 + 1
				    ofSize: sizeof(uint16_t)];
	ret = [object allocMemoryWithItemSize: sizeof(uint16_t)
					count: length * 2 + 1];

	j = 0;

	for (i = 0; i < length; i++) {
		of_unichar_t c = unicodeString[i];

		if (c > 0x10FFFF)
1993
1994
1995
1996
1997
1998
1999
2000
2001


2002
2003
2004
2005
2006
2007
2008
1998
1999
2000
2001
2002
2003
2004


2005
2006
2007
2008
2009
2010
2011
2012
2013







-
-
+
+







			ret[j++] = of_bswap16_if_le(c);
	}

	ret[j] = 0;

	@try {
		ret = [object resizeMemory: ret
				  toNItems: j + 1
				    ofSize: sizeof(uint16_t)];
				  itemSize: sizeof(uint16_t)
				     count: j + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only tried to make it smaller */
	}

	[pool release];

	return ret;