ObjFW  Diff

Differences From Artifact [a389df28b8]:

To Artifact [3a91a054b9]:


392
393
394
395
396
397
398

399
400
401
402
403
404
405
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406







+







{
	const char *cString;
	size_t i, last, length;
	int PIState = 0;
	OFString *attribute = nil;
	OFMutableString *value = nil;
	char piDelimiter = 0;
	bool hasVersion = false;

	if (!_acceptProlog)
		return false;

	_acceptProlog = false;

	pi = [pi substringWithRange: of_range(3, [pi length] - 3)];
444
445
446
447
448
449
450
451

452
453



454
455
456
457
458
459
460
445
446
447
448
449
450
451

452
453
454
455
456
457
458
459
460
461
462
463
464







-
+


+
+
+







			if (cString[i] != piDelimiter)
				continue;

			value = [OFMutableString
			    stringWithUTF8String: cString + last
					  length: i - last];

			if ([attribute isEqual: @"version"])
			if ([attribute isEqual: @"version"]) {
				if (![value hasPrefix: @"1."])
					return false;

				hasVersion = true;
			}

			if ([attribute isEqual: @"encoding"]) {
				[value lowercase];

				if ([value isEqual: @"utf-8"])
					_encoding = OF_STRING_ENCODING_UTF_8;
				else if ([value isEqual: @"iso-8859-1"])
473
474
475
476
477
478
479
480

481
482
483
484
485
486
487
477
478
479
480
481
482
483

484
485
486
487
488
489
490
491







-
+







			last = i + 1;
			PIState = 0;

			break;
		}
	}

	if (PIState != 0)
	if (PIState != 0 || !hasVersion)
		return false;

	return true;
}

/* Inside processing instructions */
- (void)OF_parseInProcessingInstructionsWithBuffer: (const char*)buffer