ObjFW  Check-in [ddc9f8ac04]

Overview
Comment:Don't let a comment prevent indentation and indent comments correctly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ddc9f8ac04c3c9e6c9a2826bc49382217241d9fa0a390cbb75455241f5d4efb0
User & Date: js on 2011-06-06 00:46:20
Other Links: manifest | tags
Context
2011-06-06
03:19
Always use unions to access a float as a uint32_t. check-in: 4b8e8836c8 user: js tags: trunk
00:46
Don't let a comment prevent indentation and indent comments correctly. check-in: ddc9f8ac04 user: js tags: trunk
00:35
Don't add unwanted whitespaces to character data on indentation. check-in: a36135d018 user: js tags: trunk
Changes

Modified src/OFXMLElement.m from [f4ee2b186f] to [e91819cfc0].

471
472
473
474
475
476
477
478
















479




480
481
482
483
484
485
486

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

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

	if (comment != nil)
















		return [OFString stringWithFormat: @"<!--%@-->", comment];





	pool = [[OFAutoreleasePool alloc] init];

	if (parent != nil && parent->namespaces != nil) {
		OFEnumerator *keyEnumerator = [namespaces keyEnumerator];
		OFEnumerator *objectEnumerator = [namespaces objectEnumerator];
		id key, object;







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







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

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

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

	if (comment != nil) {
		OFString *ret;

		if (indentation > 0 && level > 0) {
			char *whitespaces = [self
			    allocMemoryWithSize: (level * indentation) + 1];
			memset(whitespaces, ' ', level * indentation);
			whitespaces[level * indentation] = 0;

			@try {
				ret = [OFString
				    stringWithFormat: @"%s<!--%@-->",
						      whitespaces, comment];
			} @finally {
				[self freeMemory: whitespaces];
			}
		} else
			ret = [OFString stringWithFormat: @"<!--%@-->",
							  comment];

		return ret;
	}

	pool = [[OFAutoreleasePool alloc] init];

	if (parent != nil && parent->namespaces != nil) {
		OFEnumerator *keyEnumerator = [namespaces keyEnumerator];
		OFEnumerator *objectEnumerator = [namespaces objectEnumerator];
		id key, object;
613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
		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;








|
>







633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
		tmp = [OFMutableString string];
		append = [tmp methodForSelector: appendSel];

		if (indentation > 0) {
			indent = YES;

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