ObjFW  Diff

Differences From Artifact [5595432660]:

To Artifact [5f67a0c8ca]:


119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134
135
136
137
138

139
140
141
142
143
144


145
146
147
148
149
150
151
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
134
135
136
137

138
139
140
141
142


143
144
145
146
147
148
149
150
151







-
+











-
+




-
-
+
+







}

- (OFString*)string
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	char *str_c;
	size_t len, i, j, attrs_count;
	OFXMLAttribute **attrs_data;
	OFXMLAttribute **attrs_carray;
	OFString *ret, *tmp;

	len = [name cStringLength] + 4;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	*str_c = '<';
	memcpy(str_c + 1, [name cString], [name cStringLength]);
	i = [name cStringLength] + 1;

	/* Attributes */
	attrs_data = [attrs data];
	attrs_carray = [attrs cArray];
	attrs_count = [attrs count];

	for (j = 0; j < attrs_count; j++) {
		/* FIXME: Add namespace support */
		OFString *attr_name = [attrs_data[j] name];
		tmp = [[attrs_data[j] stringValue] stringByXMLEscaping];
		OFString *attr_name = [attrs_carray[j] name];
		tmp = [[attrs_carray[j] stringValue] stringByXMLEscaping];

		len += [attr_name cStringLength] + [tmp cStringLength] + 4;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
			[self freeMemory: str_c];
166
167
168
169
170
171
172
173
174


175
176
177
178
179
180
181

182
183
184

185
186
187
188
189
190
191
166
167
168
169
170
171
172


173
174
175
176
177
178
179
180

181
182
183

184
185
186
187
188
189
190
191







-
-
+
+






-
+


-
+







	}

	/* Childen */
	if (stringval != nil || children != nil) {
		if (stringval != nil)
			tmp = [stringval stringByXMLEscaping];
		else if (children != nil) {
			OFXMLElement **data = [children data];
			size_t count = [children count];
			OFXMLElement **children_carray = [children cArray];
			size_t children_count = [children count];
			IMP append;

			tmp = [OFMutableString string];
			append = [tmp methodForSelector:
			    @selector(appendCStringWithoutUTF8Checking:)];

			for (j = 0; j < count; j++)
			for (j = 0; j < children_count; j++)
				append(tmp, @selector(
				    appendCStringWithoutUTF8Checking:),
				    [[data[j] string] cString]);
				    [[children_carray[j] string] cString]);
		}

		len += [tmp cStringLength] + [name cStringLength] + 2;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {