ObjFW  Diff

Differences From Artifact [c82b6a1f56]:

To Artifact [f4ee2b186f]:


464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
	char *cString;
	size_t length, i, j, attributesCount;
	OFString *prefix, *parentPrefix;
	OFXMLAttribute **attributesCArray;
	OFString *ret, *tmp;
	OFMutableDictionary *allNamespaces;
	OFString *defaultNS;
	BOOL indentAfter = YES;

	if (characters != nil)
		return [characters stringByXMLEscaping];

	if (CDATA != nil)
		return [OFString stringWithFormat: @"<![CDATA[%@]]>", CDATA];








<







464
465
466
467
468
469
470

471
472
473
474
475
476
477
	char *cString;
	size_t length, i, j, attributesCount;
	OFString *prefix, *parentPrefix;
	OFXMLAttribute **attributesCArray;
	OFString *ret, *tmp;
	OFMutableDictionary *allNamespaces;
	OFString *defaultNS;


	if (characters != nil)
		return [characters stringByXMLEscaping];

	if (CDATA != nil)
		return [OFString stringWithFormat: @"<![CDATA[%@]]>", CDATA];

605
606
607
608
609
610
611

612
613
614
615



616
617









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

	/* Childen */
	if (children != nil) {
		OFXMLElement **childrenCArray = [children cArray];
		size_t childrenCount = [children count];
		IMP append;
		SEL appendSel = @selector(appendCStringWithoutUTF8Checking:);


		tmp = [OFMutableString string];
		append = [tmp methodForSelector: appendSel];




		for (j = 0; j < childrenCount; j++) {
			if (indentation > 0 && childrenCArray[j]->name != nil)









				append(tmp, appendSel, "\n");

			append(tmp, appendSel,
			    [[childrenCArray[j]
			    _XMLStringWithParent: self
				     indentation: indentation
					   level: level + 1]
			    cString]);
		}

		if (indentation > 0 && childrenCount > 0 &&
		    childrenCArray[j - 1]->name != nil)
			append(tmp, appendSel, "\n");
		else
			indentAfter = NO;

		length += [tmp cStringLength] + [name cStringLength] + 2 +
		    (indentAfter ? level * indentation : 0);
		@try {
			cString = [self resizeMemory: cString
					      toSize: length];
		} @catch (id e) {
			[self freeMemory: cString];
			@throw e;
		}

		cString[i++] = '>';

		memcpy(cString + i, [tmp cString], [tmp cStringLength]);
		i += [tmp cStringLength];

		if (indentAfter)
			for (j = 0; j < level * indentation; j++)
				cString[i++] = ' ';

		cString[i++] = '<';
		cString[i++] = '/';
		if (prefix != nil) {
			length += [prefix cStringLength] + 1;







>




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





|




|
<

<
<


|













|







604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
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

	/* Childen */
	if (children != nil) {
		OFXMLElement **childrenCArray = [children cArray];
		size_t childrenCount = [children count];
		IMP append;
		SEL appendSel = @selector(appendCStringWithoutUTF8Checking:);
		BOOL indent;

		tmp = [OFMutableString string];
		append = [tmp methodForSelector: appendSel];

		if (indentation > 0) {
			indent = YES;

			for (j = 0; j < childrenCount; j++) {
				if (childrenCArray[j]->name == nil) {
					indent = NO;
					break;
				}
			}
		} else
			indent = NO;

		for (j = 0; j < childrenCount; j++) {
			if (indent)
				append(tmp, appendSel, "\n");

			append(tmp, appendSel,
			    [[childrenCArray[j]
			    _XMLStringWithParent: self
				     indentation: (indent ? indentation : 0)
					   level: level + 1]
			    cString]);
		}

		if (indent)

			append(tmp, appendSel, "\n");



		length += [tmp cStringLength] + [name cStringLength] + 2 +
		    (indent ? level * indentation : 0);
		@try {
			cString = [self resizeMemory: cString
					      toSize: length];
		} @catch (id e) {
			[self freeMemory: cString];
			@throw e;
		}

		cString[i++] = '>';

		memcpy(cString + i, [tmp cString], [tmp cStringLength]);
		i += [tmp cStringLength];

		if (indent)
			for (j = 0; j < level * indentation; j++)
				cString[i++] = ' ';

		cString[i++] = '<';
		cString[i++] = '/';
		if (prefix != nil) {
			length += [prefix cStringLength] + 1;