ObjFW  Check-in [6b13727ce0]

Overview
Comment:Make use of fast enumeration

Now that we require GCC >= 4.6 anyway, there's no more reason to not use
it anymore.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6b13727ce0b7073e4e1dbd7109172be9f60723a9dfc8336c256e7b09375eebf5
User & Date: js on 2015-11-29 14:02:11
Other Links: manifest | tags
Context
2015-11-29
14:20
Clean up optional protocols check-in: ba62f00fac user: js tags: trunk
14:02
Make use of fast enumeration check-in: 6b13727ce0 user: js tags: trunk
11:43
Make properties a requirement and clean up code check-in: 48980f2297 user: js tags: trunk
Changes

Modified src/OFArray.m from [ac5ec4c8c9] to [2be2e1c20f].

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







-
-











-
+



















-
+







}

- (OFString*)OF_JSONRepresentationWithOptions: (int)options
					depth: (size_t)depth
{
	OFMutableString *JSON = [OFMutableString stringWithString: @"["];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;
	size_t i, count = [self count];

	if (options & OF_JSON_REPRESENTATION_PRETTY) {
		OFMutableString *indentation = [OFMutableString string];

		for (i = 0; i < depth; i++)
			[indentation appendString: @"\t"];

		[JSON appendString: @"\n"];

		i = 0;
		while ((object = [enumerator nextObject]) != nil) {
		for (id object in self) {
			void *pool2 = objc_autoreleasePoolPush();

			[JSON appendString: indentation];
			[JSON appendString: @"\t"];
			[JSON appendString: [object
			    OF_JSONRepresentationWithOptions: options
						       depth: depth + 1]];

			if (++i < count)
				[JSON appendString: @",\n"];
			else
				[JSON appendString: @"\n"];

			objc_autoreleasePoolPop(pool2);
		}

		[JSON appendString: indentation];
	} else {
		i = 0;
		while ((object = [enumerator nextObject]) != nil) {
		for (id object in self) {
			void *pool2 = objc_autoreleasePoolPush();

			[JSON appendString: [object
			    OF_JSONRepresentationWithOptions: options
						       depth: depth + 1]];

			if (++i < count)
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
615
616
617
618
619
620
621


622
623
624
625
626
627
628







-
-







}

- (OFDataArray*)messagePackRepresentation
{
	OFDataArray *data;
	size_t i, count;
	void *pool;
	OFEnumerator *enumerator;
	id object;

	data = [OFDataArray dataArray];
	count = [self count];

	if (count <= 15) {
		uint8_t tmp = 0x90 | ((uint8_t)count & 0xF);
		[data addItem: &tmp];
646
647
648
649
650
651
652
653

654
655
656
657
658
659
660
661
642
643
644
645
646
647
648

649

650
651
652
653
654
655
656







-
+
-







			 count: sizeof(tmp)];
	} else
		@throw [OFOutOfRangeException exception];

	pool = objc_autoreleasePoolPush();

	i = 0;
	enumerator = [self objectEnumerator];
	for (id object in self) {
	while ((object = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();
		OFDataArray *child;

		i++;

		child = [object messagePackRepresentation];
		[data addItems: [child items]
751
752
753
754
755
756
757
758

759
760
761
762
763
764
765
746
747
748
749
750
751
752

753
754
755
756
757
758
759
760







-
+








- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc] initWithArray: self
					    mutationsPtr: NULL] autorelease];
}

#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	size_t i = 0;
	bool stop = false;

	for (id object in self) {
		block(object, i++, &stop);

Modified src/OFArray_adjacent.m from [8679aa9a9b] to [2d053d23e3].

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


170
171
172
173
174
175


176
177


178
179
180
181
182
183
184







-
-






-
-
+
+
-
-








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

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if ((![[element name] isEqual: @"OFArray"] &&
		    ![[element name] isEqual: @"OFMutableArray"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];

		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		for (OFXMLElement *child in
		    [element elementsForNamespace: OF_SERIALIZATION_NS]) {

		while ((child = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			id object;

			object = [child objectByDeserializing];
			[_array addItem: &object];
			[object retain];

Modified src/OFCountedSet.m from [0df520b24c] to [9e3f055893].

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







-

-








-

-
+







	OF_UNRECOGNIZED_SELECTOR
}

- (OFString*)description
{
	OFMutableString *ret;
	void *pool;
	OFEnumerator *enumerator;
	size_t i, count = [self count];
	id object;

	if (count == 0)
		return @"{()}";

	ret = [OFMutableString stringWithString: @"{(\n"];

	pool = objc_autoreleasePoolPush();

	enumerator = [self objectEnumerator];
	i = 0;
	while ((object = [enumerator nextObject]) != nil) {
	for (id object in self) {
		void *pool2 = objc_autoreleasePoolPush();

		[ret appendString: object];
		[ret appendFormat: @": %zu", [self countForObject: object]];

		if (++i < count)
			[ret appendString: @",\n"];
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

203
204
205
206
207
208
209
210
185
186
187
188
189
190
191


192
193
194
195


196

197
198
199
200
201
202
203







-
-




-
-
+
-







	return [[OFCountedSet alloc] initWithSet: self];
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;
	OFEnumerator *enumerator;
	id <OFSerialization> object;

	element = [OFXMLElement elementWithName: @"OFCountedSet"
				      namespace: OF_SERIALIZATION_NS];

	enumerator = [self objectEnumerator];

	for (id <OFSerialization> object in self) {
	while ((object = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();

		OFXMLElement *objectElement;
		OFString *count;

		count =
		    [OFString stringWithFormat: @"%zu",
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
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







-
-

-
+





-
+
-
-
+
-
-

-










-
-

-
+





-
+
-
-
+
-
-

-





- (void)minusSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();

	if ([set isKindOfClass: [OFCountedSet class]]) {
		OFCountedSet *countedSet = (OFCountedSet*)set;
		OFEnumerator *enumerator = [countedSet objectEnumerator];
		id object;

		while ((object = [enumerator nextObject]) != nil) {
		for (id object in countedSet) {
			size_t i, count = [countedSet countForObject: object];

			for (i = 0; i < count; i++)
				[self removeObject: object];
		}
	} else {
	} else
		OFEnumerator *enumerator = [set objectEnumerator];
		id object;
		for (id object in set)

		while ((object = [enumerator nextObject]) != nil)
			[self removeObject: object];
	}

	objc_autoreleasePoolPop(pool);
}

- (void)unionSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();

	if ([set isKindOfClass: [OFCountedSet class]]) {
		OFCountedSet *countedSet = (OFCountedSet*)set;
		OFEnumerator *enumerator = [countedSet objectEnumerator];
		id object;

		while ((object = [enumerator nextObject]) != nil) {
		for (id object in countedSet) {
			size_t i, count = [countedSet countForObject: object];

			for (i = 0; i < count; i++)
				[self addObject: object];
		}
	} else {
	} else
		OFEnumerator *enumerator = [set objectEnumerator];
		id object;
		for (id object in set)

		while ((object = [enumerator nextObject]) != nil)
			[self addObject: object];
	}

	objc_autoreleasePoolPop(pool);
}
@end

Modified src/OFCountedSet_hashtable.m from [cd05f3d64e] to [87ab020669].

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







-
-
-

-
+







-
+
-
-
+
-
-

-







	self = [self init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		if ([set isKindOfClass: [OFCountedSet class]]) {
			OFCountedSet *countedSet = (OFCountedSet*)countedSet;
			OFEnumerator *enumerator =
			    [countedSet objectEnumerator];
			id object;

			while ((object = [enumerator nextObject]) != nil) {
			for (id object in countedSet) {
				size_t i, count;

				count = [countedSet countForObject: object];

				for (i = 0; i < count; i++)
					[self addObject: object];
			}
		} else {
		} else
			OFEnumerator *enumerator = [set objectEnumerator];
			id object;
			for (id object in set)

			while ((object = [enumerator nextObject]) != nil)
				[self addObject: object];
		}

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

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
125
126
127
128
129
130
131



132
133
134
135
136
137


138
139



140
141
142
143
144
145
146







-
-
-





+
-
-
+
+
-
-
-








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

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFArray *objects;
		OFEnumerator *enumerator;
		OFXMLElement *objectElement;

		if (![[element name] isEqual: @"OFCountedSet"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];

		for (OFXMLElement *objectElement in
		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];
		    [element elementsForName: @"object"
				   namespace: OF_SERIALIZATION_NS]) {

		enumerator = [objects objectEnumerator];
		while ((objectElement = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFXMLElement *object;
			OFXMLAttribute *count_;
			size_t count;

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

Modified src/OFDictionary.m from [fae9385bda] to [f9d2ed8c00].

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







-
+












-
-
-
+
+
+
+
+

-
+
-




















-

+







	return [[OFMutableDictionary alloc] initWithDictionary: self];
}

- (bool)isEqual: (id)object
{
	OFDictionary *otherDictionary;
	void *pool;
	OFEnumerator *enumerator;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	id key;

	if (![object isKindOfClass: [OFDictionary class]])
		return false;

	otherDictionary = object;

	if ([otherDictionary count] != [self count])
		return false;

	pool = objc_autoreleasePoolPush();

	enumerator = [self keyEnumerator];
	while ((key = [enumerator nextObject]) != nil) {
		id object = [otherDictionary objectForKey: key];
	keyEnumerator = [self keyEnumerator];
	objectEnumerator = [self objectEnumerator];
	while ((key = [keyEnumerator nextObject]) != nil &&
	    (object = [objectEnumerator nextObject]) != nil) {
		id otherObject = [otherDictionary objectForKey: key];

		if (object == nil ||
		if (otherObject == nil || ![otherObject isEqual: object]) {
		    ![object isEqual: [self objectForKey: key]]) {
			objc_autoreleasePoolPop(pool);
			return false;
		}
	}

	objc_autoreleasePoolPop(pool);

	return true;
}

- (bool)containsObject: (id)object
{
	void *pool;
	OFEnumerator *enumerator;
	id currentObject;

	if (object == nil)
		return false;

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	enumerator = [self objectEnumerator];
	while ((currentObject = [enumerator nextObject]) != nil) {
		if ([currentObject isEqual: object]) {
			objc_autoreleasePoolPop(pool);
			return true;
		}
	}

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







-

+















-
-
-

-
+




-
-







	OFEnumerator *enumerator;
	id currentObject;

	if (object == nil)
		return false;

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	enumerator = [self objectEnumerator];
	while ((currentObject = [enumerator nextObject]) != nil) {
		if (currentObject == object) {
			objc_autoreleasePoolPop(pool);
			return true;
		}
	}

	objc_autoreleasePoolPop(pool);

	return false;
}

- (OFArray*)allKeys
{
	OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self keyEnumerator];
	id key;

	while ((key = [enumerator nextObject]) != nil)
	for (id key in self)
		[ret addObject: key];

	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

- (OFArray*)allObjects
{
	OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]];
	void *pool = objc_autoreleasePoolPush();
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
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







-
+












-

-







- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	OF_UNRECOGNIZED_SELECTOR
}

#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{
	bool stop = false;

	for (id key in self) {
		block(key, [self objectForKey: key], &stop);

		if (stop)
			break;
	}
}
#endif

#ifdef OF_HAVE_BLOCKS
- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    bool *stop) {
		[new setObject: block(key, object)
477
478
479
480
481
482
483
484
485



486
487

488

489
490

491
492
493
494
495
496
497
471
472
473
474
475
476
477


478
479
480
481
482
483

484
485

486
487
488
489
490
491
492
493







-
-
+
+
+


+
-
+

-
+







	return new;
}
#endif

- (uint32_t)hash
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self keyEnumerator];
	id key;
	OFEnumerator *keyEnumerator = [self keyEnumerator];
	OFEnumerator *objectEnumerator = [self objectEnumerator];
	id key, object;
	uint32_t hash = 0;

	while ((key = [keyEnumerator nextObject]) != nil &&
	while ((key = [enumerator nextObject]) != nil) {
	    (object = [objectEnumerator nextObject]) != nil) {
		hash += [key hash];
		hash += [[self objectForKey: key] hash];
		hash += [object hash];
	}

	objc_autoreleasePoolPop(pool);

	return hash;
}

Modified src/OFFileManager.m from [737527b063] to [a3021efc2a].

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







-
-
-
+
-









-
-
-
+
-
-
-
+













-
+



-
-







		    exceptionWithPath: path
				errNo: errno];
}

- (void)createDirectoryAtPath: (OFString*)path
		createParents: (bool)createParents
{
	void *pool;
	OFArray *pathComponents;
	OFString *currentPath = nil, *component;
	OFString *currentPath = nil;
	OFEnumerator *enumerator;

	if (!createParents) {
		[self createDirectoryAtPath: path];
		return;
	}

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

	pool = objc_autoreleasePoolPush();

	pathComponents = [path pathComponents];
	for (OFString *component in [path pathComponents]) {
	enumerator = [pathComponents objectEnumerator];
	while ((component = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();
		void *pool = objc_autoreleasePoolPush();

		if (currentPath != nil)
			currentPath = [currentPath
			    stringByAppendingPathComponent: component];
		else
			currentPath = component;

		if ([currentPath length] > 0 &&
		    ![self directoryExistsAtPath: currentPath])
			[self createDirectoryAtPath: currentPath];

		[currentPath retain];

		objc_autoreleasePoolPop(pool2);
		objc_autoreleasePoolPop(pool);

		[currentPath autorelease];
	}

	objc_autoreleasePoolPop(pool);
}

- (OFArray*)contentsOfDirectoryAtPath: (OFString*)path
{
	OFMutableArray *files;
#ifndef OF_WINDOWS
	of_string_encoding_t encoding;
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
582
583
584
585
586
587
588


589
590
591
592
593
594
595







-
-







		@throw [OFCopyItemFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination
				      errNo: errno];

	if (S_ISDIR(s.st_mode)) {
		OFArray *contents;
		OFEnumerator *enumerator;
		OFString *item;

		@try {
			[self createDirectoryAtPath: destination];
#ifdef OF_HAVE_CHMOD
			[self changePermissionsOfItemAtPath: destination
						permissions: s.st_mode];
#endif
618
619
620
621
622
623
624
625

626
627
628
629
630
631
632
633
607
608
609
610
611
612
613

614

615
616
617
618
619
620
621







-
+
-







				    exceptionWithSourcePath: source
					    destinationPath: destination
						      errNo: [e errNo]];

			@throw e;
		}

		enumerator = [contents objectEnumerator];
		for (OFString *item in contents) {
		while ((item = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();
			OFString *sourcePath, *destinationPath;

			sourcePath =
			    [source stringByAppendingPathComponent: item];
			destinationPath =
			    [destination stringByAppendingPathComponent: item];
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
823
824
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







-
-



















-
+
-








	if (of_lstat(path, &s) != 0)
		@throw [OFRemoveItemFailedException exceptionWithPath: path
								errNo: errno];

	if (S_ISDIR(s.st_mode)) {
		OFArray *contents;
		OFEnumerator *enumerator;
		OFString *item;

		@try {
			contents = [self contentsOfDirectoryAtPath: path];
		} @catch (id e) {
			/*
			 * Only convert exceptions to
			 * OFRemoveItemFailedException that have an errNo
			 * property. This covers all I/O related exceptions
			 * from the operations used to remove an item, all
			 * others should be left as is.
			 */
			if ([e respondsToSelector: @selector(errNo)])
				@throw [OFRemoveItemFailedException
				    exceptionWithPath: path
						errNo: [e errNo]];

			@throw e;
		}

		enumerator = [contents objectEnumerator];
		for (OFString *item in contents) {
		while ((item = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();

			[self removeItemAtPath:
			    [path stringByAppendingPathComponent: item]];

			objc_autoreleasePoolPop(pool2);
		}

Modified src/OFINICategory.m from [db5fef86d0] to [ab1f7455cf].

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







-
-
-
+
-
-







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







	return [self stringForKey: key
		     defaultValue: nil];
}

- (OFString*)stringForKey: (OFString*)key
	     defaultValue: (OFString*)defaultValue
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [_lines objectEnumerator];
	id line;
	for (id line in _lines) {

	while ((line = [enumerator nextObject]) != nil) {
		OFINICategory_Pair *pair;

		if (![line isKindOfClass: [OFINICategory_Pair class]])
			continue;

		pair = line;

		if ([pair->_key isEqual: key]) {
			OFString *value = [pair->_value copy];

		if ([pair->_key isEqual: key])
			return [[pair->_value copy] autorelease];
	}
			objc_autoreleasePoolPop(pool);

			return [value autorelease];
		}
	}

	objc_autoreleasePoolPop(pool);

	return defaultValue;
}

- (intmax_t)integerForKey: (OFString*)key
	     defaultValue: (intmax_t)defaultValue
{
298
299
300
301
302
303
304
305
306
307
308

309
310
311
312
313
314
315
287
288
289
290
291
292
293


294

295
296
297
298
299
300
301
302







-
-

-
+







	return ret;
}

- (OFArray*)arrayForKey: (OFString*)key
{
	OFMutableArray *ret = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [_lines objectEnumerator];
	id line;

	while ((line = [enumerator nextObject]) != nil) {
	for (id line in _lines) {
		OFINICategory_Pair *pair;

		if (![line isKindOfClass: [OFINICategory_Pair class]])
			continue;

		pair = line;

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







-

-

-
+

















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







	return ret;
}

- (void)setString: (OFString*)string
	   forKey: (OFString*)key
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [_lines objectEnumerator];
	OFINICategory_Pair *pair;
	id line;

	while ((line = [enumerator nextObject]) != nil) {
	for (id line in _lines) {
		if (![line isKindOfClass: [OFINICategory_Pair class]])
			continue;

		pair = line;

		if ([pair->_key isEqual: key]) {
			OFString *old = pair->_value;
			pair->_value = [string copy];
			[old release];

			objc_autoreleasePoolPop(pool);

			return;
		}
	}

	pair = [[[OFINICategory_Pair alloc] init] autorelease];
	pair->_key = nil;
	pair->_value = nil;

	@try {
	pair->_key = [key copy];
	pair->_value = [string copy];
	[_lines addObject: pair];
		pair->_key = [key copy];
		pair->_value = [string copy];
		[_lines addObject: pair];
	} @catch (id e) {
		[pair->_key release];
		[pair->_value release];

		@throw e;
	}

	objc_autoreleasePoolPop(pool);
}

- (void)setInteger: (intmax_t)integer
	    forKey: (OFString*)key
{
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
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







-

-











-


-
+







	objc_autoreleasePoolPop(pool);
}

- (void)setArray: (OFArray*)array
	  forKey: (OFString*)key
{
	void *pool;
	OFEnumerator *enumerator;
	OFMutableArray *pairs;
	id object;
	id const *lines;
	size_t i, count;
	bool replaced;

	if ([array count] == 0) {
		[self removeValueForKey: key];
		return;
	}

	pool = objc_autoreleasePoolPush();

	enumerator = [array objectEnumerator];
	pairs = [OFMutableArray arrayWithCapacity: [array count]];

	while ((object = [enumerator nextObject]) != nil) {
	for (id object in array) {
		OFINICategory_Pair *pair;

		if (![object isKindOfClass: [OFString class]])
			@throw [OFInvalidArgumentException exception];

		pair = [[[OFINICategory_Pair alloc] init] autorelease];
		pair->_key = [key copy];
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
489
490
491
492
493
494
495



496
497
498
499
500
501
502
503

504

505
506
507
508
509
510
511







-
-
-








-
+
-







	objc_autoreleasePoolPop(pool);
}

- (bool)OF_writeToStream: (OFStream*)stream
		encoding: (of_string_encoding_t)encoding
		   first: (bool)first
{
	OFEnumerator *enumerator;
	id line;

	if ([_lines count] == 0)
		return false;

	if (first)
		[stream writeFormat: @"[%@]\n", _name];
	else
		[stream writeFormat: @"\n[%@]\n", _name];

	enumerator = [_lines objectEnumerator];
	for (id line in _lines) {
	while ((line = [enumerator nextObject]) != nil) {
		if ([line isKindOfClass: [OFINICategory_Comment class]]) {
			OFINICategory_Comment *comment = line;
			[stream writeLine: comment->_comment];
		} else if ([line isKindOfClass: [OFINICategory_Pair class]]) {
			OFINICategory_Pair *pair = line;
			OFString *key = escapeString(pair->_key);
			OFString *value = escapeString(pair->_value);

Modified src/OFINIFile.m from [7499aebd7d] to [754d91375c].

102
103
104
105
106
107
108
109
110
111
112

113
114
115
116
117
118
119
102
103
104
105
106
107
108

109
110

111
112
113
114
115
116
117
118







-


-
+








	[super dealloc];
}

- (OFINICategory*)categoryForName: (OFString*)name
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [_categories objectEnumerator];
	OFINICategory *category;

	while ((category = [enumerator nextObject]) != nil) {
	for (category in _categories) {
		if ([[category name] isEqual: name]) {
			OFINICategory *ret = [category retain];

			objc_autoreleasePoolPop(pool);

			return [ret autorelease];
		}
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
204
184
185
186
187
188
189
190


191
192

193
194
195
196
197
198
199
200
201







-
-


-
+









- (void)writeToFile: (OFString*)path
	   encoding: (of_string_encoding_t)encoding
{
	void *pool = objc_autoreleasePoolPush();
	OFFile *file = [OFFile fileWithPath: path
				       mode: @"w"];
	OFEnumerator *enumerator = [_categories objectEnumerator];
	OFINICategory *category;
	bool first = true;

	while ((category = [enumerator nextObject]) != nil)
	for (OFINICategory *category in _categories)
		if ([category OF_writeToStream: file
				      encoding: encoding
					 first: first])
			first = false;

	objc_autoreleasePoolPop(pool);
}
@end

Modified src/OFList.m from [a0868f6c97] to [7c70cf8600].

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53


54
55
56
57
58
59
60
61
38
39
40
41
42
43
44


45
46
47
48
49


50
51

52
53
54
55
56
57
58







-
-





-
-
+
+
-








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

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];

		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		for (OFXMLElement *child in
		    [element elementsForNamespace: OF_SERIALIZATION_NS]) {
		while ((child = [enumerator nextObject]) != nil) {
			void *pool2 = objc_autoreleasePoolPush();

			[self appendObject: [child objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
		}

Modified src/OFMutableArray.m from [b9da7d0ecc] to [0b551de582].

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
217
218
219
220
221
222
223



224
225


226



227

228



229
230
231
232
233
234
235







-
-
-
+

-
-
+
-
-
-

-
+
-
-
-







{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)insertObjectsFromArray: (OFArray*)array
		       atIndex: (size_t)index
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [array objectEnumerator];
	size_t i, count = [array count];
	size_t i = 0;

	for (i = 0; i < count; i++) {
		id object = [enumerator nextObject];
	for (id object in array)

		assert(object != nil);

		[self insertObject: object
			   atIndex: index + i];
			   atIndex: index + i++];
	}

	objc_autoreleasePoolPop(pool);
}

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

Modified src/OFMutableDictionary.m from [670510655b] to [d75be996d7].

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

192
193
194
195
196
197
198
180
181
182
183
184
185
186



187

188
189
190
191
192
193
194
195







-
-
-

-
+







{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)removeAllObjects
{
	void *pool = objc_autoreleasePoolPush();
	OFArray *keys = [self allKeys];
	OFEnumerator *enumerator = [keys objectEnumerator];
	id key;

	while ((key = [enumerator nextObject]) != nil)
	for (id key in [self allKeys])
		[self removeObjectForKey: key];

	objc_autoreleasePoolPop(pool);
}

- copy
{

Modified src/OFMutableSet.m from [472c53bec1] to [0ec52f3f83].

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







-
-
-
+
-
-

-
-












-
-



-
+
-
















-
-
-
+
-
-
-

-
-






- (void)removeObject: (id)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)minusSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [set objectEnumerator];
	id object;
	for (id object in set)

	while ((object = [enumerator nextObject]) != nil)
		[self removeObject: object];

	objc_autoreleasePoolPop(pool);
}

- (void)intersectSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	size_t count = [self count];
	id *cArray;

	cArray = [self allocMemoryWithSize: sizeof(id)
				     count: count];

	@try {
		OFEnumerator *enumerator;
		id object;
		size_t i;

		i = 0;
		enumerator = [self objectEnumerator];
		for (id object in self) {
		while ((object = [enumerator nextObject]) != nil) {
			assert(i < count);
			cArray[i++] = object;
		}

		for (i = 0; i < count; i++)
			if (![set containsObject: cArray[i]])
			      [self removeObject: cArray[i]];
	} @finally {
		[self freeMemory: cArray];
	}

	objc_autoreleasePoolPop(pool);
}

- (void)unionSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator;
	id object;
	for (id object in set)

	enumerator = [set objectEnumerator];
	while ((object = [enumerator nextObject]) != nil)
		[self addObject: object];

	objc_autoreleasePoolPop(pool);
}

- (void)makeImmutable
{
}
@end

Modified src/OFProcess.m from [b8e8f16191] to [3256a71833].

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


233
234
235
236
237
238
239







-
-







		objc_autoreleasePoolPop(pool);
#else
		SECURITY_ATTRIBUTES sa;
		PROCESS_INFORMATION pi;
		STARTUPINFOW si;
		void *pool;
		OFMutableString *argumentsString;
		OFEnumerator *enumerator;
		OFString *argument;
		of_char16_t *argumentsCopy;
		size_t length;

		sa.nLength = sizeof(sa);
		sa.bInheritHandle = TRUE;
		sa.lpSecurityDescriptor = NULL;

275
276
277
278
279
280
281
282

283
284
285
286
287
288
289
290
273
274
275
276
277
278
279

280

281
282
283
284
285
286
287







-
+
-







						 withString: @"\\\""];

		if ([argumentsString containsString: @" "]) {
			[argumentsString prependString: @"\""];
			[argumentsString appendString: @"\""];
		}

		enumerator = [arguments objectEnumerator];
		for (OFString *argument in arguments) {
		while ((argument = [enumerator nextObject]) != nil) {
			OFMutableString *tmp =
			    [[argument mutableCopy] autorelease];
			bool containsSpaces = [tmp containsString: @" "];

			[argumentsString appendString: @" "];

			if (containsSpaces)

Modified src/OFSet.m from [2b7acb7d08] to [c1fc0fd847].

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







-
-


-
+











-

-







-


-
+








	return [otherSet isSubsetOfSet: self];
}

- (uint32_t)hash
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;
	uint32_t hash = 0;

	while ((object = [enumerator nextObject]) != nil)
	for (id object in self)
		hash += [object hash];

	objc_autoreleasePoolPop(pool);

	return hash;
}

- (OFString*)description
{
	void *pool;
	OFMutableString *ret;
	OFEnumerator *enumerator;
	size_t i, count = [self count];
	id object;

	if (count == 0)
		return @"{()}";

	ret = [OFMutableString stringWithString: @"{(\n"];

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	i = 0;
	while ((object = [enumerator nextObject]) != nil) {
	for (id object in self) {
		void *pool2 = objc_autoreleasePoolPush();

		[ret appendString: [object description]];

		if (++i < count)
			[ret appendString: @",\n"];

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







-
-
-
+
-
-
-
-
+
-

-
-
-
-






-
-
-
+
-
-
-
-
+
-

-
-
-
-








-
-








-
-
+
-







- mutableCopy
{
	return [[OFMutableSet alloc] initWithSet: self];
}

- (bool)isSubsetOfSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator;
	id object;
	for (id object in self)

	enumerator = [self objectEnumerator];
	while ((object = [enumerator nextObject]) != nil) {
		if (![set containsObject: object]) {
		if (![set containsObject: object])
			objc_autoreleasePoolPop(pool);
			return false;
		}
	}

	objc_autoreleasePoolPop(pool);

	return true;
}

- (bool)intersectsSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator;
	id object;
	for (id object in self)

	enumerator = [self objectEnumerator];
	while ((object = [enumerator nextObject]) != nil) {
		if ([set containsObject: object]) {
		if ([set containsObject: object])
			objc_autoreleasePoolPop(pool);
			return true;
		}
	}

	objc_autoreleasePoolPop(pool);

	return false;
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;
	OFEnumerator *enumerator;
	id <OFSerialization> object;

	if ([self isKindOfClass: [OFMutableSet class]])
		element = [OFXMLElement elementWithName: @"OFMutableSet"
					      namespace: OF_SERIALIZATION_NS];
	else
		element = [OFXMLElement elementWithName: @"OFSet"
					      namespace: OF_SERIALIZATION_NS];

	enumerator = [self objectEnumerator];

	for (id <OFSerialization> object in self) {
	while ((object = [enumerator nextObject]) != nil) {
		void *pool2 = objc_autoreleasePoolPush();

		[element addChild: [object XMLElementBySerializing]];

		objc_autoreleasePoolPop(pool2);
	}

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







-
+











-

-







	void *pool = objc_autoreleasePoolPush();
	id ret = [[[self objectEnumerator] nextObject] retain];
	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}

#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block
{
	bool stop = false;

	for (id object in self) {
		block(object, &stop);

		if (stop)
			break;
	}
}
#endif

#ifdef OF_HAVE_BLOCKS
- (OFSet*)filteredSetUsingBlock: (of_set_filter_block_t)block
{
	OFMutableSet *ret = [OFMutableSet set];

	[self enumerateObjectsUsingBlock: ^ (id object, bool *stop) {
		if (block(object))
			[ret addObject: object];

Modified src/OFSet_hashtable.m from [fcbd1c81f4] to [1eaa048921].

96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116
117
118
119
96
97
98
99
100
101
102



103



104
105


106
107
108
109
110
111
112







-
-
-
+
-
-
-


-
-







		[self release];
		@throw e;
	}

	self = [self initWithCapacity: count];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		id object;
		for (id object in set)

		enumerator = [set objectEnumerator];
		while ((object = [enumerator nextObject]) != nil)
			[_mapTable setValue: (void*)1
				     forKey: object];

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

	return self;
}
131
132
133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
148
149
150
151
152
153
154
124
125
126
127
128
129
130



131



132
133


134
135
136
137
138
139
140







-
-
-
+
-
-
-


-
-







		[self release];
		@throw e;
	}

	self = [self initWithCapacity: count];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		id object;
		for (id object in array)

		enumerator = [array objectEnumerator];
		while ((object = [enumerator nextObject]) != nil)
			[_mapTable setValue: (void*)1
				     forKey: object];

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

	return self;
}
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
193
194
195
196
197
198
199


200
201
202
203
204
205


206
207

208
209
210
211
212
213
214







-
-






-
-
+
+
-








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

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFEnumerator *enumerator;
		OFXMLElement *child;

		if ((![[element name] isEqual: @"OFSet"] &&
		    ![[element name] isEqual: @"OFMutableSet"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];

		enumerator = [[element elementsForNamespace:
		    OF_SERIALIZATION_NS] objectEnumerator];
		for (OFXMLElement *child in
		    [element elementsForNamespace: OF_SERIALIZATION_NS]) {
		while ((child = [enumerator nextObject]) != nil) {
			void *pool2  = objc_autoreleasePoolPush();

			[_mapTable setValue: (void*)1
				     forKey: [child objectByDeserializing]];

			objc_autoreleasePoolPop(pool2);
		}

Modified src/OFString.m from [0176c8e382] to [01f9bb127a].

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
652
653
654
655
656
657
658




659
660
661
662



663
664

665


666
667
668

669
670
671
672
673
674
675







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

-
-
+
+
+
-







					   encoding: encoding] autorelease];
}
#endif

+ (OFString*)pathWithComponents: (OFArray*)components
{
	OFMutableString *ret = [OFMutableString string];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [components objectEnumerator];
	OFString *component;

	bool first = true;

	for (OFString *component in components) {
		if (!first)
	if ((component = [enumerator nextObject]) != nil)
		[ret appendString: component];
	while ((component = [enumerator nextObject]) != nil) {
			[ret appendString: OF_PATH_DELIMITER_STRING];

		[ret appendString: OF_PATH_DELIMITER_STRING];
		[ret appendString: component];
	}


		first = false;
	}
	objc_autoreleasePoolPop(pool);

	return ret;
}

- init
{
	if (object_getClass(self) == [OFString class]) {

Modified src/OFThreadPool.m from [ceb8630ad0] to [e4818c31b0].

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







-




-
-
+
-
-









-







	}

	return self;
}

- (void)dealloc
{
	void *pool = objc_autoreleasePoolPush();
	[_queueCondition lock];
	@try {
		[_countCondition lock];
		@try {
			OFEnumerator *enumerator = [_threads objectEnumerator];
			OFThreadPoolThread *thread;
			for (OFThreadPoolThread *thread in _threads)

			while ((thread = [enumerator nextObject]) != nil)
				thread->_terminate = true;
		} @finally {
			[_countCondition unlock];
		}

		[_queueCondition broadcast];
	} @finally {
		[_queueCondition unlock];
	}
	objc_autoreleasePoolPop(pool);

	[_threads release];
	[_queue release];
	[_queueCondition release];
	[_countCondition release];

	[super dealloc];

Modified src/OFXMLElement.m from [1f70933951] to [767015e338].

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







-
+
-











-
+
-







		if ((_attributes != nil && ![_attributes isKindOfClass:
		    [OFMutableArray class]]) || (_namespaces != nil &&
		    ![_namespaces isKindOfClass:
		    [OFMutableDictionary class]]) || (_children != nil &&
		    ![_children isKindOfClass: [OFMutableArray class]]))
			@throw [OFInvalidArgumentException exception];

		objectEnumerator = [_attributes objectEnumerator];
		for (object in _attributes)
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLAttribute class]])
				@throw [OFInvalidArgumentException exception];

		keyEnumerator = [_namespaces keyEnumerator];
		objectEnumerator = [_namespaces objectEnumerator];
		while ((key = [keyEnumerator nextObject]) != nil &&
		    (object = [objectEnumerator nextObject]) != nil)
			if (![key isKindOfClass: [OFString class]] ||
			    ![object isKindOfClass: [OFString class]])
				@throw [OFInvalidArgumentException exception];

		objectEnumerator = [_children objectEnumerator];
		for (object in _children)
		while ((object = [objectEnumerator nextObject]) != nil)
			if (![object isKindOfClass: [OFXMLNode class]])
				@throw [OFInvalidArgumentException exception];

		if (_namespaces == nil)
			_namespaces = [[OFMutableDictionary alloc] init];

		[_namespaces
916
917
918
919
920
921
922
923
924
925

926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
914
915
916
917
918
919
920



921


922
923
924
925
926


927
928
929
930
931
932
933







-
-
-
+
-
-





-
-







	[_children insertObject: child
			atIndex: index];
}

- (void)insertChildren: (OFArray*)children
	       atIndex: (size_t)index
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [children objectEnumerator];
	OFXMLNode *node;
	for (OFXMLNode *node in children)

	while ((node = [enumerator nextObject]) != nil)
		if ([node isKindOfClass: [OFXMLAttribute class]])
			@throw [OFInvalidArgumentException exception];

	[_children insertObjectsFromArray: children
				  atIndex: index];

	objc_autoreleasePoolPop(pool);
}

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

Modified utils/ofhash/OFHash.m from [59a725be71] to [d5afdd7b11].

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







-
-
+








-
+
-
-
-
+




+
+
+
+
+
+
+







}

@implementation OFHash
- (void)applicationDidFinishLaunching
{
	OFArray OF_GENERIC(OFString*) *arguments = [OFApplication arguments];
	id <OFHash> hash;
	OFEnumerator *enumerator;
	OFString *path;
	bool first = true;
	int exitStatus = 0;

	if ([arguments count] < 2)
		help();

	if ((hash = hashForName([arguments firstObject])) == nil)
		help();

	enumerator = [[arguments objectsInRange:
	for (OFString *path in arguments) {
	    of_range(1, [arguments count] - 1)] objectEnumerator];
	while ((path = [enumerator nextObject]) != nil) {
		void *pool = objc_autoreleasePoolPush();
		void *pool;
		OFStream *file;
		const uint8_t *digest;
		size_t i, digestSize;

		if (first) {
			first = false;
			continue;
		}

		pool = objc_autoreleasePoolPush();

		if ([path isEqual: @"-"])
			file = of_stdin;
		else {
			@try {
				file = [OFFile fileWithPath: path
						       mode: @"rb"];
			} @catch (OFOpenItemFailedException *e) {

Modified utils/ofzip/OFZIP.m from [6492307736] to [d383d3b508].

250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265
266
267
268
269
250
251
252
253
254
255
256


257




258
259
260
261
262
263
264







-
-
+
-
-
-
-







	}

	return archive;
}

- (void)listFilesInArchive: (OFZIPArchive*)archive
{
	OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *enumerator;
	OFZIPArchiveEntry *entry;
	for (OFZIPArchiveEntry *entry in [archive entries]) {

	enumerator = [[archive entries] objectEnumerator];

	while ((entry = [enumerator nextObject]) != nil) {
		void *pool = objc_autoreleasePoolPush();

		[of_stdout writeLine: [entry fileName]];

		if (_outputLevel >= 1) {
			OFString *date = [[entry modificationDate]
			    localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"];
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
304
305
306
307
308
309
310




311
312



313
314

315

316
317
318
319


320
321
322
323
324
325
326
327







-
-
-
-
+
+
-
-
-
+

-
+
-




-
-
+







	}
}

- (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files
	 fromArchive: (OFZIPArchive*)archive
{
	OFFileManager *fileManager = [OFFileManager defaultManager];
	OFEnumerator OF_GENERIC(OFZIPArchiveEntry*) *entryEnumerator;
	OFZIPArchiveEntry *entry;
	bool all;
	OFMutableSet OF_GENERIC(OFString*) *missing;
	bool all = ([files count] == 0);
	OFMutableSet OF_GENERIC(OFString*) *missing =

	all = ([files count] == 0);
	missing = [OFMutableSet setWithArray: files];
	    [OFMutableSet setWithArray: files];

	entryEnumerator = [[archive entries] objectEnumerator];
	for (OFZIPArchiveEntry *entry in [archive entries]) {
	while ((entry = [entryEnumerator nextObject]) != nil) {
		void *pool = objc_autoreleasePoolPush();
		OFString *fileName = [entry fileName];
		OFString *outFileName = [fileName stringByStandardizingPath];
		OFArray OF_GENERIC(OFString*) *pathComponents;
		OFEnumerator OF_GENERIC(OFString*) *componentEnumerator;
		OFString *component, *directory;
		OFString *directory;
		OFStream *stream;
		OFFile *output;
		char buffer[BUFFER_SIZE];
		uint64_t written = 0, size = [entry uncompressedSize];
		int_fast8_t percent = -1, newPercent;

		if (!all && ![files containsObject: fileName])
350
351
352
353
354
355
356
357

358
359
360
361
362
363
364
365
339
340
341
342
343
344
345

346

347
348
349
350
351
352
353







-
+
-







						fileName];

			_exitStatus = 1;
			goto outer_loop_end;
		}

		pathComponents = [outFileName pathComponents];
		componentEnumerator = [pathComponents objectEnumerator];
		for (OFString *component in pathComponents) {
		while ((component = [componentEnumerator nextObject]) != nil) {
			if ([component isEqual: OF_PATH_PARENT_DIRECTORY]) {
				[of_stderr writeFormat:
				    @"Refusing to extract %@!\n", fileName];

				_exitStatus = 1;
				goto outer_loop_end;
			}
476
477
478
479
480
481
482
483
484

485
486
487
488
489
490
491
492
493
494
464
465
466
467
468
469
470


471



472
473
474
475
476
477
478







-
-
+
-
-
-







						fileName];

outer_loop_end:
		objc_autoreleasePoolPop(pool);
	}

	if ([missing count] > 0) {
		OFEnumerator OF_GENERIC(OFString*) *enumerator;
		OFString *file;
		for (OFString *file in missing)

		enumerator = [missing objectEnumerator];
		while ((file = [enumerator nextObject]) != nil)
			[of_stderr writeFormat:
			    @"File %@ is not in the archive!\n", file];

		_exitStatus = 1;
	}
}
@end