ObjFW  Diff

Differences From Artifact [077a8d208b]:

To Artifact [3582bcd6d7]:


302
303
304
305
306
307
308


























309
310
311
312
313
314
315
	else
		ret = defaultValue;

	objc_autoreleasePoolPop(pool);

	return ret;
}



























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







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	else
		ret = defaultValue;

	objc_autoreleasePoolPop(pool);

	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) {
		OFINICategory_Pair *pair;

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

		pair = line;

		if ([pair->_key isEqual: key])
			[ret addObject: [[pair->_value copy] autorelease]];
	}

	objc_autoreleasePoolPop(pool);

	[ret makeImmutable];

	return ret;
}

- (void)setString: (OFString*)string
	   forKey: (OFString*)key
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [_lines objectEnumerator];
	OFINICategory_Pair *pair;
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
	void *pool = objc_autoreleasePoolPush();

	[self setString: [OFString stringWithFormat: @"%g", double_]
		 forKey: key];

	objc_autoreleasePoolPop(pool);
}


- (void)removeValueForKey: (OFString*)key
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [_lines objectEnumerator];



	size_t i;

	id line;




	i = 0;





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















		if (![line isKindOfClass: [OFINICategory_Pair class]]) {

			i++;






































			continue;
		}

		pair = line;

		if ([pair->_key isEqual: key]) {
			[_lines removeObjectAtIndex: i];
			break;


		}



		i++;
	}

	objc_autoreleasePoolPop(pool);
}

- (bool)OF_writeToStream: (OFStream*)stream
		encoding: (of_string_encoding_t)encoding








>
|

|
|
>
>
>
|
>
|
>
>
>
|
|
>
>
>
>
>
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
<
|



|
>
>
|
>
>
|
<







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497
498
499
500

501
502
503
504
505
506
507
	void *pool = objc_autoreleasePoolPush();

	[self setString: [OFString stringWithFormat: @"%g", double_]
		 forKey: key];

	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) {
		OFINICategory_Pair *pair;

		pair = [[[OFINICategory_Pair alloc] init] autorelease];
		pair->_key = [key copy];
		pair->_value = [object copy];

		[pairs addObject: pair];
	}

	lines = [_lines objects];
	count = [_lines count];
	replaced = false;

	for (i = 0; i < count; i++) {
		OFINICategory_Pair *pair;

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

		pair = lines[i];

		if ([pair->_key isEqual: key]) {
			[_lines removeObjectAtIndex: i];

			if (!replaced) {
				[_lines insertObjectsFromArray: pairs
						       atIndex: i];

				replaced = true;
				/* Continue after inserted pairs */
				i += [array count] - 1;
			} else
				i--;	/* Continue at same position */

			lines = [_lines objects];
			count = [_lines count];

			continue;
		}
	}

	if (!replaced)
		[_lines addObjectsFromArray: pairs];

	objc_autoreleasePoolPop(pool);
}

- (void)removeValueForKey: (OFString*)key
{
	void *pool = objc_autoreleasePoolPush();
	id const *lines = [_lines objects];
	size_t i, count = [_lines count];

	for (i = 0; i < count; i++) {
		OFINICategory_Pair *pair;

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


		pair = lines[i];

		if ([pair->_key isEqual: key]) {
			[_lines removeObjectAtIndex: i];

			lines = [_lines objects];
			count = [_lines count];

			i--;	/* Continue at same position */
			continue;
		}

	}

	objc_autoreleasePoolPop(pool);
}

- (bool)OF_writeToStream: (OFStream*)stream
		encoding: (of_string_encoding_t)encoding