ObjFW  Diff

Differences From Artifact [212afc270e]:

To Artifact [b5e6f95eb4]:


1
2
3
4

5
6
7
8
9
10
11
1



2
3
4
5
6
7
8
9

-
-
-
+







/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019, 2020
 *   Jonathan Schleifer <js@nil.im>
 * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
969
970
971
972
973
974
975
976

977
978
979
980
981
982
983
984
967
968
969
970
971
972
973

974

975
976
977
978
979
980
981







-
+
-







	if (of_string_utf8_decode(_s->cString + idx,
	    _s->cStringLength - idx, &character) <= 0)
		@throw [OFInvalidEncodingException exception];

	return character;
}

- (void)getCharacters: (of_unichar_t *)buffer
- (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range
	      inRange: (of_range_t)range
{
	/* TODO: Could be slightly optimized */
	void *pool = objc_autoreleasePoolPush();
	const of_unichar_t *characters = self.characters;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _s->length)
1237
1238
1239
1240
1241
1242
1243
1244

1245
1246


1247
1248
1249
1250
1251
1252
1253
1234
1235
1236
1237
1238
1239
1240

1241


1242
1243
1244
1245
1246
1247
1248
1249
1250







-
+
-
-
+
+








			continue;
		}

		if (*cString == '\n' || *cString == '\r') {
			pool = objc_autoreleasePoolPush();

			block([OFString
			block([OFString stringWithUTF8String: last
			    stringWithUTF8String: last
					  length: cString - last], &stop);
						      length: cString - last],
			    &stop);
			last = cString + 1;

			objc_autoreleasePoolPop(pool);
		}

		lastCarriageReturn = (*cString == '\r');
		cString++;