ObjFW  Check-in [31c0f5b89e]

Overview
Comment:Make Apple GCC with -Wshadow happy
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 0.90
Files: files | file ages | folders
SHA3-256: 31c0f5b89edfbcc5356cc62e958361e70021cb8f4881b2d844712ee442d01e0d
User & Date: js on 2017-10-22 14:09:23
Other Links: branch diff | manifest | tags
Context
2017-10-22
21:12
runtime: Define _Null_unspecified if missing check-in: a1d0ab5bf9 user: js tags: 0.90
14:09
Make Apple GCC with -Wshadow happy check-in: 31c0f5b89e user: js tags: 0.90
2017-10-19
21:07
Xcode project: Set correct version for bridge check-in: eec9a82059 user: js tags: 0.90
Changes

Modified src/OFApplication.m from [f12746971d] to [23fc1019fd].

91
92
93
94
95
96
97
98

99
100

101
102
103


104
105
106
107
108
109
110
91
92
93
94
95
96
97

98
99

100
101


102
103
104
105
106
107
108
109
110







-
+

-
+

-
-
+
+








	if ([delegate respondsToSelector: @selector(applicationWillTerminate)])
		[delegate applicationWillTerminate];

	[delegate release];
}

#define SIGNAL_HANDLER(sig)					\
#define SIGNAL_HANDLER(signal)					\
	static void						\
	handle##sig(int signal)					\
	handle##signal(int sig)					\
	{							\
		app->_##sig##Handler(app->_delegate,		\
		    @selector(applicationDidReceive##sig));	\
		app->_##signal##Handler(app->_delegate,		\
		    @selector(applicationDidReceive##signal));	\
	}
SIGNAL_HANDLER(SIGINT)
#ifdef SIGHUP
SIGNAL_HANDLER(SIGHUP)
#endif
#ifdef SIGUSR1
SIGNAL_HANDLER(SIGUSR1)

Modified src/OFArray.m from [ffbda05782] to [1810203c70].

259
260
261
262
263
264
265
266

267
268
269
270
271

272
273

274
275
276
277
278
279
280
259
260
261
262
263
264
265

266
267
268
269
270

271
272

273
274
275
276
277
278
279
280







-
+




-
+

-
+







}

- mutableCopy
{
	return [[OFMutableArray alloc] initWithArray: self];
}

- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
	OF_UNRECOGNIZED_SELECTOR
}

- (id)objectAtIndexedSubscript: (size_t)index
- (id)objectAtIndexedSubscript: (size_t)idx
{
	return [self objectAtIndex: index];
	return [self objectAtIndex: idx];
}

- (id)valueForKey: (OFString *)key
{
	id ret;

	if ([key hasPrefix: @"@"]) {
855
856
857
858
859
860
861
862

863
864

865
866
867
868
869
870
871
855
856
857
858
859
860
861

862
863

864
865
866
867
868
869
870
871







-
+

-
+







{
	OFArray *ret;
	size_t count = [self count];
	id *tmp = [self allocMemoryWithSize: sizeof(id)
				      count: count];

	@try {
		[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
		[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
		    bool *stop) {
			tmp[index] = block(object, index);
			tmp[idx] = block(object, idx);
		}];

		ret = [OFArray arrayWithObjects: tmp
					  count: count];
	} @finally {
		[self freeMemory: tmp];
	}
879
880
881
882
883
884
885
886

887
888

889
890
891
892
893
894
895
879
880
881
882
883
884
885

886
887

888
889
890
891
892
893
894
895







-
+

-
+







	size_t count = [self count];
	id *tmp = [self allocMemoryWithSize: sizeof(id)
				      count: count];

	@try {
		__block size_t i = 0;

		[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
		[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
		    bool *stop) {
			if (block(object, index))
			if (block(object, idx))
				tmp[i++] = object;
		}];

		ret = [OFArray arrayWithObjects: tmp
					  count: i];
	} @finally {
		[self freeMemory: tmp];
904
905
906
907
908
909
910
911

912
913
914
915

916
917
918
919
920
921
922
904
905
906
907
908
909
910

911
912
913
914

915
916
917
918
919
920
921
922







-
+



-
+







	__block id current;

	if (count == 0)
		return nil;
	if (count == 1)
		return [[[self firstObject] retain] autorelease];

	[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
	[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
	    bool *stop) {
		id new;

		if (index == 0) {
		if (idx == 0) {
			current = [object retain];
			return;
		}

		@try {
			new = [block(current, object) retain];
		} @finally {

Modified src/OFArray_adjacent.m from [45617fcf1b] to [8dbc96bba7].

197
198
199
200
201
202
203
204

205
206

207
208
209

210
211

212
213
214
215
216
217
218
197
198
199
200
201
202
203

204
205

206
207
208

209
210

211
212
213
214
215
216
217
218







-
+

-
+


-
+

-
+







}

- (id const *)objects
{
	return [_array items];
}

- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
	return *((id *)[_array itemAtIndex: index]);
	return *((id *)[_array itemAtIndex: idx]);
}

- (id)objectAtIndexedSubscript: (size_t)index
- (id)objectAtIndexedSubscript: (size_t)idx
{
	return *((id *)[_array itemAtIndex: index]);
	return *((id *)[_array itemAtIndex: idx]);
}

- (void)getObjects: (id *)buffer
	   inRange: (of_range_t)range
{
	id *objects = [_array items];
	size_t count = [_array count];

Modified src/OFArray_subarray.m from [b087bc3ca0] to [02a02cd5d6].

53
54
55
56
57
58
59
60

61
62

63
64
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

84
85

86
87
88

89
90

91
92
93

94
95
96
97
98

99
100

101
102
103

104
105

106
107
108

109
110
111
112
113
114
115
116
117
118
119
120
121
53
54
55
56
57
58
59

60
61

62
63
64

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

83
84

85
86
87

88
89

90
91
92

93
94
95
96
97

98
99

100
101
102

103
104

105
106
107

108
109
110
111
112
113
114
115
116
117
118
119
120
121







-
+

-
+


-
+

















-
+

-
+


-
+

-
+


-
+




-
+

-
+


-
+

-
+


-
+













}

- (size_t)count
{
	return _range.length;
}

- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
	if (index >= _range.length)
	if (idx >= _range.length)
		@throw [OFOutOfRangeException exception];

	return [_array objectAtIndex: index + _range.location];
	return [_array objectAtIndex: idx + _range.location];
}

- (void)getObjects: (id *)buffer
	   inRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _range.length)
		@throw [OFOutOfRangeException exception];

	range.location += _range.location;

	[_array getObjects: buffer
		   inRange: range];
}

- (size_t)indexOfObject: (id)object
{
	size_t index = [_array indexOfObject: object];
	size_t idx = [_array indexOfObject: object];

	if (index < _range.location)
	if (idx < _range.location)
		return OF_NOT_FOUND;

	index -= _range.location;
	idx -= _range.location;

	if (index >= _range.length)
	if (idx >= _range.length)
		return OF_NOT_FOUND;

	return index;
	return idx;
}

- (size_t)indexOfObjectIdenticalTo: (id)object
{
	size_t index = [_array indexOfObjectIdenticalTo: object];
	size_t idx = [_array indexOfObjectIdenticalTo: object];

	if (index < _range.location)
	if (idx < _range.location)
		return OF_NOT_FOUND;

	index -= _range.location;
	idx -= _range.location;

	if (index >= _range.length)
	if (idx >= _range.length)
		return OF_NOT_FOUND;

	return index;
	return idx;
}

- (OFArray *)objectsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _range.length)
		@throw [OFOutOfRangeException exception];

	range.location += _range.location;

	return [_array objectsInRange: range];
}
@end

Modified src/OFConstantString.m from [58b7594810] to [e45b7abf06].

324
325
326
327
328
329
330
331

332
333
334
335

336
337
338
339
340
341
342
324
325
326
327
328
329
330

331
332
333
334

335
336
337
338
339
340
341
342







-
+



-
+







- (of_comparison_result_t)caseInsensitiveCompare: (OFString *)otherString
{
	[self finishInitialization];

	return [self caseInsensitiveCompare: otherString];
}

- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
	[self finishInitialization];

	return [self characterAtIndex: index];
	return [self characterAtIndex: idx];
}

- (void)getCharacters: (of_unichar_t *)buffer
	      inRange: (of_range_t)range
{
	[self finishInitialization];

Modified src/OFData.m from [945c020d4d] to [cb311cd255].

451
452
453
454
455
456
457
458

459
460

461
462
463

464
465
466
467
468
469
470
451
452
453
454
455
456
457

458
459

460
461
462

463
464
465
466
467
468
469
470







-
+

-
+


-
+







}

- (const void *)items
{
	return _items;
}

- (const void *)itemAtIndex: (size_t)index
- (const void *)itemAtIndex: (size_t)idx
{
	if (index >= _count)
	if (idx >= _count)
		@throw [OFOutOfRangeException exception];

	return _items + index * _itemSize;
	return _items + idx * _itemSize;
}

- (const void *)firstItem
{
	if (_items == NULL || _count == 0)
		return NULL;

Modified src/OFHTTPClient.m from [29b75ba101] to [0843f75aca].

68
69
70
71
72
73
74
75

76
77
78
79
80
81

82
83
84
85

86
87
88
89
90
91
92
68
69
70
71
72
73
74

75
76
77
78
79
80

81
82
83
84

85
86
87
88
89
90
91
92







-
+





-
+



-
+







	OFTCPSocket *_socket;
	bool _hasContentLength, _chunked, _keepAlive, _atEndOfStream;
	size_t _toRead;
}

@property (nonatomic, setter=of_setKeepAlive:) bool of_keepAlive;

- initWithSocket: (OFTCPSocket *)socket;
- initWithSocket: (OFTCPSocket *)sock;
@end

@implementation OFHTTPClientResponse
@synthesize of_keepAlive = _keepAlive;

- initWithSocket: (OFTCPSocket *)socket
- initWithSocket: (OFTCPSocket *)sock
{
	self = [super init];

	_socket = [socket retain];
	_socket = [sock retain];

	return self;
}

- (void)dealloc
{
	[_socket release];
284
285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300

301
302
303

304
305
306
307
308

309
310
311
312


313
314

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329

330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350

351
352
353
354
355
356
357
284
285
286
287
288
289
290

291
292
293
294
295
296
297
298
299

300

301

302
303
304
305
306

307
308
309


310
311
312

313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348

349
350
351
352
353
354
355
356







-
+








-
+
-

-
+




-
+


-
-
+
+

-
+














-
+




















-
+







	return [self performRequest: request
			  redirects: 10];
}

- (OFTCPSocket *)of_closeAndCreateSocketForRequest: (OFHTTPRequest *)request
{
	OFURL *URL = [request URL];
	OFTCPSocket *socket;
	OFTCPSocket *sock;

	[self close];

	if ([[URL scheme] isEqual: @"https"]) {
		if (of_tls_socket_class == Nil)
			@throw [OFUnsupportedProtocolException
			    exceptionWithURL: URL];

		socket = [[[of_tls_socket_class alloc] init]
		sock = [[[of_tls_socket_class alloc] init] autorelease];
		    autorelease];
	} else
		socket = [OFTCPSocket socket];
		sock = [OFTCPSocket socket];

	if ([_delegate respondsToSelector:
	    @selector(client:didCreateSocket:request:)])
		[_delegate client: self
		  didCreateSocket: socket
		  didCreateSocket: sock
			  request: request];

	[socket connectToHost: [URL host]
			 port: [URL port]];
	[sock connectToHost: [URL host]
		       port: [URL port]];

	return socket;
	return sock;
}

- (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request
			 redirects: (size_t)redirects
{
	void *pool = objc_autoreleasePoolPush();
	OFURL *URL = [request URL];
	OFString *scheme = [URL scheme];
	of_http_request_method_t method = [request method];
	OFString *path;
	OFMutableString *requestString;
	OFString *user, *password;
	OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers;
	OFData *body = [request body];
	OFTCPSocket *socket;
	OFTCPSocket *sock;
	OFHTTPClientResponse *response;
	OFString *line, *version, *redirect, *connectionHeader;
	bool keepAlive;
	OFMutableDictionary OF_GENERIC(OFString *, OFString *) *serverHeaders;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	OFString *key, *object;
	int status;

	if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	/* Can we reuse the socket? */
	if (_socket != nil && [[_lastURL scheme] isEqual: scheme] &&
	    [[_lastURL host] isEqual: [URL host]] &&
	    [_lastURL port] == [URL port]) {
		/*
		 * Set _socket to nil, so that in case of an error it won't be
		 * reused. If everything is successful, we set _socket again
		 * at the end.
		 */
		socket = [_socket autorelease];
		sock = [_socket autorelease];
		_socket = nil;

		[_lastURL release];
		_lastURL = nil;

		@try {
			if (!_lastWasHEAD) {
367
368
369
370
371
372
373
374

375
376
377
378
379
380
381
366
367
368
369
370
371
372

373
374
375
376
377
378
379
380







-
+







				}
			}
		} @finally {
			[_lastResponse release];
			_lastResponse = nil;
		}
	} else
		socket = [self of_closeAndCreateSocketForRequest: request];
		sock = [self of_closeAndCreateSocketForRequest: request];

	/*
	 * As a work around for a bug with split packets in lighttpd when using
	 * HTTPS, we construct the complete request in a buffer string and then
	 * send it all at once.
	 *
	 * We do not use the socket's write buffer in case we need to resend
468
469
470
471
472
473
474
475

476
477
478
479
480
481
482


483
484
485
486
487


488
489
490

491
492
493
494
495
496
497
498
499
500
501
502


503
504
505
506


507
508
509
510

511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530

531
532
533
534
535

536
537
538
539
540
541
542
467
468
469
470
471
472
473

474
475
476
477
478
479


480
481
482
483
484


485
486
487
488

489
490
491
492
493
494
495
496
497
498
499


500
501
502
503


504
505

506
507

508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527

528
529
530
531
532

533
534
535
536
537
538
539
540







-
+





-
-
+
+



-
-
+
+


-
+










-
-
+
+


-
-
+
+
-


-
+



















-
+




-
+







	while ((key = [keyEnumerator nextObject]) != nil &&
	    (object = [objectEnumerator nextObject]) != nil)
		[requestString appendFormat: @"%@: %@\r\n", key, object];

	[requestString appendString: @"\r\n"];

	@try {
		[socket writeString: requestString];
		[sock writeString: requestString];
	} @catch (OFWriteFailedException *e) {
		if ([e errNo] != ECONNRESET && [e errNo] != EPIPE)
			@throw e;

		/* Reconnect in case a keep-alive connection timed out */
		socket = [self of_closeAndCreateSocketForRequest: request];
		[socket writeString: requestString];
		sock = [self of_closeAndCreateSocketForRequest: request];
		[sock writeString: requestString];
	}

	if (body != nil)
		[socket writeBuffer: [body items]
			     length: [body count] * [body itemSize]];
		[sock writeBuffer: [body items]
			   length: [body count] * [body itemSize]];

	@try {
		line = [socket readLine];
		line = [sock readLine];
	} @catch (OFInvalidEncodingException *e) {
		@throw [OFInvalidServerReplyException exception];
	}

	/*
	 * It's possible that the write succeeds on a connection that is
	 * keep-alive, but the connection has already been closed by the remote
	 * end due to a timeout. In this case, we need to reconnect.
	 */
	if (line == nil) {
		socket = [self of_closeAndCreateSocketForRequest: request];
		[socket writeString: requestString];
		sock = [self of_closeAndCreateSocketForRequest: request];
		[sock writeString: requestString];

		if (body != nil)
			[socket writeBuffer: [body items]
				     length: [body count] *
			[sock writeBuffer: [body items]
				   length: [body count] * [body itemSize]];
					     [body itemSize]];

		@try {
			line = [socket readLine];
			line = [sock readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException exception];
		}
	}

	if (![line hasPrefix: @"HTTP/"] || [line length] < 9 ||
	    [line characterAtIndex: 8] != ' ')
		@throw [OFInvalidServerReplyException exception];

	version = [line substringWithRange: of_range(5, 3)];
	if (![version isEqual: @"1.0"] && ![version isEqual: @"1.1"])
		@throw [OFUnsupportedVersionException
		    exceptionWithVersion: version];

	status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];

	serverHeaders = [OFMutableDictionary dictionary];

	for (;;) {
		OFString *key, *value, *old;
		OFString *value, *old;
		const char *lineC, *tmp;
		char *keyC;

		@try {
			line = [socket readLine];
			line = [sock readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException exception];
		}

		if (line == nil)
			@throw [OFInvalidServerReplyException exception];

583
584
585
586
587
588
589
590

591
592
593
594
595
596
597
581
582
583
584
585
586
587

588
589
590
591
592
593
594
595







-
+







	if ([_delegate respondsToSelector:
	    @selector(client:didReceiveHeaders:statusCode:request:)])
		[_delegate     client: self
		    didReceiveHeaders: serverHeaders
			   statusCode: status
			      request: request];

	response = [[[OFHTTPClientResponse alloc] initWithSocket: socket]
	response = [[[OFHTTPClientResponse alloc] initWithSocket: sock]
	    autorelease];
	[response setProtocolVersionFromString: version];
	[response setStatusCode: status];
	[response setHeaders: serverHeaders];

	connectionHeader = [serverHeaders objectForKey: @"Connection"];
	if ([version isEqual: @"1.1"]) {
607
608
609
610
611
612
613
614

615
616
617
618
619
620
621
605
606
607
608
609
610
611

612
613
614
615
616
617
618
619







-
+







		else
			keepAlive = false;
	}

	if (keepAlive) {
		[response of_setKeepAlive: true];

		_socket = [socket retain];
		_socket = [sock retain];
		_lastURL = [URL copy];
		_lastWasHEAD = (method == OF_HTTP_REQUEST_METHOD_HEAD);
		_lastResponse = [response retain];
	}

	/* FIXME: Case-insensitive check of redirect's scheme */
	if (redirects > 0 && (status == 301 || status == 302 ||
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
665
666
667
668
669
670
671



672
673
674
675
676
677
678







-
-
-








			/*
			 * 303 means the request should be converted to a GET
			 * request before redirection. This also means stripping
			 * the entity of the request.
			 */
			if (status == 303) {
				OFEnumerator *keyEnumerator, *objectEnumerator;
				id key, object;

				keyEnumerator = [headers keyEnumerator];
				objectEnumerator = [headers objectEnumerator];
				while ((key = [keyEnumerator nextObject]) !=
				    nil &&
				    (object = [objectEnumerator nextObject]) !=
				    nil)
					if ([key hasPrefix: @"Content-"])

Modified src/OFHTTPServer.m from [c477e44d18] to [ae0dbd61af].

43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57







-
+








/*
 * FIXME: Key normalization replaces headers like "DNT" with "Dnt".
 * FIXME: Errors are not reported to the user.
 */

@interface OFHTTPServer ()
- (bool)of_socket: (OFTCPSocket *)socket
- (bool)of_socket: (OFTCPSocket *)sock
  didAcceptSocket: (OFTCPSocket *)clientSocket
	exception: (OFException *)exception;
@end

static const char *
statusCodeToString(short code)
{
175
176
177
178
179
180
181
182

183
184
185
186
187
188

189
190
191
192
193
194
195

196
197
198
199
200
201
202
175
176
177
178
179
180
181

182
183
184
185
186
187

188
189
190
191
192
193
194

195
196
197
198
199
200
201
202







-
+





-
+






-
+







{
	OFTCPSocket *_socket;
	OFHTTPServer *_server;
	OFHTTPRequest *_request;
	bool _chunked, _headersSent;
}

- initWithSocket: (OFTCPSocket *)socket
- initWithSocket: (OFTCPSocket *)sock
	  server: (OFHTTPServer *)server
	 request: (OFHTTPRequest *)request;
@end

@implementation OFHTTPServerResponse
- initWithSocket: (OFTCPSocket *)socket
- initWithSocket: (OFTCPSocket *)sock
	  server: (OFHTTPServer *)server
	 request: (OFHTTPRequest *)request
{
	self = [super init];

	_statusCode = 500;
	_socket = [socket retain];
	_socket = [sock retain];
	_server = [server retain];
	_request = [request retain];

	return self;
}

- (void)dealloc
334
335
336
337
338
339
340
341

342
343

344
345
346
347
348

349
350
351
352
353
354
355
356
357

358
359
360
361
362
363

364
365
366
367

368
369
370
371
372
373
374
334
335
336
337
338
339
340

341
342

343
344
345
346
347

348
349
350
351
352
353
354
355
356

357
358
359
360
361
362

363
364
365
366

367
368
369
370
371
372
373
374







-
+

-
+




-
+








-
+





-
+



-
+







	OFString *_host, *_path;
	uint16_t _port;
	OFMutableDictionary *_headers;
	size_t _contentLength;
	OFMutableData *_body;
}

- initWithSocket: (OFTCPSocket *)socket
- initWithSocket: (OFTCPSocket *)sock
	  server: (OFHTTPServer *)server;
- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
   didReadLine: (OFString *)line
     exception: (OFException *)exception;
- (bool)parseProlog: (OFString *)line;
- (bool)parseHeaders: (OFString *)line;
-      (bool)socket: (OFTCPSocket *)socket
-      (bool)socket: (OFTCPSocket *)sock
  didReadIntoBuffer: (char *)buffer
	     length: (size_t)length
	  exception: (OFException *)exception;
- (bool)sendErrorAndClose: (short)statusCode;
- (void)createResponse;
@end

@implementation OFHTTPServer_Connection
- initWithSocket: (OFTCPSocket *)socket
- initWithSocket: (OFTCPSocket *)sock
	  server: (OFHTTPServer *)server
{
	self = [super init];

	@try {
		_socket = [socket retain];
		_socket = [sock retain];
		_server = [server retain];
		_timer = [[OFTimer
		    scheduledTimerWithTimeInterval: 10
					    target: socket
					    target: _socket
					  selector: @selector(
							cancelAsyncRequests)
					   repeats: false] retain];
		_state = AWAITING_PROLOG;
	} @catch (id e) {
		[self release];
		@throw e;
389
390
391
392
393
394
395
396

397
398
399
400
401
402
403
389
390
391
392
393
394
395

396
397
398
399
400
401
402
403







-
+







	[_path release];
	[_headers release];
	[_body release];

	[super dealloc];
}

- (bool)socket: (OFTCPSocket *)socket
- (bool)socket: (OFTCPSocket *)sock
   didReadLine: (OFString *)line
     exception: (OFException *)exception
{
	if (line == nil || exception != nil)
		return false;

	@try {
565
566
567
568
569
570
571
572

573
574
575
576
577

578
579
580
581
582
583
584
565
566
567
568
569
570
571

572
573
574
575
576

577
578
579
580
581
582
583
584







-
+




-
+







			_port = 80;
		}
	}

	return true;
}

-      (bool)socket: (OFTCPSocket *)socket
-      (bool)socket: (OFTCPSocket *)sock
  didReadIntoBuffer: (char *)buffer
	     length: (size_t)length
	  exception: (OFException *)exception
{
	if ([socket isAtEndOfStream] || exception != nil)
	if ([sock isAtEndOfStream] || exception != nil)
		return false;

	[_body addItems: buffer
		  count: length];

	if ([_body count] >= _contentLength) {
		/*
729
730
731
732
733
734
735
736

737
738
739
740
741
742
743
729
730
731
732
733
734
735

736
737
738
739
740
741
742
743







-
+







- (void)stop
{
	[_listeningSocket cancelAsyncRequests];
	[_listeningSocket release];
	_listeningSocket = nil;
}

- (bool)of_socket: (OFTCPSocket *)socket
- (bool)of_socket: (OFTCPSocket *)sock
  didAcceptSocket: (OFTCPSocket *)clientSocket
	exception: (OFException *)exception
{
	OFHTTPServer_Connection *connection;

	if (exception != nil) {
		if ([_delegate respondsToSelector:

Modified src/OFInflateStream.m from [fc22c7448d] to [93ad641546].

682
683
684
685
686
687
688
689

690
691
692
693
694
695
696

697
698

699
700
701
702
703
704
705
682
683
684
685
686
687
688

689
690
691
692
693
694
695

696
697

698
699
700
701
702
703
704
705







-
+






-
+

-
+







				uint16_t j;

				if OF_UNLIKELY (_slidingWindow == NULL)
					@throw [OFInvalidFormatException
					    exception];

				for (j = 0; j < CTX.length; j++) {
					uint16_t index;
					uint16_t idx;

					if OF_UNLIKELY (length == 0) {
						CTX.length -= j;
						return bytesWritten;
					}

					index = (_slidingWindowIndex -
					idx = (_slidingWindowIndex -
					    CTX.distance) & _slidingWindowMask;
					value = _slidingWindow[index];
					value = _slidingWindow[idx];

					buffer[bytesWritten++] = value;
					length--;

					_slidingWindow[_slidingWindowIndex] =
					    value;
					_slidingWindowIndex =

Modified src/OFMutableArray.m from [f7473af41f] to [a54de56242].

206
207
208
209
210
211
212
213

214
215
216
217
218
219

220
221
222
223
224
225

226
227
228

229
230
231
232
233
234
235

236
237

238
239
240
241
242
243
244
206
207
208
209
210
211
212

213
214
215
216
217
218

219
220
221
222
223
224

225
226
227

228
229
230
231
232
233
234

235
236

237
238
239
240
241
242
243
244







-
+





-
+





-
+


-
+






-
+

-
+







- (void)addObjectsFromArray: (OFArray *)array
{
	[self insertObjectsFromArray: array
			     atIndex: [self count]];
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)insertObjectsFromArray: (OFArray *)array
		       atIndex: (size_t)index
		       atIndex: (size_t)idx
{
	size_t i = 0;

	for (id object in array)
		[self insertObject: object
			   atIndex: index + i++];
			   atIndex: idx + i++];
}

- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
		  withObject: (id)object
{
	OF_UNRECOGNIZED_SELECTOR
}

-    (void)setObject: (id)object
  atIndexedSubscript: (size_t)index
  atIndexedSubscript: (size_t)idx
{
	[self replaceObjectAtIndex: index
	[self replaceObjectAtIndex: idx
			withObject: object];
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	size_t count;
273
274
275
276
277
278
279
280

281
282
283
284
285
286
287
273
274
275
276
277
278
279

280
281
282
283
284
285
286
287







-
+







					withObject: newObject];

			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)removeObject: (id)object
{
	size_t count;
338
339
340
341
342
343
344
345

346
347

348
349
350

351
352
353
354
355
356
357


358
359
360


361
362
363
364

365
366

367
368
369
370
371
372
373
338
339
340
341
342
343
344

345
346

347
348
349

350
351
352
353
354
355


356
357
358


359
360
361
362
363

364
365

366
367
368
369
370
371
372
373







-
+

-
+


-
+





-
-
+
+

-
-
+
+



-
+

-
+







{
	[self removeObjectsInRange: of_range(0, [self count])];
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
	[self enumerateObjectsUsingBlock: ^ (id object, size_t idx,
	    bool *stop) {
		id new = block(object, index);
		id new = block(object, idx);

		if (new != object)
			[self replaceObjectAtIndex: index
			[self replaceObjectAtIndex: idx
					withObject: new];
	}];
}
#endif

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)idx1
	    withObjectAtIndex: (size_t)idx2
{
	id object1 = [self objectAtIndex: index1];
	id object2 = [self objectAtIndex: index2];
	id object1 = [self objectAtIndex: idx1];
	id object2 = [self objectAtIndex: idx2];

	[object1 retain];
	@try {
		[self replaceObjectAtIndex: index1
		[self replaceObjectAtIndex: idx1
				withObject: object2];
		[self replaceObjectAtIndex: index2
		[self replaceObjectAtIndex: idx2
				withObject: object1];
	} @finally {
		[object1 release];
	}
}

- (void)sort

Modified src/OFMutableArray_adjacent.m from [e5a95ab2b1] to [32af0c25d1].

56
57
58
59
60
61
62
63

64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87

88
89
90
91
92
93
94
56
57
58
59
60
61
62

63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86

87
88
89
90
91
92
93
94







-
+






-
+









-
+






-
+







	[_array addItem: &object];
	[object retain];

	_mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	if (object == nil)
		@throw [OFInvalidArgumentException exception];

	@try {
		[_array insertItem: &object
			   atIndex: index];
			   atIndex: idx];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}
	[object retain];

	_mutations++;
}

- (void)insertObjectsFromArray: (OFArray *)array
		       atIndex: (size_t)index
		       atIndex: (size_t)idx
{
	id const *objects = [array objects];
	size_t count = [array count];

	@try {
		[_array insertItems: objects
			    atIndex: index
			    atIndex: idx
			      count: count];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}

	for (size_t i = 0; i < count; i++)
		[objects[i] retain];
115
116
117
118
119
120
121
122

123
124
125
126
127
128
129
130
131
132
133

134
135
136
137


138
139
140
141
142
143
144
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129
130
131
132

133
134
135


136
137
138
139
140
141
142
143
144







-
+










-
+


-
-
+
+







			objects[i] = newObject;

			return;
		}
	}
}

- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
		  withObject: (id)object
{
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];

	objects = [_array items];

	if (index >= [_array count])
	if (idx >= [_array count])
		@throw [OFOutOfRangeException exception];

	oldObject = objects[index];
	objects[index] = [object retain];
	oldObject = objects[idx];
	objects[idx] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	id *objects;
205
206
207
208
209
210
211
212

213
214
215


216
217
218
219
220
221
222
205
206
207
208
209
210
211

212
213


214
215
216
217
218
219
220
221
222







-
+

-
-
+
+







			[object release];

			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
	id object = [self objectAtIndex: index];
	[_array removeItemAtIndex: index];
	id object = [self objectAtIndex: idx];
	[_array removeItemAtIndex: idx];
	[object release];

	_mutations++;
}

- (void)removeAllObjects
{
264
265
266
267
268
269
270
271
272


273
274
275
276
277
278

279
280
281
282
283



284
285
286
287
288
289
290
264
265
266
267
268
269
270


271
272
273
274
275
276
277

278
279
280



281
282
283
284
285
286
287
288
289
290







-
-
+
+





-
+


-
-
-
+
+
+







	object = [self objectAtIndex: count - 1];
	[_array removeLastItem];
	[object release];

	_mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)idx1
	    withObjectAtIndex: (size_t)idx2
{
	id *objects = [_array items];
	size_t count = [_array count];
	id tmp;

	if (index1 >= count || index2 >= count)
	if (idx1 >= count || idx2 >= count)
		@throw [OFOutOfRangeException exception];

	tmp = objects[index1];
	objects[index1] = objects[index2];
	objects[index2] = tmp;
	tmp = objects[idx1];
	objects[idx1] = objects[idx2];
	objects[idx2] = tmp;
}

- (void)reverse
{
	id *objects = [_array items];
	size_t i, j, count = [_array count];

Modified src/OFMutableData.m from [fd7ae0376c] to [905c436919].

171
172
173
174
175
176
177
178

179
180
181

182
183
184
185
186
187
188
171
172
173
174
175
176
177

178
179
180

181
182
183
184
185
186
187
188







-
+


-
+








	memcpy(_items + _count * _itemSize, item, _itemSize);

	_count++;
}

- (void)insertItem: (const void *)item
	   atIndex: (size_t)index
	   atIndex: (size_t)idx
{
	[self insertItems: item
		  atIndex: index
		  atIndex: idx
		    count: 1];
}

- (void)addItems: (const void *)items
	   count: (size_t)count
{
	if (count > SIZE_MAX - _count)
196
197
198
199
200
201
202
203

204
205
206

207
208
209
210
211
212
213
214
215
216
217
218



219
220
221
222
223

224
225

226
227
228
229
230
231
232
196
197
198
199
200
201
202

203
204
205

206
207
208
209
210
211
212
213
214
215



216
217
218
219
220
221
222

223
224

225
226
227
228
229
230
231
232







-
+


-
+









-
-
-
+
+
+




-
+

-
+







	}

	memcpy(_items + _count * _itemSize, items, count * _itemSize);
	_count += count;
}

- (void)insertItems: (const void *)items
	    atIndex: (size_t)index
	    atIndex: (size_t)idx
	      count: (size_t)count
{
	if (count > SIZE_MAX - _count || index > _count)
	if (count > SIZE_MAX - _count || idx > _count)
		@throw [OFOutOfRangeException exception];

	if (_count + count > _capacity) {
		_items = [self resizeMemory: _items
				       size: _itemSize
				      count: _count + count];
		_capacity = _count + count;
	}

	memmove(_items + (index + count) * _itemSize,
	    _items + index * _itemSize, (_count - index) * _itemSize);
	memcpy(_items + index * _itemSize, items, count * _itemSize);
	memmove(_items + (idx + count) * _itemSize, _items + idx * _itemSize,
	   (_count - idx) * _itemSize);
	memcpy(_items + idx * _itemSize, items, count * _itemSize);

	_count += count;
}

- (void)removeItemAtIndex: (size_t)index
- (void)removeItemAtIndex: (size_t)idx
{
	[self removeItemsInRange: of_range(index, 1)];
	[self removeItemsInRange: of_range(idx, 1)];
}

- (void)removeItemsInRange: (of_range_t)range
{
	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exception];

Modified src/OFMutableString.m from [7b8005c3d9] to [d0679a5108].

292
293
294
295
296
297
298
299

300
301
302
303
304
305
306
307

308
309
310
311
312
313
314
292
293
294
295
296
297
298

299
300
301
302
303
304
305
306

307
308
309
310
311
312
313
314







-
+







-
+







	}

	objc_autoreleasePoolPop(pool);
}
#endif

- (void)setCharacter: (of_unichar_t)character
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	void *pool = objc_autoreleasePoolPush();
	OFString *string;

	string = [OFString stringWithCharacters: &character
					 length: 1];

	[self replaceCharactersInRange: of_range(index, 1)
	[self replaceCharactersInRange: of_range(idx, 1)
			    withString: string];

	objc_autoreleasePoolPop(pool);
}

- (void)appendString: (OFString *)string
{
462
463
464
465
466
467
468
469

470
471

472
473
474
475
476
477
478
462
463
464
465
466
467
468

469
470

471
472
473
474
475
476
477
478







-
+

-
+







{
	[self of_convertWithWordStartFunction: of_ascii_toupper
			   wordMiddleFunction: of_ascii_tolower];
}
#endif

- (void)insertString: (OFString *)string
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	[self replaceCharactersInRange: of_range(index, 0)
	[self replaceCharactersInRange: of_range(idx, 0)
			    withString: string];
}

- (void)deleteCharactersInRange: (of_range_t)range
{
	[self replaceCharactersInRange: range
			    withString: @""];

Modified src/OFMutableString_UTF8.m from [4a3385c744] to [688bb89a18].

176
177
178
179
180
181
182
183

184
185
186
187
188
189
190
191

192
193
194

195
196
197
198

199
200

201
202
203
204
205
206
207
208


209
210
211
212
213
214

215
216
217
218
219
220

221
222
223


224
225
226
227
228
229
230
231
232

233
234
235


236
237
238
239
240
241
242
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190

191
192
193

194
195
196
197

198
199

200
201
202
203
204
205
206


207
208
209
210
211
212
213

214
215
216
217
218
219

220



221
222
223
224
225
226
227
228
229
230

231



232
233
234
235
236
237
238
239
240







-
+







-
+


-
+



-
+

-
+






-
-
+
+





-
+





-
+
-
-
-
+
+








-
+
-
-
-
+
+







	/*
	 * Even though cStringLength can change, length cannot, therefore no
	 * need to change it.
	 */
}

- (void)setCharacter: (of_unichar_t)character
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	char buffer[4];
	of_unichar_t c;
	size_t lenNew;
	ssize_t lenOld;

	if (_s->isUTF8)
		index = of_string_utf8_get_position(_s->cString, index,
		idx = of_string_utf8_get_position(_s->cString, idx,
		    _s->cStringLength);

	if (index > _s->cStringLength)
	if (idx > _s->cStringLength)
		@throw [OFOutOfRangeException exception];

	/* Shortcut if old and new character both are ASCII */
	if (character < 0x80 && !(_s->cString[index] & 0x80)) {
	if (character < 0x80 && !(_s->cString[idx] & 0x80)) {
		_s->hashed = false;
		_s->cString[index] = character;
		_s->cString[idx] = character;
		return;
	}

	if ((lenNew = of_string_utf8_encode(character, buffer)) == 0)
		@throw [OFInvalidEncodingException exception];

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

	_s->hashed = false;

	if (lenNew == (size_t)lenOld)
		memcpy(_s->cString + index, buffer, lenNew);
		memcpy(_s->cString + idx, buffer, lenNew);
	else if (lenNew > (size_t)lenOld) {
		_s->cString = [self resizeMemory: _s->cString
					    size: _s->cStringLength -
						  lenOld + lenNew + 1];

		memmove(_s->cString + index + lenNew,
		memmove(_s->cString + idx + lenNew, _s->cString + idx + lenOld,
		    _s->cString + index + lenOld,
		    _s->cStringLength - index - lenOld);
		memcpy(_s->cString + index, buffer, lenNew);
		    _s->cStringLength - idx - lenOld);
		memcpy(_s->cString + idx, buffer, lenNew);

		_s->cStringLength -= lenOld;
		_s->cStringLength += lenNew;
		_s->cString[_s->cStringLength] = '\0';

		if (character >= 0x80)
			_s->isUTF8 = true;
	} else if (lenNew < (size_t)lenOld) {
		memmove(_s->cString + index + lenNew,
		memmove(_s->cString + idx + lenNew, _s->cString + idx + lenOld,
		    _s->cString + index + lenOld,
		    _s->cStringLength - index - lenOld);
		memcpy(_s->cString + index, buffer, lenNew);
		    _s->cStringLength - idx - lenOld);
		memcpy(_s->cString + idx, buffer, lenNew);

		_s->cStringLength -= lenOld;
		_s->cStringLength += lenNew;
		_s->cString[_s->cStringLength] = '\0';

		if (character >= 0x80)
			_s->isUTF8 = true;
506
507
508
509
510
511
512
513

514
515
516
517

518
519
520
521

522
523
524
525
526
527
528
529
530
531



532
533
534
535
536
537
538
504
505
506
507
508
509
510

511
512
513
514

515
516
517
518

519
520
521
522
523
524
525
526



527
528
529
530
531
532
533
534
535
536







-
+



-
+



-
+







-
-
-
+
+
+








		/* UTF-8 does not allow more than 4 bytes per character */
		@throw [OFInvalidEncodingException exception];
	}
}

- (void)insertString: (OFString *)string
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	size_t newCStringLength;

	if (index > _s->length)
	if (idx > _s->length)
		@throw [OFOutOfRangeException exception];

	if (_s->isUTF8)
		index = of_string_utf8_get_position(_s->cString, index,
		idx = of_string_utf8_get_position(_s->cString, idx,
		    _s->cStringLength);

	newCStringLength = _s->cStringLength + [string UTF8StringLength];
	_s->hashed = false;
	_s->cString = [self resizeMemory: _s->cString
				    size: newCStringLength + 1];

	memmove(_s->cString + index + [string UTF8StringLength],
	    _s->cString + index, _s->cStringLength - index);
	memcpy(_s->cString + index, [string UTF8String],
	memmove(_s->cString + idx + [string UTF8StringLength],
	    _s->cString + idx, _s->cStringLength - idx);
	memcpy(_s->cString + idx, [string UTF8String],
	    [string UTF8StringLength]);
	_s->cString[newCStringLength] = '\0';

	_s->cStringLength = newCStringLength;
	_s->length += [string length];

	if ([string isKindOfClass: [OFString_UTF8 class]] ||

Modified src/OFNumber.h from [b4280b6f63] to [c8232cc931].

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132










133
134
135
136
137
138
139
140




141
142
143
144
145
146
147






148
149
150
151
152
153
154
116
117
118
119
120
121
122










123
124
125
126
127
128
129
130
131
132
133
134
135
136




137
138
139
140
141






142
143
144
145
146
147
148
149
150
151
152
153
154







-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+




-
-
-
-
+
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+







 * @brief Provides a way to store a number in an object.
 */
@interface OFNumber: OFObject <OFCopying, OFComparing, OFSerialization,
    OFJSONRepresentation, OFMessagePackRepresentation>
{
	union of_number_value {
		bool		   bool_;
		signed char	   schar;
		signed short	   sshort;
		signed int	   sint;
		signed long	   slong;
		signed long long   slonglong;
		unsigned char	   uchar;
		unsigned short	   ushort;
		unsigned int	   uint;
		unsigned long	   ulong;
		unsigned long long ulonglong;
		signed char	   sChar;
		signed short	   sShort;
		signed int	   sInt;
		signed long	   sLong;
		signed long long   sLongLong;
		unsigned char	   uChar;
		unsigned short	   uShort;
		unsigned int	   uInt;
		unsigned long	   uLong;
		unsigned long long uLongLong;
		int8_t		   int8;
		int16_t		   int16;
		int32_t		   int32;
		int64_t		   int64;
		uint8_t		   uint8;
		uint16_t	   uint16;
		uint32_t	   uint32;
		uint64_t	   uint64;
		uint8_t		   uInt8;
		uint16_t	   uInt16;
		uint32_t	   uInt32;
		uint64_t	   uInt64;
		size_t		   size;
		ssize_t		   ssize;
		intmax_t	   intmax;
		uintmax_t	   uintmax;
		ptrdiff_t	   ptrdiff;
		intptr_t	   intptr;
		uintptr_t	   uintptr;
		ssize_t		   sSize;
		intmax_t	   intMax;
		uintmax_t	   uIntMax;
		ptrdiff_t	   ptrDiff;
		intptr_t	   intPtr;
		uintptr_t	   uIntPtr;
		float		   float_;
		double		   double_;
	} _value;
	of_number_type_t _type;
}

/*!

Modified src/OFNumber.m from [3d97fc0b3e] to [3da26d55ba].

30
31
32
33
34
35
36
37

38
39

40
41

42
43

44
45

46
47

48
49

50
51

52
53

54
55

56
57
58
59
60
61
62
63
64
65

66
67

68
69

70
71

72
73
74
75

76
77

78
79

80
81

82
83

84
85

86
87
88
89
90
91
92
30
31
32
33
34
35
36

37
38

39
40

41
42

43
44

45
46

47
48

49
50

51
52

53
54

55
56
57
58
59
60
61
62
63
64

65
66

67
68

69
70

71
72
73
74

75
76

77
78

79
80

81
82

83
84

85
86
87
88
89
90
91
92







-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+









-
+

-
+

-
+

-
+



-
+

-
+

-
+

-
+

-
+

-
+







#import "OFOutOfRangeException.h"

#define RETURN_AS(t)							\
	switch (_type) {						\
	case OF_NUMBER_TYPE_BOOL:					\
		return (t)_value.bool_;					\
	case OF_NUMBER_TYPE_CHAR:					\
		return (t)_value.schar;					\
		return (t)_value.sChar;					\
	case OF_NUMBER_TYPE_SHORT:					\
		return (t)_value.sshort;				\
		return (t)_value.sShort;				\
	case OF_NUMBER_TYPE_INT:					\
		return (t)_value.sint;					\
		return (t)_value.sInt;					\
	case OF_NUMBER_TYPE_LONG:					\
		return (t)_value.slong;					\
		return (t)_value.sLong;					\
	case OF_NUMBER_TYPE_LONGLONG:					\
		return (t)_value.slonglong;				\
		return (t)_value.sLongLong;				\
	case OF_NUMBER_TYPE_UCHAR:					\
		return (t)_value.uchar;					\
		return (t)_value.uChar;					\
	case OF_NUMBER_TYPE_USHORT:					\
		return (t)_value.ushort;				\
		return (t)_value.uShort;				\
	case OF_NUMBER_TYPE_UINT:					\
		return (t)_value.uint;					\
		return (t)_value.uInt;					\
	case OF_NUMBER_TYPE_ULONG:					\
		return (t)_value.ulong;					\
		return (t)_value.uLong;					\
	case OF_NUMBER_TYPE_ULONGLONG:					\
		return (t)_value.ulonglong;				\
		return (t)_value.uLongLong;				\
	case OF_NUMBER_TYPE_INT8:					\
		return (t)_value.int8;					\
	case OF_NUMBER_TYPE_INT16:					\
		return (t)_value.int16;					\
	case OF_NUMBER_TYPE_INT32:					\
		return (t)_value.int32;					\
	case OF_NUMBER_TYPE_INT64:					\
		return (t)_value.int64;					\
	case OF_NUMBER_TYPE_UINT8:					\
		return (t)_value.uint8;					\
		return (t)_value.uInt8;					\
	case OF_NUMBER_TYPE_UINT16:					\
		return (t)_value.uint16;				\
		return (t)_value.uInt16;				\
	case OF_NUMBER_TYPE_UINT32:					\
		return (t)_value.uint32;				\
		return (t)_value.uInt32;				\
	case OF_NUMBER_TYPE_UINT64:					\
		return (t)_value.uint64;				\
		return (t)_value.uInt64;				\
	case OF_NUMBER_TYPE_SIZE:					\
		return (t)_value.size;					\
	case OF_NUMBER_TYPE_SSIZE:					\
		return (t)_value.ssize;					\
		return (t)_value.sSize;					\
	case OF_NUMBER_TYPE_INTMAX:					\
		return (t)_value.intmax;				\
		return (t)_value.intMax;				\
	case OF_NUMBER_TYPE_UINTMAX:					\
		return (t)_value.uintmax;				\
		return (t)_value.uIntMax;				\
	case OF_NUMBER_TYPE_PTRDIFF:					\
		return (t)_value.ptrdiff;				\
		return (t)_value.ptrDiff;				\
	case OF_NUMBER_TYPE_INTPTR:					\
		return (t)_value.intptr;				\
		return (t)_value.intPtr;				\
	case OF_NUMBER_TYPE_UINTPTR:					\
		return (t)_value.uintptr;				\
		return (t)_value.uIntPtr;				\
	case OF_NUMBER_TYPE_FLOAT:					\
		return (t)_value.float_;				\
	case OF_NUMBER_TYPE_DOUBLE:					\
		return (t)_value.double_;				\
	default:							\
		@throw [OFInvalidFormatException exception];		\
	}
100
101
102
103
104
105
106
107

108
109

110
111
112

113
114

115
116
117

118
119

120
121
122

123
124

125
126
127

128
129

130
131
132

133
134

135
136
137

138
139

140
141
142

143
144

145
146
147

148
149

150
151
152

153
154

155
156
157
158
159
160
161
100
101
102
103
104
105
106

107
108

109
110
111

112
113

114
115
116

117
118

119
120
121

122
123

124
125
126

127
128

129
130
131

132
133

134
135
136

137
138

139
140
141

142
143

144
145
146

147
148

149
150
151

152
153

154
155
156
157
158
159
160
161







-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+







@synthesize type = _type;

+ (instancetype)numberWithBool: (bool)bool_
{
	return [[[self alloc] initWithBool: bool_] autorelease];
}

+ (instancetype)numberWithChar: (signed char)schar
+ (instancetype)numberWithChar: (signed char)sChar
{
	return [[[self alloc] initWithChar: schar] autorelease];
	return [[[self alloc] initWithChar: sChar] autorelease];
}

+ (instancetype)numberWithShort: (signed short)sshort
+ (instancetype)numberWithShort: (signed short)sShort
{
	return [[[self alloc] initWithShort: sshort] autorelease];
	return [[[self alloc] initWithShort: sShort] autorelease];
}

+ (instancetype)numberWithInt: (signed int)sint
+ (instancetype)numberWithInt: (signed int)sInt
{
	return [[[self alloc] initWithInt: sint] autorelease];
	return [[[self alloc] initWithInt: sInt] autorelease];
}

+ (instancetype)numberWithLong: (signed long)slong
+ (instancetype)numberWithLong: (signed long)sLong
{
	return [[[self alloc] initWithLong: slong] autorelease];
	return [[[self alloc] initWithLong: sLong] autorelease];
}

+ (instancetype)numberWithLongLong: (signed long long)slonglong
+ (instancetype)numberWithLongLong: (signed long long)sLongLong
{
	return [[[self alloc] initWithLongLong: slonglong] autorelease];
	return [[[self alloc] initWithLongLong: sLongLong] autorelease];
}

+ (instancetype)numberWithUnsignedChar: (unsigned char)uchar
+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar
{
	return [[[self alloc] initWithUnsignedChar: uchar] autorelease];
	return [[[self alloc] initWithUnsignedChar: uChar] autorelease];
}

+ (instancetype)numberWithUnsignedShort: (unsigned short)ushort
+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort
{
	return [[[self alloc] initWithUnsignedShort: ushort] autorelease];
	return [[[self alloc] initWithUnsignedShort: uShort] autorelease];
}

+ (instancetype)numberWithUnsignedInt: (unsigned int)uint
+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt
{
	return [[[self alloc] initWithUnsignedInt: uint] autorelease];
	return [[[self alloc] initWithUnsignedInt: uInt] autorelease];
}

+ (instancetype)numberWithUnsignedLong: (unsigned long)ulong
+ (instancetype)numberWithUnsignedLong: (unsigned long)uLong
{
	return [[[self alloc] initWithUnsignedLong: ulong] autorelease];
	return [[[self alloc] initWithUnsignedLong: uLong] autorelease];
}

+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)ulonglong
+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)uLongLong
{
	return [[[self alloc] initWithUnsignedLongLong: ulonglong] autorelease];
	return [[[self alloc] initWithUnsignedLongLong: uLongLong] autorelease];
}

+ (instancetype)numberWithInt8: (int8_t)int8
{
	return [[[self alloc] initWithInt8: int8] autorelease];
}

175
176
177
178
179
180
181
182

183
184

185
186
187

188
189

190
191
192

193
194

195
196
197
198
199
200
201
202

203
204

205
206
207

208
209

210
211
212

213
214

215
216
217

218
219

220
221
222

223
224

225
226
227

228
229

230
231
232
233
234
235
236
175
176
177
178
179
180
181

182
183

184
185
186

187
188

189
190
191

192
193

194
195
196
197
198
199
200
201

202
203

204
205
206

207
208

209
210
211

212
213

214
215
216

217
218

219
220
221

222
223

224
225
226

227
228

229
230
231
232
233
234
235
236







-
+

-
+


-
+

-
+


-
+

-
+







-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+







}

+ (instancetype)numberWithUInt8: (uint8_t)uint8
{
	return [[[self alloc] initWithUInt8: uint8] autorelease];
}

+ (instancetype)numberWithUInt16: (uint16_t)uint16
+ (instancetype)numberWithUInt16: (uint16_t)uInt16
{
	return [[[self alloc] initWithUInt16: uint16] autorelease];
	return [[[self alloc] initWithUInt16: uInt16] autorelease];
}

+ (instancetype)numberWithUInt32: (uint32_t)uint32
+ (instancetype)numberWithUInt32: (uint32_t)uInt32
{
	return [[[self alloc] initWithUInt32: uint32] autorelease];
	return [[[self alloc] initWithUInt32: uInt32] autorelease];
}

+ (instancetype)numberWithUInt64: (uint64_t)uint64
+ (instancetype)numberWithUInt64: (uint64_t)uInt64
{
	return [[[self alloc] initWithUInt64: uint64] autorelease];
	return [[[self alloc] initWithUInt64: uInt64] autorelease];
}

+ (instancetype)numberWithSize: (size_t)size
{
	return [[[self alloc] initWithSize: size] autorelease];
}

+ (instancetype)numberWithSSize: (ssize_t)ssize
+ (instancetype)numberWithSSize: (ssize_t)sSize
{
	return [[[self alloc] initWithSSize: ssize] autorelease];
	return [[[self alloc] initWithSSize: sSize] autorelease];
}

+ (instancetype)numberWithIntMax: (intmax_t)intmax
+ (instancetype)numberWithIntMax: (intmax_t)intMax
{
	return [[[self alloc] initWithIntMax: intmax] autorelease];
	return [[[self alloc] initWithIntMax: intMax] autorelease];
}

+ (instancetype)numberWithUIntMax: (uintmax_t)uintmax
+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax
{
	return [[[self alloc] initWithUIntMax: uintmax] autorelease];
	return [[[self alloc] initWithUIntMax: uIntMax] autorelease];
}

+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrdiff
+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff
{
	return [[[self alloc] initWithPtrDiff: ptrdiff] autorelease];
	return [[[self alloc] initWithPtrDiff: ptrDiff] autorelease];
}

+ (instancetype)numberWithIntPtr: (intptr_t)intptr
+ (instancetype)numberWithIntPtr: (intptr_t)intPtr
{
	return [[[self alloc] initWithIntPtr: intptr] autorelease];
	return [[[self alloc] initWithIntPtr: intPtr] autorelease];
}

+ (instancetype)numberWithUIntPtr: (uintptr_t)uintptr
+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr
{
	return [[[self alloc] initWithUIntPtr: uintptr] autorelease];
	return [[[self alloc] initWithUIntPtr: uIntPtr] autorelease];
}

+ (instancetype)numberWithFloat: (float)float_
{
	return [[[self alloc] initWithFloat: float_] autorelease];
}

250
251
252
253
254
255
256
257

258
259
260
261

262
263
264
265
266
267

268
269
270
271

272
273
274
275
276
277

278
279
280
281

282
283
284
285
286
287

288
289
290
291

292
293
294
295
296
297

298
299
300
301

302
303
304
305
306
307

308
309
310
311

312
313
314
315
316
317

318
319
320
321

322
323
324
325
326
327

328
329
330
331

332
333
334
335
336
337

338
339
340
341

342
343
344
345
346
347

348
349
350
351

352
353
354
355
356
357
358
250
251
252
253
254
255
256

257
258
259
260

261
262
263
264
265
266

267
268
269
270

271
272
273
274
275
276

277
278
279
280

281
282
283
284
285
286

287
288
289
290

291
292
293
294
295
296

297
298
299
300

301
302
303
304
305
306

307
308
309
310

311
312
313
314
315
316

317
318
319
320

321
322
323
324
325
326

327
328
329
330

331
332
333
334
335
336

337
338
339
340

341
342
343
344
345
346

347
348
349
350

351
352
353
354
355
356
357
358







-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+








	_value.bool_ = bool_;
	_type = OF_NUMBER_TYPE_BOOL;

	return self;
}

- initWithChar: (signed char)schar
- initWithChar: (signed char)sChar
{
	self = [super init];

	_value.schar = schar;
	_value.sChar = sChar;
	_type = OF_NUMBER_TYPE_CHAR;

	return self;
}

- initWithShort: (signed short)sshort
- initWithShort: (signed short)sShort
{
	self = [super init];

	_value.sshort = sshort;
	_value.sShort = sShort;
	_type = OF_NUMBER_TYPE_SHORT;

	return self;
}

- initWithInt: (signed int)sint
- initWithInt: (signed int)sInt
{
	self = [super init];

	_value.sint = sint;
	_value.sInt = sInt;
	_type = OF_NUMBER_TYPE_INT;

	return self;
}

- initWithLong: (signed long)slong
- initWithLong: (signed long)sLong
{
	self = [super init];

	_value.slong = slong;
	_value.sLong = sLong;
	_type = OF_NUMBER_TYPE_LONG;

	return self;
}

- initWithLongLong: (signed long long)slonglong
- initWithLongLong: (signed long long)sLongLong
{
	self = [super init];

	_value.slonglong = slonglong;
	_value.sLongLong = sLongLong;
	_type = OF_NUMBER_TYPE_LONGLONG;

	return self;
}

- initWithUnsignedChar: (unsigned char)uchar
- initWithUnsignedChar: (unsigned char)uChar
{
	self = [super init];

	_value.uchar = uchar;
	_value.uChar = uChar;
	_type = OF_NUMBER_TYPE_UCHAR;

	return self;
}

- initWithUnsignedShort: (unsigned short)ushort
- initWithUnsignedShort: (unsigned short)uShort
{
	self = [super init];

	_value.ushort = ushort;
	_value.uShort = uShort;
	_type = OF_NUMBER_TYPE_USHORT;

	return self;
}

- initWithUnsignedInt: (unsigned int)uint
- initWithUnsignedInt: (unsigned int)uInt
{
	self = [super init];

	_value.uint = uint;
	_value.uInt = uInt;
	_type = OF_NUMBER_TYPE_UINT;

	return self;
}

- initWithUnsignedLong: (unsigned long)ulong
- initWithUnsignedLong: (unsigned long)uLong
{
	self = [super init];

	_value.ulong = ulong;
	_value.uLong = uLong;
	_type = OF_NUMBER_TYPE_ULONG;

	return self;
}

- initWithUnsignedLongLong: (unsigned long long)ulonglong
- initWithUnsignedLongLong: (unsigned long long)uLongLong
{
	self = [super init];

	_value.ulonglong = ulonglong;
	_value.uLongLong = uLongLong;
	_type = OF_NUMBER_TYPE_ULONGLONG;

	return self;
}

- initWithInt8: (int8_t)int8
{
390
391
392
393
394
395
396
397

398
399
400
401

402
403
404
405
406
407

408
409
410
411

412
413
414
415
416
417

418
419
420
421

422
423
424
425
426
427

428
429
430
431

432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447

448
449
450
451

452
453
454
455
456
457

458
459
460
461

462
463
464
465
466
467

468
469
470
471

472
473
474
475
476
477

478
479
480
481

482
483
484
485
486
487

488
489
490
491

492
493
494
495
496
497

498
499
500
501

502
503
504
505
506
507
508
390
391
392
393
394
395
396

397
398
399
400

401
402
403
404
405
406

407
408
409
410

411
412
413
414
415
416

417
418
419
420

421
422
423
424
425
426

427
428
429
430

431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446

447
448
449
450

451
452
453
454
455
456

457
458
459
460

461
462
463
464
465
466

467
468
469
470

471
472
473
474
475
476

477
478
479
480

481
482
483
484
485
486

487
488
489
490

491
492
493
494
495
496

497
498
499
500

501
502
503
504
505
506
507
508







-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+















-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+





-
+



-
+








	_value.int64 = int64;
	_type = OF_NUMBER_TYPE_INT64;

	return self;
}

- initWithUInt8: (uint8_t)uint8
- initWithUInt8: (uint8_t)uInt8
{
	self = [super init];

	_value.uint8 = uint8;
	_value.uInt8 = uInt8;
	_type = OF_NUMBER_TYPE_UINT8;

	return self;
}

- initWithUInt16: (uint16_t)uint16
- initWithUInt16: (uint16_t)uInt16
{
	self = [super init];

	_value.uint16 = uint16;
	_value.uInt16 = uInt16;
	_type = OF_NUMBER_TYPE_UINT16;

	return self;
}

- initWithUInt32: (uint32_t)uint32
- initWithUInt32: (uint32_t)uInt32
{
	self = [super init];

	_value.uint32 = uint32;
	_value.uInt32 = uInt32;
	_type = OF_NUMBER_TYPE_UINT32;

	return self;
}

- initWithUInt64: (uint64_t)uint64
- initWithUInt64: (uint64_t)uInt64
{
	self = [super init];

	_value.uint64 = uint64;
	_value.uInt64 = uInt64;
	_type = OF_NUMBER_TYPE_UINT64;

	return self;
}

- initWithSize: (size_t)size
{
	self = [super init];

	_value.size = size;
	_type = OF_NUMBER_TYPE_SIZE;

	return self;
}

- initWithSSize: (ssize_t)ssize
- initWithSSize: (ssize_t)sSize
{
	self = [super init];

	_value.ssize = ssize;
	_value.sSize = sSize;
	_type = OF_NUMBER_TYPE_SSIZE;

	return self;
}

- initWithIntMax: (intmax_t)intmax
- initWithIntMax: (intmax_t)intMax
{
	self = [super init];

	_value.intmax = intmax;
	_value.intMax = intMax;
	_type = OF_NUMBER_TYPE_INTMAX;

	return self;
}

- initWithUIntMax: (uintmax_t)uintmax
- initWithUIntMax: (uintmax_t)uIntMax
{
	self = [super init];

	_value.uintmax = uintmax;
	_value.uIntMax = uIntMax;
	_type = OF_NUMBER_TYPE_UINTMAX;

	return self;
}

- initWithPtrDiff: (ptrdiff_t)ptrdiff
- initWithPtrDiff: (ptrdiff_t)ptrDiff
{
	self = [super init];

	_value.ptrdiff = ptrdiff;
	_value.ptrDiff = ptrDiff;
	_type = OF_NUMBER_TYPE_PTRDIFF;

	return self;
}

- initWithIntPtr: (intptr_t)intptr
- initWithIntPtr: (intptr_t)intPtr
{
	self = [super init];

	_value.intptr = intptr;
	_value.intPtr = intPtr;
	_type = OF_NUMBER_TYPE_INTPTR;

	return self;
}

- initWithUIntPtr: (uintptr_t)uintptr
- initWithUIntPtr: (uintptr_t)uIntPtr
{
	self = [super init];

	_value.uintptr = uintptr;
	_value.uIntPtr = uIntPtr;
	_type = OF_NUMBER_TYPE_UINTPTR;

	return self;
}

- initWithFloat: (float)float_
{
549
550
551
552
553
554
555
556

557
558
559

560
561
562
563
564
565
566
549
550
551
552
553
554
555

556
557
558

559
560
561
562
563
564
565
566







-
+


-
+







				@throw [OFInvalidArgumentException exception];
		} else if ([typeString isEqual: @"unsigned"]) {
			/*
			 * FIXME: This will fail if the value is bigger than
			 *	  INTMAX_MAX!
			 */
			_type = OF_NUMBER_TYPE_UINTMAX;
			_value.uintmax = [element decimalValue];
			_value.uIntMax = [element decimalValue];
		} else if ([typeString isEqual: @"signed"]) {
			_type = OF_NUMBER_TYPE_INTMAX;
			_value.intmax = [element decimalValue];
			_value.intMax = [element decimalValue];
		} else if ([typeString isEqual: @"float"]) {
			union {
				float f;
				uint32_t u;
			} f;

			f.u = OF_BSWAP32_IF_LE(

Modified src/OFRunLoop.m from [2bcc651795] to [15a7c5ffb7].

310
311
312
313
314
315
316
317

318
319
320
321
322
323
324
310
311
312
313
314
315
316

317
318
319
320
321
322
323
324







-
+








# ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		return _block(object, _buffer, length, address, exception);
	else {
# endif
		bool (*func)(id, SEL, OFUDPSocket *, void *, size_t,
		    of_udp_socket_address_t address, OFException *) =
		    of_udp_socket_address_t, OFException *) =
		    (bool (*)(id, SEL, OFUDPSocket *, void *, size_t,
		    of_udp_socket_address_t, OFException *))
		    [_target methodForSelector: _selector];

		return func(_target, _selector, object, _buffer, length,
		    address, exception);
# ifdef OF_HAVE_BLOCKS
426
427
428
429
430
431
432
433

434
435
436
437
438
439

440
441
442
443
444
445
446
426
427
428
429
430
431
432

433
434
435
436
437
438

439
440
441
442
443
444
445
446







-
+





-
+







{
	ADD_READ(OFRunLoop_AcceptQueueItem, stream, {
		queueItem->_target = [target retain];
		queueItem->_selector = selector;
	})
}

+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock
				buffer: (void *)buffer
				length: (size_t)length
				target: (id)target
			      selector: (SEL)selector
{
	ADD_READ(OFRunLoop_UDPReceiveQueueItem, socket, {
	ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, {
		queueItem->_buffer = buffer;
		queueItem->_length = length;
		queueItem->_target = [target retain];
		queueItem->_selector = selector;
	})
}

483
484
485
486
487
488
489
490

491
492
493
494
495
496

497
498
499
500
501
502
503
483
484
485
486
487
488
489

490
491
492
493
494
495

496
497
498
499
500
501
502
503







-
+





-
+







				block: (of_tcp_socket_async_accept_block_t)block
{
	ADD_READ(OFRunLoop_AcceptQueueItem, stream, {
		queueItem->_block = [block copy];
	})
}

+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)socket
+ (void)of_addAsyncReceiveForUDPSocket: (OFUDPSocket *)sock
				buffer: (void *)buffer
				length: (size_t)length
				 block: (of_udp_socket_async_receive_block_t)
					    block
{
	ADD_READ(OFRunLoop_UDPReceiveQueueItem, socket, {
	ADD_READ(OFRunLoop_UDPReceiveQueueItem, sock, {
		queueItem->_buffer = buffer;
		queueItem->_length = length;
		queueItem->_block = [block copy];
	})
}
# endif
# undef ADD_READ

Modified src/OFString.m from [fc3a0af468] to [29ce2b94a9].

1477
1478
1479
1480
1481
1482
1483
1484

1485
1486
1487
1488
1489
1490
1491
1477
1478
1479
1480
1481
1482
1483

1484
1485
1486
1487
1488
1489
1490
1491







-
+







}

- (size_t)UTF8StringLength
{
	return [self cStringLengthWithEncoding: OF_STRING_ENCODING_UTF_8];
}

- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)getCharacters: (of_unichar_t *)buffer
	      inRange: (of_range_t)range
{

Modified src/OFString_UTF8.m from [62af83b584] to [fb6ee6e76b].

147
148
149
150
151
152
153
154

155
156
157
158

159
160

161
162
163
164

165
166

167
168

169
170
171

172
173
174
175
176
177
178
147
148
149
150
151
152
153

154
155
156
157

158
159

160
161
162
163

164
165

166
167

168
169
170

171
172
173
174
175
176
177
178







-
+



-
+

-
+



-
+

-
+

-
+


-
+








	return isUTF8;
}

size_t
of_string_utf8_get_index(const char *string, size_t position)
{
	size_t index = position;
	size_t idx = position;

	for (size_t i = 0; i < position; i++)
		if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
			index--;
			idx--;

	return index;
	return idx;
}

size_t
of_string_utf8_get_position(const char *string, size_t index, size_t length)
of_string_utf8_get_position(const char *string, size_t idx, size_t length)
{
	for (size_t i = 0; i <= index; i++)
	for (size_t i = 0; i <= idx; i++)
		if OF_UNLIKELY ((string[i] & 0xC0) == 0x80)
			if (++index > length)
			if (++idx > length)
				return OF_NOT_FOUND;

	return index;
	return idx;
}

@implementation OFString_UTF8
- init
{
	self = [super init];

942
943
944
945
946
947
948
949

950
951
952
953

954
955
956
957

958
959

960
961
962
963


964
965
966
967
968
969
970
942
943
944
945
946
947
948

949
950
951
952

953
954
955
956

957
958

959

960


961
962
963
964
965
966
967
968
969







-
+



-
+



-
+

-
+
-

-
-
+
+








	_s->hash = hash;
	_s->hashed = true;

	return hash;
}

- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
	of_unichar_t character;

	if (index >= _s->length)
	if (idx >= _s->length)
		@throw [OFOutOfRangeException exception];

	if (!_s->isUTF8)
		return _s->cString[index];
		return _s->cString[idx];

	index = of_string_utf8_get_position(_s->cString, index,
	idx = of_string_utf8_get_position(_s->cString, idx, _s->cStringLength);
	    _s->cStringLength);

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

	return character;
}

- (void)getCharacters: (of_unichar_t *)buffer
	      inRange: (of_range_t)range

Modified src/OFTCPSocket+SOCKS5.m from [08455d53f4] to [7ec0dff4e0].

28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

60
61
62

63
64
65
66
67
68
69
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

59
60
61

62
63
64
65
66
67
68
69







-
+








-
+














-
+


-
+








#import "socket_helpers.h"

/* Reference for static linking */
int _OFTCPSocket_SOCKS5_reference;

static void
send_or_exception(OFTCPSocket *self, of_socket_t socket, char *buffer,
send_or_exception(OFTCPSocket *self, of_socket_t sock, char *buffer,
    int length)
{
#ifndef OF_WINDOWS
	ssize_t bytesWritten;
#else
	int bytesWritten;
#endif

	if ((bytesWritten = send(socket, (const void *)buffer, length, 0)) < 0)
	if ((bytesWritten = send(sock, (const void *)buffer, length, 0)) < 0)
		@throw [OFWriteFailedException
		    exceptionWithObject: self
			requestedLength: length
			   bytesWritten: 0
				  errNo: of_socket_errno()];

	if ((int)bytesWritten != length)
		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length
						      bytesWritten: bytesWritten
							     errNo: 0];
}

static void
recv_exact(OFTCPSocket *self, of_socket_t socket, char *buffer, int length)
recv_exact(OFTCPSocket *self, of_socket_t sock, char *buffer, int length)
{
	while (length > 0) {
		ssize_t ret = recv(socket, (void *)buffer, length, 0);
		ssize_t ret = recv(sock, (void *)buffer, length, 0);

		if (ret < 0)
			@throw [OFReadFailedException
			    exceptionWithObject: self
				requestedLength: length
					  errNo: of_socket_errno()];

Modified src/OFTCPSocket.m from [9870a76e72] to [51b517e269].

93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
134

135
136
137
138
139
140
141
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132
133

134
135
136
137
138
139
140
141







-
+









-
+














-
+








-
+







		  port: (uint16_t)port
		 block: (of_tcp_socket_async_connect_block_t)block;
# endif
@end

@implementation OFTCPSocket_ConnectThread
- initWithSourceThread: (OFThread *)sourceThread
		socket: (OFTCPSocket *)socket
		socket: (OFTCPSocket *)sock
		  host: (OFString *)host
		  port: (uint16_t)port
		target: (id)target
	      selector: (SEL)selector
{
	self = [super init];

	@try {
		_sourceThread = [sourceThread retain];
		_socket = [socket retain];
		_socket = [sock retain];
		_host = [host copy];
		_port = port;
		_target = [target retain];
		_selector = selector;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

# ifdef OF_HAVE_BLOCKS
- initWithSourceThread: (OFThread *)sourceThread
		socket: (OFTCPSocket *)socket
		socket: (OFTCPSocket *)sock
		  host: (OFString *)host
		  port: (uint16_t)port
		 block: (of_tcp_socket_async_connect_block_t)block
{
	self = [super init];

	@try {
		_sourceThread = [sourceThread retain];
		_socket = [socket retain];
		_socket = [sock retain];
		_host = [host copy];
		_port = port;
		_block = [block copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

Modified src/OFUDPSocket.m from [c8e3c83553] to [fdfc6330cc].

173
174
175
176
177
178
179
180

181
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200


201
202

203
204

205
206
207
208
209
210
211
212
213
214
215


216
217

218
219
220
221



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

238
239

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

256
257
258


259
260
261
262
263
264
265
266

267
268

269
270
271
272
273


274
275
276
277
278
279
280
173
174
175
176
177
178
179

180
181

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198


199
200
201

202
203

204
205
206
207
208
209
210
211
212
213


214
215
216

217
218



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

237
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254

255
256


257
258
259
260
261
262
263
264
265

266
267

268
269
270
271


272
273
274
275
276
277
278
279
280







-
+

-
+
















-
-
+
+

-
+

-
+









-
-
+
+

-
+

-
-
-
+
+
+















-
+

-
+















-
+

-
-
+
+







-
+

-
+



-
-
+
+







@end
#endif

bool
of_udp_socket_address_equal(of_udp_socket_address_t *address1,
    of_udp_socket_address_t *address2)
{
	struct sockaddr_in *sin_1, *sin_2;
	struct sockaddr_in *addrIn1, *addrIn2;
#ifdef HAVE_IPV6
	struct sockaddr_in6 *sin6_1, *sin6_2;
	struct sockaddr_in6 *addrIn6_1, *addrIn6_2;
#endif

	if (address1->address.ss_family != address2->address.ss_family)
		return false;

	switch (address1->address.ss_family) {
	case AF_INET:
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
		if (address1->length < (socklen_t)sizeof(struct sockaddr_in) ||
		    address2->length < (socklen_t)sizeof(struct sockaddr_in))
			@throw [OFInvalidArgumentException exception];
#else
		if (address1->length < 8 || address2->length < 8)
			@throw [OFInvalidArgumentException exception];
#endif

		sin_1 = (struct sockaddr_in *)&address1->address;
		sin_2 = (struct sockaddr_in *)&address2->address;
		addrIn1 = (struct sockaddr_in *)&address1->address;
		addrIn2 = (struct sockaddr_in *)&address2->address;

		if (sin_1->sin_port != sin_2->sin_port)
		if (addrIn1->sin_port != addrIn2->sin_port)
			return false;
		if (sin_1->sin_addr.s_addr != sin_2->sin_addr.s_addr)
		if (addrIn1->sin_addr.s_addr != addrIn2->sin_addr.s_addr)
			return false;

		break;
#ifdef HAVE_IPV6
	case AF_INET6:
		if (address1->length < sizeof(struct sockaddr_in6) ||
		    address2->length < sizeof(struct sockaddr_in6))
			@throw [OFInvalidArgumentException exception];

		sin6_1 = (struct sockaddr_in6 *)&address1->address;
		sin6_2 = (struct sockaddr_in6 *)&address2->address;
		addrIn6_1 = (struct sockaddr_in6 *)&address1->address;
		addrIn6_2 = (struct sockaddr_in6 *)&address2->address;

		if (sin6_1->sin6_port != sin6_2->sin6_port)
		if (addrIn6_1->sin6_port != addrIn6_2->sin6_port)
			return false;
		if (memcmp(sin6_1->sin6_addr.s6_addr,
		    sin6_2->sin6_addr.s6_addr,
		    sizeof(sin6_1->sin6_addr.s6_addr)) != 0)
		if (memcmp(addrIn6_1->sin6_addr.s6_addr,
		    addrIn6_2->sin6_addr.s6_addr,
		    sizeof(addrIn6_1->sin6_addr.s6_addr)) != 0)
			return false;

		break;
#endif
	default:
		@throw [OFInvalidArgumentException exception];
	}

	return true;
}

uint32_t
of_udp_socket_address_hash(of_udp_socket_address_t *address)
{
	uint32_t hash = of_hash_seed;
	struct sockaddr_in *sin;
	struct sockaddr_in *addrIn;
#ifdef HAVE_IPV6
	struct sockaddr_in6 *sin6;
	struct sockaddr_in6 *addrIn6;
	uint32_t subhash;
#endif

	hash += address->address.ss_family;

	switch (address->address.ss_family) {
	case AF_INET:
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
		if (address->length < (socklen_t)sizeof(struct sockaddr_in))
			@throw [OFInvalidArgumentException exception];
#else
		if (address->length < 8)
			@throw [OFInvalidArgumentException exception];
#endif

		sin = (struct sockaddr_in *)&address->address;
		addrIn = (struct sockaddr_in *)&address->address;

		hash += (sin->sin_port << 1);
		hash ^= sin->sin_addr.s_addr;
		hash += (addrIn->sin_port << 1);
		hash ^= addrIn->sin_addr.s_addr;

		break;
#ifdef HAVE_IPV6
	case AF_INET6:
		if (address->length < sizeof(struct sockaddr_in6))
			@throw [OFInvalidArgumentException exception];

		sin6 = (struct sockaddr_in6 *)&address->address;
		addrIn6 = (struct sockaddr_in6 *)&address->address;

		hash += (sin6->sin6_port << 1);
		hash += (addrIn6->sin6_port << 1);

		OF_HASH_INIT(subhash);

		for (size_t i = 0; i < sizeof(sin6->sin6_addr.s6_addr); i++)
			OF_HASH_ADD(subhash, sin6->sin6_addr.s6_addr[i]);
		for (size_t i = 0; i < sizeof(addrIn6->sin6_addr.s6_addr); i++)
			OF_HASH_ADD(subhash, adrIn6->sin6_addr.s6_addr[i]);

		OF_HASH_FINALIZE(subhash);

		hash ^= subhash;

		break;
#endif

Modified src/OFXMLElement.m from [28440d417d] to [ec0f980efe].

880
881
882
883
884
885
886
887

888
889
890
891
892
893
894
895
896

897
898
899
900

901
902
903
904
905
906
907

908
909
910
911
912
913
914
915
916
917
918

919
920

921
922
923
924
925
926
927
928
929
930
931
932
933
934

935
936
937
938
939
940

941
942
943
944
945
946
947
880
881
882
883
884
885
886

887
888
889
890
891
892
893
894
895

896
897
898
899

900
901
902
903
904
905
906

907
908
909
910
911
912
913
914
915
916
917

918
919

920
921
922
923
924
925
926
927
928
929
930
931
932
933

934
935
936
937
938
939

940
941
942
943
944
945
946
947







-
+








-
+



-
+






-
+










-
+

-
+













-
+





-
+







	if (_children == nil)
		_children = [[OFMutableArray alloc] init];

	[_children addObject: child];
}

- (void)insertChild: (OFXMLNode *)child
	    atIndex: (size_t)index
	    atIndex: (size_t)idx
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];

	if (_children == nil)
		_children = [[OFMutableArray alloc] init];

	[_children insertObject: child
			atIndex: index];
			atIndex: idx];
}

- (void)insertChildren: (OFArray *)children
	       atIndex: (size_t)index
	       atIndex: (size_t)idx
{
	for (OFXMLNode *node in children)
		if ([node isKindOfClass: [OFXMLAttribute class]])
			@throw [OFInvalidArgumentException exception];

	[_children insertObjectsFromArray: children
				  atIndex: index];
				  atIndex: idx];
}

- (void)removeChild: (OFXMLNode *)child
{
	if ([child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];

	[_children removeObject: child];
}

- (void)removeChildAtIndex: (size_t)index
- (void)removeChildAtIndex: (size_t)idx
{
	[_children removeObjectAtIndex: index];
	[_children removeObjectAtIndex: idx];
}

- (void)replaceChild: (OFXMLNode *)child
	    withNode: (OFXMLNode *)node
{
	if ([node isKindOfClass: [OFXMLAttribute class]] ||
	    [child isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];

	[_children replaceObject: child
		      withObject: node];
}

- (void)replaceChildAtIndex: (size_t)index
- (void)replaceChildAtIndex: (size_t)idx
		   withNode: (OFXMLNode *)node
{
	if ([node isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];

	[_children replaceObjectAtIndex: index
	[_children replaceObjectAtIndex: idx
			     withObject: node];
}

- (OFXMLElement *)elementForName: (OFString *)elementName
{
	return [[self elementsForName: elementName] firstObject];
}

Modified src/OFZIPArchive.m from [65a1aa4c22] to [cf738fc904].

511
512
513
514
515
516
517

518

519

520
521
522
523
524
525
526
511
512
513
514
515
516
517
518

519
520
521
522
523
524
525
526
527
528







+
-
+

+








	if (_stream == nil)
		@throw [OFNotOpenException exceptionWithObject: self];

	if (_atEndOfStream)
		return 0;

#if SIZE_MAX >= UINT64_MAX
	if (sizeof(length) >= sizeof(uint64_t) && length > UINT64_MAX)
	if (length > UINT64_MAX)
		@throw [OFOutOfRangeException exception];
#endif

	if ((uint64_t)length > _toRead)
		length = (size_t)_toRead;

	ret = [_decompressedStream readIntoBuffer: buffer
					   length: length];

Modified src/bridge/NSArray+OFObject.h from [809f57cb1e] to [5da20e887d].

14
15
16
17
18
19
20

21

22
23
24
25
26
27
28
29
30
31

32

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







+

+










+

+
 * file.
 */

#import <Foundation/NSArray.h>

#import "NSBridging.h"

#ifdef NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#endif

/*!
 * @category NSArray (OFObject) \
 *	     NSArray+OFObject.h ObjFW-Bridge/NSArray+OFObject.h
 *
 * @brief Support for bridging NSArrays to OFArrays.
 */
@interface NSArray (OFObject) <NSBridging>
@end

#ifdef NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
#endif

Modified src/bridge/NSArray_OFArray.h from [fa0ba160b6] to [4744ea3293].

14
15
16
17
18
19
20

21

22
23
24
25
26
27
28
29
30

31

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35







+

+









+

+
 * file.
 */

#import <Foundation/NSArray.h>

@class OFArray;

#ifdef NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#endif

@interface NSArray_OFArray: NSArray
{
	OFArray *_array;
}

- initWithOFArray: (OFArray *)array;
@end

#ifdef NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
#endif

Modified src/bridge/NSArray_OFArray.m from [ab0fe4a97d] to [9048491627].

30
31
32
33
34
35
36
37

38
39

40
41
42
43
44
45
46
30
31
32
33
34
35
36

37
38

39
40
41
42
43
44
45
46







-
+

-
+







			return nil;
		}
	}

	return self;
}

- (id)objectAtIndex: (NSUInteger)index
- (id)objectAtIndex: (NSUInteger)idx
{
	id object = [_array objectAtIndex: index];
	id object = [_array objectAtIndex: idx];

	if ([(OFObject *)object conformsToProtocol: @protocol(OFBridging)])
		return [object NSObject];

	return object;
}

Modified src/bridge/NSDictionary+OFObject.h from [d446c3feff] to [2738a1e15f].

14
15
16
17
18
19
20

21

22
23
24
25
26
27
28
29
30
31

32

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







+

+










+

+
 * file.
 */

#import <Foundation/NSDictionary.h>

#import "NSBridging.h"

#ifdef NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#endif

/*!
 * @category NSDictionary (OFObject) \
 *	     NSDictionary+OFObject.h ObjFW-Bridge/NSDictionary+OFObject.h
 *
 * @brief Support for bridging NSDictionaries to OFDictionaries.
 */
@interface NSDictionary (OFObject) <NSBridging>
@end

#ifdef NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
#endif

Modified src/bridge/NSDictionary_OFDictionary.h from [a63731835d] to [c7bdcee03e].

14
15
16
17
18
19
20

21

22
23
24
25
26
27
28
29
30

31

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35







+

+









+

+
 * file.
 */

#import <Foundation/NSDictionary.h>

@class OFDictionary;

#ifdef NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#endif

@interface NSDictionary_OFDictionary: NSDictionary
{
	OFDictionary *_dictionary;
}

- initWithOFDictionary: (OFDictionary *)dictionary;
@end

#ifdef NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
#endif

Modified src/bridge/NSString+OFObject.h from [e98c3df1ce] to [523c8eea31].

14
15
16
17
18
19
20

21

22
23
24
25
26
27
28
29
30
31
32
33
34
35

36

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+

+














+

+
 * file.
 */

#import <Foundation/NSString.h>

#import "NSBridging.h"

#ifdef NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#endif

/*!
 * @category NSString (OFObject)
 *	     NSString+OFObject.h ObjFW-Bridge/NSString+OFObject.h
 *
 * @brief Support for bridging NSStrings to OFStrings.
 *
 * Unfortunately, they need to be copied, as NSString is not capable of
 * handling UCS-4 properly (a character of NSString is only 2 bytes, while a
 * character of OFString is 4).
 */
@interface NSString (OFObject) <NSBridging>
@end

#ifdef NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
#endif

Modified src/bridge/OFArray_NSArray.m from [94ceef5c3f] to [541b962ef5].

37
38
39
40
41
42
43
44

45
46
47
48

49
50
51

52
53
54
55
56
57
58
59
60
61
62
63
37
38
39
40
41
42
43

44
45
46
47

48
49
50

51
52
53
54
55
56
57
58
59
60
61
62
63







-
+



-
+


-
+












		[self release];
		@throw e;
	}

	return self;
}

- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
	id object;

	if (index > NSUIntegerMax)
	if (idx > NSUIntegerMax)
		@throw [OFOutOfRangeException exception];

	object = [_array objectAtIndex: index];
	object = [_array objectAtIndex: idx];

	if ([(NSObject *)object conformsToProtocol: @protocol(NSBridging)])
		return [object OFObject];

	return object;
}

- (size_t)count
{
	return [_array count];
}
@end

Modified src/encodings/codepage_437.m from [c1aa2005c6] to [8cf0d5a40f].

133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
133
134
135
136
137
138
139

140
141
142
143
144
145
146
147







-
+







of_unicode_to_codepage_437(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/codepage_850.m from [59298ea7e4] to [42a9f55d3e].

109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
109
110
111
112
113
114
115

116
117
118
119
120
121
122
123







-
+







of_unicode_to_codepage_850(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/codepage_858.m from [d4ab6dcec9] to [a1c541d3cd].

115
116
117
118
119
120
121
122

123
124
125
126
127
128
129
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129







-
+







of_unicode_to_codepage_858(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/common.h from [8b3b315d4d] to [321ef98b23].

17
18
19
20
21
22
23
24

25
26

27
28
29
30
31

32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50
51

52
53

54
55
56
57
58
59
60
61

62
17
18
19
20
21
22
23

24
25

26
27
28
29
30

31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50

51
52

53
54
55
56
57
58
59
60

61
62







-
+

-
+




-
+







-
+











-
+

-
+







-
+

#define CASE_MISSING_IS_KEEP(nr)				\
	case nr:						\
		if OF_UNLIKELY ((c & 0xFF) < page##nr##Start) {	\
			output[i] = (unsigned char)c;		\
			continue;				\
		}						\
								\
		index = (c & 0xFF) - page##nr##Start;		\
		idx = (c & 0xFF) - page##nr##Start;		\
								\
		if (index >= sizeof(page##nr)) {		\
		if (idx >= sizeof(page##nr)) {			\
			output[i] = (unsigned char)c;		\
			continue;				\
		}						\
								\
		if (page##nr[index] == 0x00) {			\
		if (page##nr[idx] == 0x00) {			\
			if (lossy) {				\
				output[i] = '?';		\
				continue;			\
			} else					\
				return false;			\
		}						\
								\
		output[i] = page##nr[index];			\
		output[i] = page##nr[idx];			\
		break;
#define CASE_MISSING_IS_ERROR(nr)					 \
	case 0x##nr:							 \
		if OF_UNLIKELY ((c & 0xFF) < page##nr##Start) {		 \
			if (lossy) {					 \
				output[i] = '?';			 \
				continue;				 \
			} else						 \
				return false;				 \
		}							 \
									 \
		index = (c & 0xFF) - page##nr##Start;			 \
		idx = (c & 0xFF) - page##nr##Start;			 \
									 \
		if (index >= sizeof(page##nr) || page##nr[index] == 0) { \
		if (idx >= sizeof(page##nr) || page##nr[idx] == 0) { \
			if (lossy) {					 \
				output[i] = '?';			 \
				continue;				 \
			} else						 \
				return false;				 \
		}							 \
									 \
		output[i] = page##nr[index];				 \
		output[i] = page##nr[idx];				 \
		break;

Modified src/encodings/iso_8859_15.m from [16863c4f02] to [8f6da128e4].

64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78







-
+







of_unicode_to_iso_8859_15(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/iso_8859_2.m from [744cbf950c] to [de487566d1].

84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98







-
+







of_unicode_to_iso_8859_2(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/iso_8859_3.m from [3670e938ce] to [ca6d9c039c].

81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95







-
+







of_unicode_to_iso_8859_3(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/koi8_r.m from [512f05d1ec] to [e77fc0ad5b].

119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133







-
+







of_unicode_to_koi8_r(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/koi8_u.m from [b72abc7c7a] to [a1d99e8a1a].

127
128
129
130
131
132
133
134

135
136
137
138
139
140
141
127
128
129
130
131
132
133

134
135
136
137
138
139
140
141







-
+







of_unicode_to_koi8_u(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/mac_roman.m from [621b6250aa] to [c8c7b33ca3].

153
154
155
156
157
158
159
160

161
162
163
164
165
166
167
153
154
155
156
157
158
159

160
161
162
163
164
165
166
167







-
+







of_unicode_to_mac_roman(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/windows_1251.m from [752c057c67] to [c78eb7b263].

106
107
108
109
110
111
112
113

114
115
116
117
118
119
120
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120







-
+







of_unicode_to_windows_1251(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/encodings/windows_1252.m from [8416ceeb47] to [a7686520cf].

102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116







-
+







of_unicode_to_windows_1252(const of_unichar_t *input, unsigned char *output,
    size_t length, bool lossy)
{
	for (size_t i = 0; i < length; i++) {
		of_unichar_t c = input[i];

		if OF_UNLIKELY (c > 0x7F) {
			uint8_t index;
			uint8_t idx;

			if OF_UNLIKELY (c > 0xFFFF) {
				if (lossy) {
					output[i] = '?';
					continue;
				} else
					return false;

Modified src/macros.h from [62a0be4bea] to [ed1d1a5d46].

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
626
627
628
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
626
627
628







-
+

-
+



-
+

-
+



-
+

-
+







		OF_HASH_ADD(hash, (otherCopy >> 24) & 0xFF);	\
		OF_HASH_ADD(hash, (otherCopy >> 16) & 0xFF);	\
		OF_HASH_ADD(hash, (otherCopy >>  8) & 0xFF);	\
		OF_HASH_ADD(hash, otherCopy & 0xFF);		\
	}

static OF_INLINE bool
of_bitset_isset(uint8_t *_Nonnull storage, size_t index)
of_bitset_isset(uint8_t *_Nonnull storage, size_t idx)
{
	return storage[index / 8] & (1 << (index % 8));
	return storage[idx / 8] & (1 << (idx % 8));
}

static OF_INLINE void
of_bitset_set(uint8_t *_Nonnull storage, size_t index)
of_bitset_set(uint8_t *_Nonnull storage, size_t idx)
{
	storage[index / 8] |= (1 << (index % 8));
	storage[idx / 8] |= (1 << (idx % 8));
}

static OF_INLINE void
of_bitset_clear(uint8_t *_Nonnull storage, size_t index)
of_bitset_clear(uint8_t *_Nonnull storage, size_t idx)
{
	storage[index / 8] &= ~(1 << (index % 8));
	storage[idx / 8] &= ~(1 << (idx % 8));
}

static OF_INLINE char *_Nullable
of_strdup(const char *_Nonnull string)
{
	char *copy;
	size_t length = strlen(string);

Modified src/socket.h from [1d3c37e76e] to [ea1fed378b].

109
110
111
112
113
114
115
116
117


118
119
120
121
122
123
109
110
111
112
113
114
115


116
117
118
119
120
121
122
123







-
-
+
+







#ifdef __cplusplus
extern "C" {
#endif
extern bool of_socket_init(void);
extern int of_socket_errno(void);
# ifndef OF_WII
extern int of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len);
extern int of_getsockname(of_socket_t sock, struct sockaddr *restrict addr,
    socklen_t *restrict addrLen);
# endif
#ifdef __cplusplus
}
#endif

OF_ASSUME_NONNULL_END

Modified src/socket.m from [c5f416940a] to [ac7909760b].

189
190
191
192
193
194
195
196
197


198
199
200
201
202
203
204
205
206
207

208
209
210
211
212
213
214
215
216
189
190
191
192
193
194
195


196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214
215
216







-
-
+
+









-
+










	return 0;
#endif
}

#ifndef OF_WII
int
of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len)
of_getsockname(of_socket_t sock, struct sockaddr *restrict addr,
    socklen_t *restrict addrLen)
{
	int ret;

# ifdef OF_HAVE_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exception];

# endif

	ret = getsockname(socket, address, address_len);
	ret = getsockname(sock, addr, addrLen);

# ifdef OF_HAVE_THREADS
	if (!of_mutex_unlock(&mutex))
		@throw [OFUnlockFailedException exception];
# endif

	return ret;
}
#endif

Modified tests/OFArrayTests.m from [bbcc951492] to [caf218a7ef].

96
97
98
99
100
101
102
103

104
105

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

123
124
125

126
127
128

129
130
131

132
133
134
135

136
137

138
139
140
141
142
143
144
96
97
98
99
100
101
102

103
104

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

122
123
124

125
126
127

128
129
130

131
132
133
134

135
136

137
138
139
140
141
142
143
144







-
+

-
+
















-
+


-
+


-
+


-
+



-
+

-
+







- (void)dealloc
{
	[_array release];

	[super dealloc];
}

- (id)objectAtIndex: (size_t)index
- (id)objectAtIndex: (size_t)idx
{
	return [_array objectAtIndex: index];
	return [_array objectAtIndex: idx];
}

- (size_t)count
{
	return [_array count];
}
@end

@implementation SimpleMutableArray
+ (void)initialize
{
	if (self == [SimpleMutableArray class])
		[self inheritMethodsFromClass: [SimpleArray class]];
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	[_array insertObject: object
		     atIndex: index];
		     atIndex: idx];
}

- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
		  withObject: (id)object
{
	[_array replaceObjectAtIndex: index
	[_array replaceObjectAtIndex: idx
			  withObject: object];
}

- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
	[_array removeObjectAtIndex: index];
	[_array removeObjectAtIndex: idx];
}
@end

@implementation TestsAppDelegate (OFArrayTests)
- (void)arrayTestsWithClass: (Class)arrayClass
	       mutableClass: (Class)mutableArrayClass
{

Modified tests/OFStringTests.m from [addca37143] to [1b6d7256b5].

170
171
172
173
174
175
176
177

178
179

180
181
182
183
184
185
186
170
171
172
173
174
175
176

177
178

179
180
181
182
183
184
185
186







-
+

-
+







- (void)dealloc
{
	[_string release];

	[super dealloc];
}

- (of_unichar_t)characterAtIndex: (size_t)index
- (of_unichar_t)characterAtIndex: (size_t)idx
{
	return [_string characterAtIndex: index];
	return [_string characterAtIndex: idx];
}

- (size_t)length
{
	return [_string length];
}
@end

Modified utils/ofhttp/OFHTTP.m from [92c2a328ea] to [511674f2be].

372
373
374
375
376
377
378
379

380
381
382

383
384

385
386
387
388
389
390
391
372
373
374
375
376
377
378

379
380
381

382
383

384
385
386
387
388
389
390
391







-
+


-
+

-
+







	}

	[self performSelector: @selector(downloadNextURL)
		   afterDelay: 0];
}

-    (void)client: (OFHTTPClient *)client
  didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket
  didCreateSocket: (OF_KINDOF(OFTCPSocket *))sock
	  request: (OFHTTPRequest *)request
{
	if (_insecure && [socket respondsToSelector:
	if (_insecure && [sock respondsToSelector:
	    @selector(setCertificateVerificationEnabled:)])
		[socket setCertificateVerificationEnabled: false];
		[sock setCertificateVerificationEnabled: false];
}

-	  (bool)client: (OFHTTPClient *)client
  shouldFollowRedirect: (OFURL *)URL
	    statusCode: (int)statusCode
	       request: (OFHTTPRequest *)request
	      response: (OFHTTPResponse *)response

Modified utils/ofhttp/ProgressBar.m from [509373b942] to [55d6da0b1d].

101
102
103
104
105
106
107
108

109
110

111
112

113
114

115
116

117
118

119
120

121
122

123
124
125
126
127
128
129
101
102
103
104
105
106
107

108
109

110
111

112
113

114
115

116
117

118
119

120
121

122
123
124
125
126
127
128
129







-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+







	    (float)(_resumedFrom + _length) * 100;

	[of_stdout writeString: @"\r  ▕"];

	for (size_t i = 0; i < (size_t)bars; i++)
		[of_stdout writeString: @"█"];
	if (bars < barWidth) {
		float remainder = bars - floorf(bars);
		float rem = bars - floorf(bars);

		if (remainder >= 0.875)
		if (rem >= 0.875)
			[of_stdout writeString: @"▉"];
		else if (remainder >= 0.75)
		else if (rem >= 0.75)
			[of_stdout writeString: @"▊"];
		else if (remainder >= 0.625)
		else if (rem >= 0.625)
			[of_stdout writeString: @"▋"];
		else if (remainder >= 0.5)
		else if (rem >= 0.5)
			[of_stdout writeString: @"▌"];
		else if (remainder >= 0.375)
		else if (rem >= 0.375)
			[of_stdout writeString: @"▍"];
		else if (remainder >= 0.25)
		else if (rem >= 0.25)
			[of_stdout writeString: @"▎"];
		else if (remainder >= 0.125)
		else if (rem >= 0.125)
			[of_stdout writeString: @"▏"];
		else
			[of_stdout writeString: @" "];

		for (size_t i = 0; i < barWidth - (size_t)bars - 1; i++)
			[of_stdout writeString: @" "];
	}