ObjFW  Check-in [e1e7ffa903]

Overview
Comment:Exceptions are now autoreleased.

This is safe as an "exception loop" can't happen, since if allocating
an exception fails, it throws an OFAllocFailedException which is
preallocated and can always be thrown.

So, the worst case would be that an autorelease of an exception fails,
triggering an OFOutOfMemoryException for which there is no memory,
resulting in an OFAllocFailedException to be thrown.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e1e7ffa90302ec9cd76679259eed6baf49972adb47935823bd379047b8400823
User & Date: js on 2011-09-22 23:25:42
Other Links: manifest | tags
Context
2011-09-25
22:14
Add missing files to Xcode project. check-in: 8307a85283 user: js tags: trunk
2011-09-22
23:25
Exceptions are now autoreleased. check-in: e1e7ffa903 user: js tags: trunk
12:09
Make it impossible to add objects to arbitrary autorelease pools. check-in: 2e484248de user: js tags: trunk
Changes

Modified src/OFApplication.m from [42eccf6f0e] to [e705f7e9ee].

263
264
265
266
267
268
269
270
271


272
273
274
275
276
277
263
264
265
266
267
268
269


270
271
272
273
274
275
276
277







-
-
+
+






	[super dealloc];
}
@end

@implementation OFObject (OFApplicationDelegate)
- (void)applicationDidFinishLaunching
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)applicationWillTerminate
{
}
@end

Modified src/OFArray.m from [a34fd71e38] to [9d67fa5621].

101
102
103
104
105
106
107
108
109


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


108
109
110
111
112
113
114
115
116







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFArray
+ (void)initialize
{
167
168
169
170
171
172
173
174
175


176
177
178
179
180
181
182
167
168
169
170
171
172
173


174
175
176
177
178
179
180
181
182







-
-
+
+







}

- init
{
	if (isa == [OFArray class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- initWithObject: (id)object
{
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
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







-
-
+
+






-
-
+
+






-
-
+
+







-
-
+
+






-
-
+
+




-
-
+
+







}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithArray: (OFArray*)array
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithCArray: (id*)objects
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithCArray: (id*)objects
	  length: (size_t)length
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithSerialization: (OFXMLElement*)element
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (size_t)count
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	size_t i;

278
279
280
281
282
283
284
285
286


287
288
289
290
291
292
293
278
279
280
281
282
283
284


285
286
287
288
289
290
291
292
293







-
-
+
+







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

- (id)objectAtIndex: (size_t)index
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (size_t)indexOfObject: (id)object
{
	size_t i, count = [self count];

	for (i = 0; i < count; i++)
527
528
529
530
531
532
533
534

535
536
537
538
539
540
541
527
528
529
530
531
532
533

534
535
536
537
538
539
540
541







-
+







			   objects: (id*)objects
			     count: (int)count_
{
	/* FIXME: Use -[getObjects:inRange:] on the passed objects */
	size_t count = [self count];

	if (count > INT_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [self cArray];
	state->mutationsPtr = (unsigned long*)self;
664
665
666
667
668
669
670
671
672



673
674
675
676
677
678
679
680
681
682
683
684



685
686
687
688
664
665
666
667
668
669
670


671
672
673
674
675
676
677
678
679
680
681
682
683


684
685
686
687
688
689
690







-
-
+
+
+










-
-
+
+
+





	[super dealloc];
}

- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa
							     object: array];
		@throw [OFEnumerationMutationException
		    exceptionWithClass: isa
				object: array];

	if (position < count)
		return [array objectAtIndex: position++];

	return nil;
}

- (void)reset
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa
							     object: array];
		@throw [OFEnumerationMutationException
		    exceptionWithClass: isa
				object: array];

	position = 0;
}
@end

Modified src/OFArray_adjacent.m from [831950ce9b] to [d472eede07].

185
186
187
188
189
190
191
192
193



194
195
196
197
198
199
200
185
186
187
188
189
190
191


192
193
194
195
196
197
198
199
200
201







-
-
+
+
+







		OFXMLElement *child;

		pool = [[OFAutoreleasePool alloc] init];

		if ((![[element name] isEqual: @"OFArray"] &&
		    ![[element name] isEqual: @"OFMutableArray"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		enumerator = [[element children] objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			id object;

235
236
237
238
239
240
241
242

243
244
245
246
247
248
249
236
237
238
239
240
241
242

243
244
245
246
247
248
249
250







-
+







- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	id *cArray = [array cArray];
	size_t i, count = [array count];

	if (range.start + range.length > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	for (i = 0; i < range.length; i++)
		buffer[i] = cArray[range.start + i];
}

- (size_t)indexOfObject: (id)object
{
277
278
279
280
281
282
283
284

285
286
287
288
289
290
291
278
279
280
281
282
283
284

285
286
287
288
289
290
291
292







-
+







	if (![self isKindOfClass: [OFMutableArray class]])
		return [OFArray_adjacentSubarray arrayWithArray: self
							  range: range];

	count = [array count];

	if (range.start + range.length > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [OFArray arrayWithCArray: (id*)[array cArray] + range.start
				 length: range.length];
}

- (BOOL)isEqual: (id)object
{

Modified src/OFArray_subarray.m from [77e6be7acc] to [0cdeecac33].

56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79







-
+








-
+







{
	return range.length;
}

- (id)objectAtIndex: (size_t)index
{
	if (index >= range.length)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [array objectAtIndex: index + range.start];
}

- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range_
{
	if (range_.start + range_.length > range.length)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	range_.start += range.start;

	return [array getObjects: buffer
			 inRange: range_];
}

106
107
108
109
110
111
112
113

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

113
114
115
116
117
118
119







-
+







	return index;
}

- (OFArray*)objectsInRange: (of_range_t)range_
{
	if (range_.start + range_.length > range.length)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	range_.start += range.start;

	return [array objectsInRange: range_];
}
@end

Modified src/OFAutoreleasePool.m from [74a7fa7b2d] to [6cfd14d520].

37
38
39
40
41
42
43
44


45
46
47
48
49
50
51
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52







-
+
+







#ifdef OF_THREADS
+ (void)initialize
{
	if (self != [OFAutoreleasePool class])
		return;

	if (!of_tlskey_new(&firstKey) || !of_tlskey_new(&lastKey))
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
}
#endif

+ (void)addObject: (id)object
{
#ifdef OF_THREADS
	id lastPool = of_tlskey_get(lastKey);
62
63
64
65
66
67
68
69


70
71
72
73
74
75
76
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78







-
+
+







#ifdef OF_THREADS
		lastPool = of_tlskey_get(lastKey);
#endif
	}

	if (lastPool == nil) {
		[object release];
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	}

	@try {
		[lastPool _addObject: object];
	} @catch (id e) {
		[object release];
		@throw e;
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
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







-
+










-
+







	@try {
#ifdef OF_THREADS
		id firstPool = of_tlskey_get(firstKey);
		previousPool = of_tlskey_get(lastKey);

		if (!of_tlskey_set(lastKey, self))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];
#else
		previousPool = lastPool;
		lastPool = self;
#endif

		if (firstPool == nil) {
#ifdef OF_THREADS
			if (!of_tlskey_set(firstKey, self)) {
				of_tlskey_set(lastKey, previousPool);
				@throw [OFInitializationFailedException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}
#else
			firstPool = self;
#endif
		}

		if (previousPool != nil)
205
206
207
208
209
210
211
212
213


214
215
216
217
218
219


220
221
207
208
209
210
211
212
213


214
215
216
217
218
219


220
221
222
223







-
-
+
+




-
-
+
+


#endif

	[super dealloc];
}

- retain
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- autorelease
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}
@end

Modified src/OFBlock.m from [736d4bd7b9] to [4b700a1d09].

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
375
376
377
378
379
380
381
382

383
384
385
386
387
388
389


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
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
375
376
377
378
379
380
381
382
383
384

385
386
387
388
389
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







-
+
+





-
+
+





-
+
+














-
+





-
-
+
+




-
-
+
+




-
-
+
+




-
-
+
+





-
-
+
+





-
-
+
+






-
-
+
+




-
-
+
+







	/*
	 * There is no objc_initializeClassPair in 10.5.
	 * However, objc_allocateClassPair does not register the new class with
	 * the subclass in the ObjC1 runtime like the ObjC2 runtime does, so
	 * this workaround should be fine.
	 */
	if ((tmp = objc_allocateClassPair(self, "OFStackBlock", 0)) == NULL)
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	memcpy(&_NSConcreteStackBlock, tmp, sizeof(_NSConcreteStackBlock));
	free(tmp);
	objc_registerClassPair((Class)&_NSConcreteStackBlock);

	if ((tmp = objc_allocateClassPair(self, "OFGlobalBlock", 0)) == NULL)
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	memcpy(&_NSConcreteGlobalBlock, tmp, sizeof(_NSConcreteGlobalBlock));
	free(tmp);
	objc_registerClassPair((Class)&_NSConcreteGlobalBlock);

	if ((tmp = objc_allocateClassPair(self, "OFMallocBlock", 0)) == NULL)
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	memcpy(&_NSConcreteMallocBlock, tmp, sizeof(_NSConcreteMallocBlock));
	free(tmp);
	objc_registerClassPair((Class)&_NSConcreteMallocBlock);
}
#endif

#if !defined(OF_ATOMIC_OPS)
+ (void)initialize
{
	size_t i;

	for (i = 0; i < NUM_SPINLOCKS; i++)
		if (!of_spinlock_new(&spinlocks[i]))
			@throw [OFInitializationFailedException
			    newWithClass: self];
			    exceptionWithClass: self];
}
#endif

+ alloc
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)addMemoryToPool: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)allocMemoryWithSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)allocMemoryForNItems: (size_t)nitems
		     withSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)resizeMemory: (void*)ptr
	       toSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)resizeMemory: (void*)ptr
	     toNItems: (size_t)nitems
	     withSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)freeMemory: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- retain
{
	if (isa == (Class)&_NSConcreteMallocBlock)
		return Block_copy(self);

469
470
471
472
473
474
475
476
477


478
479
480
481
482
483
484
472
473
474
475
476
477
478


479
480
481
482
483
484
485
486
487







-
-
+
+







{
	if (isa == (Class)&_NSConcreteMallocBlock)
		Block_release(self);
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

#if defined(OF_APPLE_RUNTIME) && defined(__OBJC2__)
@implementation OFStackBlock
+ (void)load

Modified src/OFConstantString.m from [5b58150777] to [c74b1f841a].

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
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
142
143
144
145
146
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
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
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
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
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
142
143
144
145
146
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
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
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







-
-
+
+
+












-
+












-
-
+
+






-
-
+
+






-
-
+
+







-
-
+
+







-
-
+
+








-
-
+
+






-
-
+
+






-
-
+
+







-
-
+
+







-
-
+
+








-
-
+
+







-
-
+
+







-
-
+
+








-
-
+
+






-
-
+
+







-
-
+
+






-
-
+
+







-
-
+
+






-
-
+
+







-
-
+
+






-
-
+
+







-
-
+
+







-
-
+
+








-
-
+
+




-
-
+
+





-
-
+
+





-
-
+
+






-
-
+
+




-
-
+
+







{
	struct of_string_ivars *ivars;

	if (initialized == SIZE_MAX)
		return;

	if ((ivars = malloc(sizeof(*ivars))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: sizeof(*ivars)];
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: sizeof(*ivars)];
	memset(ivars, 0, sizeof(*ivars));

	ivars->cString = (char*)s;
	ivars->cStringLength = initialized;

	switch (of_string_check_utf8(ivars->cString, ivars->cStringLength,
	    &ivars->length)) {
	case 1:
		ivars->UTF8 = YES;
		break;
	case -1:
		free(ivars);
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];
	}

	s = ivars;
	initialized = SIZE_MAX;
}

/*
 * The following methods are not available since it's a constant string, which
 * can't be allocated or initialized at runtime.
 */
+ alloc
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUTF8String: (const char*)UTF8String
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUTF8String: (const char*)UTF8String
	      length: (size_t)UTF8StringLength
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithCString: (const char*)cString
	 encoding: (of_string_encoding_t)encoding
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithCString: (const char*)cString
	 encoding: (of_string_encoding_t)encoding
	   length: (size_t)cStringLength
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithString: (OFString*)string
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUnicodeString: (of_unichar_t*)string
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUnicodeString: (of_unichar_t*)string
	      byteOrder: (of_endianess_t)byteOrder
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUnicodeString: (of_unichar_t*)string
		 length: (size_t)length
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUnicodeString: (of_unichar_t*)string
	      byteOrder: (of_endianess_t)byteOrder
		 length: (size_t)length
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUTF16String: (uint16_t*)string
	    byteOrder: (of_endianess_t)byteOrder
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUTF16String: (uint16_t*)string
	       length: (size_t)length
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithUTF16String: (uint16_t*)string
	    byteOrder: (of_endianess_t)byteOrder
	       length: (size_t)length
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithFormat: (OFConstantString*)format, ...
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithFormat: (OFConstantString*)format
       arguments: (va_list)args
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithPath: (OFString*)firstComponent, ...
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithPath: (OFString*)firstComponent
     arguments: (va_list)arguments
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithContentsOfFile: (OFString*)path
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithContentsOfFile: (OFString*)path
		encoding: (of_string_encoding_t)encoding
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithContentsOfURL: (OFURL*)URL
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithContentsOfURL: (OFURL*)URL
	       encoding: (of_string_encoding_t)encoding
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

/* From protocol OFSerializing */
- initWithSerialization: (OFXMLElement*)element
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

/*
 * The following methods are not available because constant strings are
 * preallocated by the compiler and thus don't have a memory pool.
 */
- (void)addMemoryToPool: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)allocMemoryWithSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)allocMemoryForNItems: (size_t)nitems
		     withSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)resizeMemory: (void*)ptr
	       toSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)resizeMemory: (void*)ptr
	     toNItems: (size_t)nitems
	     withSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)freeMemory: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

/*
 * The following methods are unnecessary because constant strings are
 * singletons.
 */
- retain
337
338
339
340
341
342
343
344
345


346
347
348
349
350
351
352
338
339
340
341
342
343
344


345
346
347
348
349
350
351
352
353







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}

/*
 * In all following methods, it is checked whether the constant string has been
 * initialized. If not, it will be initialized. Finally, the implementation of
 * the superclass will be called.

Modified src/OFCountedSet.m from [4086910c39] to [a285a63049].

83
84
85
86
87
88
89
90
91


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


90
91
92
93
94
95
96
97
98







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFCountedSet
+ (void)initialize
{
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
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







-
-
+
+







-
-
+
+







}

- init
{
	if (isa == [OFCountedSet class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- (size_t)countForObject: (id)object
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (OFString*)description
{
	OFMutableString *ret;
	OFAutoreleasePool *pool, *pool2;
	OFEnumerator *enumerator;

Modified src/OFCountedSet_hashtable.m from [fef635224c] to [5a2ad653a8].

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







-
-
+
+
+


















-
+







		OFAutoreleasePool *pool2;
		OFArray *objects;
		OFEnumerator *enumerator;
		OFXMLElement *objectElement;

		if (![[element name] isEqual: @"OFCountedSet"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		enumerator = [objects objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((objectElement = [enumerator nextObject]) != nil) {
			OFXMLElement *object;
			OFXMLAttribute *count;
			OFNumber *number;

			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			count = [objectElement attributeForName: @"count"];

			if (object == nil || count == nil)
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			number = [OFNumber numberWithSize:
			    (size_t)[[count stringValue] decimalValue]];

			[dictionary _setObject: number
					forKey: [object objectByDeserializing]
				       copyKey: NO];

Modified src/OFDataArray.m from [9af5fde103] to [bb3cd515fc].

82
83
84
85
86
87
88
89
90


91
92
93
94
95
96
97
82
83
84
85
86
87
88


89
90
91
92
93
94
95
96
97







-
-
+
+







- initWithItemSize: (size_t)itemSize_
{
	self = [super init];

	if (itemSize_ == 0) {
		Class c = isa;
		[self release];
		@throw [OFInvalidArgumentException newWithClass: c
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: c
							     selector: _cmd];
	}

	itemSize = itemSize_;

	return self;
}

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







-
-
-
+
+
+

















-
+

















-
-
+
+
+







-
+
+







	}

	request = [OFHTTPRequest requestWithURL: URL];
	result = [request perform];

	if ([result statusCode] != 200)
		@throw [OFHTTPRequestFailedException
		    newWithClass: [request class]
		     HTTPRequest: request
			  result: result];
		    exceptionWithClass: [request class]
			   HTTPRequest: request
				result: result];

	self = [[result data] retain];
	[pool release];
	return self;
}

- initWithBase64EncodedString: (OFString*)string
{
	self = [super init];

	itemSize = 1;

	if (!of_base64_decode(self,
	    [string cStringWithEncoding: OF_STRING_ENCODING_ASCII],
	    [string cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) {
		Class c = isa;
		[self release];
		@throw [OFInvalidEncodingException newWithClass: c];
		@throw [OFInvalidEncodingException exceptionWithClass: c];
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	itemSize = 1;

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFString *stringValue;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		stringValue = [element stringValue];

		if (!of_base64_decode(self,
		    [stringValue cStringWithEncoding: OF_STRING_ENCODING_ASCII],
		    [stringValue cStringLengthWithEncoding:
		    OF_STRING_ENCODING_ASCII]))
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240







-
+







{
	return data;
}

- (void*)itemAtIndex: (size_t)index
{
	if (index >= count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return data + index * itemSize;
}

- (void*)firstItem
{
	if (data == NULL || count == 0)
248
249
250
251
252
253
254
255

256
257
258
259
260
261
262
250
251
252
253
254
255
256

257
258
259
260
261
262
263
264







-
+








	return data + (count - 1) * itemSize;
}

- (void)addItem: (const void*)item
{
	if (SIZE_MAX - count < 1)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + 1
			   ofSize: itemSize];

	memcpy(data + count * itemSize, item, itemSize);

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







-
+














-
+







		atIndex: index];
}

- (void)addNItems: (size_t)nItems
       fromCArray: (const void*)cArray
{
	if (nItems > SIZE_MAX - count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + nItems
			   ofSize: itemSize];

	memcpy(data + count * itemSize, cArray, nItems * itemSize);
	count += nItems;
}

- (void)addNItems: (size_t)nItems
       fromCArray: (const void*)cArray
	  atIndex: (size_t)index
{
	if (nItems > SIZE_MAX - count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data = [self resizeMemory: data
			 toNItems: count + nItems
			   ofSize: itemSize];

	memmove(data + (index + nItems) * itemSize, data + index * itemSize,
	    (count - index) * itemSize);
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
359
360
361
362
363
364
365
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
359
360
361
362
363
364







-
+









-







-
+











-












-







	[self removeNItems: 1
		   atIndex: index];
}

- (void)removeNItems: (size_t)nItems
{
	if (nItems > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];


	count -= nItems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeNItems: (size_t)nItems
	     atIndex: (size_t)index
{
	if (nItems > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	memmove(data + index * itemSize, data + (index + nItems) * itemSize,
	    (count - index - nItems) * itemSize);

	count -= nItems;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)removeLastItem
{
	count--;
	@try {
		data = [self resizeMemory: data
				 toNItems: count
				   ofSize: itemSize];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't care, as we only made it smaller */
		[e release];
	}
}

- copy
{
	OFDataArray *copy = [[isa alloc] initWithItemSize: itemSize];

390
391
392
393
394
395
396
397
398


399
400
401
402
403


404
405
406
407
408
409
410
389
390
391
392
393
394
395


396
397
398
399
400


401
402
403
404
405
406
407
408
409







-
-
+
+



-
-
+
+







- (of_comparison_result_t)compare: (id)object
{
	OFDataArray *otherDataArray;
	int comparison;
	size_t otherCount, minimumCount;

	if (![object isKindOfClass: [OFDataArray class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];
	otherDataArray = object;

	if ([otherDataArray itemSize] != itemSize)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherCount = [otherDataArray count];
	minimumCount = (count > otherCount ? otherCount : count);

	if ((comparison = memcmp(data, [otherDataArray cArray],
	    minimumCount * itemSize)) == 0) {
		if (count > otherCount)
453
454
455
456
457
458
459
460
461


462
463
464
465
466
467
468
452
453
454
455
456
457
458


459
460
461
462
463
464
465
466
467







-
-
+
+








- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool;
	OFXMLElement *element;

	if (itemSize != 1)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	element = [OFXMLElement
	    elementWithName: [self className]
		  namespace: OF_SERIALIZATION_NS
		stringValue: of_base64_encode(data, count * itemSize)];

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







-
+




















-
+








@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
	size_t newSize, lastPageByte;

	if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	lastPageByte = of_pagesize - 1;
	newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				   toSize: newSize];

	memcpy(data + count * itemSize, item, itemSize);

	count++;
	size = newSize;
}

- (void)addNItems: (size_t)nItems
       fromCArray: (const void*)cArray
{
	size_t newSize, lastPageByte;

	if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	lastPageByte = of_pagesize - 1;
	newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				   toSize: newSize];
519
520
521
522
523
524
525
526

527
528
529
530
531
532
533
518
519
520
521
522
523
524

525
526
527
528
529
530
531
532







-
+







- (void)addNItems: (size_t)nItems
       fromCArray: (const void*)cArray
	  atIndex: (size_t)index
{
	size_t newSize, lastPageByte;

	if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	lastPageByte = of_pagesize - 1;
	newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				 toNItems: newSize
542
543
544
545
546
547
548
549

550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567

568
569
570
571
572
573
574
541
542
543
544
545
546
547

548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565

566
567
568
569
570
571
572
573







-
+

















-
+







}

- (void)removeNItems: (size_t)nItems
{
	size_t newSize, lastPageByte;

	if (nItems > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	count -= nItems;
	lastPageByte = of_pagesize - 1;
	newSize = (count * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize)
		data = [self resizeMemory: data
				   toSize: newSize];
	size = newSize;
}

- (void)removeNItems: (size_t)nItems
	     atIndex: (size_t)index
{
	size_t newSize, lastPageByte;

	if (nItems > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	memmove(data + index * itemSize, data + (index + nItems) * itemSize,
	    (count - index - nItems) * itemSize);

	count -= nItems;
	lastPageByte = of_pagesize - 1;
	newSize = (count * itemSize + lastPageByte) & ~lastPageByte;

Modified src/OFDate.m from [a20bfc7333] to [03b1ee2aba].

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
















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







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

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



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

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


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

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








#if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \
    defined(OF_THREADS)
static OFMutex *mutex;
#endif

#ifdef HAVE_GMTIME_R
# define GMTIME_RET(field)						  \
	time_t seconds_ = (time_t)seconds;				  \
	struct tm tm;							  \
									  \
	if (seconds_ != floor(seconds))					  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
	if (gmtime_r(&seconds_, &tm) == NULL)				  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
# define GMTIME_RET(field)						\
	time_t seconds_ = (time_t)seconds;				\
	struct tm tm;							\
									\
	if (seconds_ != floor(seconds))					\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	if (gmtime_r(&seconds_, &tm) == NULL)				\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	return tm.field;
# define LOCALTIME_RET(field)						  \
	time_t seconds_ = (time_t)seconds;				  \
	struct tm tm;							  \
									  \
	if (seconds_ != floor(seconds))					  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
	if (localtime_r(&seconds_, &tm) == NULL)			  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
# define LOCALTIME_RET(field)						\
	time_t seconds_ = (time_t)seconds;				\
	struct tm tm;							\
									\
	if (seconds_ != floor(seconds))					\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	if (localtime_r(&seconds_, &tm) == NULL)			\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	return tm.field;
#else
# ifdef OF_THREADS
#  define GMTIME_RET(field)						  \
	time_t seconds_ = (time_t)seconds;				  \
	struct tm *tm;							  \
									  \
	if (seconds_ != floor(seconds))					  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
	[mutex lock];							  \
									  \
	@try {								  \
		if ((tm = gmtime(&seconds_)) == NULL)			  \
			@throw [OFOutOfRangeException newWithClass: isa]; \
									  \
		return tm->field;					  \
	} @finally {							  \
		[mutex unlock];						  \
#  define GMTIME_RET(field)						\
	time_t seconds_ = (time_t)seconds;				\
	struct tm *tm;							\
									\
	if (seconds_ != floor(seconds))					\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	[mutex lock];							\
									\
	@try {								\
		if ((tm = gmtime(&seconds_)) == NULL)			\
			@throw [OFOutOfRangeException			\
			    exceptionWithClass: isa];			\
									\
		return tm->field;					\
	} @finally {							\
		[mutex unlock];						\
	}
#  define LOCALTIME_RET(field)						  \
	time_t seconds_ = (time_t)seconds;				  \
	struct tm *tm;							  \
									  \
	if (seconds_ != floor(seconds))					  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
	[mutex lock];							  \
									  \
	@try {								  \
		if ((tm = localtime(&seconds_)) == NULL)		  \
			@throw [OFOutOfRangeException newWithClass: isa]; \
									  \
		return tm->field;					  \
	} @finally {							  \
		[mutex unlock];						  \
#  define LOCALTIME_RET(field)						\
	time_t seconds_ = (time_t)seconds;				\
	struct tm *tm;							\
									\
	if (seconds_ != floor(seconds))					\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	[mutex lock];							\
									\
	@try {								\
		if ((tm = localtime(&seconds_)) == NULL)		\
			@throw [OFOutOfRangeException			\
			    exceptionWithClass: isa];			\
									\
		return tm->field;					\
	} @finally {							\
		[mutex unlock];						\
	}
# else
#  define GMTIME_RET(field)						  \
	time_t seconds_ = (time_t)seconds;				  \
	struct tm *tm;							  \
									  \
	if (seconds_ != floor(seconds))					  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
	if ((tm = gmtime(&seconds_)) == NULL)				  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
#  define GMTIME_RET(field)						\
	time_t seconds_ = (time_t)seconds;				\
	struct tm *tm;							\
									\
	if (seconds_ != floor(seconds))					\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	if ((tm = gmtime(&seconds_)) == NULL)				\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	return tm->field;
#  define LOCALTIME_RET(field)						  \
	time_t seconds_ = (time_t)seconds;				  \
	struct tm *tm;							  \
									  \
	if (seconds_ != floor(seconds))					  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
	if ((tm = localtime(&seconds_)) == NULL)			  \
		@throw [OFOutOfRangeException newWithClass: isa];	  \
									  \
#  define LOCALTIME_RET(field)						\
	time_t seconds_ = (time_t)seconds;				\
	struct tm *tm;							\
									\
	if (seconds_ != floor(seconds))					\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	if ((tm = localtime(&seconds_)) == NULL)			\
		@throw [OFOutOfRangeException exceptionWithClass: isa];	\
									\
	return tm->field;
# endif
#endif

@implementation OFDate
#if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \
    defined(OF_THREADS)
225
226
227
228
229
230
231
232


233
234
235


236
237
238


239
240
241
242
243
244
245
227
228
229
230
231
232
233

234
235
236
237

238
239
240
241

242
243
244
245
246
247
248
249
250







-
+
+


-
+
+


-
+
+







	@try {
		struct tm tm = {};

		tm.tm_isdst = -1;

		if (strptime([string UTF8String], [format UTF8String],
		    &tm) == NULL)
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		if (tm.tm_gmtoff)
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		if ((seconds = mktime(&tm)) == -1)
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		seconds += tm.tm_gmtoff;
	} @catch (id e) {
		[self release];
		@throw e;
	}

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







-
+
+


-
+
+

















-
-
+
+
+







	@try {
		struct tm tm = {};

		tm.tm_isdst = -1;

		if (strptime([string UTF8String], [format UTF8String],
		    &tm) == NULL)
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		if ((seconds = mktime(&tm)) == -1)
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		seconds = [element doubleValue];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
335
336
337
338
339
340
341
342
343


344
345
346
347
348
349
350
343
344
345
346
347
348
349


350
351
352
353
354
355
356
357
358







-
-
+
+







}

- (of_comparison_result_t)compare: (id)object
{
	OFDate *otherDate;

	if (![object isKindOfClass: [OFDate class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherDate = object;

	if (seconds < otherDate->seconds)
		return OF_ORDERED_ASCENDING;
	if (seconds > otherDate->seconds)
		return OF_ORDERED_DESCENDING;
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
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
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
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
543
544
545
546
547
548







-
+



-
+









-
+













-
+

















-
+



-
+









-
+













-
+







{
	OFString *ret;
	time_t seconds_ = (time_t)seconds;
	struct tm tm;
	char *buffer;

	if (seconds_ != floor(seconds))
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

#ifdef HAVE_GMTIME_R
	if (gmtime_r(&seconds_, &tm) == NULL)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];
#else
# ifdef OF_THREADS
	[mutex lock];

	@try {
# endif
		struct tm *tmp;

		if ((tmp = gmtime(&seconds_)) == NULL)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		tm = *tmp;
# ifdef OF_THREADS
	} @finally {
		[mutex unlock];
	}
# endif
#endif

	buffer = [self allocMemoryWithSize: of_pagesize];

	@try {
		if (!strftime(buffer, of_pagesize, [format UTF8String], &tm))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		ret = [OFString stringWithUTF8String: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;
}

- (OFString*)localDateStringWithFormat: (OFConstantString*)format
{
	OFString *ret;
	time_t seconds_ = (time_t)seconds;
	struct tm tm;
	char *buffer;

	if (seconds_ != floor(seconds))
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

#ifdef HAVE_LOCALTIME_R
	if (localtime_r(&seconds_, &tm) == NULL)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];
#else
# ifdef OF_THREADS
	[mutex lock];

	@try {
# endif
		struct tm *tmp;

		if ((tmp = localtime(&seconds_)) == NULL)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		tm = *tmp;
# ifdef OF_THREADS
	} @finally {
		[mutex unlock];
	}
# endif
#endif

	buffer = [self allocMemoryWithSize: of_pagesize];

	@try {
		if (!strftime(buffer, of_pagesize, [format UTF8String], &tm))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		ret = [OFString stringWithUTF8String: buffer];
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;

Modified src/OFDictionary.m from [26000249ed] to [9dbdf6b2a1].

95
96
97
98
99
100
101
102
103


104
105
106
107
108
109
110
95
96
97
98
99
100
101


102
103
104
105
106
107
108
109
110







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFDictionary
+ (void)initialize
{
158
159
160
161
162
163
164
165
166


167
168
169
170
171
172
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
158
159
160
161
162
163
164


165
166
167
168
169
170
171
172
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







-
-
+
+









-
-
+
+













-
-
+
+




















-
-
+
+






-
-
+
+




-
-
+
+




-
-
+
+







}

- init
{
	if (isa == [OFDictionary class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- initWithDictionary: (OFDictionary*)dictionary
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithObject: (id)object
	  forKey: (id)key
{
	return [self initWithKeysAndObjects: key, object, nil];
}

- initWithObjects: (OFArray*)objects
	  forKeys: (OFArray*)keys
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithKeysAndObjects: (id)firstKey, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstKey);
	ret = [self initWithKey: firstKey
		      arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithKey: (id)firstKey
    arguments: (va_list)arguments
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithSerialization: (OFXMLElement*)element
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (id)objectForKey: (id)key
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (size_t)count
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- copy
{
	return [self retain];
}

365
366
367
368
369
370
371
372
373


374
375
376
377
378
379


380
381
382
383
384
385
386
387


388
389
390
391
392
393
394
365
366
367
368
369
370
371


372
373
374
375
376
377


378
379
380
381
382
383
384
385


386
387
388
389
390
391
392
393
394







-
-
+
+




-
-
+
+






-
-
+
+







	}

	return ret;
}

- (OFEnumerator*)objectEnumerator
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (OFEnumerator*)keyEnumerator
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{
	BOOL stop = NO;

Modified src/OFDictionary_hashtable.m from [a4202c2dfc] to [e193cfb1d7].

63
64
65
66
67
68
69
70
71



72
73
74
75
76
77
78



79
80
81
82
83
84
85
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







-
-
+
+
+





-
-
+
+
+







	self = [super init];

	@try {
		uint32_t i;
		OFDictionary_hashtable *hashtable;

		if (dictionary == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		if (![dictionary isKindOfClass:
		    [OFDictionary_hashtable class]] &&
		    ![dictionary isKindOfClass:
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		hashtable = (OFDictionary_hashtable*)dictionary;

		data = [self allocMemoryForNItems: hashtable->size
					   ofSize: sizeof(*data)];

		for (i = 0; i < hashtable->size; i++)
126
127
128
129
130
131
132
133

134
135
136
137
138

139
140
141
142
143
144
145
128
129
130
131
132
133
134

135
136
137
138
139

140
141
142
143
144
145
146
147







-
+




-
+







		OFEnumerator *enumerator;
		id key;
		uint32_t i, newSize;

		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);

		if (newSize == 0)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];

		for (i = 0; i < newSize; i++)
			data[i] = NULL;

164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
166
167
168
169
170
171
172

173
174
175
176
177
178
179
180







-
+







				last = hash & (size - 1);

				for (i = 0; i < last && data[i] != NULL; i++);
			}

			if (data[i] != NULL)
				@throw [OFOutOfRangeException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			bucket = [self allocMemoryWithSize: sizeof(*bucket)];

			object = [dictionary objectForKey: key];

			bucket->key = [key copy];
			bucket->object = [object retain];
196
197
198
199
200
201
202
203
204



205
206
207
208
209
210
211
198
199
200
201
202
203
204


205
206
207
208
209
210
211
212
213
214







-
-
+
+
+







	self = [super init];

	@try {
		uint32_t i;
		struct of_dictionary_hashtable_bucket *bucket;

		if (key == nil || object == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		data = [self allocMemoryForNItems: 2
					   ofSize: sizeof(*data)];

		size = 2;
		for (i = 0; i < size; i++)
			data[i] = NULL;
237
238
239
240
241
242
243
244

245
246
247
248
249

250
251
252
253
254
255
256
240
241
242
243
244
245
246

247
248
249
250
251

252
253
254
255
256
257
258
259







-
+




-
+







		uint32_t i, j, newSize;

		keysCArray = [keys cArray];
		objectsCArray = [objects cArray];
		count = [keys count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);

		if (newSize == 0)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];

		for (j = 0; j < newSize; j++)
			data[j] = NULL;

294
295
296
297
298
299
300
301

302
303
304
305
306
307
308
297
298
299
300
301
302
303

304
305
306
307
308
309
310
311







-
+








					for (j = 0; j < last && data[j] != NULL;
					    j++);
				}

				if (j >= last)
					@throw [OFOutOfRangeException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				bucket =
				    [self allocMemoryWithSize: sizeof(*bucket)];
				key = [keysCArray[i] copy];

				bucket->key = key;
				bucket->object = [objectsCArray[i] retain];
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
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
375
376
377
378
379







-
-
+
+
+




-
-
+
+
+






-
+




-
+







		uint32_t i, j, hash, newSize;
		va_list argumentsCopy;
		struct of_dictionary_hashtable_bucket *bucket;

		va_copy(argumentsCopy, arguments);

		if (firstKey == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		key = firstKey;

		if ((object = va_arg(arguments, id)) == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		count = 1;
		for (; va_arg(argumentsCopy, id) != nil; count++);
		count >>= 1;

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		for (newSize = 1; newSize < count; newSize <<= 1);

		if (newSize == 0)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryForNItems: newSize
					   ofSize: sizeof(*data)];

		for (j = 0; j < newSize; j++)
			data[j] = NULL;

389
390
391
392
393
394
395
396
397


398
399
400
401
402
403
404
394
395
396
397
398
399
400


401
402
403
404
405
406
407
408
409







-
-
+
+







			uint32_t last;

			key = va_arg(arguments, id);
			object = va_arg(arguments, id);

			if (key == nil || object == nil)
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];
				    exceptionWithClass: isa
					      selector: _cmd];

			hash = [key hash];
			last = size;

			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([data[j]->key isEqual: key])
427
428
429
430
431
432
433
434

435
436
437
438
439
440
441
432
433
434
435
436
437
438

439
440
441
442
443
444
445
446







-
+








					for (j = 0; j < last && data[j] != NULL;
					    j++);
				}

				if (j >= last)
					@throw [OFOutOfRangeException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				bucket =
				    [self allocMemoryWithSize: sizeof(*bucket)];
				bucket->key = [key copy];
				bucket->object = [object retain];
				bucket->hash = hash;

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







-
-
+
+
+









-
+
+
















-
+







		OFArray *keys, *objects;
		OFEnumerator *keyEnumerator, *objectEnumerator;
		OFXMLElement *keyElement, *objectElement;

		if ((![[element name] isEqual: @"OFDictionary"] &&
		    ![[element name] isEqual: @"OFMutableDictionary"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		dictionary = [OFMutableDictionary dictionary];

		keys = [element elementsForName: @"key"
				      namespace: OF_SERIALIZATION_NS];
		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		if ([keys count] != [objects count])
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		keyEnumerator = [keys objectEnumerator];
		objectEnumerator = [objects objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((keyElement = [keyEnumerator nextObject]) != nil &&
		    (objectElement = [objectEnumerator nextObject]) != nil) {
			OFXMLElement *key, *object;

			key = [[keyElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			object = [[objectElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];

			if (key == nil || object == nil)
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			[dictionary setObject: [object objectByDeserializing]
				       forKey: [key objectByDeserializing]];

			[pool2 releaseObjects];
		}

524
525
526
527
528
529
530
531
532


533
534
535
536
537
538
539
531
532
533
534
535
536
537


538
539
540
541
542
543
544
545
546







-
-
+
+







}

- (id)objectForKey: (id)key
{
	uint32_t i, hash, last;

	if (key == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	hash = [key hash];
	last = size;

	for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
		if (data[i] == DELETED)
			continue;
767
768
769
770
771
772
773
774
775


776
777
778
779
780
781
782
783
784
785
786
787


788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805


806
807
808
809
810
811
812
813
814
815
774
775
776
777
778
779
780


781
782
783
784
785
786
787
788
789
790
791
792


793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810


811
812
813
814
815
816
817
818
819
820
821
822







-
-
+
+










-
-
+
+
















-
-
+
+










	[super dealloc];
}

- (void)reset
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException
		    newWithClass: isa
			  object: dictionary];
		    exceptionWithClass: isa
				object: dictionary];

	pos = 0;
}
@end

@implementation OFDictionaryObjectEnumerator_hashtable
- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException
		    newWithClass: isa
			  object: dictionary];
		    exceptionWithClass: isa
				object: dictionary];

	for (; pos < size && (data[pos] == NULL ||
	    data[pos] == DELETED); pos++);

	if (pos < size)
		return data[pos++]->object;
	else
		return nil;
}
@end

@implementation OFDictionaryKeyEnumerator_hashtable
- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException
		    newWithClass: isa
			  object: dictionary];
		    exceptionWithClass: isa
				object: dictionary];

	for (; pos < size && (data[pos] == NULL ||
	    data[pos] == DELETED); pos++);

	if (pos < size)
		return data[pos++]->key;
	else
		return nil;
}
@end

Modified src/OFDoubleMatrix.m from [8e0af9d60e] to [9473f8f25c].

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







-
-
+
+














-
+



-
-
+
+
+







	return ret;
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithRows: (size_t)rows_
       columns: (size_t)columns_
{
	self = [super init];

	@try {
		rows = rows_;
		columns = columns_;

		if (SIZE_MAX / rows < columns ||
		    SIZE_MAX / rows * columns < sizeof(double))
			@throw [OFOutOfRangeException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		if ((data = malloc(rows * columns * sizeof(double))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(double)];
			     exceptionWithClass: isa
				  requestedSize: rows * columns *
						 sizeof(double)];

		memset(data, 0, rows * columns * sizeof(double));

		if (rows == columns) {
			size_t i;

			for (i = 0; i < rows * columns; i += rows + 1)
135
136
137
138
139
140
141
142

143
144
145
146
147



148
149
150
151
152
153
154
136
137
138
139
140
141
142

143
144
145
146


147
148
149
150
151
152
153
154
155
156







-
+



-
-
+
+
+







		size_t i;

		rows = rows_;
		columns = columns_;

		if (SIZE_MAX / rows < columns ||
		    SIZE_MAX / rows * columns < sizeof(double))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		if ((data = malloc(rows * columns * sizeof(double))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(double)];
			     exceptionWithClass: isa
				  requestedSize: rows * columns *
						 sizeof(double)];

		for (i = 0; i < rows; i++) {
			size_t j;

			for (j = i; j < rows * columns; j += rows)
				data[j] = (j == 0
				    ? data_ : va_arg(arguments, double));
169
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
194







-
+








-
+







}

- (void)setValue: (double)value
	  forRow: (size_t)row
	  column: (size_t)column
{
	if (row >= rows || column >= columns)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data[row * columns + column] = value;
}

- (double)valueForRow: (size_t)row
	       column: (size_t)column
{
	if (row >= rows || column >= columns)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return data[row * columns + column];
}

- (size_t)rows
{
	return rows;
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
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







-
-
+
+











-
-
+
+








- (void)addMatrix: (OFDoubleMatrix*)matrix
{
	size_t i;

	if (matrix->isa != isa || matrix->rows != rows ||
	    matrix->columns != columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < rows * columns; i++)
		data[i] += matrix->data[i];
}

- (void)subtractMatrix: (OFDoubleMatrix*)matrix
{
	size_t i;

	if (matrix->isa != isa || matrix->rows != rows ||
	    matrix->columns != columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < rows * columns; i++)
		data[i] -= matrix->data[i];
}


- (void)multiplyWithScalar: (double)scalar
333
334
335
336
337
338
339
340
341


342
343
344
345
346



347
348
349
350
351
352
353
335
336
337
338
339
340
341


342
343
344
345
346


347
348
349
350
351
352
353
354
355
356







-
-
+
+



-
-
+
+
+








- (void)multiplyWithMatrix: (OFDoubleMatrix*)matrix
{
	double *newData;
	size_t i, base1, base2;

	if (rows != matrix->columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if ((newData = malloc(matrix->rows * columns * sizeof(double))) == NULL)
		@throw [OFOutOfMemoryException
		     newWithClass: isa
		    requestedSize: matrix->rows * columns * sizeof(double)];
		     exceptionWithClass: isa
			  requestedSize: matrix->rows * columns *
					 sizeof(double)];

	base1 = 0;
	base2 = 0;

	for (i = 0; i < columns; i++) {
		size_t base3 = base2;
		size_t j;
380
381
382
383
384
385
386
387
388



389
390
391
392
393
394
395
396
383
384
385
386
387
388
389


390
391
392

393
394
395
396
397
398
399







-
-
+
+
+
-








- (void)transpose
{
	double *newData;
	size_t i, k;

	if ((newData = malloc(rows * columns * sizeof(double))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: rows * columns *
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: rows * columns * sizeof(double)];
							     sizeof(double)];

	rows ^= columns;
	columns ^= rows;
	rows ^= columns;

	for (i = k = 0; i < rows; i++) {
		size_t j;
406
407
408
409
410
411
412
413
414


415
416
417
418
419
420
421
409
410
411
412
413
414
415


416
417
418
419
420
421
422
423
424







-
-
+
+







- (void)translateWithVector: (OFDoubleVector*)vector
{
	OFDoubleMatrix *translation;
	double *cArray;

	if (rows != columns || vector->isa != doubleVector ||
	    vector->dimension != rows - 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	cArray = [vector cArray];
	translation = [[OFDoubleMatrix alloc] initWithRows: rows
						  columns: columns];

	memcpy(translation->data + (columns - 1) * rows, cArray,
	    (rows - 1) * sizeof(double));
431
432
433
434
435
436
437
438
439


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


441
442
443
444
445
446
447
448
449







-
-
+
+







		   angle: (double)angle
{
	OFDoubleMatrix *rotation;
	double n[3], m, angleCos, angleSin;

	if (rows != 4 || columns != 4 || vector->isa != doubleVector ||
	    vector->dimension != 3)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	n[0] = vector->data[0];
	n[1] = vector->data[1];
	n[2] = vector->data[2];

	m = sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);

480
481
482
483
484
485
486
487
488


489
490
491
492
493
494
495
483
484
485
486
487
488
489


490
491
492
493
494
495
496
497
498







-
-
+
+







{
	OFDoubleMatrix *scale;
	double *cArray;
	size_t i, j;

	if (rows != columns || vector->isa != doubleVector ||
	    vector->dimension != rows - 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	cArray = [vector cArray];
	scale = [[OFDoubleMatrix alloc] initWithRows: rows
					    columns: columns];

	for (i = j = 0; i < ((rows - 1) * columns) - 1; i += rows + 1)
		scale->data[i] = cArray[j++];

Modified src/OFDoubleVector.m from [3c930c2cbc] to [83bd61c36b].

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







-
-
+
+










-
+



-
-
+
+







	return ret;
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithDimension: (size_t)dimension_
{
	self = [super init];

	@try {
		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(double))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		if ((data = malloc(dimension * sizeof(double))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(double)];
			     exceptionWithClass: isa
				  requestedSize: dimension * sizeof(double)];

		memset(data, 0, dimension * sizeof(double));
	} @catch (id e) {
		[self release];
		@throw e;
	}

115
116
117
118
119
120
121
122

123
124
125
126
127


128
129
130
131
132
133
134
115
116
117
118
119
120
121

122
123
124
125


126
127
128
129
130
131
132
133
134







-
+



-
-
+
+








	@try {
		size_t i;

		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(double))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		if ((data = malloc(dimension * sizeof(double))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(double)];
			     exceptionWithClass: isa
				  requestedSize: dimension * sizeof(double)];

		data[0] = data_;
		for (i = 1; i < dimension; i++)
			data[i] = va_arg(arguments, double);
	} @catch (id e) {
		[self release];
		@throw e;
144
145
146
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
179
180
181
182
183
184
144
145
146
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
179
180
181
182
183
184







-
+







-
+















-
-
+
+
+
-







	[super dealloc];
}

- (void)setValue: (double)value
	 atIndex: (size_t)index
{
	if (index >= dimension)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data[index] = value;
}

- (double)valueAtIndex: (size_t)index
{
	if (index >= dimension)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return data[index];
}

- (size_t)dimension
{
	return dimension;
}

- (void)setDimension: (size_t)dimension_
{
	double *newData;
	size_t i;

	if ((newData = realloc(data, dimension_ * sizeof(double))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: dimension_ *
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: dimension_ * sizeof(double)];
							     sizeof(double)];

	data = newData;

	for (i = dimension; i < dimension_; i++)
		data[i] = 0;

	dimension = dimension_;
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
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







-
-
+
+










-
-
+
+







}

- (void)addVector: (OFDoubleVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] += vector->data[i];
}

- (void)subtractVector: (OFDoubleVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] -= vector->data[i];
}

- (void)multiplyWithScalar: (double)scalar
{
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
359
360
361
362
363
364
365
366


367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382


383
384
385
386


387
388
389
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
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
359
360
361
362
363
364


365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380


381
382
383
384


385
386
387
388
389
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







-
-
+
+










-
-
+
+











-
-
+
+














-
-
+
+


-
-
+
+



















-
-
+
+



-
-
+
+







}

- (void)multiplyWithComponentsOfVector: (OFDoubleVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] *= vector->data[i];
}

- (void)divideByComponentsOfVector: (OFDoubleVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] /= vector->data[i];
}

- (double)dotProductWithVector: (OFDoubleVector*)vector
{
	double dotProduct;
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	dotProduct = 0.0;

	for (i = 0; i < dimension; i++)
		dotProduct += data[i] * vector->data[i];

	return dotProduct;
}

- (OFDoubleVector*)crossProductWithVector: (OFDoubleVector*)vector
{
	OFDoubleVector *crossProduct;

	if (dimension != 3)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];

	if (vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	crossProduct = [OFDoubleVector vectorWithDimension: 3];

	crossProduct->data[0] =
	    data[1] * vector->data[2] - data[2] * vector->data[1];
	crossProduct->data[1] =
	    data[2] * vector->data[0] - data[0] * vector->data[2];
	crossProduct->data[2] =
	    data[0] * vector->data[1] - data[1] * vector->data[0];

	return crossProduct;
}

- (void)multiplyWithMatrix: (OFDoubleMatrix*)matrix
{
	double *newData;
	size_t i, j, k;

	if (matrix->isa != doubleMatrix || dimension != matrix->columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if ((newData = malloc(matrix->rows * sizeof(double))) == NULL)
		@throw [OFOutOfMemoryException
		     newWithClass: isa
		    requestedSize: matrix->rows * sizeof(double)];
		     exceptionWithClass: isa
			  requestedSize: matrix->rows * sizeof(double)];

	memset(newData, 0, matrix->rows * sizeof(double));

	for (i = j = k = 0; i < matrix->rows * matrix->columns; i++) {
		newData[j] += matrix->data[i] * data[k];

		if (++j == matrix->rows) {

Modified src/OFEnumerator.m from [0110d1af9e] to [322f8fbdbb].

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







-
-
+
+







-
-
+
+




-
-
+
+



@implementation OFEnumerator
- init
{
	if (isa == [OFEnumerator class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- (id)nextObject
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)reset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}
@end

Modified src/OFFile.m from [689b4e3ed7] to [c6a9166c97].

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







-
-
+
+
+













-
-
+
+







{
#ifndef _WIN32
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    DIR_MODE))
#else
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
		@throw [OFCreateDirectoryFailedException newWithClass: self
								 path: path];
		@throw [OFCreateDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

+ (OFArray*)filesInDirectoryAtPath: (OFString*)path
{
	OFAutoreleasePool *pool;
	OFMutableArray *files = [OFMutableArray array];

#ifndef _WIN32
	DIR *dir;
	struct dirent *dirent;

	if ((dir = opendir([path cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL)
		@throw [OFOpenFileFailedException newWithClass: self
							  path: path
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
							  mode: @"r"];

	@try {
		pool = [[OFAutoreleasePool alloc] init];

		while ((dirent = readdir(dir)) != NULL) {
			OFString *file;
278
279
280
281
282
283
284
285
286
287



288
289
290
291
292
293
294
279
280
281
282
283
284
285



286
287
288
289
290
291
292
293
294
295







-
-
-
+
+
+







	WIN32_FIND_DATA fd;

	pool = [[OFAutoreleasePool alloc] init];
	path = [path stringByAppendingString: @"\\*"];

	if ((handle = FindFirstFile([path cString], &fd)) ==
	    INVALID_HANDLE_VALUE)
		@throw [OFOpenFileFailedException newWithClass: self
							  path: path
							  mode: @"r"];
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	@try {
		OFAutoreleasePool *pool2 = [[OFAutoreleasePool alloc] init];

		do {
			OFString *file;

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
359
360
361
362
363
364



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380


381
382
383
384
385
386
387
388
389
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
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
359
360
361
362
363
364
365
366



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383


384
385
386
387
388
389
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







-
-
+
+
+








-
-
-
+
+
+
+




-
-
-
+
+
+
+







-
-
-
+
+
+
+











-
-
-
+
+
+














-
-
+
+












-
-
-
-
+
+
+
+










-
-
-
-
+
+
+
+











-
-
-
-
+
+
+
+
+








	return files;
}

+ (void)changeToDirectory: (OFString*)path
{
	if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
		@throw [OFChangeDirectoryFailedException newWithClass: self
								 path: path];
		@throw [OFChangeDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

#ifndef _PSP
+ (void)changeModeOfFile: (OFString*)path
		  toMode: (mode_t)mode
{
# ifndef _WIN32
	if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode))
		@throw [OFChangeFileModeFailedException newWithClass: self
								path: path
								mode: mode];
		@throw [OFChangeFileModeFailedException
		    exceptionWithClass: self
				  path: path
				  mode: mode];
# else
	DWORD attributes = GetFileAttributes([path cString]);

	if (attributes == INVALID_FILE_ATTRIBUTES)
		@throw [OFChangeFileModeFailedException newWithClass: self
								path: path
								mode: mode];
		@throw [OFChangeFileModeFailedException
		    exceptionWithClass: self
				  path: path
				  mode: mode];

	if ((mode / 100) & 2)
		attributes &= ~FILE_ATTRIBUTE_READONLY;
	else
		attributes |= FILE_ATTRIBUTE_READONLY;

	if (!SetFileAttributes([path cString], attributes))
		@throw [OFChangeFileModeFailedException newWithClass: self
								path: path
								mode: mode];
		@throw [OFChangeFileModeFailedException
		    exceptionWithClass: self
				  path: path
				  mode: mode];
# endif
}
#endif

+ (OFDate*)modificationDateOfFile: (OFString*)path
{
	struct stat s;

	if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    &s) == -1)
		/* FIXME: Maybe use another exception? */
		@throw [OFOpenFileFailedException newWithClass: self
							  path: path
							  mode: @"r"];
		@throw [OFOpenFileFailedException exceptionWithClass: self
								path: path
								mode: @"r"];

	/* FIXME: We could be more precise on some OSes */
	return [OFDate dateWithTimeIntervalSince1970: s.st_mtime];
}

#if !defined(_WIN32) && !defined(_PSP)
+ (void)changeOwnerOfFile: (OFString*)path
		  toOwner: (OFString*)owner
		    group: (OFString*)group
{
	uid_t uid = -1;
	gid_t gid = -1;

	if (owner == nil && group == nil)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

# ifdef OF_THREADS
	[mutex lock];

	@try {
# endif
		if (owner != nil) {
			struct passwd *passwd;

			if ((passwd = getpwnam([owner cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFChangeFileOwnerFailedException
				    newWithClass: self
					    path: path
					   owner: owner
					   group: group];
				    exceptionWithClass: self
						  path: path
						 owner: owner
						 group: group];

			uid = passwd->pw_uid;
		}

		if (group != nil) {
			struct group *group_;

			if ((group_ = getgrnam([group cStringWithEncoding:
			    OF_STRING_ENCODING_NATIVE])) == NULL)
				@throw [OFChangeFileOwnerFailedException
				    newWithClass: self
					    path: path
					   owner: owner
					   group: group];
				    exceptionWithClass: self
						  path: path
						 owner: owner
						 group: group];

			gid = group_->gr_gid;
		}
# ifdef OF_THREADS
	} @finally {
		[mutex unlock];
	}
# endif

	if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    uid, gid))
		@throw [OFChangeFileOwnerFailedException newWithClass: self
								 path: path
								owner: owner
								group: group];
		@throw [OFChangeFileOwnerFailedException
		    exceptionWithClass: self
				  path: path
				 owner: owner
				 group: group];
}
#endif

+ (void)copyFileAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
440
441
442
443
444
445
446
447
448


449
450
451
452
453
454
455
446
447
448
449
450
451
452


453
454
455
456
457
458
459
460
461







-
-
+
+







		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	override = [self fileExistsAtPath: destination];

	if ((buffer = malloc(of_pagesize)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: self
					      requestedSize: of_pagesize];
		@throw [OFOutOfMemoryException exceptionWithClass: self
						    requestedSize: of_pagesize];

	@try {
		sourceFile = [OFFile fileWithPath: source
					     mode: @"rb"];
		destinationFile = [OFFile fileWithPath: destination
						  mode: @"wb"];

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
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562




563
564
565
566
567
568
569
570
571
572
573


574
575
576
577
578
579
580
581
582
583
584
585
586
587



588
589
590
591
592
593




594
595
596
597
598
599
600
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
543
544
545



546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567



568
569
570
571
572
573
574
575
576
577
578
579
580


581
582
583
584
585
586
587
588
589
590
591
592
593
594


595
596
597
598
599
600



601
602
603
604
605
606
607
608
609
610
611







-
-
-
+
+
+
+











-
-
+
+





-
-
+
+
+
















-
-
-
+
+
+



















-
-
-
+
+
+
+









-
-
+
+












-
-
+
+
+



-
-
-
+
+
+
+







#ifndef _WIN32
	if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (!MoveFile([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
		@throw [OFRenameFileFailedException newWithClass: self
						      sourcePath: source
						 destinationPath: destination];
		@throw [OFRenameFileFailedException
		    exceptionWithClass: self
			    sourcePath: source
		       destinationPath: destination];

	[pool release];
}

+ (void)deleteFileAtPath: (OFString*)path
{
#ifndef _WIN32
	if (unlink([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (!DeleteFile([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
		@throw [OFDeleteFileFailedException newWithClass: self
							    path: path];
		@throw [OFDeleteFileFailedException exceptionWithClass: self
								  path: path];
}

+ (void)deleteDirectoryAtPath: (OFString*)path
{
	if (rmdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
		@throw [OFDeleteDirectoryFailedException newWithClass: self
								 path: path];
		@throw [OFDeleteDirectoryFailedException
		    exceptionWithClass: self
				  path: path];
}

#ifndef _WIN32
+ (void)linkFileAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	if ([self directoryExistsAtPath: destination]) {
		OFString *filename = [source lastPathComponent];
		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
		@throw [OFLinkFailedException newWithClass: self
						sourcePath: source
					   destinationPath: destination];
		@throw [OFLinkFailedException exceptionWithClass: self
						      sourcePath: source
						 destinationPath: destination];

	[pool release];
}
#endif

#if !defined(_WIN32) && !defined(_PSP)
+ (void)symlinkFileAtPath: (OFString*)source
		   toPath: (OFString*)destination
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	if ([self directoryExistsAtPath: destination]) {
		OFString *filename = [source lastPathComponent];
		destination = [OFString stringWithPath: destination, filename,
							nil];
	}

	if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0)
		@throw [OFSymlinkFailedException newWithClass: self
						   sourcePath: source
					      destinationPath: destination];
		@throw [OFSymlinkFailedException
		    exceptionWithClass: self
			    sourcePath: source
		       destinationPath: destination];

	[pool release];
}
#endif

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithPath: (OFString*)path
	  mode: (OFString*)mode
{
	self = [super init];

	@try {
		int flags;

		if ((flags = parse_mode([mode cStringWithEncoding:
		    OF_STRING_ENCODING_NATIVE])) == -1)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		if ((fileDescriptor = open([path cStringWithEncoding:
		    OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1)
			@throw [OFOpenFileFailedException newWithClass: isa
								  path: path
								  mode: mode];
			@throw [OFOpenFileFailedException
			    exceptionWithClass: isa
					  path: path
					  mode: mode];

		closable = YES;
	} @catch (id e) {
		[self release];
		@throw e;
	}

620
621
622
623
624
625
626
627
628
629



630
631
632
633
634
635
636
637
638
639
640
641
642
643
644



645
646
647
648
649
650
651
652
653




654
655
656
657
658
659
660
661
662
663
664




665
666
667
668
669
670
671
672
673
674
675
676
677




678
679
680
681
682
683
684
631
632
633
634
635
636
637



638
639
640
641
642
643
644
645
646
647
648
649
650
651
652



653
654
655
656
657
658
659
660




661
662
663
664
665
666
667
668
669
670
671




672
673
674
675
676
677
678
679
680
681
682
683
684




685
686
687
688
689
690
691
692
693
694
695







-
-
-
+
+
+












-
-
-
+
+
+





-
-
-
-
+
+
+
+







-
-
-
-
+
+
+
+









-
-
-
-
+
+
+
+








- (size_t)_readNBytes: (size_t)length
	   intoBuffer: (void*)buffer
{
	size_t ret;

	if (fileDescriptor == -1 || atEndOfStream)
		@throw [OFReadFailedException newWithClass: isa
						    stream: self
					   requestedLength: length];
		@throw [OFReadFailedException exceptionWithClass: isa
							  stream: self
						 requestedLength: length];

	if ((ret = read(fileDescriptor, buffer, length)) == 0)
		atEndOfStream = YES;

	return ret;
}

- (void)_writeNBytes: (size_t)length
	  fromBuffer: (const void*)buffer
{
	if (fileDescriptor == -1 || atEndOfStream ||
	    write(fileDescriptor, buffer, length) < length)
		@throw [OFWriteFailedException newWithClass: isa
						     stream: self
					    requestedLength: length];
		@throw [OFWriteFailedException exceptionWithClass: isa
							   stream: self
						  requestedLength: length];
}

- (void)_seekToOffset: (off_t)offset
{
	if (lseek(fileDescriptor, offset, SEEK_SET) == -1)
		@throw [OFSeekFailedException newWithClass: isa
						    stream: self
						    offset: offset
						    whence: SEEK_SET];
		@throw [OFSeekFailedException exceptionWithClass: isa
							  stream: self
							  offset: offset
							  whence: SEEK_SET];
}

- (off_t)_seekForwardWithOffset: (off_t)offset
{
	off_t ret;

	if ((ret = lseek(fileDescriptor, offset, SEEK_CUR)) == -1)
		@throw [OFSeekFailedException newWithClass: isa
						    stream: self
						    offset: offset
						    whence: SEEK_CUR];
		@throw [OFSeekFailedException exceptionWithClass: isa
							  stream: self
							  offset: offset
							  whence: SEEK_CUR];

	return ret;
}

- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
	off_t ret;

	if ((ret = lseek(fileDescriptor, offset, SEEK_END)) == -1)
		@throw [OFSeekFailedException newWithClass: isa
						    stream: self
						    offset: offset
						    whence: SEEK_END];
		@throw [OFSeekFailedException exceptionWithClass: isa
							  stream: self
							  offset: offset
							  whence: SEEK_END];

	return ret;
}

- (int)fileDescriptor
{
	return fileDescriptor;
703
704
705
706
707
708
709
710
711


712
713
714
715
716
717
718
714
715
716
717
718
719
720


721
722
723
724
725
726
727
728
729







-
-
+
+








@implementation OFFileSingleton
- initWithPath: (OFString*)path
	  mode: (OFString*)mode
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- autorelease
{
	return self;
}

728
729
730
731
732
733
734
735
736


737
738
739
740
741
742
743


744
745
746
747
748
749


750
751
752
753
754
755


756
757
739
740
741
742
743
744
745


746
747
748
749
750
751
752


753
754
755
756
757
758


759
760
761
762
763
764


765
766
767
768







-
-
+
+





-
-
+
+




-
-
+
+




-
-
+
+


- (unsigned int)retainCount
{
	return OF_RETAIN_COUNT_MAX;
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of stupid warning */
}

- (void)_seekToOffset: (off_t)offset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (off_t)_seekForwardWithOffset: (off_t)offset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}
@end

Modified src/OFFloatMatrix.m from [0e7f420221] to [077edbfb6d].

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







-
-
+
+













-
+
-



-
-
+
+
+







	return ret;
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithRows: (size_t)rows_
       columns: (size_t)columns_
{
	self = [super init];

	@try {
		rows = rows_;
		columns = columns_;

		if (SIZE_MAX / rows < columns ||
		    SIZE_MAX / rows * columns < sizeof(float))
			@throw [OFOutOfRangeException
			@throw [OFOutOfRangeException exceptionWithClass: isa];
			    newWithClass: isa];

		if ((data = malloc(rows * columns * sizeof(float))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(float)];
			     exceptionWithClass: isa
				  requestedSize: rows * columns *
						 sizeof(float)];

		memset(data, 0, rows * columns * sizeof(float));

		if (rows == columns) {
			size_t i;

			for (i = 0; i < rows * columns; i += rows + 1)
135
136
137
138
139
140
141
142

143
144
145
146
147



148
149
150
151
152
153
154
135
136
137
138
139
140
141

142
143
144
145


146
147
148
149
150
151
152
153
154
155







-
+



-
-
+
+
+







		size_t i;

		rows = rows_;
		columns = columns_;

		if (SIZE_MAX / rows < columns ||
		    SIZE_MAX / rows * columns < sizeof(float))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		if ((data = malloc(rows * columns * sizeof(float))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: rows * columns * sizeof(float)];
			     exceptionWithClass: isa
				  requestedSize: rows * columns *
						 sizeof(float)];

		for (i = 0; i < rows; i++) {
			size_t j;

			for (j = i; j < rows * columns; j += rows)
				data[j] = (j == 0
				    ? data_ : (float)va_arg(arguments, double));
169
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193







-
+








-
+







}

- (void)setValue: (float)value
	  forRow: (size_t)row
	  column: (size_t)column
{
	if (row >= rows || column >= columns)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data[row * columns + column] = value;
}

- (float)valueForRow: (size_t)row
	      column: (size_t)column
{
	if (row >= rows || column >= columns)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return data[row * columns + column];
}

- (size_t)rows
{
	return rows;
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
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







-
-
+
+











-
-
+
+








- (void)addMatrix: (OFFloatMatrix*)matrix
{
	size_t i;

	if (matrix->isa != isa || matrix->rows != rows ||
	    matrix->columns != columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < rows * columns; i++)
		data[i] += matrix->data[i];
}

- (void)subtractMatrix: (OFFloatMatrix*)matrix
{
	size_t i;

	if (matrix->isa != isa || matrix->rows != rows ||
	    matrix->columns != columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < rows * columns; i++)
		data[i] -= matrix->data[i];
}


- (void)multiplyWithScalar: (float)scalar
333
334
335
336
337
338
339
340
341


342
343
344
345
346



347
348
349
350
351
352
353
334
335
336
337
338
339
340


341
342
343
344
345


346
347
348
349
350
351
352
353
354
355







-
-
+
+



-
-
+
+
+








- (void)multiplyWithMatrix: (OFFloatMatrix*)matrix
{
	float *newData;
	size_t i, base1, base2;

	if (rows != matrix->columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if ((newData = malloc(matrix->rows * columns * sizeof(float))) == NULL)
		@throw [OFOutOfMemoryException
		     newWithClass: isa
		    requestedSize: matrix->rows * columns * sizeof(float)];
		     exceptionWithClass: isa
			  requestedSize: matrix->rows * columns *
					 sizeof(float)];

	base1 = 0;
	base2 = 0;

	for (i = 0; i < columns; i++) {
		size_t base3 = base2;
		size_t j;
380
381
382
383
384
385
386
387
388



389
390
391
392
393
394
395
396
382
383
384
385
386
387
388


389
390
391

392
393
394
395
396
397
398







-
-
+
+
+
-








- (void)transpose
{
	float *newData;
	size_t i, k;

	if ((newData = malloc(rows * columns * sizeof(float))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: rows * columns *
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: rows * columns * sizeof(float)];
							     sizeof(float)];

	rows ^= columns;
	columns ^= rows;
	rows ^= columns;

	for (i = k = 0; i < rows; i++) {
		size_t j;
406
407
408
409
410
411
412
413
414


415
416
417
418
419
420
421
408
409
410
411
412
413
414


415
416
417
418
419
420
421
422
423







-
-
+
+







- (void)translateWithVector: (OFFloatVector*)vector
{
	OFFloatMatrix *translation;
	float *cArray;

	if (rows != columns || vector->isa != floatVector ||
	    vector->dimension != rows - 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	cArray = [vector cArray];
	translation = [[OFFloatMatrix alloc] initWithRows: rows
						  columns: columns];

	memcpy(translation->data + (columns - 1) * rows, cArray,
	    (rows - 1) * sizeof(float));
431
432
433
434
435
436
437
438
439


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


440
441
442
443
444
445
446
447
448







-
-
+
+







		   angle: (float)angle
{
	OFFloatMatrix *rotation;
	float n[3], m, angleCos, angleSin;

	if (rows != 4 || columns != 4 || vector->isa != floatVector ||
	    vector->dimension != 3)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	n[0] = vector->data[0];
	n[1] = vector->data[1];
	n[2] = vector->data[2];

	m = sqrtf(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]);

480
481
482
483
484
485
486
487
488


489
490
491
492
493
494
495
482
483
484
485
486
487
488


489
490
491
492
493
494
495
496
497







-
-
+
+







{
	OFFloatMatrix *scale;
	float *cArray;
	size_t i, j;

	if (rows != columns || vector->isa != floatVector ||
	    vector->dimension != rows - 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	cArray = [vector cArray];
	scale = [[OFFloatMatrix alloc] initWithRows: rows
					    columns: columns];

	for (i = j = 0; i < ((rows - 1) * columns) - 1; i += rows + 1)
		scale->data[i] = cArray[j++];

Modified src/OFFloatVector.m from [ca289ecb6a] to [0c98a1d7e8].

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







-
-
+
+










-
+



-
-
+
+







	return ret;
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithDimension: (size_t)dimension_
{
	self = [super init];

	@try {
		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(float))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		if ((data = malloc(dimension * sizeof(float))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(float)];
			     exceptionWithClass: isa
				  requestedSize: dimension * sizeof(float)];

		memset(data, 0, dimension * sizeof(float));
	} @catch (id e) {
		[self release];
		@throw e;
	}

115
116
117
118
119
120
121
122

123
124
125
126
127


128
129
130
131
132
133
134
115
116
117
118
119
120
121

122
123
124
125


126
127
128
129
130
131
132
133
134







-
+



-
-
+
+








	@try {
		size_t i;

		dimension = dimension_;

		if (SIZE_MAX / dimension < sizeof(float))
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		if ((data = malloc(dimension * sizeof(float))) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: dimension * sizeof(float)];
			     exceptionWithClass: isa
				  requestedSize: dimension * sizeof(float)];

		data[0] = data_;
		for (i = 1; i < dimension; i++)
			data[i] = (float)va_arg(arguments, double);
	} @catch (id e) {
		[self release];
		@throw e;
144
145
146
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
179
180
181
182
183
184
144
145
146
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
179
180
181
182
183
184







-
+







-
+















-
-
+
+
+
-







	[super dealloc];
}

- (void)setValue: (float)value
	 atIndex: (size_t)index
{
	if (index >= dimension)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	data[index] = value;
}

- (float)valueAtIndex: (size_t)index
{
	if (index >= dimension)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return data[index];
}

- (size_t)dimension
{
	return dimension;
}

- (void)setDimension: (size_t)dimension_
{
	float *newData;
	size_t i;

	if ((newData = realloc(data, dimension_ * sizeof(float))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: dimension_ *
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: dimension_ * sizeof(float)];
							     sizeof(float)];

	data = newData;

	for (i = dimension; i < dimension_; i++)
		data[i] = 0;

	dimension = dimension_;
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
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







-
-
+
+










-
-
+
+







}

- (void)addVector: (OFFloatVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] += vector->data[i];
}

- (void)subtractVector: (OFFloatVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] -= vector->data[i];
}

- (void)multiplyWithScalar: (float)scalar
{
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
359
360
361
362
363
364
365
366


367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382


383
384
385
386


387
388
389
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
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
359
360
361
362
363
364


365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380


381
382
383
384


385
386
387
388
389
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







-
-
+
+










-
-
+
+











-
-
+
+














-
-
+
+


-
-
+
+



















-
-
+
+



-
-
+
+







}

- (void)multiplyWithComponentsOfVector: (OFFloatVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] *= vector->data[i];
}

- (void)divideByComponentsOfVector: (OFFloatVector*)vector
{
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	for (i = 0; i < dimension; i++)
		data[i] /= vector->data[i];
}

- (float)dotProductWithVector: (OFFloatVector*)vector
{
	float dotProduct;
	size_t i;

	if (vector->isa != isa || vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	dotProduct = 0.0f;

	for (i = 0; i < dimension; i++)
		dotProduct += data[i] * vector->data[i];

	return dotProduct;
}

- (OFFloatVector*)crossProductWithVector: (OFFloatVector*)vector
{
	OFFloatVector *crossProduct;

	if (dimension != 3)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];

	if (vector->dimension != dimension)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	crossProduct = [OFFloatVector vectorWithDimension: 3];

	crossProduct->data[0] =
	    data[1] * vector->data[2] - data[2] * vector->data[1];
	crossProduct->data[1] =
	    data[2] * vector->data[0] - data[0] * vector->data[2];
	crossProduct->data[2] =
	    data[0] * vector->data[1] - data[1] * vector->data[0];

	return crossProduct;
}

- (void)multiplyWithMatrix: (OFFloatMatrix*)matrix
{
	float *newData;
	size_t i, j, k;

	if (matrix->isa != floatMatrix || dimension != matrix->columns)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if ((newData = malloc(matrix->rows * sizeof(float))) == NULL)
		@throw [OFOutOfMemoryException
		     newWithClass: isa
		    requestedSize: matrix->rows * sizeof(float)];
		     exceptionWithClass: isa
			  requestedSize: matrix->rows * sizeof(float)];

	memset(newData, 0, matrix->rows * sizeof(float));

	for (i = j = k = 0; i < matrix->rows * matrix->columns; i++) {
		newData[j] += matrix->data[i] * data[k];

		if (++j == matrix->rows) {

Modified src/OFHTTPRequest.m from [7c931c50fb] to [66f489833f].

187
188
189
190
191
192
193
194
195


196
197
198
199
200
201
202
203


204
205
206
207
208
209
210
187
188
189
190
191
192
193


194
195
196
197
198
199
200
201


202
203
204
205
206
207
208
209
210







-
-
+
+






-
-
+
+







{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *scheme = [URL scheme];
	OFTCPSocket *sock;
	OFHTTPRequestResult *result;

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

	if ([scheme isEqual: @"http"])
		sock = [OFTCPSocket socket];
	else {
		if (of_http_request_tls_socket_class == Nil)
			@throw [OFUnsupportedProtocolException
			    newWithClass: isa
				     URL: URL];
			    exceptionWithClass: isa
					   URL: URL];

		sock = [[[of_http_request_tls_socket_class alloc] init]
		    autorelease];
	}

	@try {
		OFString *line, *path;
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
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







-
+















-
+







		 * We also need to check for HTTP/1.1 since Apache always
		 * declares the reply to be HTTP/1.1.
		 */
		line = [sock readLine];
		if (![line hasPrefix: @"HTTP/1.0 "] &&
		    ![line hasPrefix: @"HTTP/1.1 "])
			@throw [OFInvalidServerReplyException
			    newWithClass: isa];
			    exceptionWithClass: isa];

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

		serverHeaders = [OFMutableDictionary dictionary];

		while ((line = [sock readLine]) != nil) {
			OFString *key, *value;
			const char *line_c = [line UTF8String], *tmp;

			if ([line isEqual: @""])
				break;

			if ((tmp = strchr(line_c, ':')) == NULL)
				@throw [OFInvalidServerReplyException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			key = [OFString stringWithUTF8String: line_c
						      length: tmp - line_c];
			normalize_key(key);

			do {
				tmp++;
382
383
384
385
386
387
388
389

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
382
383
384
385
386
387
388

389
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







-
+









-
+












-
-
-
+
+
+








		if ((contentLengthHeader =
		    [serverHeaders objectForKey: @"Content-Length"]) != nil) {
			intmax_t cl = [contentLengthHeader decimalValue];

			if (cl > SIZE_MAX)
				@throw [OFOutOfRangeException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			/*
			 * We only want to throw on these status codes as we
			 * will throw an OFHTTPRequestFailedException for all
			 * other status codes later.
			 */
			if (cl != bytesReceived && (status == 200 ||
			    status == 301 || status == 302 || status == 303))
				@throw [OFTruncatedDataException
				    newWithClass: isa];
				    exceptionWithClass: isa];
		}

		[serverHeaders makeImmutable];

		result = [[OFHTTPRequestResult alloc]
		    initWithStatusCode: status
			       headers: serverHeaders
				  data: data];

		if (status != 200 && status != 301 && status != 302 &&
		    status != 303)
			@throw [OFHTTPRequestFailedException
			    newWithClass: isa
			     HTTPRequest: self
				  result: result];
			    exceptionWithClass: isa
				   HTTPRequest: self
					result: result];
	} @finally {
		[pool release];
	}

	return [result autorelease];
}
@end

Modified src/OFHash.m from [4c0ad468a8] to [a4b7ddc1da].

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







-
-
+
+




-
-
+
+





-
-
+
+




-
-
+
+







#import "OFHash.h"

#import "OFNotImplementedException.h"

@implementation OFHash
+ (size_t)digestSize
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (size_t)blockSize
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

- (void)updateWithBuffer: (const char*)buffer
		  length: (size_t)length
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (uint8_t*)digest
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (BOOL)isCalculated
{
	return calculated;
}
@end

Modified src/OFList.m from [a2958826ad] to [c2b5c044cc].

43
44
45
46
47
48
49
50
51



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


50
51
52
53
54
55
56
57
58
59







-
-
+
+
+







		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFAutoreleasePool *pool2;
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		enumerator = [[element children] objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			if (![[child namespace] isEqual: OF_SERIALIZATION_NS])
				continue;
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
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







-
-
+
+
+













-
+
+
+




}

- (id)nextObject
{
	id ret;

	if (*mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa
							     object: list];
		@throw [OFEnumerationMutationException
		    exceptionWithClass: isa
				object: list];

	if (current == NULL)
		return nil;

	ret = current->object;
	current = current->next;

	return ret;
}

- (void)reset
{
	if (*mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa];
		@throw [OFEnumerationMutationException
		    exceptionWithClass: isa
				object: list];

	current = [list firstListObject];
}
@end

Modified src/OFMD5Hash.m from [c4ee6e4bc8] to [65056dd7ed].

151
152
153
154
155
156
157
158
159



160
161
162
163
164
165
166
151
152
153
154
155
156
157


158
159
160
161
162
163
164
165
166
167







-
-
+
+
+







{
	uint32_t t;

	if (length == 0)
		return;

	if (calculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa
								 hash: self];
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithClass: isa
				  hash: self];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)length << 3)) < t)
		/* Carry from low to high */
		bits[1]++;
	bits[1] += (uint32_t)length >> 29;

Modified src/OFMutableArray.m from [8a1851f596] to [95f73007dc].

99
100
101
102
103
104
105
106
107


108
109
110
111
112
113
114
99
100
101
102
103
104
105


106
107
108
109
110
111
112
113
114







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFMutableArray
+ (void)initialize
{
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


162
163
164
165
166
167
168
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
162
163
164
165
166
167
168







-
-
+
+



















-
-
+
+





-
-
+
+







}

- init
{
	if (isa == [OFMutableArray class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- copy
{
	return [[OFArray alloc] initWithArray: self];
}

- (void)addObject: (id)object
{
	[self addObject: object
		atIndex: [self count]];
}

- (void)addObject: (id)object
	  atIndex: (size_t)index
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	size_t i, count = [self count];

188
189
190
191
192
193
194
195
196


197
198
199
200
201
202
203
188
189
190
191
192
193
194


195
196
197
198
199
200
201
202
203







-
-
+
+







			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)removeObject: (id)object
{
	size_t i, count = [self count];

	for (i = 0; i < count; i++) {

Modified src/OFMutableArray_adjacent.m from [fb38385e6c] to [cacb4ce363].

72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
72
73
74
75
76
77
78

79
80
81
82
83
84
85
86







-
+







- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
{
	id *cArray = [array cArray];
	id oldObject;

	if (index >= [array count])
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	oldObject = cArray[index];
	cArray[index] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
147
148
149
150
151
152
153

154
155
156
157
158
159
160
161







-
+








- (void)removeNObjects: (size_t)nObjects
{
	id *cArray = [array cArray], *copy;
	size_t i, count = [array count];

	if (nObjects > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	copy = [self allocMemoryForNItems: nObjects
				   ofSize: sizeof(id)];
	memcpy(copy, cArray + (count - nObjects), nObjects * sizeof(id));

	@try {
		[array removeNItems: nObjects];
170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184







-
+








- (void)removeObjectsInRange: (of_range_t)range
{
	id *cArray = [array cArray], *copy;
	size_t i, count = [array count];

	if (range.length > count - range.start)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	copy = [self allocMemoryForNItems: range.length
				   ofSize: sizeof(id)];
	memcpy(copy, cArray + range.start, range.length * sizeof(id));

	@try {
		[array removeNItems: range.length
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
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







-
-
+
+

















-
-
+
+




-
-
+
+
+













	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < count && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];
			    exceptionWithClass: isa
					object: self];

		block(cArray[i], i, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < count && !stop; i++) {
		id newObject;

		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];
			    exceptionWithClass: isa
					object: self];

		newObject = block(cArray[i], i, &stop);

		if (newObject == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		[newObject retain];
		[cArray[i] release];
		cArray[i] = newObject;
	}
}
#endif

- (void)makeImmutable
{
	isa = [OFArray_adjacent class];
}
@end

Modified src/OFMutableDictionary.m from [4c5a03559b] to [07bbff71b3].

92
93
94
95
96
97
98
99
100


101
102
103
104
105
106
107
92
93
94
95
96
97
98


99
100
101
102
103
104
105
106
107







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFMutableDictionary
+ (void)initialize
{
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
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







-
-
+
+








-
-
+
+




-
-
+
+







}

- init
{
	if (isa == [OFMutableDictionary class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- (void)setObject: (id)object
	   forKey: (id)key
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)removeObjectForKey: (id)key
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- copy
{
	return [[OFDictionary alloc] initWithDictionary: self];
}

Modified src/OFMutableDictionary_hashtable.m from [ae72503787] to [7e1c4d0cdb].

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







-
+









-
+







- (void)_resizeForCount: (size_t)newCount
{
	size_t fullness = newCount * 4 / size;
	struct of_dictionary_hashtable_bucket **newData;
	uint32_t i, newSize;

	if (newCount > UINT32_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	if (fullness >= 3)
		newSize = size << 1;
	else if (fullness <= 1)
		newSize = size >> 1;
	else
		return;

	if (newSize == 0)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	newData = [self allocMemoryForNItems: newSize
				      ofSize: sizeof(*newData)];

	for (i = 0; i < newSize; i++)
		newData[i] = NULL;

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







-
+



















-
-
+
+







				for (j = 0; j < last &&
				    newData[j] != NULL; j++);
			}

			if (j >= last) {
				[self freeMemory: newData];
				@throw [OFOutOfRangeException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}

			newData[j] = data[i];
		}
	}

	[self freeMemory: data];
	data = newData;
	size = newSize;
}

- (void)_setObject: (id)object
	    forKey: (id)key
	   copyKey: (BOOL)copyKey
{
	uint32_t i, hash, last;
	id old;

	if (key == nil || object == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	hash = [key hash];
	last = size;

	for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
		if (data[i] == DELETED)
			continue;
151
152
153
154
155
156
157
158

159
160
161
162
163
164
165
151
152
153
154
155
156
157

158
159
160
161
162
163
164
165







-
+







			last = hash & (size - 1);

			for (i = 0; i < last && data[i] != NULL &&
			    data[i] != DELETED; i++);
		}

		if (i >= last)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		bucket = [self allocMemoryWithSize: sizeof(*bucket)];

		if (copyKey) {
			@try {
				bucket->key = [key copy];
			} @catch (id e) {
192
193
194
195
196
197
198
199
200


201
202
203
204
205
206
207
192
193
194
195
196
197
198


199
200
201
202
203
204
205
206
207







-
-
+
+







}

- (void)removeObjectForKey: (id)key
{
	uint32_t i, hash, last;

	if (key == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	hash = [key hash];
	last = size;

	for (i = hash & (size - 1); i < last && data[i] != NULL; i++) {
		if (data[i] == DELETED)
			continue;
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
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







-
-
+
+















-
-
+
+






-
-
+
+







	size_t i;
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < size && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];
			    exceptionWithClass: isa
					object: self];

		if (data[i] != NULL && data[i] != DELETED)
			block(data[i]->key, data[i]->object, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	size_t i;
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < size && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];
			    exceptionWithClass: isa
					object: self];

		if (data[i] != NULL && data[i] != DELETED) {
			id new = block(data[i]->key, data[i]->object, &stop);

			if (new == nil)
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];
				    exceptionWithClass: isa
					      selector: _cmd];

			[new retain];
			[data[i]->object release];
			data[i]->object = new;
		}
	}
}

Modified src/OFMutableSet.m from [ca9a8cdb54] to [0dd3658171].

82
83
84
85
86
87
88
89
90


91
92
93
94
95
96
97
82
83
84
85
86
87
88


89
90
91
92
93
94
95
96
97







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFMutableSet
+ (void)initialize
{
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
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







-
-
+
+







-
-
+
+




-
-
+
+







}

- init
{
	if (isa == [OFMutableSet class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- (void)addObject: (id)object
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)removeObject: (id)object
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)minusSet: (OFSet*)set
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFEnumerator *enumerator = [set objectEnumerator];
	id object;

Modified src/OFMutableString.m from [e446d14903] to [471b2f9466].

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
122


123
124
125
126
127
128
129
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
122
123

124
125
126
127
128
129
130
131
132







-
+
+




















-
+
+



















-
+
+








	while (i < s->cStringLength) {
		cLen = of_string_utf8_to_unicode(s->cString + i,
		    s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF) {
			[self freeMemory: unicodeString];
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		if (c >> 8 < tableSize) {
			of_unichar_t tc = table[c >> 8][c & 0xFF];

			if (tc)
				c = tc;
		}
		unicodeString[j++] = c;

		if (c < 0x80)
			newCStringLength++;
		else if (c < 0x800)
			newCStringLength += 2;
		else if (c < 0x10000)
			newCStringLength += 3;
		else if (c < 0x110000)
			newCStringLength += 4;
		else {
			[self freeMemory: unicodeString];
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		i += cLen;
	}

	@try {
		newCString = [self allocMemoryWithSize: newCStringLength + 1];
	} @catch (id e) {
		[self freeMemory: unicodeString];
		@throw e;
	}

	j = 0;

	for (i = 0; i < unicodeLen; i++) {
		if ((d = of_string_unicode_to_utf8(unicodeString[i],
		    newCString + j)) == 0) {
			[self freeMemory: unicodeString];
			[self freeMemory: newCString];
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}
		j += d;
	}

	assert(j == newCStringLength);
	newCString[j] = 0;
	[self freeMemory: unicodeString];
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166







-
+







	}

	switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) {
	case 1:
		s->UTF8 = YES;
		break;
	case -1:
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];
	}

	s->cString = [self resizeMemory: s->cString
				 toSize: s->cStringLength +
					 UTF8StringLength + 1];
	memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength + 1);

176
177
178
179
180
181
182
183

184
185
186
187
188
189
190
179
180
181
182
183
184
185

186
187
188
189
190
191
192
193







-
+







	}

	switch (of_string_check_utf8(UTF8String, UTF8StringLength, &length)) {
	case 1:
		s->UTF8 = YES;
		break;
	case -1:
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];
	}

	s->cString = [self resizeMemory: s->cString
				 toSize: s->cStringLength +
					 UTF8StringLength + 1];
	memcpy(s->cString + s->cStringLength, UTF8String, UTF8StringLength);

220
221
222
223
224
225
226
227
228


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


230
231
232
233
234
235
236
237
238







-
-
+
+







}

- (void)appendString: (OFString*)string
{
	size_t UTF8StringLength;

	if (string == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	UTF8StringLength = [string UTF8StringLength];

	s->cString = [self resizeMemory: s->cString
				 toSize: s->cStringLength +
					 UTF8StringLength + 1];
	memcpy(s->cString + s->cStringLength, string->s->cString,
257
258
259
260
261
262
263
264
265


266
267
268
269

270
271
272
273
274
275
276
260
261
262
263
264
265
266


267
268
269
270
271

272
273
274
275
276
277
278
279







-
-
+
+



-
+







- (void)appendFormat: (OFConstantString*)format
       withArguments: (va_list)arguments
{
	char *UTF8String;
	int UTF8StringLength;

	if (format == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException newWithClass: isa];
		@throw [OFInvalidFormatException exceptionWithClass: isa];

	@try {
		[self appendUTF8String: UTF8String
			    withLength: UTF8StringLength];
	} @finally {
		free(UTF8String);
	}
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372

373
374
375
376
377
378
379
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

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

379
380
381
382
383
384
385
386







-
+
+






-
+
+
















-
+
+
















-
+
+


















-
+







		/* ASCII */
		if (OF_LIKELY(!(s->cString[i] & 0x80)))
			continue;

		/* A start byte can't happen first as we reversed everything */
		if (OF_UNLIKELY(s->cString[i] & 0x40)) {
			madvise(s->cString, s->cStringLength, MADV_NORMAL);
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		/* Next byte must not be ASCII */
		if (OF_UNLIKELY(s->cStringLength < i + 1 ||
		    !(s->cString[i + 1] & 0x80))) {
			madvise(s->cString, s->cStringLength, MADV_NORMAL);
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		/* Next byte is the start byte */
		if (OF_LIKELY(s->cString[i + 1] & 0x40)) {
			s->cString[i] ^= s->cString[i + 1];
			s->cString[i + 1] ^= s->cString[i];
			s->cString[i] ^= s->cString[i + 1];

			i++;
			continue;
		}

		/* Second next byte must not be ASCII */
		if (OF_UNLIKELY(s->cStringLength < i + 2 ||
		    !(s->cString[i + 2] & 0x80))) {
			madvise(s->cString, s->cStringLength, MADV_NORMAL);
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		/* Second next byte is the start byte */
		if (OF_LIKELY(s->cString[i + 2] & 0x40)) {
			s->cString[i] ^= s->cString[i + 2];
			s->cString[i + 2] ^= s->cString[i];
			s->cString[i] ^= s->cString[i + 2];

			i += 2;
			continue;
		}

		/* Third next byte must not be ASCII */
		if (OF_UNLIKELY(s->cStringLength < i + 3 ||
		    !(s->cString[i + 3] & 0x80))) {
			madvise(s->cString, s->cStringLength, MADV_NORMAL);
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		/* Third next byte is the start byte */
		if (OF_LIKELY(s->cString[i + 3] & 0x40)) {
			s->cString[i] ^= s->cString[i + 3];
			s->cString[i + 3] ^= s->cString[i];
			s->cString[i] ^= s->cString[i + 3];

			s->cString[i + 1] ^= s->cString[i + 2];
			s->cString[i + 2] ^= s->cString[i + 1];
			s->cString[i + 1] ^= s->cString[i + 2];

			i += 3;
			continue;
		}

		/* UTF-8 does not allow more than 4 bytes per character */
		madvise(s->cString, s->cStringLength, MADV_NORMAL);
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];
	}

	madvise(s->cString, s->cStringLength, MADV_NORMAL);
}

- (void)upper
{
389
390
391
392
393
394
395
396

397
398
399
400
401
402
403
396
397
398
399
400
401
402

403
404
405
406
407
408
409
410







-
+








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

	if (index > s->length)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	if (s->UTF8)
		index = of_string_index_to_position(s->cString, index,
		    s->cStringLength);

	newCStringLength = s->cStringLength + [string UTF8StringLength];
	s->cString = [self resizeMemory: s->cString
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
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







-
-
+
+


-
+



















-











-
-
+
+


-
+








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

	if (start > end)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

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

	s->length -= end - start;

	if (s->UTF8) {
		start = of_string_index_to_position(s->cString, start,
		    s->cStringLength);
		end = of_string_index_to_position(s->cString, end,
		    s->cStringLength);
	}

	memmove(s->cString + start, s->cString + end, s->cStringLength - end);
	s->cStringLength -= end - start;
	s->cString[s->cStringLength] = 0;

	@try {
		s->cString = [self resizeMemory: s->cString
					 toSize: s->cStringLength + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)replaceCharactersInRange: (of_range_t)range
		      withString: (OFString*)replacement
{
	size_t start = range.start;
	size_t end = range.start + range.length;
	size_t newCStringLength, newLength;

	if (start > end)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

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

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

	if (s->UTF8) {
		start = of_string_index_to_position(s->cString, start,
		    s->cStringLength);
		end = of_string_index_to_position(s->cString, end,
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
571
572
573
574
575
576
577

578
579
580
581
582
583
584







-







	s->cString[s->cStringLength] = '\0';

	@try {
		s->cString = [self resizeMemory: s->cString
					 toSize: s->cStringLength + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)deleteTrailingWhitespaces
{
	size_t d;
	char *p;
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
597
598
599
600
601
602
603

604
605
606
607
608
609
610







-







	s->length -= d;

	@try {
		s->cString = [self resizeMemory: s->cString
					 toSize: s->cStringLength + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- (void)deleteEnclosingWhitespaces
{
	size_t d, i;
	char *p;
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
635
636
637
638
639
640
641

642
643
644
645
646
647
648
649
650
651
652
653
654







-













	s->cString[s->cStringLength] = '\0';

	@try {
		s->cString = [self resizeMemory: s->cString
					 toSize: s->cStringLength + 1];
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e release];
	}
}

- copy
{
	return [[OFString alloc] initWithString: self];
}

- (void)makeImmutable
{
	isa = [OFString class];
}
@end

Modified src/OFNull.m from [d91bdef886] to [6eac9873fd].

43
44
45
46
47
48
49
50
51


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


50
51
52
53
54
55
56
57
58







-
-
+
+








	[self release];

	pool = [[OFAutoreleasePool alloc] init];

	if (![[element name] isEqual: [self className]] ||
	    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	[pool release];

	return [OFNull null];
}

- (OFString*)description
97
98
99
100
101
102
103
104
105


106
107
108
97
98
99
100
101
102
103


104
105
106
107
108







-
-
+
+



- (unsigned int)retainCount
{
	return OF_RETAIN_COUNT_MAX;
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

Modified src/OFNumber.m from [687e9eb918] to [37c360709c].

80
81
82
83
84
85
86
87


88
89
90
91
92
93
94
80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
95







-
+
+







	case OF_NUMBER_UINTPTR:						\
		return (t)value.uintptr;				\
	case OF_NUMBER_FLOAT:						\
		return (t)value.float_;					\
	case OF_NUMBER_DOUBLE:						\
		return (t)value.double_;				\
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: isa];				\
	}
#define CALCULATE(o, n)							\
	switch (type) {							\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool:			\
		    value.bool_ o [n boolValue]];			\
	case OF_NUMBER_CHAR:						\
163
164
165
166
167
168
169
170


171
172
173
174
175
176
177
164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179







-
+
+







	case OF_NUMBER_FLOAT:						\
		return [OFNumber numberWithFloat:			\
		    value.float_ o [n floatValue]];			\
	case OF_NUMBER_DOUBLE:						\
		return [OFNumber numberWithDouble:			\
		    value.double_ o [n doubleValue]];			\
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: isa];				\
	}
#define CALCULATE2(o, n)						\
	switch (type) {							\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool:			\
		    value.bool_ o [n boolValue]];			\
	case OF_NUMBER_CHAR:						\
241
242
243
244
245
246
247
248
249



250
251


252
253
254
255
256
257
258
243
244
245
246
247
248
249


250
251
252
253

254
255
256
257
258
259
260
261
262







-
-
+
+
+

-
+
+







		return [OFNumber numberWithIntPtr:			\
		    value.intptr o [n intPtrValue]];			\
	case OF_NUMBER_UINTPTR:						\
		return [OFNumber numberWithUIntPtr:			\
		    value.uintptr o [n uIntPtrValue]];			\
	case OF_NUMBER_FLOAT:						\
	case OF_NUMBER_DOUBLE:						\
		@throw [OFNotImplementedException newWithClass: isa	\
						      selector: _cmd];	\
		@throw [OFNotImplementedException			\
		    exceptionWithClass: isa				\
			      selector: _cmd];				\
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: isa];				\
	}
#define CALCULATE3(o)							\
	switch (type) {							\
	case OF_NUMBER_BOOL:						\
		return [OFNumber numberWithBool: value.bool_ o];	\
	case OF_NUMBER_CHAR:						\
		return [OFNumber numberWithChar: value.char_ o];	\
304
305
306
307
308
309
310
311


312
313
314
315
316
317
318
308
309
310
311
312
313
314

315
316
317
318
319
320
321
322
323







-
+
+







	case OF_NUMBER_UINTPTR:						\
		return [OFNumber numberWithUIntPtr: value.uintptr o];	\
	case OF_NUMBER_FLOAT:						\
		return [OFNumber numberWithFloat: value.float_ o];	\
	case OF_NUMBER_DOUBLE:						\
		return [OFNumber numberWithDouble: value.double_ o];	\
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
		@throw [OFInvalidFormatException			\
		    exceptionWithClass: isa];				\
	}

@implementation OFNumber
+ numberWithBool: (BOOL)bool_
{
	return [[[self alloc] initWithBool: bool_] autorelease];
}
440
441
442
443
444
445
446
447
448


449
450
451
452
453
454
455
445
446
447
448
449
450
451


452
453
454
455
456
457
458
459
460







-
-
+
+







+ numberWithDouble: (double)double_
{
	return [[[self alloc] initWithDouble: double_] autorelease];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- initWithBool: (BOOL)bool_
{
	self = [super init];

	value.bool_ = bool_;
714
715
716
717
718
719
720
721
722



723
724
725
726
727
728
729
730
731
732
733
734
735
736


737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755



756
757
758
759
760
761
762
719
720
721
722
723
724
725


726
727
728
729
730
731
732
733
734
735
736
737
738
739
740


741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759


760
761
762
763
764
765
766
767
768
769







-
-
+
+
+












-
-
+
+

















-
-
+
+
+








	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFString *typeString;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		typeString = [[element attributeForName: @"type"] stringValue];

		if ([typeString isEqual: @"boolean"]) {
			type = OF_NUMBER_BOOL;

			if ([[element stringValue] isEqual: @"YES"])
				value.bool_ = YES;
			else if ([[element stringValue] isEqual: @"NO"])
				value.bool_ = NO;
			else
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];
				    exceptionWithClass: isa
					      selector: _cmd];
		} else if ([typeString isEqual: @"unsigned"]) {
			/*
			 * FIXME: This will fail if the value is bigger than
			 *	  INTMAX_MAX!
			 */
			type = OF_NUMBER_UINTMAX;
			value.uintmax = [element decimalValue];
		} else if ([typeString isEqual: @"signed"]) {
			type = OF_NUMBER_INTMAX;
			value.intmax = [element decimalValue];
		} else if ([typeString isEqual: @"float"]) {
			type = OF_NUMBER_FLOAT;
			value.float_ = [element floatValue];
		} else if ([typeString isEqual: @"double"]) {
			type = OF_NUMBER_DOUBLE;
			value.double_ = [element doubleValue];
		} else
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

1114
1115
1116
1117
1118
1119
1120
1121

1122
1123
1124
1125
1126
1127
1128
1121
1122
1123
1124
1125
1126
1127

1128
1129
1130
1131
1132
1133
1134
1135







-
+







	case OF_NUMBER_FLOAT:
		return [OFNumber
		    numberWithFloat: fmodf(value.float_, [number floatValue])];
	case OF_NUMBER_DOUBLE:
		return [OFNumber numberWithDouble:
		    fmod(value.double_, [number doubleValue])];
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
		@throw [OFInvalidFormatException exceptionWithClass: isa];
	}
}

- copy
{
	return [self retain];
}
1158
1159
1160
1161
1162
1163
1164
1165

1166
1167
1168
1169
1170
1171
1172
1165
1166
1167
1168
1169
1170
1171

1172
1173
1174
1175
1176
1177
1178
1179







-
+







	case OF_NUMBER_INTPTR:
		return [OFString stringWithFormat: @"%jd", [self intMaxValue]];
	case OF_NUMBER_FLOAT:
		return [OFString stringWithFormat: @"%g", value.float_];
	case OF_NUMBER_DOUBLE:
		return [OFString stringWithFormat: @"%lg", value.double_];
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
		@throw [OFInvalidFormatException exceptionWithClass: isa];
	}
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;
1220
1221
1222
1223
1224
1225
1226
1227

1228
1229
1230
1231
1232
1233
1234
1235
1236
1227
1228
1229
1230
1231
1232
1233

1234
1235
1236
1237
1238
1239
1240
1241
1242
1243







-
+









		[element addAttributeWithName: @"type"
				  stringValue: @"double"];
		[element setStringValue:
		    [OFString stringWithFormat: @"%la", value.double_]];

		break;
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
		@throw [OFInvalidFormatException exceptionWithClass: isa];
	}

	[element retain];
	[pool release];
	[element autorelease];

	return element;
}
@end

Modified src/OFObject+Serialization.m from [914b1a9829] to [f21298cd9d].

33
34
35
36
37
38
39
40
41


42
43
44
45
46
47
48
33
34
35
36
37
38
39


40
41
42
43
44
45
46
47
48







-
-
+
+







	OFAutoreleasePool *pool;
	OFXMLElement *element;
	OFXMLElement *root;
	OFString *ret;

	if (![self conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFNotImplementedException
		    newWithClass: isa
			selector: @selector(stringBySerializing)];
		    exceptionWithClass: isa
			      selector: @selector(stringBySerializing)];

	pool = [[OFAutoreleasePool alloc] init];
	element = [(id)self XMLElementBySerializing];

	root = [OFXMLElement elementWithName: @"serialization"
				   namespace: OF_SERIALIZATION_NS];
	[root addAttributeWithName: @"version"

Modified src/OFObject.m from [e5c0e6c88e] to [6a6eeb3258].

97
98
99
100
101
102
103
104
105



106
107
108
109
110
111
112
97
98
99
100
101
102
103


104
105
106
107
108
109
110
111
112
113







-
-
+
+
+







#ifdef NEED_OBJC_PROPERTIES_INIT
extern BOOL objc_properties_init();
#endif

static void
enumeration_mutation_handler(id object)
{
	@throw [OFEnumerationMutationException newWithClass: [object class]
						     object: object];
	@throw [OFEnumerationMutationException
	    exceptionWithClass: [object class]
			object: object];
}

#ifndef HAVE_OBJC_ENUMERATIONMUTATION
void
objc_enumerationMutation(id object)
{
	enumeration_mutation_handler(object);
193
194
195
196
197
198
199
200


201
202
203
204
205
206
207
194
195
196
197
198
199
200

201
202
203
204
205
206
207
208
209







-
+
+







	((struct pre_ivar*)instance)->memoryChunksSize = 0;
	((struct pre_ivar*)instance)->retainCount = 1;

#if !defined(OF_ATOMIC_OPS)
	if (!of_spinlock_new(
	    &((struct pre_ivar*)instance)->retainCountSpinlock)) {
		free(instance);
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	}
#endif

	instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN);
	memset(instance, 0, instanceSize);
	instance->isa = self;

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
359
360
361
362
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
359
360
361
362
363
364







-
-
+
+







-
-
+
+








-
-
+
+















-
-
+
+









-
-
+
+








+ (const char*)typeEncodingForInstanceSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	const char *ret;

	if ((ret = objc_get_type_encoding(self, selector)) == NULL)
		@throw [OFNotImplementedException newWithClass: self
						      selector: selector];
		@throw [OFNotImplementedException exceptionWithClass: self
							    selector: selector];

	return ret;
#elif defined(OF_OLD_GNU_RUNTIME)
	Method_t m;

	if ((m = class_get_instance_method(self, selector)) == NULL ||
	    m->method_types == NULL)
		@throw [OFNotImplementedException newWithClass: self
						      selector: selector];
		@throw [OFNotImplementedException exceptionWithClass: self
							    selector: selector];

	return m->method_types;
#else
	Method m;
	const char *ret;

	if ((m = class_getInstanceMethod(self, selector)) == NULL ||
	    (ret = method_getTypeEncoding(m)) == NULL)
		@throw [OFNotImplementedException newWithClass: self
						      selector: selector];
		@throw [OFNotImplementedException exceptionWithClass: self
							    selector: selector];

	return ret;
#endif
}

+ (OFString*)description
{
	return [self className];
}

+ (IMP)setImplementation: (IMP)newImp
	  forClassMethod: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	if (newImp == (IMP)0 || !class_respondsToSelector(self->isa, selector))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	return objc_replace_class_method(self, selector, newImp);
#elif defined(OF_OLD_GNU_RUNTIME)
	Method_t method;
	MethodList_t iter;

	method = class_get_class_method(self->class_pointer, selector);

	if (newImp == (IMP)0 || method == METHOD_NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	for (iter = ((Class)self->class_pointer)->methods; iter != NULL;
	    iter = iter->method_next) {
		int i;

		for (i = 0; i < iter->method_count; i++)
			if (sel_eq(iter->method_list[i].method_name,
379
380
381
382
383
384
385
386
387


388
389
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
381
382
383
384
385
386
387


388
389
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







-
-
+
+
















-
-
+
+












-
-
+
+









-
-
+
+








	return (IMP)0;
#else
	Method method;

	if (newImp == (IMP)0 ||
	    (method = class_getClassMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	/*
	 * Cast needed because it's isa in the Apple runtime, but class_pointer
	 * in the GNU runtime.
	 */
	return class_replaceMethod(((OFObject*)self)->isa, selector, newImp,
	    method_getTypeEncoding(method));
#endif
}

+ (IMP)replaceClassMethod: (SEL)selector
      withMethodFromClass: (Class)class
{
	IMP newImp;

	if (![class isSubclassOfClass: self])
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	newImp = [class methodForSelector: selector];

	return [self setImplementation: newImp
			forClassMethod: selector];
}

+ (IMP)setImplementation: (IMP)newImp
       forInstanceMethod: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	if (newImp == (IMP)0 || !class_respondsToSelector(self, selector))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	return objc_replace_instance_method(self, selector, newImp);
#elif defined(OF_OLD_GNU_RUNTIME)
	Method_t method;
	MethodList_t iter;

	method = class_get_instance_method(self, selector);

	if (newImp == (IMP)0 || method == METHOD_NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	for (iter = ((Class)self)->methods; iter != NULL;
	    iter = iter->method_next) {
		int i;

		for (i = 0; i < iter->method_count; i++)
			if (sel_eq(iter->method_list[i].method_name,
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
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







-
-
+
+












-
-
+
+








	return (IMP)0;
#else
	Method method;

	if (newImp == (IMP)0 ||
	    (method = class_getInstanceMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	return class_replaceMethod(self, selector, newImp,
	    method_getTypeEncoding(method));
#endif
}

+ (IMP)replaceInstanceMethod: (SEL)selector
	 withMethodFromClass: (Class)class
{
	IMP newImp;

	if (![class isSubclassOfClass: self])
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	newImp = [class instanceMethodForSelector: selector];

	return [self setImplementation: newImp
		     forInstanceMethod: selector];
}

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







-
-
+
+














-
-
+
+







			if (sel_eq(methodList->method_list[i].method_name,
			    selector))
				return NO;
	}

	if ((methodList = malloc(sizeof(*methodList))) == NULL)
		@throw [OFOutOfMemoryException
		    newWithClass: self
		   requestedSize: sizeof(*methodList)];
		    exceptionWithClass: self
			 requestedSize: sizeof(*methodList)];

	methodList->method_next = ((Class)self)->methods;
	methodList->method_count = 1;

	methodList->method_list[0].method_name = selector;
	methodList->method_list[0].method_types = typeEncoding;
	methodList->method_list[0].method_imp = implementation;

	((Class)self)->methods = methodList;

	__objc_update_dispatch_table_for_class(self);

	return YES;
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
#endif
}

+ (BOOL)addClassMethod: (SEL)selector
      withTypeEncoding: (const char*)typeEncoding
	implementation: (IMP)implementation
{
540
541
542
543
544
545
546
547
548


549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564


565
566
567
568
569
570
571
542
543
544
545
546
547
548


549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564


565
566
567
568
569
570
571
572
573







-
-
+
+














-
-
+
+







			if (sel_eq(methodList->method_list[i].method_name,
			    selector))
				return NO;
	}

	if ((methodList = malloc(sizeof(*methodList))) == NULL)
		@throw [OFOutOfMemoryException
		    newWithClass: self
		   requestedSize: sizeof(*methodList)];
		    exceptionWithClass: self
			 requestedSize: sizeof(*methodList)];

	methodList->method_next = ((Class)self->class_pointer)->methods;
	methodList->method_count = 1;

	methodList->method_list[0].method_name = selector;
	methodList->method_list[0].method_types = typeEncoding;
	methodList->method_list[0].method_imp = implementation;

	((Class)self->class_pointer)->methods = methodList;

	__objc_update_dispatch_table_for_class((Class)self->class_pointer);

	return YES;
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
#endif
}

+ (void)inheritMethodsFromClass: (Class)class
{
	Class superclass = [self superclass];

696
697
698
699
700
701
702
703
704


705
706
707
708
709
710
711
698
699
700
701
702
703
704


705
706
707
708
709
710
711
712
713







-
-
+
+







				[self addInstanceMethod: selector
				       withTypeEncoding: typeEncoding
					 implementation: implementation];
			}
		}
	}
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
#endif

	[self inheritMethodsFromClass: [class superclass]];
}

- init
{
788
789
790
791
792
793
794
795
796


797
798
799
800
801
802
803
804
805


806
807
808
809
810
811
812
813
814
815


816
817
818
819
820
821
822
790
791
792
793
794
795
796


797
798
799
800
801
802
803
804
805


806
807
808
809
810
811
812
813
814
815


816
817
818
819
820
821
822
823
824







-
-
+
+







-
-
+
+








-
-
+
+








- (const char*)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	const char *ret;

	if ((ret = objc_get_type_encoding(isa, selector)) == NULL)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: selector];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: selector];

	return ret;
#elif defined(OF_OLD_GNU_RUNTIME)
	Method_t m;

	if ((m = class_get_instance_method(isa, selector)) == NULL ||
	    m->method_types == NULL)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: selector];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: selector];

	return m->method_types;
#else
	Method m;
	const char *ret;

	if ((m = class_getInstanceMethod(isa, selector)) == NULL ||
	    (ret = method_getTypeEncoding(m)) == NULL)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: selector];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: selector];

	return ret;
#endif
}

- (BOOL)isEqual: (id)object
{
841
842
843
844
845
846
847
848

849
850
851
852
853



854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872

873
874
875
876


877
878
879
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
843
844
845
846
847
848
849

850
851
852
853


854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874

875
876
877


878
879
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







-
+



-
-
+
+
+


















-
+


-
-
+
+




-
-
+
+
+
















-
+







	void **memoryChunks;
	unsigned int memoryChunksSize;

	memoryChunksSize = PRE_IVAR->memoryChunksSize + 1;

	if (UINT_MAX - PRE_IVAR->memoryChunksSize < 1 ||
	    memoryChunksSize > UINT_MAX / sizeof(void*))
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	if ((memoryChunks = realloc(PRE_IVAR->memoryChunks,
	    memoryChunksSize * sizeof(void*))) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: memoryChunksSize];
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: memoryChunksSize];

	PRE_IVAR->memoryChunks = memoryChunks;
	PRE_IVAR->memoryChunks[PRE_IVAR->memoryChunksSize] = pointer;
	PRE_IVAR->memoryChunksSize = memoryChunksSize;
}

- (void*)allocMemoryWithSize: (size_t)size
{
	void *pointer, **memoryChunks;
	unsigned int memoryChunksSize;

	if (size == 0)
		return NULL;

	memoryChunksSize = PRE_IVAR->memoryChunksSize + 1;

	if (UINT_MAX - PRE_IVAR->memoryChunksSize == 0 ||
	    memoryChunksSize > UINT_MAX / sizeof(void*))
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	if ((pointer = malloc(size)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: size];
		@throw [OFOutOfMemoryException exceptionWithClass: isa
						    requestedSize: size];

	if ((memoryChunks = realloc(PRE_IVAR->memoryChunks,
	    memoryChunksSize * sizeof(void*))) == NULL) {
		free(pointer);
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: memoryChunksSize];
		@throw [OFOutOfMemoryException
		    exceptionWithClass: isa
			 requestedSize: memoryChunksSize];
	}

	PRE_IVAR->memoryChunks = memoryChunks;
	PRE_IVAR->memoryChunks[PRE_IVAR->memoryChunksSize] = pointer;
	PRE_IVAR->memoryChunksSize = memoryChunksSize;

	return pointer;
}

- (void*)allocMemoryForNItems: (size_t)nItems
		       ofSize: (size_t)size
{
	if (nItems == 0 || size == 0)
		return NULL;

	if (nItems > SIZE_MAX / size)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [self allocMemoryWithSize: nItems * size];
}

- (void*)resizeMemory: (void*)pointer
	       toSize: (size_t)size
{
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
948
949
950

951
952
953
954
955
956
957
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
948
949
950
951
952
953

954
955
956
957
958
959
960
961







-
-
+
+






-
-
+
+
















-
+







	iter = PRE_IVAR->memoryChunks + PRE_IVAR->memoryChunksSize;

	while (iter-- > PRE_IVAR->memoryChunks) {
		if (OF_UNLIKELY(*iter == pointer)) {
			if (OF_UNLIKELY((pointer = realloc(pointer,
			    size)) == NULL))
				@throw [OFOutOfMemoryException
				     newWithClass: isa
				    requestedSize: size];
				     exceptionWithClass: isa
					  requestedSize: size];

			*iter = pointer;
			return pointer;
		}
	}

	@throw [OFMemoryNotPartOfObjectException newWithClass: isa
						      pointer: pointer];
	@throw [OFMemoryNotPartOfObjectException exceptionWithClass: isa
							    pointer: pointer];
}

- (void*)resizeMemory: (void*)pointer
	     toNItems: (size_t)nItems
	       ofSize: (size_t)size
{
	if (pointer == NULL)
		return [self allocMemoryForNItems: nItems
					   ofSize: size];

	if (nItems == 0 || size == 0) {
		[self freeMemory: pointer];
		return NULL;
	}

	if (nItems > SIZE_MAX / size)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [self resizeMemory: pointer
			   toSize: nItems * size];
}

- (void)freeMemory: (void*)pointer
{
995
996
997
998
999
1000
1001
1002
1003


1004
1005
1006
1007
1008
1009
1010
999
1000
1001
1002
1003
1004
1005


1006
1007
1008
1009
1010
1011
1012
1013
1014







-
-
+
+








			PRE_IVAR->memoryChunks = memoryChunks;

			return;
		}
	}

	@throw [OFMemoryNotPartOfObjectException newWithClass: isa
						      pointer: pointer];
	@throw [OFMemoryNotPartOfObjectException exceptionWithClass: isa
							    pointer: pointer];
}

- retain
{
#if defined(OF_ATOMIC_OPS)
	of_atomic_inc_32(&PRE_IVAR->retainCount);
#else
1087
1088
1089
1090
1091
1092
1093
1094
1095


1096
1097
1098
1099
1100
1101
1102
1103
1104


1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116


1117
1118
1119
1120
1121
1122


1123
1124
1125
1126
1127
1128
1129


1130
1131
1132
1133
1134
1135
1136


1137
1138
1139
1140
1141
1142
1143
1144


1145
1146
1147
1148
1149
1150


1151
1152
1153
1154
1155
1156
1157
1091
1092
1093
1094
1095
1096
1097


1098
1099
1100
1101
1102
1103
1104
1105
1106


1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118


1119
1120
1121
1122
1123
1124


1125
1126
1127
1128
1129
1130
1131


1132
1133
1134
1135
1136
1137
1138


1139
1140
1141
1142
1143
1144
1145
1146


1147
1148
1149
1150
1151
1152


1153
1154
1155
1156
1157
1158
1159
1160
1161







-
-
+
+







-
-
+
+










-
-
+
+




-
-
+
+





-
-
+
+





-
-
+
+






-
-
+
+




-
-
+
+







	free((char*)self - PRE_IVAR_ALIGN);
}

/* Required to use properties with the Apple runtime */
- copyWithZone: (void*)zone
{
	if (zone != NULL)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];

	return [(id)self copy];
}

- mutableCopyWithZone: (void*)zone
{
	if (zone != NULL)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];

	return [(id)self mutableCopy];
}

/*
 * Those are needed as the root class is the superclass of the root class's
 * metaclass and thus instance methods can be sent to class objects as well.
 */
+ (void)addMemoryToPool: (void*)pointer
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)allocMemoryWithSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)allocMemoryForNItems: (size_t)nItems
		       ofSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)resizeMemory: (void*)pointer
	       toSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void*)resizeMemory: (void*)pointer
	     toNItems: (size_t)nItems
	      ofSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ (void)freeMemory: (void*)pointer
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ retain
{
	return self;
}

1167
1168
1169
1170
1171
1172
1173
1174
1175


1176
1177
1178
1179
1180
1181


1182
1183
1184
1185
1186
1187


1188
1189
1171
1172
1173
1174
1175
1176
1177


1178
1179
1180
1181
1182
1183


1184
1185
1186
1187
1188
1189


1190
1191
1192
1193







-
-
+
+




-
-
+
+




-
-
+
+



+ (void)release
{
}

+ (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ copyWithZone: (void*)zone
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

+ mutableCopyWithZone: (void*)zone
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}
@end

Modified src/OFPlugin.m from [a03d84cb4d] to [eaefae089e].

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







-
+
+






-
+
+











-
-
+
+








	pool = [[OFAutoreleasePool alloc] init];
	file = [OFMutableString stringWithString: path];
	[file appendString: @PLUGIN_SUFFIX];

	if ((handle = dlopen([file cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE], RTLD_LAZY)) == NULL)
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];

	[pool release];

	initPlugin = (OFPlugin*(*)())dlsym(handle, "init_plugin");
	if (initPlugin == NULL || (plugin = initPlugin()) == nil) {
		dlclose(handle);
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
	}

	plugin->handle = handle;
	return plugin;
}

- init
{
	if (isa == [OFPlugin class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- (void)dealloc
{

Modified src/OFSHA1Hash.m from [d50a626d64] to [8c5830ca8e].

160
161
162
163
164
165
166
167
168



169
170
171
172
173
174
175
160
161
162
163
164
165
166


167
168
169
170
171
172
173
174
175
176







-
-
+
+
+







- (void)updateWithBuffer: (const char*)buffer_
		  length: (size_t)length
{
	if (length == 0)
		return;

	if (calculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa
								 hash: self];
		@throw [OFHashAlreadyCalculatedException
		    exceptionWithClass: isa
				  hash: self];

	sha1_update(state, &count, buffer, buffer_, length);
}

- (uint8_t*)digest
{
	size_t i;

Modified src/OFSOCKS5Socket.m from [0957d5a6c1] to [42fad2fbd2].

29
30
31
32
33
34
35
36
37


38
39
40
41
42
43
44
29
30
31
32
33
34
35


36
37
38
39
40
41
42
43
44







-
-
+
+







					   port: port] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithProxyHost: (OFString*)host
	       port: (uint16_t)port
{
	self = [super init];

75
76
77
78
79
80
81
82
83
84
85





86
87
88
89
90
91
92
75
76
77
78
79
80
81




82
83
84
85
86
87
88
89
90
91
92
93







-
-
-
-
+
+
+
+
+







	       fromBuffer: request];

	[self readExactlyNBytes: 2
		     intoBuffer: reply];

	if (reply[0] != 5 || reply[1] != 0) {
		[self close];
		@throw [OFConnectionFailedException newWithClass: isa
							  socket: self
							    host: proxyHost
							    port: proxyPort];
		@throw [OFConnectionFailedException
		    exceptionWithClass: isa
				socket: self
				  host: proxyHost
				  port: proxyPort];
	}

	oldBuffersWrites = [self buffersWrites];
	[self setBuffersWrites: YES];

	/* CONNECT request */
	[self writeNBytes: 4
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
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







-
-
-
-
+
+
+
+


















-
-
-
-
+
+
+
+





	[self setBuffersWrites: oldBuffersWrites];

	[self readExactlyNBytes: 4
		     intoBuffer: reply];

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];
		@throw [OFConnectionFailedException newWithClass: isa
							  socket: self
							    host: host
							    port: port];
		@throw [OFConnectionFailedException exceptionWithClass: isa
								socket: self
								  host: host
								  port: port];
	}

	/* Skip the rest of the reply */
	switch (reply[3]) {
	case 1: /* IPv4 */
		[self readExactlyNBytes: 4
			     intoBuffer: reply];
		break;
	case 3: /* Domainname */
		[self readExactlyNBytes: [self readInt8]
			     intoBuffer: reply];
		break;
	case 4: /* IPv6 */
		[self readExactlyNBytes: 16
			     intoBuffer: reply];
		break;
	default:
		[self close];
		@throw [OFConnectionFailedException newWithClass: isa
							  socket: self
							    host: host
							    port: port];
		@throw [OFConnectionFailedException exceptionWithClass: isa
								socket: self
								  host: host
								  port: port];
	}

	[self readBigEndianInt16];
}
@end

Modified src/OFSeekableStream.m from [cbcf953b58] to [d2de206fb4].

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







-
-
+
+




-
-
+
+




-
-
+
+







#import "OFSeekableStream.h"

#import "OFNotImplementedException.h"

@implementation OFSeekableStream
- (void)_seekToOffset: (off_t)offset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (off_t)_seekForwardWithOffset: (off_t)offset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (off_t)_seekToOffsetRelativeToEnd: (off_t)offset
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)seekToOffset: (off_t)offset
{
	[self _seekToOffset: offset];

	[self freeMemory: cache];

Modified src/OFSet.m from [6bb947808b] to [f6a72ae961].

81
82
83
84
85
86
87
88
89


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


88
89
90
91
92
93
94
95
96







-
-
+
+








- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

@implementation OFSet
+ (void)initialize
{
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
162


163
164
165
166
167
168
169
170
171
172
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
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
162
163
164
165
166
167
168
169
170
171
172
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







-
-
+
+









-
-
+
+






-
-
+
+




















-
-
+
+






-
-
+
+




-
-
+
+




-
-
+
+




-
-
+
+






-
-
+
+







}

- init
{
	if (isa == [OFSet class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	return [super init];
}

- initWithSet: (OFSet*)set
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithArray: (OFArray*)array
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (id)initWithObjects:(id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [self initWithObject: firstObject
			 arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithSerialization: (OFXMLElement*)element
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (size_t)count
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (BOOL)containsObject: (id)object
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (OFEnumerator*)objectEnumerator
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (BOOL)isEqual: (id)object
{
	OFSet *otherSet;

	if (![object isKindOfClass: [OFSet class]])

Modified src/OFSet_hashtable.m from [11a7d709fa] to [3a56324a72].

136
137
138
139
140
141
142
143
144



145
146
147
148
149
150
151
136
137
138
139
140
141
142


143
144
145
146
147
148
149
150
151
152







-
-
+
+
+







		OFXMLElement *child;

		pool = [[OFAutoreleasePool alloc] init];

		if ((![[element name] isEqual: @"OFSet"] &&
		    ![[element name] isEqual: @"OFMutableSet"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		one = [OFNumber numberWithSize: 1];

		enumerator = [[element children] objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {

Modified src/OFStream.m from [0cc0418399] to [8092efbfd1].

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







-
-
+
+













-
-
+
+





-
-
+
+





-
-
+
+







#endif

- init
{
	if (isa == [OFStream class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException newWithClass: c
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: c
							    selector: _cmd];
	}

	self = [super init];

	cache = NULL;
	writeBuffer = NULL;
	blocking = YES;

	return self;
}

- (BOOL)_isAtEndOfStream
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (size_t)_readNBytes: (size_t)length
	   intoBuffer: (void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)_writeNBytes: (size_t)length
	  fromBuffer: (const void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- copy
{
	return [self retain];
}

689
690
691
692
693
694
695
696
697


698
699
700
701
702
703
704
689
690
691
692
693
694
695


696
697
698
699
700
701
702
703
704







-
-
+
+








	/* FIXME: Convert delimiter to specified charset */
	delimiterUTF8String = [delimiter UTF8String];
	delimiterLength = [delimiter UTF8StringLength];
	j = 0;

	if (delimiterLength == 0)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	/* Look if there's something in our cache */
	if (!waitingForDelimiter && cache != NULL) {
		for (i = 0; i < cacheLength; i++) {
			if (cache[i] != delimiterUTF8String[j++])
				j = 0;

1328
1329
1330
1331
1332
1333
1334
1335
1336


1337
1338
1339
1340

1341
1342
1343
1344
1345
1346
1347
1328
1329
1330
1331
1332
1333
1334


1335
1336
1337
1338
1339

1340
1341
1342
1343
1344
1345
1346
1347







-
-
+
+



-
+







- (size_t)writeFormat: (OFConstantString*)format
	withArguments: (va_list)arguments
{
	char *UTF8String;
	int length;

	if (format == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	if ((length = of_vasprintf(&UTF8String, [format UTF8String],
	    arguments)) == -1)
		@throw [OFInvalidFormatException newWithClass: isa];
		@throw [OFInvalidFormatException exceptionWithClass: isa];

	@try {
		[self writeNBytes: length
		       fromBuffer: UTF8String];
	} @finally {
		free(UTF8String);
	}
1363
1364
1365
1366
1367
1368
1369
1370
1371


1372
1373
1374
1375
1376
1377
1378
1379
1380


1381
1382
1383


1384
1385
1386
1387
1388
1389
1390


1391
1392
1393
1394
1395
1396


1397
1398
1399
1400
1401
1402
1403
1363
1364
1365
1366
1367
1368
1369


1370
1371
1372
1373
1374
1375
1376
1377
1378


1379
1380
1381


1382
1383
1384
1385
1386
1387
1388


1389
1390
1391
1392
1393
1394


1395
1396
1397
1398
1399
1400
1401
1402
1403







-
-
+
+







-
-
+
+

-
-
+
+





-
-
+
+




-
-
+
+







{
#ifndef _WIN32
	int flags;

	blocking = enable;

	if ((flags = fcntl([self fileDescriptor], F_GETFL)) == -1)
		@throw [OFSetOptionFailedException newWithClass: isa
							 stream: self];
		@throw [OFSetOptionFailedException exceptionWithClass: isa
							       stream: self];

	if (enable)
		flags &= ~O_NONBLOCK;
	else
		flags |= O_NONBLOCK;

	if (fcntl([self fileDescriptor], F_SETFL, flags) == -1)
		@throw [OFSetOptionFailedException newWithClass: isa
							 stream: self];
		@throw [OFSetOptionFailedException exceptionWithClass: isa
							       stream: self];
#else
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
#endif
}

- (int)fileDescriptor
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)close
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (BOOL)_isWaitingForDelimiter
{
	return waitingForDelimiter;
}
@end

Modified src/OFStreamObserver.m from [c099293000] to [fa968ce497].

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







-
+










-
+










-
+






-
+







		queue = [[OFMutableArray alloc] init];
		queueInfo = [[OFDataArray alloc] initWithItemSize: sizeof(int)];
		queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)];

#ifndef _WIN32
		if (pipe(cancelFD))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];
#else
		/* Make sure WSAStartup has been called */
		[OFTCPSocket class];

		cancelFD[0] = socket(AF_INET, SOCK_DGRAM, 0);
		cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0);

		if (cancelFD[0] == INVALID_SOCKET ||
		    cancelFD[1] == INVALID_SOCKET)
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		cancelAddr.sin_family = AF_INET;
		cancelAddr.sin_port = 0;
		cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
		cancelAddr2 = cancelAddr;

		if (bind(cancelFD[0], (struct sockaddr*)&cancelAddr,
		    sizeof(cancelAddr)) || bind(cancelFD[1],
		    (struct sockaddr*)&cancelAddr2, sizeof(cancelAddr2)))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		cancelAddrLen = sizeof(cancelAddr);

		if (getsockname(cancelFD[0], (struct sockaddr*)&cancelAddr,
		    &cancelAddrLen))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];
#endif

		maxFD = cancelFD[0];
		FDToStream = [self allocMemoryForNItems: maxFD + 1
						 ofSize: sizeof(OFStream*)];
		FDToStream[cancelFD[0]] = nil;

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







-
-
+
+




-
-
+
+




-
-
+
+




-
-
+
+







	assert(sendto(cancelFD[1], "", 1, 0, (struct sockaddr*)&cancelAddr,
	    sizeof(cancelAddr)) > 0);
#endif
}

- (void)_addFileDescriptorForReading: (int)fd
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)_addFileDescriptorForWriting: (int)fd
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)_removeFileDescriptorForReading: (int)fd
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)_removeFileDescriptorForWriting: (int)fd
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)_processQueue
{
	[mutex lock];
	@try {
		OFStream **queueCArray = [queue cArray];
368
369
370
371
372
373
374
375
376


377
378
379
380
381
382
383
368
369
370
371
372
373
374


375
376
377
378
379
380
381
382
383







-
-
+
+







- (void)observe
{
	[self observeWithTimeout: -1];
}

- (BOOL)observeWithTimeout: (int)timeout
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (BOOL)_processCache
{
	OFAutoreleasePool *pool;
	OFStream **cArray = [readStreams cArray];
	size_t i, count = [readStreams count];

Modified src/OFStreamObserver_kqueue.m from [24c0cc0a69] to [fea66ded56].

37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51







-
+







- init
{
	self = [super init];

	@try {
		if ((kernelQueue = kqueue()) == -1)
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		changeList = [[OFDataArray alloc] initWithItemSize:
		    sizeof(struct kevent)];

		[self _addFileDescriptorForReading: cancelFD[0]];
	} @catch (id e) {
		[self release];
111
112
113
114
115
116
117
118

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

118
119
120
121
122
123
124
125







-
+







	    (timeout == -1 ? NULL : &timespec));

	if (events == -1) {
		switch (errno) {
		case EINTR:
			return NO;
		case ENOMEM:
			@throw [OFOutOfMemoryException newWithClass: isa];
			@throw [OFOutOfMemoryException exceptionWithClass: isa];
		default:
			assert(0);
		}
	}

	[changeList removeNItems: [changeList count]];

Modified src/OFStreamObserver_poll.m from [c77b1b02fd] to [032c6d7a87].

131
132
133
134
135
136
137
138

139
140
141
142
143
144
145
131
132
133
134
135
136
137

138
139
140
141
142
143
144
145







-
+







		return YES;

	FDsCArray = [FDs cArray];
	nFDs = [FDs count];

#ifdef OPEN_MAX
	if (nFDs > OPEN_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];
#endif

	if (poll(FDsCArray, (nfds_t)nFDs, timeout) < 1)
		return NO;

	for (i = 0; i < nFDs; i++) {
		if (FDsCArray[i].revents & POLLIN) {

Modified src/OFStreamSocket.m from [dffe75edba] to [45578e9a1c].

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
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
142
143


144
145
146
147
148
149
150
151
152
153
154
155
156


157
158
159
160
161
162
163
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
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
142


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


156
157
158
159
160
161
162
163
164







-
+
+



















-
-
+
+




-
-
-
+
+
+










-
-
-
+
+
+











-
-
+
+




-
-
-
+
+
+










-
-
-
+
+
+









-
-
+
+











-
-
+
+







{
	WSADATA wsa;

	if (self != [OFStreamSocket class])
		return;

	if (WSAStartup(MAKEWORD(2, 0), &wsa))
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
}
#endif

+ socket
{
	return [[[self alloc] init] autorelease];
}

- (BOOL)_isAtEndOfStream
{
	return atEndOfStream;
}

- (size_t)_readNBytes: (size_t)length
	   intoBuffer: (void*)buffer
{
	ssize_t ret;

	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa
						      socket: self];
		@throw [OFNotConnectedException exceptionWithClass: isa
							    socket: self];

	if (atEndOfStream) {
		OFReadFailedException *e;

		e = [OFReadFailedException newWithClass: isa
						 stream: self
					requestedLength: length];
		e = [OFReadFailedException exceptionWithClass: isa
						       stream: self
					      requestedLength: length];
#ifndef _WIN32
		e->errNo = ENOTCONN;
#else
		e->errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if ((ret = recv(sock, buffer, length, 0)) < 0)
		@throw [OFReadFailedException newWithClass: isa
						    stream: self
					   requestedLength: length];
		@throw [OFReadFailedException exceptionWithClass: isa
							  stream: self
						 requestedLength: length];

	if (ret == 0)
		atEndOfStream = YES;

	return ret;
}

- (void)_writeNBytes: (size_t)length
	  fromBuffer: (const void*)buffer
{
	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa
						      socket: self];
		@throw [OFNotConnectedException exceptionWithClass: isa
							    socket: self];

	if (atEndOfStream) {
		OFWriteFailedException *e;

		e = [OFWriteFailedException newWithClass: isa
						  stream: self
					 requestedLength: length];
		e = [OFWriteFailedException exceptionWithClass: isa
							stream: self
					       requestedLength: length];
#ifndef _WIN32
		e->errNo = ENOTCONN;
#else
		e->errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if (send(sock, buffer, length, 0) < length)
		@throw [OFWriteFailedException newWithClass: isa
						     stream: self
					    requestedLength: length];
		@throw [OFWriteFailedException exceptionWithClass: isa
							   stream: self
						  requestedLength: length];
}

#ifdef _WIN32
- (void)setBlocking: (BOOL)enable
{
	u_long v = enable;
	blocking = enable;

	if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException newWithClass: isa
							 stream: self];
		@throw [OFSetOptionFailedException exceptionWithClass: isa
							       stream: self];
}
#endif

- (int)fileDescriptor
{
	return sock;
}

- (void)close
{
	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa
						      socket: self];
		@throw [OFNotConnectedException exceptionWithClass: isa
							    socket: self];

	close(sock);

	sock = INVALID_SOCKET;
	atEndOfStream = NO;
}

Modified src/OFString+Serialization.m from [fd771ca2dd] to [927cabf999].

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







-
-
-
+
+

-
-
-
+
+





-
-
+
+










	OFXMLElement *root;
	OFArray *elements;
	id object;

	@try {
		root = [OFXMLElement elementWithXMLString: self];
	} @catch (OFMalformedXMLException *e) {
		[e release];
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];
	} @catch (OFUnboundNamespaceException *e) {
		[e release];
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];
	}

	elements = [root elementsForNamespace: OF_SERIALIZATION_NS];

	if ([elements count] != 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	object = [[elements firstObject] objectByDeserializing];

	[object retain];
	[pool release];
	[object autorelease];

	return object;
}
@end

Modified src/OFString+URLEncoding.m from [67c1b2dfaa] to [cfd7bec6c2].

39
40
41
42
43
44
45
46
47


48
49
50
51
52
53
54
39
40
41
42
43
44
45


46
47
48
49
50
51
52
53
54







-
-
+
+







	/*
	 * Worst case: 3 times longer than before.
	 * Oh, and we can't use [self allocWithSize:] here as self might be a
	 * @"" literal.
	 */
	if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL)
		@throw [OFOutOfMemoryException
		    newWithClass: isa
		   requestedSize: ([self UTF8StringLength] * 3) + 1];
		    exceptionWithClass: isa
			 requestedSize: ([self UTF8StringLength] * 3) + 1];

	for (i = 0; *string != '\0'; string++) {
		if (isalnum((int)*string) || *string == '-' || *string == '_' ||
		    *string == '.' || *string == '~')
			retCString[i++] = *string;
		else {
			uint8_t high, low;
81
82
83
84
85
86
87
88
89


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


88
89
90
91
92
93
94
95
96







-
-
+
+







	char *retCString;
	char byte = 0;
	int state = 0;
	size_t i;

	if ((retCString = malloc([self UTF8StringLength] + 1)) == NULL)
		@throw [OFOutOfMemoryException
		    newWithClass: isa
		   requestedSize: [self UTF8StringLength] + 1];
		    exceptionWithClass: isa
			 requestedSize: [self UTF8StringLength] + 1];

	for (i = 0; *string; string++) {
		switch (state) {
		case 0:
			if (*string == '%')
				state = 1;
			else if (*string == '+')
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
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







-
+















-
+











			else if (*string >= 'A' && *string <= 'F')
				byte += (*string - 'A' + 10) << shift;
			else if (*string >= 'a' && *string <= 'f')
				byte += (*string - 'a' + 10) << shift;
			else {
				free(retCString);
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}

			if (++state == 3) {
				retCString[i++] = byte;
				state = 0;
				byte = 0;
			}

			break;
		}
	}
	retCString[i] = '\0';

	if (state != 0) {
		free(retCString);
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];
	}

	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: i];
	} @finally {
		free(retCString);
	}
	return ret;
}
@end

Modified src/OFString+XMLEscaping.m from [4986f53819] to [4bad4e66f4].

41
42
43
44
45
46
47
48
49


50
51
52
53
54
55
56
41
42
43
44
45
46
47


48
49
50
51
52
53
54
55
56







-
-
+
+







	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: retLength];
		@throw [OFOutOfMemoryException exceptionWithClass: isa
						    requestedSize: retLength];

	for (i = 0; i < length; i++) {
		switch (string[i]) {
			case '<':
				append = "&lt;";
				appendLen = 4;
				break;
82
83
84
85
86
87
88
89
90


91
92
93
94
95
96
97
82
83
84
85
86
87
88


89
90
91
92
93
94
95
96
97







-
-
+
+







		if (append != NULL) {
			char *newRetCString;

			if ((newRetCString = realloc(retCString,
			    retLength + appendLen)) == NULL) {
				free(retCString);
				@throw [OFOutOfMemoryException
				     newWithClass: isa
				    requestedSize: retLength + appendLen];
				     exceptionWithClass: isa
					  requestedSize: retLength + appendLen];
			}
			retCString = newRetCString;
			retLength += appendLen - 1;

			memcpy(retCString + j, append, appendLen);
			j += appendLen;
		} else

Modified src/OFString+XMLUnescaping.m from [46e3e8dd49] to [5784ae8273].

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

162
163
164
165
166
167

168
169
170
171
172
173
174
175

176
177
178
179
180
181
182
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
162
163
164
165
166

167
168
169
170
171
172
173
174

175
176
177
178
179
180
181
182







-
+

















-
+





-
+







-
+








				pool = [[OFAutoreleasePool alloc] init];
				tmp = parse_numeric_entity(entity,
				    entityLength);

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				[ret appendString: tmp];
				[pool release];
			} else if (delegate != nil) {
				OFAutoreleasePool *pool;
				OFString *n, *tmp;

				pool = [[OFAutoreleasePool alloc] init];

				n = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp =	  [delegate string: self
				containsUnknownEntityNamed: n];

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				[ret appendString: tmp];
				[pool release];
			} else
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			last = i + 1;
			inEntity = NO;
		}
	}

	if (inEntity)
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];

	[ret appendUTF8String: string + last
		   withLength: i - last];

	[ret makeImmutable];

	return ret;
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
281
282
283
284
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
281
282
283
284







-
+
















-
+











-
+











				pool = [[OFAutoreleasePool alloc] init];
				tmp = parse_numeric_entity(entity,
				    entityLength);

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				[ret appendString: tmp];
				[pool release];
			} else {
				OFAutoreleasePool *pool;
				OFString *entityString, *tmp;

				pool = [[OFAutoreleasePool alloc] init];

				entityString = [OFString
				    stringWithUTF8String: entity
						  length: entityLength];
				tmp = block(self, entityString);

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				[ret appendString: tmp];
				[pool release];
			}

			last = i + 1;
			inEntity = NO;
		}
	}

	if (inEntity)
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];

	[ret appendUTF8String: string + last
		   withLength: i - last];

	[ret makeImmutable];

	return ret;
}
#endif
@end

Modified src/OFString.m from [5fcda1615b] to [93030ae4fe].

494
495
496
497
498
499
500
501

502
503
504
505
506
507

508
509
510
511
512
513
514
494
495
496
497
498
499
500

501
502
503
504
505
506

507
508
509
510
511
512
513
514







-
+





-
+







		if (encoding == OF_STRING_ENCODING_UTF_8 ||
		    encoding == OF_STRING_ENCODING_ASCII) {
			switch (of_string_check_utf8(cString, cStringLength,
			    &s->length)) {
			case 1:
				if (encoding == OF_STRING_ENCODING_ASCII)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				s->UTF8 = YES;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}

			memcpy(s->cString, cString, cStringLength);
			s->cString[cStringLength] = 0;

			return self;
		}
528
529
530
531
532
533
534
535

536
537
538
539
540
541
542
528
529
530
531
532
533
534

535
536
537
538
539
540
541
542







-
+








				s->UTF8 = YES;
				bytes = of_string_unicode_to_utf8(
				    (uint8_t)cString[i], buffer);

				if (bytes == 0)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				s->cStringLength += bytes - 1;
				s->cString = [self
				    resizeMemory: s->cString
					  toSize: s->cStringLength + 1];

				memcpy(s->cString + j, buffer, bytes);
552
553
554
555
556
557
558
559


560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576

577
578
579
580
581
582
583
584

585
586
587
588
589
590
591
552
553
554
555
556
557
558

559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576

577
578
579
580
581
582
583
584

585
586
587
588
589
590
591
592







-
+
+
















-
+







-
+







		case OF_STRING_ENCODING_ISO_8859_15:
			table = of_iso_8859_15;
			break;
		case OF_STRING_ENCODING_WINDOWS_1252:
			table = of_windows_1252;
			break;
		default:
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];
		}

		for (i = j = 0; i < cStringLength; i++) {
			char buffer[4];
			of_unichar_t character;
			size_t characterBytes;

			if (!(cString[i] & 0x80)) {
				s->cString[j++] = cString[i];
				continue;
			}

			character = table[(uint8_t)cString[i]];

			if (character == 0xFFFD)
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			s->UTF8 = YES;
			characterBytes = of_string_unicode_to_utf8(character,
			    buffer);

			if (characterBytes == 0)
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			s->cStringLength += characterBytes - 1;
			s->cString = [self resizeMemory: s->cString
						 toSize: s->cStringLength + 1];

			memcpy(s->cString + j, buffer, characterBytes);
			j += characterBytes;
708
709
710
711
712
713
714
715

716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
709
710
711
712
713
714
715

716
717
718
719
720
721
722
723
724
725
726

727
728
729
730
731
732
733







-
+










-








				memcpy(s->cString + j, buffer, 4);
				j += 4;

				break;
			default:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}
		}

		s->cString[j] = '\0';

		@try {
			s->cString = [self resizeMemory: s->cString
						 toSize: s->cStringLength + 1];
		} @catch (OFOutOfMemoryException *e) {
			/* We don't care, as we only tried to make it smaller */
			[e release];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
788
789
790
791
792
793
794
795

796
797
798
799
800
801
802

803
804
805
806
807
808
809
788
789
790
791
792
793
794

795
796
797
798
799
800
801

802
803
804
805
806
807
808
809







-
+






-
+







			of_unichar_t character =
			    (swap ? of_bswap16(string[i]) : string[i]);
			size_t characterLen;

			/* Missing high surrogate */
			if ((character & 0xFC00) == 0xDC00)
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			if ((character & 0xFC00) == 0xD800) {
				uint16_t nextCharacter;

				if (length <= i + 1)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];
					    exceptionWithClass: isa];

				nextCharacter = (swap
				    ? of_bswap16(string[i + 1])
				    : string[i + 1]);
				character = (((character & 0x3FF) << 10) |
				    (nextCharacter & 0x3FF)) + 0x10000;

841
842
843
844
845
846
847
848

849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
841
842
843
844
845
846
847

848
849
850
851
852
853
854
855
856
857
858

859
860
861
862
863
864
865







-
+










-








				memcpy(s->cString + j, buffer, 4);
				j += 4;

				break;
			default:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}
		}

		s->cString[j] = '\0';

		@try {
			s->cString = [self resizeMemory: s->cString
						 toSize: s->cStringLength + 1];
		} @catch (OFOutOfMemoryException *e) {
			/* We don't care, as we only tried to make it smaller */
			[e release];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
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
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







-
-
+
+
+






-
+
+











-
+





+







{
	self = [super init];

	@try {
		int cStringLength;

		if (format == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		s = [self allocMemoryWithSize: sizeof(*s)];
		memset(s, 0, sizeof(*s));

		if ((cStringLength = of_vasprintf(&s->cString,
		    [format UTF8String], arguments)) == -1)
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		s->cStringLength = cStringLength;

		@try {
			switch (of_string_check_utf8(s->cString,
			    cStringLength, &s->length)) {
			case 1:
				s->UTF8 = YES;
				break;
			case -1:
				@throw [OFInvalidEncodingException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			}

			[self addMemoryToPool: s->cString];
		} @catch (id e) {
			free(s->cString);
			@throw e;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020




1021
1022
1023

1024
1025
1026
1027
1028
1029
1030
1013
1014
1015
1016
1017
1018
1019



1020
1021
1022
1023
1024
1025

1026
1027
1028
1029
1030
1031
1032
1033







-
-
-
+
+
+
+


-
+







	struct stat st;

	@try {
		OFFile *file;

		if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
		    &st) == -1)
			@throw [OFOpenFileFailedException newWithClass: isa
								  path: path
								  mode: @"rb"];
			@throw [OFOpenFileFailedException
			    exceptionWithClass: isa
					  path: path
					  mode: @"rb"];

		if (st.st_size > SIZE_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		file = [[OFFile alloc] initWithPath: path
					       mode: @"rb"];

		@try {
			tmp = [self allocMemoryWithSize: (size_t)st.st_size];

1077
1078
1079
1080
1081
1082
1083
1084
1085
1086



1087
1088
1089
1090
1091
1092
1093
1080
1081
1082
1083
1084
1085
1086



1087
1088
1089
1090
1091
1092
1093
1094
1095
1096







-
-
-
+
+
+







	}

	request = [OFHTTPRequest requestWithURL: URL];
	result = [request perform];

	if ([result statusCode] != 200)
		@throw [OFHTTPRequestFailedException
		    newWithClass: [request class]
		     HTTPRequest: request
			  result: result];
		    exceptionWithClass: [request class]
			   HTTPRequest: request
				result: result];

	if (encoding == OF_STRING_ENCODING_AUTODETECT &&
	    (contentType = [[result headers] objectForKey: @"Content-Type"])) {
		contentType = [[contentType mutableCopy] autorelease];
		[contentType lower];

		if ([contentType hasSuffix: @"charset=UTF-8"])
1114
1115
1116
1117
1118
1119
1120
1121
1122



1123
1124
1125
1126
1127
1128
1129
1117
1118
1119
1120
1121
1122
1123


1124
1125
1126
1127
1128
1129
1130
1131
1132
1133







-
-
+
+
+







- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		self = [self initWithString: [element stringValue]];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
1140
1141
1142
1143
1144
1145
1146
1147


1148
1149
1150
1151
1152


1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173


1174
1175
1176
1177
1178


1179
1180
1181
1182
1183
1184
1185
1144
1145
1146
1147
1148
1149
1150

1151
1152
1153
1154
1155


1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177

1178
1179
1180
1181
1182


1183
1184
1185
1186
1187
1188
1189
1190
1191







-
+
+



-
-
+
+




















-
+
+



-
-
+
+







- (const char*)cStringWithEncoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_UTF_8:
		return s->cString;
	case OF_STRING_ENCODING_ASCII:
		if (s->UTF8)
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];

		return s->cString;
	default:
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];
	}
}

- (size_t)length
{
	return s->length;
}

- (size_t)UTF8StringLength
{
	return s->cStringLength;
}

- (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding
{
	switch (encoding) {
	case OF_STRING_ENCODING_UTF_8:
		return s->cStringLength;
	case OF_STRING_ENCODING_ASCII:
		if (s->UTF8)
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];

		return s->cStringLength;
	default:
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];
		@throw [OFNotImplementedException exceptionWithClass: isa
							    selector: _cmd];
	}
}

- (BOOL)isEqual: (id)object
{
	OFString *otherString;

1211
1212
1213
1214
1215
1216
1217
1218
1219


1220
1221
1222
1223
1224
1225
1226
1217
1218
1219
1220
1221
1222
1223


1224
1225
1226
1227
1228
1229
1230
1231
1232







-
-
+
+







- (of_comparison_result_t)compare: (id)object
{
	OFString *otherString;
	size_t otherCStringLength, minimumCStringLength;
	int compare;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherString = object;
	otherCStringLength = [otherString UTF8StringLength];
	minimumCStringLength = (s->cStringLength > otherCStringLength
	    ? otherCStringLength : s->cStringLength);

	if ((compare = memcmp(s->cString, [otherString UTF8String],
1241
1242
1243
1244
1245
1246
1247
1248
1249


1250
1251
1252
1253
1254
1255
1256
1247
1248
1249
1250
1251
1252
1253


1254
1255
1256
1257
1258
1259
1260
1261
1262







-
-
+
+







- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	const char *otherCString;
	size_t i, j, otherCStringLength, minimumCStringLength;
	int compare;

	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherCString = [otherString UTF8String];
	otherCStringLength = [otherString UTF8StringLength];

	if (!s->UTF8) {
		minimumCStringLength = (s->cStringLength > otherCStringLength
		    ? otherCStringLength : s->cStringLength);
1278
1279
1280
1281
1282
1283
1284
1285


1286
1287
1288
1289
1290
1291
1292
1284
1285
1286
1287
1288
1289
1290

1291
1292
1293
1294
1295
1296
1297
1298
1299







-
+
+








		l1 = of_string_utf8_to_unicode(s->cString + i,
		    s->cStringLength - i, &c1);
		l2 = of_string_utf8_to_unicode(otherCString + j,
		    otherCStringLength - j, &c2);

		if (l1 == 0 || l2 == 0 || c1 > 0x10FFFF || c2 > 0x10FFFF)
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];

		if (c1 >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) {
			of_unichar_t tc =
			    of_unicode_casefolding_table[c1 >> 8][c1 & 0xFF];

			if (tc)
				c1 = tc;
1358
1359
1360
1361
1362
1363
1364
1365

1366
1367
1368
1369
1370
1371
1372
1373
1374
1375

1376
1377
1378
1379
1380
1381
1382
1365
1366
1367
1368
1369
1370
1371

1372
1373
1374
1375
1376
1377
1378
1379
1380
1381

1382
1383
1384
1385
1386
1387
1388
1389







-
+









-
+







}

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

	if (index >= s->length)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	if (!s->UTF8)
		return s->cString[index];

	index = of_string_index_to_position(s->cString, index,
	    s->cStringLength);

	if (!of_string_utf8_to_unicode(s->cString + index,
	    s->cStringLength - index, &character))
		@throw [OFInvalidEncodingException newWithClass: isa];
		@throw [OFInvalidEncodingException exceptionWithClass: isa];

	return character;
}

- (size_t)indexOfFirstOccurrenceOfString: (OFString*)string
{
	const char *cString = [string UTF8String];
1437
1438
1439
1440
1441
1442
1443
1444

1445
1446
1447
1448
1449
1450
1451
1444
1445
1446
1447
1448
1449
1450

1451
1452
1453
1454
1455
1456
1457
1458







-
+








- (OFString*)substringWithRange: (of_range_t)range
{
	size_t start = range.start;
	size_t end = range.start + range.length;

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

	if (s->UTF8) {
		start = of_string_index_to_position(s->cString, start,
		    s->cStringLength);
		end = of_string_index_to_position(s->cString, end,
		    s->cStringLength);
	}
1743
1744
1745
1746
1747
1748
1749
1750

1751
1752
1753
1754
1755
1756
1757
1758

1759
1760
1761
1762
1763
1764
1765
1766


1767
1768
1769
1770
1771
1772
1773
1750
1751
1752
1753
1754
1755
1756

1757
1758
1759
1760
1761
1762
1763
1764

1765
1766
1767
1768
1769
1770
1771
1772

1773
1774
1775
1776
1777
1778
1779
1780
1781







-
+







-
+







-
+
+








	for (; i < cStringLength; i++) {
		if (expectWhitespace) {
			if (cString[i] != ' ' && cString[i] != '\t' &&
			    cString[i] != '\n' && cString[i] != '\r' &&
			    cString[i] != '\f')
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			continue;
		}

		if (cString[i] >= '0' && cString[i] <= '9') {
			if (INTMAX_MAX / 10 < value ||
			    INTMAX_MAX - value * 10 < cString[i] - '0')
				@throw [OFOutOfRangeException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			value = (value * 10) + (cString[i] - '0');
		} else if (cString[i] == ' ' || cString[i] == '\t' ||
		    cString[i] == '\n' || cString[i] == '\r' ||
		    cString[i] == '\f')
			expectWhitespace = YES;
		else
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];
	}

	if (cString[0] == '-')
		value *= -1;

	return value;
}
1798
1799
1800
1801
1802
1803
1804
1805

1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824


1825
1826
1827

1828
1829
1830
1831
1832
1833

1834
1835
1836
1837
1838
1839
1840
1806
1807
1808
1809
1810
1811
1812

1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831

1832
1833
1834
1835

1836
1837
1838
1839
1840
1841

1842
1843
1844
1845
1846
1847
1848
1849







-
+


















-
+
+


-
+





-
+







		uintmax_t newValue;

		if (expectWhitespace) {
			if (cString[i] != ' ' && cString[i] != '\t' &&
			    cString[i] != '\n' && cString[i] != '\r' &&
			    cString[i] != '\f')
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];
			continue;
		}

		if (cString[i] >= '0' && cString[i] <= '9') {
			newValue = (value << 4) | (cString[i] - '0');
			foundValue = YES;
		} else if (cString[i] >= 'A' && cString[i] <= 'F') {
			newValue = (value << 4) | (cString[i] - 'A' + 10);
			foundValue = YES;
		} else if (cString[i] >= 'a' && cString[i] <= 'f') {
			newValue = (value << 4) | (cString[i] - 'a' + 10);
			foundValue = YES;
		} else if (cString[i] == 'h' || cString[i] == ' ' ||
		    cString[i] == '\t' || cString[i] == '\n' ||
		    cString[i] == '\r' || cString[i] == '\f') {
			expectWhitespace = YES;
			continue;
		} else
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		if (newValue < value)
			@throw [OFOutOfRangeException newWithClass: isa];
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		value = newValue;
	}

	if (!foundValue)
		@throw [OFInvalidFormatException newWithClass: isa];
		@throw [OFInvalidFormatException exceptionWithClass: isa];

	return value;
}

- (float)floatValue
{
	const char *cString = s->cString;
1850
1851
1852
1853
1854
1855
1856
1857

1858
1859
1860
1861
1862
1863
1864
1859
1860
1861
1862
1863
1864
1865

1866
1867
1868
1869
1870
1871
1872
1873







-
+







	/* Check if there are any invalid chars left */
	if (endPointer != NULL)
		for (; *endPointer != '\0'; endPointer++)
			if (*endPointer != ' ' && *endPointer != '\t' &&
			    *endPointer != '\n' && *endPointer != '\r' &&
			    *endPointer != '\f')
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];

	return value;
}

- (double)doubleValue
{
	const char *cString = s->cString;
1874
1875
1876
1877
1878
1879
1880
1881

1882
1883
1884
1885
1886
1887
1888
1883
1884
1885
1886
1887
1888
1889

1890
1891
1892
1893
1894
1895
1896
1897







-
+







	/* Check if there are any invalid chars left */
	if (endPointer != NULL)
		for (; *endPointer != '\0'; endPointer++)
			if (*endPointer != ' ' && *endPointer != '\t' &&
			    *endPointer != '\n' && *endPointer != '\r' &&
			    *endPointer != '\f')
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];

	return value;
}

- (of_unichar_t*)unicodeString
{
	OFObject *object = [[[OFObject alloc] init] autorelease];
1901
1902
1903
1904
1905
1906
1907
1908


1909
1910
1911
1912
1913
1914
1915
1910
1911
1912
1913
1914
1915
1916

1917
1918
1919
1920
1921
1922
1923
1924
1925







-
+
+







		of_unichar_t c;
		size_t cLen;

		cLen = of_string_utf8_to_unicode(s->cString + i,
		    s->cStringLength - i, &c);

		if (cLen == 0 || c > 0x10FFFF)
			@throw [OFInvalidEncodingException newWithClass: isa];
			@throw [OFInvalidEncodingException
			    exceptionWithClass: isa];

		ret[j++] = c;
		i += cLen;
	}

	ret[j] = 0;

Modified src/OFTCPSocket.m from [37dbaea5b8] to [6c64c65615].

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







-
-
+
+












-
-
-
+
+
+
+







	return self;
}

- (void)connectToHost: (OFString*)host
		 port: (uint16_t)port
{
	if (sock != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException newWithClass: isa
							  socket: self];
		@throw [OFAlreadyConnectedException exceptionWithClass: isa
								socket: self];

#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints, *res, *res0;
	char portCString[7];

	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	snprintf(portCString, 7, "%" PRIu16, port);

	if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    portCString, &hints, &res0))
		@throw [OFAddressTranslationFailedException newWithClass: isa
								  socket: self
								    host: host];
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: isa
				socket: self
				  host: host];

	for (res = res0; res != NULL; res = res->ai_next) {
		if ((sock = socket(res->ai_family, res->ai_socktype,
		    res->ai_protocol)) == INVALID_SOCKET)
			continue;

		if (connect(sock, res->ai_addr, res->ai_addrlen) == -1) {
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
162
163
164
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
162
163
164
165
166







-
-
-
+
+
+
+












-
-
-
-
+
+
+
+








	if ((he = gethostbyname([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
		[addrlist release];
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException newWithClass: isa
								  socket: self
								    host: host];
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: isa
				socket: self
				  host: host];
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = of_bswap16_if_le(port);

	if (he->h_addrtype != AF_INET ||
	    (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
# ifdef OF_THREADS
		[addrlist release];
		[mutex unlock];
# endif
		@throw [OFConnectionFailedException newWithClass: isa
							  socket: self
							    host: host
							    port: port];
		@throw [OFConnectionFailedException exceptionWithClass: isa
								socket: self
								  host: host
								  port: port];
	}

# ifdef OF_THREADS
	@try {
		for (ip = he->h_addr_list; *ip != NULL; ip++)
			[addrlist addItem: ip];

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
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
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
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
359
360
361
362







-
-
-
-
+
+
+
+













-
-
+
+












-
-
-
+
+
+
+


-
-
-
-
+
+
+
+





-
-
-
-
+
+
+
+















-
-
-
+
+
+
+










-
-
-
+
+
+
+








-
-
-
-
+
+
+
+




-
-
-
-
+
+
+
+










-
-
-
-
+
+
+
+









-
-
-
-
+
+
+
+





-
-
+
+


-
-
-
+
+
+







-
-
+
+


-
-
-
+
+
+







	if (!connected) {
		close(sock);
		sock = INVALID_SOCKET;
	}
#endif

	if (sock == INVALID_SOCKET)
		@throw [OFConnectionFailedException newWithClass: isa
							  socket: self
							    host: host
							    port: port];
		@throw [OFConnectionFailedException exceptionWithClass: isa
								socket: self
								  host: host
								  port: port];
}

- (uint16_t)bindToHost: (OFString*)host
		  port: (uint16_t)port
{
	union {
		struct sockaddr_storage storage;
		struct sockaddr_in in;
		struct sockaddr_in6 in6;
	} addr;
	socklen_t addrLen;

	if (sock != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException newWithClass: isa
							  socket: self];
		@throw [OFAlreadyConnectedException exceptionWithClass: isa
								socket: self];

#ifdef HAVE_THREADSAFE_GETADDRINFO
	struct addrinfo hints, *res;
	char portCString[7];

	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	snprintf(portCString, 7, "%" PRIu16, port);

	if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    portCString, &hints, &res))
		@throw [OFAddressTranslationFailedException newWithClass: isa
								  socket: self
								    host: host];
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: isa
				socket: self
				  host: host];

	if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
		@throw [OFBindFailedException newWithClass: isa
						    socket: self
						      host: host
						      port: port];
		@throw [OFBindFailedException exceptionWithClass: isa
							  socket: self
							    host: host
							    port: port];

	if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) {
		freeaddrinfo(res);
		close(sock);
		sock = INVALID_SOCKET;
		@throw [OFBindFailedException newWithClass: isa
						    socket: self
						      host: host
						      port: port];
		@throw [OFBindFailedException exceptionWithClass: isa
							  socket: self
							    host: host
							    port: port];
	}

	freeaddrinfo(res);
#else
	struct hostent *he;

# ifdef OF_THREADS
	[mutex lock];
# endif

	if ((he = gethostbyname([host cStringWithEncoding:
	    OF_STRING_ENCODING_NATIVE])) == NULL) {
# ifdef OF_THREADS
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException newWithClass: isa
								  socket: self
								    host: host];
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: isa
				socket: self
				  host: host];
	}

	memset(&addr, 0, sizeof(addr));
	addr.in.sin_family = AF_INET;
	addr.in.sin_port = of_bswap16_if_le(port);

	if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) {
# ifdef OF_THREADS
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException newWithClass: isa
								  socket: self
								    host: host];
		@throw [OFAddressTranslationFailedException
		    exceptionWithClass: isa
				socket: self
				  host: host];
	}

	memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length);

# ifdef OF_THREADS
	[mutex unlock];
# endif
	if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
		@throw [OFBindFailedException newWithClass: isa
						    socket: self
						      host: host
						      port: port];
		@throw [OFBindFailedException exceptionWithClass: isa
							  socket: self
							    host: host
							    port: port];

	if (bind(sock, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) {
		close(sock);
		sock = INVALID_SOCKET;
		@throw [OFBindFailedException newWithClass: isa
						    socket: self
						      host: host
						      port: port];
		@throw [OFBindFailedException exceptionWithClass: isa
							  socket: self
							    host: host
							    port: port];
	}
#endif

	if (port > 0)
		return port;

	addrLen = sizeof(addr.storage);
	if (getsockname(sock, (struct sockaddr*)&addr, &addrLen)) {
		close(sock);
		sock = INVALID_SOCKET;
		@throw [OFBindFailedException newWithClass: isa
						    socket: self
						      host: host
						      port: port];
		@throw [OFBindFailedException exceptionWithClass: isa
							  socket: self
							    host: host
							    port: port];
	}

	if (addr.storage.ss_family == AF_INET)
		return of_bswap16_if_le(addr.in.sin_port);
	if (addr.storage.ss_family == AF_INET6)
		return of_bswap16_if_le(addr.in6.sin6_port);

	close(sock);
	sock = INVALID_SOCKET;
	@throw [OFBindFailedException newWithClass: isa
					    socket: self
					      host: host
					      port: port];
	@throw [OFBindFailedException exceptionWithClass: isa
						  socket: self
						    host: host
						    port: port];
}

- (void)listenWithBackLog: (int)backLog
{
	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa
						      socket: self];
		@throw [OFNotConnectedException exceptionWithClass: isa
							    socket: self];

	if (listen(sock, backLog) == -1)
		@throw [OFListenFailedException newWithClass: isa
						      socket: self
						     backLog: backLog];
		@throw [OFListenFailedException exceptionWithClass: isa
							    socket: self
							   backLog: backLog];

	listening = YES;
}

- (void)listen
{
	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa
						      socket: self];
		@throw [OFNotConnectedException exceptionWithClass: isa
							    socket: self];

	if (listen(sock, 5) == -1)
		@throw [OFListenFailedException newWithClass: isa
						      socket: self
						     backLog: 5];
		@throw [OFListenFailedException exceptionWithClass: isa
							    socket: self
							   backLog: 5];

	listening = YES;
}

- (OFTCPSocket*)accept
{
	OFTCPSocket *newSocket;
368
369
370
371
372
373
374
375
376


377
378
379
380
381
382
383
384
385
386
387
388
389
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
373
374
375
376
377
378
379


380
381
382
383
384
385
386
387
388
389
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







-
-
+
+














-
-
+
+







-
-
+
+








-
+
















-
+







		[newSocket release];
		@throw e;
	}

	if ((newSock = accept(sock, (struct sockaddr*)addr,
	    &addrLen)) == INVALID_SOCKET) {
		[newSocket release];
		@throw [OFAcceptFailedException newWithClass: isa
						      socket: self];
		@throw [OFAcceptFailedException exceptionWithClass: isa
							    socket: self];
	}

	newSocket->sock = newSock;
	newSocket->sockAddr = addr;
	newSocket->sockAddrLen = addrLen;

	return newSocket;
}

- (void)setKeepAlivesEnabled: (BOOL)enable
{
	int v = enable;

	if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v)))
		@throw [OFSetOptionFailedException newWithClass: isa
							 stream: self];
		@throw [OFSetOptionFailedException exceptionWithClass: isa
							       stream: self];
}

- (OFString*)remoteAddress
{
	char *host;

	if (sockAddr == NULL || sockAddrLen == 0)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

#ifdef HAVE_THREADSAFE_GETADDRINFO
	host = [self allocMemoryWithSize: NI_MAXHOST];

	@try {
		if (getnameinfo((struct sockaddr*)sockAddr, sockAddrLen, host,
		    NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		return [OFString stringWithCString: host
					  encoding: OF_STRING_ENCODING_NATIVE];
	} @finally {
		[self freeMemory: host];
	}
#else
# ifdef OF_THREADS
	[mutex lock];

	@try {
# endif
		host = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr);

		if (host == NULL)
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		return [OFString stringWithCString: host
					  encoding: OF_STRING_ENCODING_NATIVE];
# ifdef OF_THREADS
	} @finally {
		[mutex unlock];
	}

Modified src/OFThread.m from [b865223801] to [475603ba84].

63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77







-
+








#if defined(OF_GNU_RUNTIME) || defined(OF_OLD_GNU_RUNTIME)
	objc_thread_add();
#endif

	if (!of_tlskey_set(threadSelf, thread))
		@throw [OFInitializationFailedException
		    newWithClass: [thread class]];
		    exceptionWithClass: [thread class]];

	/*
	 * Nasty workaround for thread implementations which can't return a
	 * value on join.
	 */
#ifdef OF_HAVE_BLOCKS
	if (thread->block != NULL)
105
106
107
108
109
110
111
112


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

112
113
114
115
116
117
118
119
120







-
+
+








+ (void)initialize
{
	if (self != [OFThread class])
		return;

	if (!of_tlskey_new(&threadSelf))
		@throw [OFInitializationFailedException newWithClass: self];
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];
}

+ thread
{
	return [[[self alloc] init] autorelease];
}

138
139
140
141
142
143
144
145
146


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
179
180
181
182
183
184
185
186

187
188
189
190
191
192

193
194
195
196
197
198
199
139
140
141
142
143
144
145


146
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
179
180
181
182
183
184
185
186

187
188
189
190
191
192

193
194
195
196
197
198
199
200







-
-
+
+

















-
+



-
+





-
+











-
+





-
+








+ (void)setObject: (id)object
	forTLSKey: (OFTLSKey*)key
{
	id oldObject = of_tlskey_get(key->key);

	if (!of_tlskey_set(key->key, [object retain]))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

	[oldObject release];
}

+ (id)objectForTLSKey: (OFTLSKey*)key
{
	return [[of_tlskey_get(key->key) retain] autorelease];
}

+ (OFThread*)currentThread
{
	return [[of_tlskey_get(threadSelf) retain] autorelease];
}

+ (void)sleepForTimeInterval: (double)seconds
{
	if (seconds < 0)
		@throw [OFOutOfRangeException newWithClass: self];
		@throw [OFOutOfRangeException exceptionWithClass: self];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];
		@throw [OFOutOfRangeException exceptionWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)rint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];
		@throw [OFOutOfRangeException exceptionWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	double seconds = [date timeIntervalSinceNow];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];
		@throw [OFOutOfRangeException exceptionWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)rint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];
		@throw [OFOutOfRangeException exceptionWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)yield
{
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
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







-
-
+
+











-
-
+
+










-
-
+
+








-
-
+
+









-
-
+
+








	return self;
}
#endif

- (id)main
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];

	return nil;
}

- (void)handleTermination
{
}

- (void)start
{
	if (running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException newWithClass: isa
							    thread: self];
		@throw [OFThreadStillRunningException exceptionWithClass: isa
								  thread: self];

	if (running == OF_THREAD_WAITING_FOR_JOIN) {
		of_thread_detach(thread);
		[returnValue release];
	}

	[self retain];

	if (!of_thread_new(&thread, call_main, self)) {
		[self release];
		@throw [OFThreadStartFailedException newWithClass: isa
							   thread: self];
		@throw [OFThreadStartFailedException exceptionWithClass: isa
								 thread: self];
	}

	running = OF_THREAD_RUNNING;
}

- (id)join
{
	if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread))
		@throw [OFThreadJoinFailedException newWithClass: isa
							  thread: self];
		@throw [OFThreadJoinFailedException exceptionWithClass: isa
								thread: self];

	running = OF_THREAD_NOT_RUNNING;

	return returnValue;
}

- (void)dealloc
{
	if (running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException newWithClass: isa
							    thread: self];
		@throw [OFThreadStillRunningException exceptionWithClass: isa
								  thread: self];

	/*
	 * We should not be running anymore, but call detach in order to free
	 * the resources.
	 */
	if (running == OF_THREAD_WAITING_FOR_JOIN)
		of_thread_detach(thread);
361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
362
363
364
365
366
367
368

369
370
371
372
373
374
375
376







-
+







- init
{
	self = [super init];

	@try {
		if (!of_tlskey_new(&key))
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		initialized = YES;

		@synchronized (TLSKeys) {
			listObject = [TLSKeys appendObject: self];
		}
	} @catch (id e) {
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
509
510


511
512
513
514
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
509
510
511
512
513


514
515
516
517
518
519







-
+










-
-
+
+










-
-
+
+






-
-
+
+
+


















-
+










-
-
+
+
+





-
-
+
+
+





-
-
+
+
+







-
-
+
+




- init
{
	self = [super init];

	if (!of_mutex_new(&mutex)) {
		Class c = isa;
		[self release];
		@throw [OFInitializationFailedException newWithClass: c];
		@throw [OFInitializationFailedException exceptionWithClass: c];
	}

	initialized = YES;

	return self;
}

- (void)lock
{
	if (!of_mutex_lock(&mutex))
		@throw [OFMutexLockFailedException newWithClass: isa
							  mutex: self];
		@throw [OFMutexLockFailedException exceptionWithClass: isa
								mutex: self];
}

- (BOOL)tryLock
{
	return of_mutex_trylock(&mutex);
}

- (void)unlock
{
	if (!of_mutex_unlock(&mutex))
		@throw [OFMutexUnlockFailedException newWithClass: isa
							    mutex: self];
		@throw [OFMutexUnlockFailedException exceptionWithClass: isa
								  mutex: self];
}

- (void)dealloc
{
	if (initialized)
		if (!of_mutex_free(&mutex))
			@throw [OFMutexStillLockedException newWithClass: isa
								   mutex: self];
			@throw [OFMutexStillLockedException
			    exceptionWithClass: isa
					 mutex: self];

	[super dealloc];
}
@end

@implementation OFCondition
+ condition
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	if (!of_condition_new(&condition)) {
		Class c = isa;
		[self release];
		@throw [OFInitializationFailedException newWithClass: c];
		@throw [OFInitializationFailedException exceptionWithClass: c];
	}

	conditionInitialized = YES;

	return self;
}

- (void)wait
{
	if (!of_condition_wait(&condition, &mutex))
		@throw [OFConditionWaitFailedException newWithClass: isa
							  condition: self];
		@throw [OFConditionWaitFailedException
		    exceptionWithClass: isa
			     condition: self];
}

- (void)signal
{
	if (!of_condition_signal(&condition))
		@throw [OFConditionSignalFailedException newWithClass: isa
							    condition: self];
		@throw [OFConditionSignalFailedException
		    exceptionWithClass: isa
			     condition: self];
}

- (void)broadcast
{
	if (!of_condition_broadcast(&condition))
		@throw [OFConditionBroadcastFailedException newWithClass: isa
							       condition: self];
		@throw [OFConditionBroadcastFailedException
		    exceptionWithClass: isa
			     condition: self];
}

- (void)dealloc
{
	if (conditionInitialized)
		if (!of_condition_free(&condition))
			@throw [OFConditionStillWaitingException
			    newWithClass: isa
			       condition: self];
			    exceptionWithClass: isa
				     condition: self];

	[super dealloc];
}
@end

Modified src/OFURL.m from [9e5eb723f2] to [d2a8a715d5].

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







-
-
+
+















-
+
+







	self = [super init];

	@try {
		char *tmp, *tmp2;

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: [string UTF8StringLength]];
			     exceptionWithClass: isa
				  requestedSize: [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if (!strncmp(UTF8String, "file://", 7)) {
			scheme = @"file";
			path = [[OFString alloc]
			    initWithUTF8String: UTF8String + 7];
			return self;
		} else if (!strncmp(UTF8String, "http://", 7)) {
			scheme = @"http";
			UTF8String += 7;
		} else if (!strncmp(UTF8String, "https://", 8)) {
			scheme = @"https";
			UTF8String += 8;
		} else
			@throw [OFInvalidFormatException newWithClass: isa];
			@throw [OFInvalidFormatException
			    exceptionWithClass: isa];

		if ((tmp = strchr(UTF8String, '/')) != NULL) {
			*tmp = '\0';
			tmp++;
		}

		if ((tmp2 = strchr(UTF8String, '@')) != NULL) {
157
158
159
160
161
162
163
164

165
166
167
168
169
170
171
158
159
160
161
162
163
164

165
166
167
168
169
170
171
172







-
+







			    initWithUTF8String: UTF8String];

			pool = [[OFAutoreleasePool alloc] init];
			portString = [OFString stringWithUTF8String: tmp2];

			if ([portString decimalValue] > 65535)
				@throw [OFInvalidFormatException
				    newWithClass: isa];
				    exceptionWithClass: isa];

			port = [portString decimalValue];

			[pool release];
		} else {
			host = [[OFString alloc]
			    initWithUTF8String: UTF8String];
231
232
233
234
235
236
237
238
239


240
241
242
243
244
245
246
232
233
234
235
236
237
238


239
240
241
242
243
244
245
246
247







-
-
+
+







		host = [URL->host copy];
		port = URL->port;
		user = [URL->user copy];
		password = [URL->password copy];

		if ((UTF8String2 = strdup([string UTF8String])) == NULL)
			@throw [OFOutOfMemoryException
			     newWithClass: isa
			    requestedSize: [string UTF8StringLength]];
			     exceptionWithClass: isa
				  requestedSize: [string UTF8StringLength]];

		UTF8String = UTF8String2;

		if ((tmp = strchr(UTF8String, '#')) != NULL) {
			*tmp = '\0';
			fragment = [[OFString alloc]
			    initWithUTF8String: tmp + 1];
292
293
294
295
296
297
298
299
300



301
302
303
304
305
306
307
293
294
295
296
297
298
299


300
301
302
303
304
305
306
307
308
309







-
-
+
+
+







- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		self = [self initWithString: [element stringValue]];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
407
408
409
410
411
412
413
414
415


416
417
418
419
420
421
422
409
410
411
412
413
414
415


416
417
418
419
420
421
422
423
424







-
-
+
+







{
	OF_GETTER(scheme, YES)
}

- (void)setScheme: (OFString*)scheme_
{
	if (![scheme_ isEqual: @"http"] && ![scheme_ isEqual: @"https"])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	OF_SETTER(scheme, scheme_, YES, YES)
}

- (OFString*)host
{
	OF_GETTER(host, YES)
462
463
464
465
466
467
468
469
470


471
472
473
474
475
476
477
464
465
466
467
468
469
470


471
472
473
474
475
476
477
478
479







-
-
+
+







	OF_GETTER(path, YES)
}

- (void)setPath: (OFString*)path_
{
	if (([scheme isEqual: @"http"] || [scheme isEqual: @"https"]) &&
	    ![path_ hasPrefix: @"/"])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	OF_SETTER(path, path_, YES, YES)
}

- (OFString*)parameters
{
	OF_GETTER(parameters, YES)

Modified src/OFXMLAttribute.m from [d248ebf982] to [04b01cd2af].

59
60
61
62
63
64
65
66
67



68
69
70
71
72
73
74
59
60
61
62
63
64
65


66
67
68
69
70
71
72
73
74
75







-
-
+
+
+







	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		name = [[[element attributeForName: @"name"] stringValue]
		    copy];
		ns = [[[element attributeForName: @"namespace"] stringValue]
		    copy];
		stringValue = [[[element attributeForName: @"stringValue"]
		    stringValue] copy];

Modified src/OFXMLElement+Serialization.m from [190d9e84e0] to [5a6af4a224].

36
37
38
39
40
41
42
43

44
45
46
47
48


49
50
51
52
53
54
55
56
36
37
38
39
40
41
42

43
44
45
46


47
48
49
50
51
52
53
54
55
56







-
+



-
-
+
+








	Class class;
	id object;

	pool = [[OFAutoreleasePool alloc] init];

	if ((class = objc_lookUpClass([name cStringWithEncoding:
	    OF_STRING_ENCODING_ASCII])) == Nil)
		@throw [OFNotImplementedException newWithClass: Nil];
		@throw [OFNotImplementedException exceptionWithClass: Nil];

	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFNotImplementedException
		    newWithClass: class
			selector: @selector(initWithSerialization:)];
		    exceptionWithClass: class
			      selector: @selector(initWithSerialization:)];

	object = [[class alloc] initWithSerialization: self];

	[pool release];

	return [object autorelease];
}
@end

Modified src/OFXMLElement.m from [cc9da6f502] to [9e3650faaf].

131
132
133
134
135
136
137
138
139


140
141
142
143
144
145
146
131
132
133
134
135
136
137


138
139
140
141
142
143
144
145
146







-
-
+
+







	return [[[self alloc] initWithFile: path] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithName: (OFString*)name_
{
	return [self initWithName: name_
			namespace: nil
		      stringValue: nil];
166
167
168
169
170
171
172
173
174



175
176
177
178
179
180
181
166
167
168
169
170
171
172


173
174
175
176
177
178
179
180
181
182







-
-
+
+
+







     namespace: (OFString*)ns_
   stringValue: (OFString*)stringValue
{
	self = [super init];

	@try {
		if (name_ == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		name = [name_ copy];
		ns = [ns_ copy];

		namespaces = [[OFMutableDictionary alloc]
		    initWithKeysAndObjects:
		    @"http://www.w3.org/XML/1998/namespace", @"xml",
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
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







-
-
+
+
+
















-
-
+
+
+
















-
-
+
+
+
















-
-
+
+
+








- initWithCharacters: (OFString*)characters_
{
	self = [super init];

	@try {
		if (characters_ == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		characters = [characters_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithCDATA: (OFString*)CDATA_
{
	self = [super init];

	@try {
		if (CDATA_ == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		CDATA = [CDATA_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithComment: (OFString*)comment_
{
	self = [super init];

	@try {
		if (comment_ == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		comment = [comment_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithElement: (OFXMLElement*)element
{
	self = [super init];

	@try {
		if (element == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		name = [element->name copy];
		ns = [element->ns copy];
		defaultNamespace = [element->defaultNamespace copy];
		attributes = [element->attributes mutableCopy];
		namespaces = [element->namespaces mutableCopy];
		children = [element->children mutableCopy];
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
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







-
-
+
+














-
-
+
+







	OFXMLElement_OFXMLElementBuilderDelegate *delegate;
	Class c;

	c = isa;
	[self release];

	if (string == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];

	parser = [OFXMLParser parser];
	builder = [OFXMLElementBuilder elementBuilder];
	delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init]
	    autorelease];

	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseString: string];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException newWithClass: c
						      parser: parser];
		@throw [OFMalformedXMLException exceptionWithClass: c
							    parser: parser];

	self = [delegate->element retain];

	[pool release];

	return self;
}
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



359
360
361
362
363
364
365
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







-
-
+
+



















-
-
+
+
+








	[parser setDelegate: builder];
	[builder setDelegate: delegate];

	[parser parseFile: path];

	if (![parser finishedParsing])
		@throw [OFMalformedXMLException newWithClass: c
						      parser: parser];
		@throw [OFMalformedXMLException exceptionWithClass: c
							    parser: parser];

	self = [delegate->element retain];

	[pool release];

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		name = [[[element attributeForName: @"name"] stringValue] copy];
		ns = [[[element attributeForName: @"namespace"] stringValue]
		    copy];
		defaultNamespace = [[[element attributeForName:
		    @"defaultNamespace"] stringValue] copy];
		characters = [[[element
389
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
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







-
-
+
+
+













-
-
+
+












-
-
+
+







		namespaces = [[namespacesElement objectByDeserializing] copy];
		children = [[childrenElement objectByDeserializing] copy];

		if (!((name != nil || ns != nil || defaultNamespace != nil ||
		    [attributes count] > 0 || [namespaces count] > 0 ||
		    [children count] > 0) ^ (characters != nil) ^
		    (CDATA != nil) ^ (comment != nil)))
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)setName: (OFString*)name_
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	OF_SETTER(name, name_, YES, YES)
}

- (OFString*)name
{
	return [[name copy] autorelease];
}

- (void)setNamespace: (OFString*)ns_
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	OF_SETTER(ns, ns_, YES, YES)
}

- (OFString*)namespace
{
	return [[ns copy] autorelease];
644
645
646
647
648
649
650
651
652



653
654
655
656
657
658
659
651
652
653
654
655
656
657


658
659
660
661
662
663
664
665
666
667







-
-
+
+
+







		OFString *tmp =
		    [[attributesCArray[j] stringValue] stringByXMLEscaping];

		if ([attributesCArray[j] namespace] != nil &&
		    (attributePrefix = [allNamespaces objectForKey:
		    [attributesCArray[j] namespace]]) == nil)
			@throw [OFUnboundNamespaceException
			    newWithClass: isa
			       namespace: [attributesCArray[j] namespace]];
			    exceptionWithClass: isa
				     namespace: [attributesCArray[j]
						    namespace]];

		length += [attributeName UTF8StringLength] +
		    (attributePrefix != nil ?
		    [attributePrefix UTF8StringLength] + 1 : 0) +
		    [tmp UTF8StringLength] + 4;

		@try {
877
878
879
880
881
882
883
884
885


886
887
888
889
890
891
892
885
886
887
888
889
890
891


892
893
894
895
896
897
898
899
900







-
-
+
+








	return element;
}

- (void)addAttribute: (OFXMLAttribute*)attribute
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

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

	if ([self attributeForName: attribute->name
			 namespace: attribute->ns] == nil)
		[attributes addObject: attribute];
903
904
905
906
907
908
909
910
911


912
913
914
915
916
917
918
911
912
913
914
915
916
917


918
919
920
921
922
923
924
925
926







-
-
+
+







- (void)addAttributeWithName: (OFString*)name_
		   namespace: (OFString*)ns_
		 stringValue: (OFString*)stringValue
{
	OFAutoreleasePool *pool;

	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: ns_
						  stringValue: stringValue]];
	[pool release];
}
986
987
988
989
990
991
992
993
994


995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016


1017
1018
1019
1020
1021
1022
1023
1024
1025


1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036


1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048


1049
1050
1051
1052
1053
1054
1055
994
995
996
997
998
999
1000


1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022


1023
1024
1025
1026
1027
1028
1029
1030
1031


1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042


1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054


1055
1056
1057
1058
1059
1060
1061
1062
1063







-
-
+
+




















-
-
+
+







-
-
+
+









-
-
+
+










-
-
+
+







	}
}

- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns_
{
	if (name == nil || prefix == nil || [prefix isEqual: @""])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];
	if (ns_ == nil)
		ns_ = @"";

	[namespaces setObject: prefix
		       forKey: ns_];
}

- (void)bindPrefix: (OFString*)prefix
      forNamespace: (OFString*)ns_
{
	[self setPrefix: prefix
	   forNamespace: ns_];
	[self addAttributeWithName: prefix
			 namespace: @"http://www.w3.org/2000/xmlns/"
		       stringValue: ns_];
}

- (OFString*)defaultNamespace
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	return [[defaultNamespace retain] autorelease];
}

- (void)setDefaultNamespace: (OFString*)ns_
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	OFString *old = defaultNamespace;
	defaultNamespace = [ns_ copy];
	[old release];
}

- (void)addChild: (OFXMLElement*)child
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

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

	[children addObject: child];
}

- (void)removeChild: (OFXMLElement*)child
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	[children removeObject: child];
}

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

Modified src/OFXMLElementBuilder.m from [0ff6d1dc0d] to [fd1f10a22d].

190
191
192
193
194
195
196
197
198


199
200
201
202
203
204
205
206
190
191
192
193
194
195
196


197
198
199
200
201
202
203
204
205
206







-
-
+
+








}

- (void)elementBuilder: (OFXMLElementBuilder*)builder
  didNotExpectCloseTag: (OFString*)name
	    withPrefix: (OFString*)prefix
	     namespace: (OFString*)ns
{
	@throw [OFMalformedXMLException newWithClass: [builder class]
					      parser: nil];
	@throw [OFMalformedXMLException exceptionWithClass: [builder class]
						    parser: nil];
}

- (OFString*)elementBuilder: (OFXMLElementBuilder*)builder
    foundUnknownEntityNamed: (OFString*)entity
{
	return nil;
}
@end

Modified src/OFXMLParser.m from [4039ac2894] to [8741247447].

116
117
118
119
120
121
122
123
124


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


123
124
125
126
127
128
129
130
131







-
-
+
+







	if (attributePrefix == nil)
		return;

	attributeNS = namespace_for_prefix(attributePrefix, namespaces);

	if ((attributePrefix != nil && attributeNS == nil))
		@throw [OFUnboundNamespaceException
		    newWithClass: isa
			  prefix: attributePrefix];
		    exceptionWithClass: isa
				prefix: attributePrefix];

	[attribute->ns release];
	attribute->ns = [attributeNS retain];
}

@implementation OFXMLParser
+ (void)initialize
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168







-
+







		@selector(_parseInDoctypeWithBuffer:i:last:),
	};
	memcpy(selectors, selectors_, sizeof(selectors_));

	for (i = 0; i < OF_XMLPARSER_NUM_STATES; i++) {
		if (![self instancesRespondToSelector: selectors[i]])
			@throw [OFInitializationFailedException
			    newWithClass: self];
			    exceptionWithClass: self];

		lookupTable[i] = (state_function)
		    [self instanceMethodForSelector: selectors[i]];
	}
}

+ parser
300
301
302
303
304
305
306
307
308


309
310
311
312
313
314
315
300
301
302
303
304
305
306


307
308
309
310
311
312
313
314
315







-
-
+
+







			      last: (size_t*)last
{
	size_t length;

	if ((finishedParsing || [previous count] < 1) && buffer[*i] != ' ' &&
	    buffer[*i] != '\t' && buffer[*i] != '\n' && buffer[*i] != '\r' &&
	    buffer[*i] != '\f' && buffer[*i] != '<')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (buffer[*i] != '<')
		return;

	if ((length = *i - *last) > 0)
		cache_append(cache, buffer + *last, encoding, length);

334
335
336
337
338
339
340
341
342


343
344
345
346
347
348
349
334
335
336
337
338
339
340


341
342
343
344
345
346
347
348
349







-
-
+
+








/* Tag was just opened */
- (void)_parseTagOpenedWithBuffer: (const char*)buffer
				i: (size_t*)i
			     last: (size_t*)last
{
	if (finishedParsing && buffer[*i] != '!' && buffer[*i] != '?')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	switch (buffer[*i]) {
		case '?':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
			level = 0;
			break;
477
478
479
480
481
482
483
484
485


486
487
488
489
490
491
492
477
478
479
480
481
482
483


484
485
486
487
488
489
490
491
492







-
-
+
+







		pi = transform_string(cache, 1, NO, nil);

		if ([pi isEqual: @"xml"] || [pi hasPrefix: @"xml "] ||
		    [pi hasPrefix: @"xml\t"] || [pi hasPrefix: @"xml\r"] ||
		    [pi hasPrefix: @"xml\n"])
			if (![self _parseXMLProcessingInstructions: pi])
				@throw [OFMalformedXMLException
				    newWithClass: isa
					parser: self];
				    exceptionWithClass: isa
						parser: self];

		[delegate parser: self
		    foundProcessingInstructions: pi];

		[pool release];

		[cache removeNItems: [cache count]];
537
538
539
540
541
542
543
544
545
546



547
548
549
550
551
552
553
537
538
539
540
541
542
543



544
545
546
547
548
549
550
551
552
553







-
-
-
+
+
+







	if (buffer[*i] == '>' || buffer[*i] == '/') {
		OFAutoreleasePool *pool2;
		OFString *ns;

		ns = namespace_for_prefix(prefix, namespaces);

		if (prefix != nil && ns == nil)
			@throw
			    [OFUnboundNamespaceException newWithClass: isa
							       prefix: prefix];
			@throw [OFUnboundNamespaceException
			    exceptionWithClass: isa
					prefix: prefix];

		pool2 = [[OFAutoreleasePool alloc] init];

		[delegate parser: self
		 didStartElement: name
		      withPrefix: prefix
		       namespace: ns
622
623
624
625
626
627
628
629
630


631
632
633
634
635
636
637
638
639


640
641
642
643
644
645
646
622
623
624
625
626
627
628


629
630
631
632
633
634
635
636
637


638
639
640
641
642
643
644
645
646







-
-
+
+







-
-
+
+







				length: tmp - cacheCString];
	} else {
		name = [cacheString copy];
		prefix = nil;
	}

	if (![[previous lastObject] isEqual: cacheString])
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	[previous removeLastObject];

	[cache removeNItems: [cache count]];

	ns = namespace_for_prefix(prefix, namespaces);
	if (prefix != nil && ns == nil)
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: prefix];
		@throw [OFUnboundNamespaceException exceptionWithClass: isa
								prefix: prefix];

	[delegate parser: self
	   didEndElement: name
	      withPrefix: prefix
	       namespace: ns];

	[pool release];
683
684
685
686
687
688
689
690
691


692
693
694
695
696
697
698
683
684
685
686
687
688
689


690
691
692
693
694
695
696
697
698







-
-
+
+








	attributesCArray = [attributes cArray];
	attributesCount = [attributes count];

	ns = namespace_for_prefix(prefix, namespaces);

	if (prefix != nil && ns == nil)
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: prefix];
		@throw [OFUnboundNamespaceException exceptionWithClass: isa
								prefix: prefix];

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesCArray[j], namespaces,
		    isa);

	pool = [[OFAutoreleasePool alloc] init];

788
789
790
791
792
793
794
795
796


797
798
799
800
801
802
803
788
789
790
791
792
793
794


795
796
797
798
799
800
801
802
803







-
-
+
+







	*last = *i + 1;

	if (buffer[*i] == ' ' || buffer[*i] == '\t' || buffer[*i] == '\n' ||
	    buffer[*i] == '\r' || buffer[*i] == '\f')
		return;

	if (buffer[*i] != '\'' && buffer[*i] != '"')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	delimiter = buffer[*i];
	state = OF_XMLPARSER_IN_ATTR_VALUE;
}

/* Looking for attribute value */
- (void)_parseInAttributeValueWithBuffer: (const char*)buffer
848
849
850
851
852
853
854
855
856


857
858
859
860
861
862
863
864
865
866
867
868
869
870


871
872
873
874
875
876
877
878
879
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
848
849
850
851
852
853
854


855
856
857
858
859
860
861
862
863
864
865
866
867
868


869
870
871
872
873
874
875
876
877
878


879
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







-
-
+
+












-
-
+
+








-
-
+
+










-
-
+
+










-
-
+
+







				  i: (size_t*)i
			       last: (size_t*)last
{
	if (buffer[*i] == '>') {
		*last = *i + 1;
		state = OF_XMLPARSER_OUTSIDE_TAG;
	} else
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];
}

/* Expecting closing '>' or space */
- (void)_parseExpectSpaceOrCloseWithBuffer: (const char*)buffer
					 i: (size_t*)i
				      last: (size_t*)last
{
	if (buffer[*i] == '>') {
		*last = *i + 1;
		state = OF_XMLPARSER_OUTSIDE_TAG;
	} else if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
	    buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '\f')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];
}

/* In <! */
- (void)_parseInExclamationMarkWithBuffer: (const char*)buffer
					i: (size_t*)i
				     last: (size_t*)last
{
	if (finishedParsing && buffer[*i] != '-')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (buffer[*i] == '-')
		state = OF_XMLPARSER_IN_COMMENT_OPENING;
	else if (buffer[*i] == '[') {
		state = OF_XMLPARSER_IN_CDATA_OPENING;
		level = 0;
	} else if (buffer[*i] == 'D') {
		state = OF_XMLPARSER_IN_DOCTYPE;
		level = 0;
	} else
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	*last = *i + 1;
}

/* CDATA */
- (void)_parseInCDATAOpeningWithBuffer: (const char*)buffer
				     i: (size_t*)i
				  last: (size_t*)last
{
	if (buffer[*i] != "CDATA["[level])
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (++level == 6) {
		state = OF_XMLPARSER_IN_CDATA_1;
		level = 0;
	}

	*last = *i + 1;
956
957
958
959
960
961
962
963
964


965
966
967
968
969
970
971
956
957
958
959
960
961
962


963
964
965
966
967
968
969
970
971







-
-
+
+








/* Comment */
- (void)_parseInCommentOpeningWithBuffer: (const char*)buffer
				       i: (size_t*)i
				    last: (size_t*)last
{
	if (buffer[*i] != '-')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	*last = *i + 1;
	state = OF_XMLPARSER_IN_COMMENT_1;
	level = 0;
}

- (void)_parseInComment1WithBuffer: (const char*)buffer
985
986
987
988
989
990
991
992
993


994
995
996
997
998
999
1000
985
986
987
988
989
990
991


992
993
994
995
996
997
998
999
1000







-
-
+
+







				 i: (size_t*)i
			      last: (size_t*)last
{
	OFAutoreleasePool *pool;
	OFString *comment;

	if (buffer[*i] != '>')
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	pool = [[OFAutoreleasePool alloc] init];

	cache_append(cache, buffer + *last, encoding, *i - *last);
	comment = transform_string(cache, 2, NO, nil);

	[delegate parser: self
1012
1013
1014
1015
1016
1017
1018
1019
1020


1021
1022
1023
1024
1025
1026
1027
1012
1013
1014
1015
1016
1017
1018


1019
1020
1021
1022
1023
1024
1025
1026
1027







-
-
+
+







- (void)_parseInDoctypeWithBuffer: (const char*)buffer
				i: (size_t*)i
			     last: (size_t*)last
{
	if ((level < 6 && buffer[*i] != "OCTYPE"[level]) ||
	    (level == 6 && buffer[*i] != ' ' && buffer[*i] != '\t' &&
	    buffer[*i] != '\n' && buffer[*i] != '\r' && buffer[*i] != '\f'))
		@throw [OFMalformedXMLException newWithClass: isa
						      parser: self];
		@throw [OFMalformedXMLException exceptionWithClass: isa
							    parser: self];

	if (level < 7 || buffer[*i] == '<')
		level++;

	if (buffer[*i] == '>') {
		if (level == 7)
			state = OF_XMLPARSER_OUTSIDE_TAG;

Modified src/exceptions/OFAcceptFailedException.h from [104989e573] to [3baccee512].

33
34
35
36
37
38
39
40
41


42
43
44
45
46
47
48
33
34
35
36
37
38
39


40
41
42
43
44
45
46
47
48







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not accept a connection
 * \return A new accept failed exception
 */
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket;
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket;

/**
 * Initializes an already allocated accept failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not accept a connection
 * \return An initialized accept failed exception

Modified src/exceptions/OFAcceptFailedException.m from [dae33a0f3a] to [68ca85216e].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFTCPSocket.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFAcceptFailedException
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
{
	return [[self alloc] initWithClass: class_
				    socket: socket];
	return [[[self alloc] initWithClass: class_
				     socket: socket] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFAddressTranslationFailedException.h from [0ed93ff62f] to [27158048e9].

36
37
38
39
40
41
42
43
44
45



46
47
48
49
50
51
52
36
37
38
39
40
41
42



43
44
45
46
47
48
49
50
51
52







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not translate the address
 * \param host The host for which translation was requested
 * \return A new address translation failed exception
 */
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
	  host: (OFString*)host;
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
		host: (OFString*)host;

/**
 * Initializes an already allocated address translation failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not translate the address
 * \param host The host for which translation was requested

Modified src/exceptions/OFAddressTranslationFailedException.m from [934b14dab9] to [55b7414608].

19
20
21
22
23
24
25
26
27
28



29
30
31
32



33
34
35
36
37
38
39
19
20
21
22
23
24
25



26
27
28
29



30
31
32
33
34
35
36
37
38
39







-
-
-
+
+
+

-
-
-
+
+
+







#import "OFAddressTranslationFailedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "common.h"

@implementation OFAddressTranslationFailedException
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
	  host: (OFString*)host
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
		host: (OFString*)host
{
	return [[self alloc] initWithClass: class_
				    socket: socket
				      host: host];
	return [[[self alloc] initWithClass: class_
				     socket: socket
				       host: host] autorelease];
}

- initWithClass: (Class)class_
{
	self = [super initWithClass: class_];

	errNo = GET_AT_ERRNO;

Modified src/exceptions/OFAllocFailedException.m from [5462d5e2c5] to [d793965763].

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
63
64
65
66
67
68


69
70
71
72
73
74


75
76
77
78
79
80
81
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
63
64
65
66


67
68
69
70
71
72


73
74
75
76
77
78
79
80
81







-
-
+
+




-
-
+
+




-
-
+
+




-
-
+
+





-
-
+
+





-
-
+
+






-
-
+
+




-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFAllocFailedException
+ alloc
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: self
						    selector: _cmd];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)addMemoryToPool: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)allocMemoryWithSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)allocMemoryForNItems: (size_t)nitems
                     withSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)resizeMemory: (void*)ptr
	       toSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void*)resizeMemory: (void*)ptr
	     toNItems: (size_t)nitems
	     withSize: (size_t)size
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- (void)freeMemory: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
}

- retain
{
	return self;
}

91
92
93
94
95
96
97
98
99


100
101
102
103
104
105
106
107
91
92
93
94
95
96
97


98
99
100
101
102
103
104
105
106
107







-
-
+
+









- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: isa
						    selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}

- (OFString*)description
{
	return @"Allocating an object failed!";
}
@end

Modified src/exceptions/OFAlreadyConnectedException.h from [15e72a820b] to [550efe3a75].

32
33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
32
33
34
35
36
37
38


39
40
41
42
43
44
45
46
47







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which is already connected
 * \return A new already connected exception
 */
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket;
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket;

/**
 * Initializes an already allocated already connected exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which is already connected
 * \return An initialized already connected exception

Modified src/exceptions/OFAlreadyConnectedException.m from [aff1092b87] to [eee4e0d53c].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFAlreadyConnectedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "OFNotImplementedException.h"

@implementation OFAlreadyConnectedException
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
{
	return [[self alloc] initWithClass: class_
				    socket: socket];
	return [[[self alloc] initWithClass: class_
				     socket: socket] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFBindFailedException.h from [e567d3a7b8] to [4b614bf39c].

39
40
41
42
43
44
45
46
47
48
49




50
51
52
53
54
55
56
39
40
41
42
43
44
45




46
47
48
49
50
51
52
53
54
55
56







-
-
-
-
+
+
+
+







/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not be bound
 * \param host The host on which binding failed
 * \param port The port on which binding failed
 * \return A new bind failed exception
 */
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
	  host: (OFString*)host
	  port: (uint16_t)port;
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
		host: (OFString*)host
		port: (uint16_t)port;

/**
 * Initializes an already allocated bind failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not be bound
 * \param host The host on which binding failed

Modified src/exceptions/OFBindFailedException.m from [6af98418a1] to [91fa7c8872].

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







-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+






-
-
+
+







#import "OFTCPSocket.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFBindFailedException
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
	  host: (OFString*)host
	  port: (uint16_t)port
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
		host: (OFString*)host
		port: (uint16_t)port
{
	return [[self alloc] initWithClass: class_
				    socket: socket
				      host: host
				      port: port];
	return [[[self alloc] initWithClass: class_
				     socket: socket
				       host: host
				       port: port] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket_
	   host: (OFString*)host_
	   port: (uint16_t)port_
{

Modified src/exceptions/OFChangeDirectoryFailedException.h from [6483c43480] to [dcb92aff17].

32
33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
32
33
34
35
36
37
38


39
40
41
42
43
44
45
46
47







-
-
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param path A string with the path of the directory to which couldn't be
 *	       changed
 * \return A new change directory failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path;

/**
 * Initializes an already allocated change directory failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path A string with the path of the directory to which couldn't be
 *	       changed

Modified src/exceptions/OFChangeDirectoryFailedException.m from [06b017f928] to [9262514964].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFChangeDirectoryFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path_
+ exceptionWithClass: (Class)class_
		path: (OFString*)path_
{
	return [[self alloc] initWithClass: class_
				      path: path_];
	return [[[self alloc] initWithClass: class_
				       path: path_] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFChangeFileModeFailedException.h from [68f1a5ae2c] to [9ff87f6941].

36
37
38
39
40
41
42
43
44
45



46
47
48
49
50
51
52
36
37
38
39
40
41
42



43
44
45
46
47
48
49
50
51
52







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param path The path of the file
 * \param mode The new mode for the file
 * \return An initialized change file mode failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path
	  mode: (mode_t)mode;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path
		mode: (mode_t)mode;

/**
 * Initializes an already allocated change file mode failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path The path of the file
 * \param mode The new mode for the file

Modified src/exceptions/OFChangeFileModeFailedException.m from [eb09d95cbe] to [c79ce35a3f].

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







-
-
-
+
+
+

-
+


-
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFChangeFileModeFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path
	  mode: (mode_t)mode
+ exceptionWithClass: (Class)class_
		path: (OFString*)path
		mode: (mode_t)mode
{
	return [(OFChangeFileModeFailedException*)[self alloc]
	return [(OFChangeFileModeFailedException*)[[self alloc]
	    initWithClass: class_
		     path: path
		     mode: mode];
		     mode: mode] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	   mode: (mode_t)mode_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFChangeFileOwnerFailedException.h from [b9e808a048] to [5693aff4f5].

38
39
40
41
42
43
44
45
46
47
48




49
50
51
52
53
54
55
38
39
40
41
42
43
44




45
46
47
48
49
50
51
52
53
54
55







-
-
-
-
+
+
+
+







/**
 * \param class_ The class of the object which caused the exception
 * \param path The path of the file
 * \param owner The new owner for the file
 * \param group The new group for the file
 * \return An initialized change file owner failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path
	 owner: (OFString*)owner
	 group: (OFString*)group;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path
	       owner: (OFString*)owner
	       group: (OFString*)group;

/**
 * Initializes an already allocated change file owner failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path The path of the file
 * \param owner The new owner for the file

Modified src/exceptions/OFChangeFileOwnerFailedException.m from [7dece9bb14] to [c859a62a45].

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







-
-
+
+



-
-
-
-
+
+
+
+






-
-
+
+








#import "OFNotImplementedException.h"

#import "common.h"

#ifndef _WIN32
@implementation OFChangeFileOwnerFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path
+ exceptionWithClass: (Class)class_
		path: (OFString*)path
	 owner: (OFString*)owner
	 group: (OFString*)group
{
	return [[self alloc] initWithClass: class_
				      path: path
				     owner: owner
				     group: group];
	return [[[self alloc] initWithClass: class_
				       path: path
				      owner: owner
				      group: group] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	  owner: (OFString*)owner_
	  group: (OFString*)group_
{

Modified src/exceptions/OFConditionBroadcastFailedException.h from [e12b7ee71b] to [fd13d98fd6].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param condition The condition which could not be broadcasted
 * \return A new condition broadcast failed exception
 */
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition;
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition;

/**
 * Initializes an already allocated condition broadcast failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param condition The condition which could not be broadcasted
 * \return An initialized condition broadcast failed exception

Modified src/exceptions/OFConditionBroadcastFailedException.m from [f825f144e3] to [0d533191d7].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFConditionBroadcastFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFConditionBroadcastFailedException
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition
{
	return [[self alloc] initWithClass: class_
				 condition: condition];
	return [[[self alloc] initWithClass: class_
				  condition: condition] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
      condition: (OFCondition*)condition_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFConditionSignalFailedException.h from [f77723c6e0] to [cdbb182805].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param condition The condition which could not be signaled
 * \return A new condition signal failed exception
 */
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition;
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition;

/**
 * Initializes an already allocated condition signal failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param condition The condition which could not be signaled
 * \return An initialized condition signal failed exception

Modified src/exceptions/OFConditionSignalFailedException.m from [c77808a760] to [f819045aa0].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFConditionSignalFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFConditionSignalFailedException
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition
{
	return [[self alloc] initWithClass: class_
				 condition: condition];
	return [[[self alloc] initWithClass: class_
				  condition: condition] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
      condition: (OFCondition*)condition_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFConditionStillWaitingException.h from [8a6b485889] to [70e094545b].

32
33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
32
33
34
35
36
37
38


39
40
41
42
43
44
45
46
47







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param condition The condition for which is still being waited
 * \return A new condition still waiting exception
 */
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition;
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition;

/**
 * Initializes an already allocated condition still waiting exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param condition The condition for which is still being waited
 * \return An initialized condition still waiting exception

Modified src/exceptions/OFConditionStillWaitingException.m from [3e5fe446f3] to [e03a2989d0].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFConditionStillWaitingException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFConditionStillWaitingException
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition
{
	return [[self alloc] initWithClass: class_
				 condition: condition];
	return [[[self alloc] initWithClass: class_
				  condition: condition] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
      condition: (OFCondition*)condition_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFConditionWaitFailedException.h from [58c72c5dc6] to [7f73464612].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param condition The condition for which could not be waited
 * \return A new condition wait failed exception
 */
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition;
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition;

/**
 * Initializes an already allocated condition wait failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param condition The condition for which could not be waited
 * \return An initialized condition wait failed exception

Modified src/exceptions/OFConditionWaitFailedException.m from [8456d86d00] to [b72e25239f].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFConditionWaitFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFConditionWaitFailedException
+ newWithClass: (Class)class_
     condition: (OFCondition*)condition
+ exceptionWithClass: (Class)class_
	   condition: (OFCondition*)condition
{
	return [[self alloc] initWithClass: class_
				 condition: condition];
	return [[[self alloc] initWithClass: class_
				  condition: condition] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
      condition: (OFCondition*)condition_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFConnectionFailedException.h from [97e9485df5] to [1b2365cc81].

39
40
41
42
43
44
45
46
47
48
49




50
51
52
53
54
55
56
39
40
41
42
43
44
45




46
47
48
49
50
51
52
53
54
55
56







-
-
-
-
+
+
+
+







/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not connect
 * \param host The host to which the connection failed
 * \param port The port on the host to which the connection failed
 * \return A new connection failed exception
 */
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
	  host: (OFString*)host
	  port: (uint16_t)port;
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
		host: (OFString*)host
		port: (uint16_t)port;

/**
 * Initializes an already allocated connection failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which could not connect
 * \param host The host to which the connection failed

Modified src/exceptions/OFConnectionFailedException.m from [4942ddb4be] to [579f49dedb].

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







-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+






-
-
+
+







#import "OFTCPSocket.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFConnectionFailedException
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
	  host: (OFString*)host
	  port: (uint16_t)port
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
		host: (OFString*)host
		port: (uint16_t)port
{
	return [[self alloc] initWithClass: class_
				    socket: socket
				      host: host
				      port: port];
	return [[[self alloc] initWithClass: class_
				     socket: socket
				       host: host
				       port: port] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket_
	   host: (OFString*)host_
	   port: (uint16_t)port_
{

Modified src/exceptions/OFCopyFileFailedException.h from [30e5ddb8e4] to [6171556d95].

34
35
36
37
38
39
40
41
42
43



44
45
46
47
48
49
50
34
35
36
37
38
39
40



41
42
43
44
45
46
47
48
49
50







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param src The original path
 * \param dst The new path
 * \return A new copy file failed exception
 */
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst;
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dst;

/**
 * Initializes an already allocated copy file failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param src The original path
 * \param dst The new path

Modified src/exceptions/OFCopyFileFailedException.m from [b4ff248d49] to [2f82a9d520].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFCopyFileFailedException
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dst
{
	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dst];
	return [[[self alloc] initWithClass: class_
				 sourcePath: src
			    destinationPath: dst] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFCreateDirectoryFailedException.h from [98c9ebf6f0] to [7606304628].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param path A string with the path of the directory which couldn't be created
 * \return A new create directory failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path;

/**
 * Initializes an already allocated create directory failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path A string with the path of the directory which couldn't be created
 * \return An initialized create directory failed exception

Modified src/exceptions/OFCreateDirectoryFailedException.m from [be39db6bb2] to [dcbc43ee4f].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFCreateDirectoryFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path_
+ exceptionWithClass: (Class)class_
		path: (OFString*)path_
{
	return [[self alloc] initWithClass: class_
				      path: path_];
	return [[[self alloc] initWithClass: class_
				       path: path_] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFDeleteDirectoryFailedException.h from [13b57a1979] to [bb41cf3072].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param path The path of the directory
 * \return A new delete directory failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path;

/**
 * Initializes an already allocated delete directory failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path The path of the directory
 * \return An initialized delete directory failed exception

Modified src/exceptions/OFDeleteDirectoryFailedException.m from [e991429104] to [fcaf5b6fe1].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFDeleteDirectoryFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path_
+ exceptionWithClass: (Class)class_
		path: (OFString*)path_
{
	return [[self alloc] initWithClass: class_
				      path: path_];
	return [[[self alloc] initWithClass: class_
				       path: path_] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFDeleteFileFailedException.h from [d210ec66f8] to [0ed0b87e06].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param path The path of the file
 * \return A new delete file failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path;

/**
 * Initializes an already allocated delete file failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path The path of the file
 * \return An initialized delete file failed exception

Modified src/exceptions/OFDeleteFileFailedException.m from [d704352100] to [046ff78fb5].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFDeleteFileFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path_
+ exceptionWithClass: (Class)class_
		path: (OFString*)path_
{
	return [[self alloc] initWithClass: class_
				      path: path_];
	return [[[self alloc] initWithClass: class_
				       path: path_] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFEnumerationMutationException.h from [455af96c9c] to [a31b7743be].

26
27
28
29
30
31
32
33
34


35
36
37
38
39
40
41
26
27
28
29
30
31
32


33
34
35
36
37
38
39
40
41







-
-
+
+







}

/**
 * \param class_ The class of the object which caused the exception
 * \param object The object which was mutated during enumeration
 * \return A new enumeration mutation exception
 */
+ newWithClass: (Class)class_
	object: (id)object;
+ exceptionWithClass: (Class)class_
	      object: (id)object;

/**
 * Initializes an already allocated enumeration mutation exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param object The object which was mutated during enumeration
 * \return An initialized enumeration mutation exception

Modified src/exceptions/OFEnumerationMutationException.m from [f7c21afbd0] to [62f4043eb8].

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







-
-
+
+

-
-
+
+






-
-
+
+








#import "OFEnumerationMutationException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFEnumerationMutationException
+ newWithClass: (Class)class_
	object: (id)object
+ exceptionWithClass: (Class)class_
	      object: (id)object
{
	return [[self alloc] initWithClass: class_
				    object: object];
	return [[[self alloc] initWithClass: class_
				     object: object] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 object: (id)object_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFException.h from [aa189c31b8] to [a8b41d395b].

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







-
-
-

















-
+







@class OFString;

/**
 * \brief The base class for all exceptions in ObjFW
 *
 * The OFException class is the base class for all exceptions in ObjFW, except
 * the OFAllocFailedException.
 *
 * IMPORTANT: Exceptions do NOT use OFAutoreleasePools and can't be autoreleased
 * either! You have to make sure to dealloc the exception in your \@catch block!
 */
@interface OFException: OFObject
{
	Class inClass;
	OFString *description;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) Class inClass;
#endif

/**
 * Creates a new exception.
 *
 * \param class_ The class of the object which caused the exception
 * \return A new exception
 */
+ newWithClass: (Class)class_;
+ exceptionWithClass: (Class)class_;

/**
 * Initializes an already allocated OFException.
 *
 * \param class_ The class of the object which caused the exception
 * \return An initialized OFException
 */

Modified src/exceptions/OFException.m from [d023c56c3e] to [77fce54f87].

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







-
+

-
+






-
-
+
+








#import "OFException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFException
+ newWithClass: (Class)class_
+ exceptionWithClass: (Class)class_
{
	return [[self alloc] initWithClass: class_];
	return [[[self alloc] initWithClass: class_] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
{
	self = [super init];

	inClass = class_;
56
57
58
59
60
61
62
63
64
65
66
67
68
69
56
57
58
59
60
61
62






63







-
-
-
-
-
-

	return inClass;
}

- (OFString*)description
{
	return @"An exception occurred";
}

- autorelease
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end

Modified src/exceptions/OFHTTPRequestFailedException.h from [583fdc4f7f] to [1ca1bd68da].

35
36
37
38
39
40
41
42
43
44



45
46
47
48
49
50
51
35
36
37
38
39
40
41



42
43
44
45
46
47
48
49
50
51







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param request The HTTP request which failed
 * \param result The result of the failed HTTP request
 * \return A new HTTP request failed exception
 */
+ newWithClass: (Class)class_
   HTTPRequest: (OFHTTPRequest*)request
	result: (OFHTTPRequestResult*)result;
+ exceptionWithClass: (Class)class_
	 HTTPRequest: (OFHTTPRequest*)request
	      result: (OFHTTPRequestResult*)result;

/**
 * Initializes an already allocated HTTP request failed exception
 *
 * \param class_ The class of the object which caused the exception
 * \param request The HTTP request which failed
 * \param result The result of the failed HTTP request

Modified src/exceptions/OFHTTPRequestFailedException.m from [d4466ea6fb] to [70197ef817].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+







#import "OFString.h"
#import "OFHTTPRequest.h"
#import "OFAutoreleasePool.h"

#import "OFNotImplementedException.h"

@implementation OFHTTPRequestFailedException
+ newWithClass: (Class)class_
   HTTPRequest: (OFHTTPRequest*)request
	result: (OFHTTPRequestResult*)result
+ exceptionWithClass: (Class)class_
	 HTTPRequest: (OFHTTPRequest*)request
	      result: (OFHTTPRequestResult*)result
{
	return [[self alloc] initWithClass: class_
			       HTTPRequest: request
				    result: result];
	return [[[self alloc] initWithClass: class_
				HTTPRequest: request
				     result: result] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
    HTTPRequest: (OFHTTPRequest*)request
	 result: (OFHTTPRequestResult*)result_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFHashAlreadyCalculatedException.h from [f1dcc4433a] to [b07b38ca06].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param hash The hash which has already been calculated
 * \return A new hash already calculated exception
 */
+ newWithClass: (Class)class_
	  hash: (OFHash*)hash;
+ exceptionWithClass: (Class)class_
		hash: (OFHash*)hash;

/**
 * Initializes an already allocated hash already calculated exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param hash The hash which has already been calculated
 * \return An initialized hash already calculated exception

Modified src/exceptions/OFHashAlreadyCalculatedException.m from [468e6a75ff] to [017349a806].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFHashAlreadyCalculatedException.h"
#import "OFString.h"
#import "OFHash.h"

#import "OFNotImplementedException.h"

@implementation OFHashAlreadyCalculatedException
+ newWithClass: (Class)class_
	  hash: (OFHash*)hash
+ exceptionWithClass: (Class)class_
		hash: (OFHash*)hash
{
	return [[self alloc] initWithClass: class_
				      hash: hash];
	return [[[self alloc] initWithClass: class_
				       hash: hash] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   hash: (OFHash*)hash
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFInvalidArgumentException.h from [7302819d12] to [4cf81f0986].

29
30
31
32
33
34
35
36
37


38
39
40
41
42
43
44
29
30
31
32
33
34
35


36
37
38
39
40
41
42
43
44







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param selector The selector which doesn't accept the argument
 * \return A new invalid argument exception
 */
+ newWithClass: (Class)class_
      selector: (SEL)selector;
+ exceptionWithClass: (Class)class_
	    selector: (SEL)selector;

/**
 * Initializes an already allocated invalid argument exception
 *
 * \param class_ The class of the object which caused the exception
 * \param selector The selector which doesn't accept the argument
 * \return An initialized invalid argument exception

Modified src/exceptions/OFInvalidArgumentException.m from [6c8188e145] to [5ba58dfefd].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFInvalidArgumentException
+ newWithClass: (Class)class_
      selector: (SEL)selector_
+ exceptionWithClass: (Class)class_
	    selector: (SEL)selector_
{
	return [[self alloc] initWithClass: class_
				  selector: selector_];
	return [[[self alloc] initWithClass: class_
				   selector: selector_] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFLinkFailedException.h from [30ebd8184e] to [1e0f3671d5].

35
36
37
38
39
40
41
42
43
44



45
46
47
48
49
50
51
35
36
37
38
39
40
41



42
43
44
45
46
47
48
49
50
51







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param src The source for the link
 * \param dest The destination for the link
 * \return A new link failed exception
 */
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest;
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dest;

/**
 * Initializes an already allocated link failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param src The source for the link
 * \param dest The destination for the link

Modified src/exceptions/OFLinkFailedException.m from [77f18c4a57] to [f3dc677892].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+








#import "OFNotImplementedException.h"

#import "common.h"

#ifndef _WIN32
@implementation OFLinkFailedException
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dest
{
	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dest];
	return [[[self alloc] initWithClass: class_
				 sourcePath: src
			    destinationPath: dest] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFListenFailedException.h from [4490777cf7] to [7f32ead302].

36
37
38
39
40
41
42
43
44
45



46
47
48
49
50
51
52
36
37
38
39
40
41
42



43
44
45
46
47
48
49
50
51
52







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which failed to listen
 * \param backlog The requested size of the back log
 * \return A new listen failed exception
 */
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
       backLog: (int)backlog;
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
	     backLog: (int)backlog;

/**
 * Initializes an already allocated listen failed exception
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which failed to listen
 * \param backlog The requested size of the back log

Modified src/exceptions/OFListenFailedException.m from [7907901ed0] to [8cd38ab1ca].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+







#import "OFTCPSocket.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFListenFailedException
+ newWithClass: (Class)class_
	socket: (OFTCPSocket*)socket
       backLog: (int)backlog
+ exceptionWithClass: (Class)class_
	      socket: (OFTCPSocket*)socket
	     backLog: (int)backlog
{
	return [[self alloc] initWithClass: class_
				    socket: socket
				   backLog: backlog];
	return [[[self alloc] initWithClass: class_
				     socket: socket
				    backLog: backlog] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 socket: (OFTCPSocket*)socket_
	backLog: (int)backlog
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFMalformedXMLException.h from [eb34a728c6] to [c7012e2725].

30
31
32
33
34
35
36
37
38


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


37
38
39
40
41
42
43
44
45







-
-
+
+







@property (readonly, nonatomic) OFXMLParser *parser;
#endif

/**
 * \param parser The parser which encountered malformed XML
 * \return A new malformed XML exception
 */
+ newWithClass: (Class)class_
	parser: (OFXMLParser*)parser;
+ exceptionWithClass: (Class)class_
	      parser: (OFXMLParser*)parser;

/**
 * Initializes an already allocated malformed XML exception.
 *
 * \param parser The parser which encountered malformed XML
 * \return An initialized malformed XML exception
 */

Modified src/exceptions/OFMalformedXMLException.m from [e9017c6da2] to [e2ab581c5c].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFMalformedXMLException.h"
#import "OFString.h"
#import "OFXMLParser.h"

#import "OFNotImplementedException.h"

@implementation OFMalformedXMLException
+ newWithClass: (Class)class_
	parser: (OFXMLParser*)parser
+ exceptionWithClass: (Class)class_
	      parser: (OFXMLParser*)parser
{
	return [[self alloc] initWithClass: class_
				    parser: parser];
	return [[[self alloc] initWithClass: class_
				     parser: parser] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 parser: (OFXMLParser*)parser_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFMemoryNotPartOfObjectException.h from [9e8c6288b3] to [f6a34da674].

29
30
31
32
33
34
35
36
37


38
39
40
41
42
43
44
29
30
31
32
33
34
35


36
37
38
39
40
41
42
43
44







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param ptr A pointer to the memory that is not part of the object
 * \return A new memory not part of object exception
 */
+ newWithClass: (Class)class_
       pointer: (void*)ptr;
+ exceptionWithClass: (Class)class_
	     pointer: (void*)ptr;

/**
 * Initializes an already allocated memory not part of object exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param ptr A pointer to the memory that is not part of the object
 * \return An initialized memory not part of object exception

Modified src/exceptions/OFMemoryNotPartOfObjectException.m from [e3d434cf63] to [e32818754d].

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







-
-
+
+

-
-
+
+






-
-
+
+








#import "OFMemoryNotPartOfObjectException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFMemoryNotPartOfObjectException
+ newWithClass: (Class)class_
       pointer: (void*)ptr
+ exceptionWithClass: (Class)class_
	     pointer: (void*)ptr
{
	return [[self alloc] initWithClass: class_
				   pointer: ptr];
	return [[[self alloc] initWithClass: class_
				    pointer: ptr] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	pointer: (void*)ptr
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFMutexLockFailedException.h from [83c96b5ca9] to [5800b9b1cb].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is could not be locked
 * \return A new mutex lock failed exception
 */
+ newWithClass: (Class)class_
	 mutex: (OFMutex*)mutex;
+ exceptionWithClass: (Class)class_
	       mutex: (OFMutex*)mutex;

/**
 * Initializes an already allocated mutex lock failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is could not be locked
 * \return An initialized mutex lock failed exception

Modified src/exceptions/OFMutexLockFailedException.m from [cfc2a2c3db] to [836573c633].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFMutexLockFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFMutexLockFailedException
+ newWithClass: (Class)class_
	 mutex: (OFMutex*)mutex
+ exceptionWithClass: (Class)class_
	       mutex: (OFMutex*)mutex
{
	return [[self alloc] initWithClass: class_
				     mutex: mutex];
	return [[[self alloc] initWithClass: class_
				      mutex: mutex] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFMutexStillLockedException.h from [f912b04534] to [33a6088f80].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is still locked
 * \return A new mutex still locked exception
 */
+ newWithClass: (Class)class_
	 mutex: (OFMutex*)mutex;
+ exceptionWithClass: (Class)class_
	       mutex: (OFMutex*)mutex;

/**
 * Initializes an already allocated mutex still locked exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is still locked
 * \return An initialized mutex still locked exception

Modified src/exceptions/OFMutexStillLockedException.m from [2f49017fed] to [d61ef3efd8].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFMutexStillLockedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFMutexStillLockedException
+ newWithClass: (Class)class_
	 mutex: (OFMutex*)mutex
+ exceptionWithClass: (Class)class_
	       mutex: (OFMutex*)mutex
{
	return [[self alloc] initWithClass: class_
				     mutex: mutex];
	return [[[self alloc] initWithClass: class_
				      mutex: mutex] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFMutexUnlockFailedException.h from [0397bcea81] to [e3dde65ccc].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which could not be unlocked
 * \return A new mutex unlock failed exception
 */
+ newWithClass: (Class)class_
	 mutex: (OFMutex*)mutex;
+ exceptionWithClass: (Class)class_
	       mutex: (OFMutex*)mutex;

/**
 * Initializes an already allocated mutex unlock failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which could not be unlocked
 * \return An initialized mutex unlock failed exception

Modified src/exceptions/OFMutexUnlockFailedException.m from [6b04031efb] to [3270e6620d].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFMutexUnlockFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFMutexUnlockFailedException
+ newWithClass: (Class)class_
	 mutex: (OFMutex*)mutex
+ exceptionWithClass: (Class)class_
	       mutex: (OFMutex*)mutex
{
	return [[self alloc] initWithClass: class_
				     mutex: mutex];
	return [[[self alloc] initWithClass: class_
				      mutex: mutex] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFNotConnectedException.h from [951b1065be] to [54fed7532e].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which is not connected
 * \return A new not connected exception
 */
+ newWithClass: (Class)class_
	socket: (OFStreamSocket*)socket;
+ exceptionWithClass: (Class)class_
	      socket: (OFStreamSocket*)socket;

/**
 * Initializes an already allocated not connected exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param socket The socket which is not connected
 * \return An initialized not connected exception

Modified src/exceptions/OFNotConnectedException.m from [3cf49774fa] to [564baa5da5].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFNotConnectedException.h"
#import "OFString.h"
#import "OFTCPSocket.h"

#import "OFNotImplementedException.h"

@implementation OFNotConnectedException
+ newWithClass: (Class)class_
	socket: (OFStreamSocket*)socket
+ exceptionWithClass: (Class)class_
	      socket: (OFStreamSocket*)socket
{
	return [[self alloc] initWithClass: class_
				    socket: socket];
	return [[[self alloc] initWithClass: class_
				     socket: socket] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 socket: (OFStreamSocket*)socket_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFNotImplementedException.h from [957dabccca] to [1238a82c27].

30
31
32
33
34
35
36
37
38


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


37
38
39
40
41
42
43
44
45







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param selector The selector which is not or not fully implemented
 * \return A new not implemented exception
 */
+ newWithClass: (Class)class_
      selector: (SEL)selector;
+ exceptionWithClass: (Class)class_
	    selector: (SEL)selector;

/**
 * Initializes an already allocated not implemented exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param selector The selector which is not or not fully implemented
 * \return An initialized not implemented exception

Modified src/exceptions/OFNotImplementedException.m from [50c9b1f819] to [4d852f9f00].

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







-
-
+
+

-
-
+
+






-
-
+
+








#import "OFNotImplementedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFNotImplementedException
+ newWithClass: (Class)class_
      selector: (SEL)selector
+ exceptionWithClass: (Class)class_
	    selector: (SEL)selector
{
	return [[self alloc] initWithClass: class_
				  selector: selector];
	return [[[self alloc] initWithClass: class_
				   selector: selector] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFOpenFileFailedException.h from [44994cd303] to [97b9695ecb].

34
35
36
37
38
39
40
41
42
43



44
45
46
47
48
49
50
34
35
36
37
38
39
40



41
42
43
44
45
46
47
48
49
50







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param path A string with the path of the file tried to open
 * \param mode A string with the mode in which the file should have been opened
 * \return A new open file failed exception
 */
+ newWithClass: (Class)class_
	  path: (OFString*)path
	  mode: (OFString*)mode;
+ exceptionWithClass: (Class)class_
		path: (OFString*)path
		mode: (OFString*)mode;

/**
 * Initializes an already allocated open file failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param path A string with the path of the file which couldn't be opened
 * \param mode A string with the mode in which the file should have been opened

Modified src/exceptions/OFOpenFileFailedException.m from [cb2bafa22a] to [8c923f326e].

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







-
-
+
+


-
-
-
+
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFOpenFileFailedException
+ newWithClass: (Class)class_
	  path: (OFString*)path
+ exceptionWithClass: (Class)class_
		path: (OFString*)path
	  mode: (OFString*)mode
{
	return [[self alloc] initWithClass: class_
				      path: path
				      mode: mode];
	return [[[self alloc] initWithClass: class_
				       path: path
				       mode: mode] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	   mode: (OFString*)mode_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFOutOfMemoryException.h from [4e3ba93e08] to [cce22250c3].

29
30
31
32
33
34
35
36
37


38
39
40
41
42
43
44
29
30
31
32
33
34
35


36
37
38
39
40
41
42
43
44







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param size The size of the memory that couldn't be allocated
 * \return A new no memory exception
 */
+  newWithClass: (Class)class_
  requestedSize: (size_t)size;
+ exceptionWithClass: (Class)class_
       requestedSize: (size_t)size;

/**
 * Initializes an already allocated no memory exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param size The size of the memory that couldn't be allocated
 * \return An initialized no memory exception

Modified src/exceptions/OFOutOfMemoryException.m from [047d11c618] to [8c4896d652].

16
17
18
19
20
21
22
23
24


25
26
27


28
29
30
31
32
33
34
16
17
18
19
20
21
22


23
24
25


26
27
28
29
30
31
32
33
34







-
-
+
+

-
-
+
+








#include "config.h"

#import "OFOutOfMemoryException.h"
#import "OFString.h"

@implementation OFOutOfMemoryException
+  newWithClass: (Class)class_
  requestedSize: (size_t)size
+ exceptionWithClass: (Class)class_
       requestedSize: (size_t)size
{
	return [[self alloc] initWithClass: class_
			     requestedSize: size];
	return [[[self alloc] initWithClass: class_
			      requestedSize: size] autorelease];
}

- initWithClass: (Class)class_
  requestedSize: (size_t)size
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFReadOrWriteFailedException.h from [26ee57d0e2] to [360e4ce578].

38
39
40
41
42
43
44
45
46
47



48
49
50
51
52
53
54
38
39
40
41
42
43
44



45
46
47
48
49
50
51
52
53
54







-
-
-
+
+
+







/**
 * \param class_ The class of the object which caused the exception
 * \param stream The stream which caused the read or write failed exception
 * \param length The requested length of the data that couldn't be read /
 *		 written
 * \return A new open file failed exception
 */
+    newWithClass: (Class)class_
	   stream: (OFStream*)stream
  requestedLength: (size_t)length;
+ exceptionWithClass: (Class)class_
	      stream: (OFStream*)stream
     requestedLength: (size_t)length;

/**
 * Initializes an already allocated read or write failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param stream The stream which caused the read or write failed exception
 * \param length The requested length of the data that couldn't be read /

Modified src/exceptions/OFReadOrWriteFailedException.m from [274c6b9632] to [c53987a5bd].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+







#import "OFStreamSocket.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFReadOrWriteFailedException
+    newWithClass: (Class)class_
	   stream: (OFStream*)stream
  requestedLength: (size_t)length
+ exceptionWithClass: (Class)class_
	      stream: (OFStream*)stream
     requestedLength: (size_t)length
{
	return [[self alloc] initWithClass: class_
				    stream: stream
			   requestedLength: length];
	return [[[self alloc] initWithClass: class_
				     stream: stream
			    requestedLength: length] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

-   initWithClass: (Class)class_
	   stream: (OFStream*)stream_
  requestedLength: (size_t)length
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFRenameFileFailedException.h from [193ea8dcf6] to [c5b895de82].

34
35
36
37
38
39
40
41
42
43



44
45
46
47
48
49
50
34
35
36
37
38
39
40



41
42
43
44
45
46
47
48
49
50







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param src The original path
 * \param dst The new path
 * \return A new rename file failed exception
 */
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst;
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dst;

/**
 * Initializes an already allocated rename failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param src The original path
 * \param dst The new path

Modified src/exceptions/OFRenameFileFailedException.m from [0319ec8956] to [8147d28862].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+







#import "OFString.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFRenameFileFailedException
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dst
{
	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dst];
	return [[[self alloc] initWithClass: class_
				 sourcePath: src
			    destinationPath: dst] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dst
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFSeekFailedException.h from [8fab00e250] to [896f779d12].

42
43
44
45
46
47
48
49
50
51
52




53
54
55
56
57
58
59
42
43
44
45
46
47
48




49
50
51
52
53
54
55
56
57
58
59







-
-
-
-
+
+
+
+








/**
 * \param stream The stream for which seeking failed
 * \param offset The offset to which seeking failed
 * \param whence To what the offset is relative
 * \return A new seek failed exception
 */
+ newWithClass: (Class)class_
	stream: (OFSeekableStream*)stream
	offset: (off_t)offset
	whence: (int)whence;
+ exceptionWithClass: (Class)class_
	      stream: (OFSeekableStream*)stream
	      offset: (off_t)offset
	      whence: (int)whence;

/**
 * Initializes an already allocated seek failed exception.
 *
 * \param stream The stream for which seeking failed
 * \param offset The offset to which seeking failed
 * \param whence To what the offset is relative

Modified src/exceptions/OFSeekFailedException.m from [5afb1ec110] to [52581f6912].

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







-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+






-
-
+
+







#import "OFSeekableStream.h"

#import "OFNotImplementedException.h"

#import "common.h"

@implementation OFSeekFailedException
+ newWithClass: (Class)class_
	stream: (OFSeekableStream*)stream
	offset: (off_t)offset
	whence: (int)whence
+ exceptionWithClass: (Class)class_
	      stream: (OFSeekableStream*)stream
	      offset: (off_t)offset
	      whence: (int)whence
{
	return [[self alloc] initWithClass: class_
				    stream: stream
				    offset: offset
				    whence: whence];
	return [[[self alloc] initWithClass: class_
				     stream: stream
				     offset: offset
				     whence: whence] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 stream: (OFSeekableStream*)stream_
	 offset: (off_t)offset_
	 whence: (int)whence_
{

Modified src/exceptions/OFSetOptionFailedException.h from [0409392fd7] to [9e9fbb94e3].

30
31
32
33
34
35
36
37
38


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


37
38
39
40
41
42
43
44
45







-
-
+
+







@property (readonly, nonatomic) OFStream *stream;
#endif

/**
 * \param stream The stream for which the option could not be set
 * \return A new set option failed exception
 */
+ newWithClass: (Class)class_
	stream: (OFStream*)stream;
+ exceptionWithClass: (Class)class_
	      stream: (OFStream*)stream;

/**
 * Initializes an already allocated set option failed exception.
 *
 * \param stream The stream for which the option could not be set
 * \return An initialized set option failed exception
 */

Modified src/exceptions/OFSetOptionFailedException.m from [8350b08e96] to [e9c6ba1290].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFSetOptionFailedException.h"
#import "OFString.h"
#import "OFStream.h"

#import "OFNotImplementedException.h"

@implementation OFSetOptionFailedException
+ newWithClass: (Class)class_
	stream: (OFStream*)stream
+ exceptionWithClass: (Class)class_
	      stream: (OFStream*)stream
{
	return [[self alloc] initWithClass: class_
				    stream: stream];
	return [[[self alloc] initWithClass: class_
				     stream: stream] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 stream: (OFStream*)stream_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFSymlinkFailedException.h from [c22ec1582c] to [f52060f788].

35
36
37
38
39
40
41
42
43
44



45
46
47
48
49
50
51
35
36
37
38
39
40
41



42
43
44
45
46
47
48
49
50
51







-
-
-
+
+
+








/**
 * \param class_ The class of the object which caused the exception
 * \param src The source for the symlink
 * \param dest The destination for the symlink
 * \return A new symlink failed exception
 */
+   newWithClass: (Class)class_
      sourcePath: (OFString*)src
 destinationPath: (OFString*)dest;
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dest;

/**
 * Initializes an already allocated symlink failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param src The source for the symlink
 * \param dest The destination for the symlink

Modified src/exceptions/OFSymlinkFailedException.m from [947e43bc5f] to [5c0721daae].

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







-
-
-
+
+
+

-
-
-
+
+
+






-
-
+
+








#import "OFNotImplementedException.h"

#import "common.h"

#ifndef _WIN32
@implementation OFSymlinkFailedException
+    newWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest
+ exceptionWithClass: (Class)class_
	  sourcePath: (OFString*)src
     destinationPath: (OFString*)dest
{
	return [[self alloc] initWithClass: class_
				sourcePath: src
			   destinationPath: dest];
	return [[[self alloc] initWithClass: class_
				 sourcePath: src
			    destinationPath: dest] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

-   initWithClass: (Class)class_
       sourcePath: (OFString*)src
  destinationPath: (OFString*)dest
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFThreadJoinFailedException.h from [01dedbef95] to [7b0847de05].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be joined
 * \return A new thread join failed exception
 */
+ newWithClass: (Class)class_
	thread: (OFThread*)thread;
+ exceptionWithClass: (Class)class_
	      thread: (OFThread*)thread;

/**
 * Initializes an already allocated thread join failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be joined
 * \return An initialized thread join failed exception

Modified src/exceptions/OFThreadJoinFailedException.m from [6b0a958bc3] to [32fb64056e].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFThreadJoinFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFThreadJoinFailedException
+ newWithClass: (Class)class_
	thread: (OFThread*)thread
+ exceptionWithClass: (Class)class_
	      thread: (OFThread*)thread
{
	return [[self alloc] initWithClass: class_
				    thread: thread];
	return [[[self alloc] initWithClass: class_
				     thread: thread] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 thread: (OFThread*)thread_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFThreadStartFailedException.h from [e37cf48324] to [8f3421b3f1].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be started
 * \return An initialized thread start failed exception
 */
+ newWithClass: (Class)class_
	thread: (OFThread*)thread;
+ exceptionWithClass: (Class)class_
	      thread: (OFThread*)thread;

/**
 * Initializes an already allocated thread start failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be started
 * \return An initialized thread start failed exception

Modified src/exceptions/OFThreadStartFailedException.m from [9afd364fa9] to [6e7c5112ed].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFThreadStartFailedException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFThreadStartFailedException
+ newWithClass: (Class)class_
	thread: (OFThread*)thread
+ exceptionWithClass: (Class)class_
	      thread: (OFThread*)thread
{
	return [[self alloc] initWithClass: class_
				    thread: thread];
	return [[[self alloc] initWithClass: class_
				     thread: thread] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 thread: (OFThread*)thread_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFThreadStillRunningException.h from [8e53069837] to [6eb60f6131].

31
32
33
34
35
36
37
38
39


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


38
39
40
41
42
43
44
45
46







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which is still running
 * \return A new thread still running exception
 */
+ newWithClass: (Class)class_
	thread: (OFThread*)thread;
+ exceptionWithClass: (Class)class_
	      thread: (OFThread*)thread;

/**
 * Initializes an already allocated thread still running exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which is still running
 * \return An initialized thread still running exception

Modified src/exceptions/OFThreadStillRunningException.m from [58927c8f24] to [f1a7a65ab1].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFThreadStillRunningException.h"
#import "OFString.h"
#import "OFThread.h"

#import "OFNotImplementedException.h"

@implementation OFThreadStillRunningException
+ newWithClass: (Class)class_
	thread: (OFThread*)thread
+ exceptionWithClass: (Class)class_
	      thread: (OFThread*)thread
{
	return [[self alloc] initWithClass: class_
				    thread: thread];
	return [[[self alloc] initWithClass: class_
				     thread: thread] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	 thread: (OFThread*)thread_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFUnboundNamespaceException.h from [1633396dd3] to [70d4eb3489].

31
32
33
34
35
36
37
38
39


40
41
42
43
44
45
46
47


48
49
50
51
52
53
54
31
32
33
34
35
36
37


38
39
40
41
42
43
44
45


46
47
48
49
50
51
52
53
54







-
-
+
+






-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param ns The namespace which is unbound
 * \return A new unbound namespace exception
 */
+ newWithClass: (Class)class_
     namespace: (OFString*)ns;
+ exceptionWithClass: (Class)class_
	   namespace: (OFString*)ns;

/**
 * \param class_ The class of the object which caused the exception
 * \param prefix The prefix which is unbound
 * \return A new unbound namespace exception
 */
+ newWithClass: (Class)class_
	prefix: (OFString*)prefix;
+ exceptionWithClass: (Class)class_
	      prefix: (OFString*)prefix;

/**
 * Initializes an already allocated unbound namespace exception
 *
 * \param class_ The class of the object which caused the exception
 * \param ns The namespace which is unbound
 * \return An initialized unbound namespace exception

Modified src/exceptions/OFUnboundNamespaceException.m from [303b5d3929] to [b54969fda6].

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







-
-
+
+

-
-
+
+


-
-
+
+

-
-
+
+






-
-
+
+








#import "OFUnboundNamespaceException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFUnboundNamespaceException
+ newWithClass: (Class)class_
     namespace: (OFString*)ns
+ exceptionWithClass: (Class)class_
	   namespace: (OFString*)ns
{
	return [[self alloc] initWithClass: class_
				 namespace: ns];
	return [[[self alloc] initWithClass: class_
				  namespace: ns] autorelease];
}

+ newWithClass: (Class)class_
	prefix: (OFString*)prefix
+ exceptionWithClass: (Class)class_
	      prefix: (OFString*)prefix
{
	return [[self alloc] initWithClass: class_
				    prefix: prefix];
	return [[[self alloc] initWithClass: class_
				     prefix: prefix] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
      namespace: (OFString*)ns_
{
	self = [super initWithClass: class_];

Modified src/exceptions/OFUnsupportedProtocolException.h from [84dad3e146] to [b72b766785].

32
33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
32
33
34
35
36
37
38


39
40
41
42
43
44
45
46
47







-
-
+
+







#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param url The URL whose protocol is unsupported
 * \return A new unsupported protocol exception
 */
+ newWithClass: (Class)class_
	   URL: (OFURL*)url;
+ exceptionWithClass: (Class)class_
		 URL: (OFURL*)url;

/**
 * Initializes an already allocated unsupported protocol exception
 *
 * \param class_ The class of the object which caused the exception
 * \param url The URL whose protocol is unsupported
 * \return An initialized unsupported protocol exception

Modified src/exceptions/OFUnsupportedProtocolException.m from [a860657b20] to [3d357d66d2].

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







-
-
+
+

-
-
+
+






-
-
+
+







#import "OFUnsupportedProtocolException.h"
#import "OFString.h"
#import "OFURL.h"

#import "OFNotImplementedException.h"

@implementation OFUnsupportedProtocolException
+ newWithClass: (Class)class_
	   URL: (OFURL*)url
+ exceptionWithClass: (Class)class_
		 URL: (OFURL*)url
{
	return [[self alloc] initWithClass: class_
				       URL: url];
	return [[[self alloc] initWithClass: class_
					URL: url] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	    URL: (OFURL*)url
{
	self = [super initWithClass: class_];

Modified src/of_asprintf.m from [31524fd43b] to [d33bc3adcc].

275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
275
276
277
278
279
280
281

282
283
284
285
286
287
288







-







		OFAutoreleasePool *pool;

		ctx->subformat[ctx->subformatLen - 1] = 's';

		@try {
			pool = [[OFAutoreleasePool alloc] init];
		} @catch (id e) {
			[e release];
			return false;
		}

		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil)

Modified tests/OFArrayTests.m from [8332694435] to [723d9a0843].

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
208
209
210
211
212
213
214

215
216
217
218
219
220
221







-







		for (OFString *s in m[0]) {
			if (i == 0)
				[m[0] addObject: @""];
			i++;
		}
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		[e release];
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[m[0] removeNObjects: 1];
#endif

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
244
245
246
247
248
249
250

251
252
253
254
255

256
257
258
259
260
261
262







-





-







		@try {
			[a2 enumerateObjectsUsingBlock:
			    ^ (id obj, size_t idx, BOOL *stop) {
				[a2 removeObjectAtIndex: idx];
			}];
		} @catch (OFEnumerationMutationException *e) {
			ok = YES;
			[e release];
		} @catch (OFOutOfRangeException *e) {
			/*
			 * Out of bounds access due to enumeration not being
			 * detected.
			 */
			[e release];
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",

Modified tests/OFDictionaryTests.m from [127b7e8b9a] to [04d0bf130a].

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

117
118
119
120
121
122
123







-







	ok = NO;
	@try {
		for (OFString *key in dict)
			[dict setObject: @""
				 forKey: @""];
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		[e dealloc];
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[dict removeObjectForKey: @""];
#endif

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

149
150
151
152
153
154
155







-







			[dict enumerateKeysAndObjectsUsingBlock:
			    ^ (id key, id obj, BOOL *stop) {
				[dict setObject: @""
					 forKey: @""];
			}];
		} @catch (OFEnumerationMutationException *e) {
			ok = YES;
			[e dealloc];
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)

		[dict removeObjectForKey: @""];
	}

Modified tests/OFListTests.m from [0db3614a7f] to [ec7c33e58e].

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157







-









	ok = NO;
	@try {
		for (OFString *obj in list)
			[list removeListObject: [list lastListObject]];
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		[e dealloc];
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)
#endif

	[pool drain];
}
@end

Modified tests/OFSet.m from [7fcfa63b54] to [63f1a92dda].

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
125
126
127
128
129
130
131

132
133
134
135
136
137
138
139







-









	ok = NO;
	@try {
		for (OFString *s in mutableSet)
			[mutableSet removeObject: s];
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		[e dealloc];
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok);
#endif

	[pool drain];
}
@end

Modified tests/TestsAppDelegate.h from [366cc90aaf] to [3f94796a0a].

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

45
46
47
48
49
50
51







-







		[self outputTesting: test		\
			   inModule: module];		\
							\
		@try {					\
			code;				\
		} @catch (exception *e) {		\
			caught = YES;			\
			[e release];			\
		}					\
							\
		if (caught)				\
			[self outputSuccess: test	\
				   inModule: module];	\
		else {					\
			[self outputFailure: test	\