ObjFW  Diff

Differences From Artifact [768dfa63ad]:

To Artifact [8f2d46a92b]:


94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
109
110

111
112
113
114
115
116
117
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116
117







-
+








-
+








	return ret;
}

static OFString*
namespace_for_prefix(OFString *prefix, OFArray *namespaces)
{
	OFDictionary **cArray = [namespaces cArray];
	OFDictionary **objects = [namespaces objects];
	ssize_t i;

	if (prefix == nil)
		prefix = @"";

	for (i = [namespaces count] - 1; i >= 0; i--) {
		OFString *tmp;

		if ((tmp = [cArray[i] objectForKey: prefix]) != nil)
		if ((tmp = [objects[i] objectForKey: prefix]) != nil)
			return tmp;
	}

	return nil;
}

static OF_INLINE void
185
186
187
188
189
190
191

192
193
194
195
196
197
198
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199







+







	@try {
		OFAutoreleasePool *pool;
		OFMutableDictionary *dict;

		cache = [[OFBigDataArray alloc] init];
		previous = [[OFMutableArray alloc] init];
		namespaces = [[OFMutableArray alloc] init];
		attributes = [[OFMutableArray alloc] init];

		pool = [[OFAutoreleasePool alloc] init];
		dict = [OFMutableDictionary dictionaryWithKeysAndObjects:
		    @"xml", @"http://www.w3.org/XML/1998/namespace",
		    @"xmlns", @"http://www.w3.org/2000/xmlns/", nil];
		[namespaces addObject: dict];

666
667
668
669
670
671
672
673

674
675
676
677
678
679
680
681
682
683
684
685
686
687

688
689
690
691
692
693
694
695
696
697

698
699
700
701
702
703
704
667
668
669
670
671
672
673

674
675
676
677
678
679
680
681
682
683
684
685
686
687

688
689
690
691
692
693
694
695
696
697

698
699
700
701
702
703
704
705







-
+













-
+









-
+







/* Inside a tag, name found */
- (void)_parseInTagWithBuffer: (const char*)buffer
			    i: (size_t*)i
			 last: (size_t*)last
{
	OFAutoreleasePool *pool;
	OFString *ns;
	OFXMLAttribute **attributesCArray;
	OFXMLAttribute **attributesObjects;
	size_t j, attributesCount;

	if (buffer[*i] != '>' && buffer[*i] != '/') {
		if (buffer[*i] != ' ' && buffer[*i] != '\t' &&
		    buffer[*i] != '\n' && buffer[*i] != '\r') {
			*last = *i;
			state = OF_XMLPARSER_IN_ATTR_NAME;
			(*i)--;
		}

		return;
	}

	attributesCArray = [attributes cArray];
	attributesObjects = [attributes objects];
	attributesCount = [attributes count];

	ns = namespace_for_prefix(prefix, namespaces);

	if (prefix != nil && ns == nil)
		@throw [OFUnboundNamespaceException exceptionWithClass: isa
								prefix: prefix];

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesCArray[j], namespaces,
		resolve_attribute_namespace(attributesObjects[j], namespaces,
		    isa);

	pool = [[OFAutoreleasePool alloc] init];

	[delegate parser: self
	 didStartElement: name
	      withPrefix: prefix
722
723
724
725
726
727
728
729

730
731
732
733
734
735
736
737
738
723
724
725
726
727
728
729

730
731

732
733
734
735
736
737
738







-
+

-







	} else
		[previous addObject: name];

	[pool release];

	[name release];
	[prefix release];
	[attributes release];
	[attributes removeAllObjects];
	name = prefix = nil;
	attributes = nil;

	*last = *i + 1;
	state = (buffer[*i] == '/'
	    ? OF_XMLPARSER_EXPECT_CLOSE
	    : OF_XMLPARSER_OUTSIDE_TAG);
}

823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
823
824
825
826
827
828
829



830
831
832
833
834
835
836







-
-
-







	if (attributePrefix == nil && [attributeName isEqual: @"xmlns"])
		[[namespaces lastObject] setObject: attributeValue
					    forKey: @""];
	if ([attributePrefix isEqual: @"xmlns"])
		[[namespaces lastObject] setObject: attributeValue
					    forKey: attributeName];

	if (attributes == nil)
		attributes = [[OFMutableArray alloc] init];

	[attributes addObject:
	    [OFXMLAttribute attributeWithName: attributeName
				    namespace: attributePrefix
				  stringValue: attributeValue]];

	[pool release];