ObjFW  Diff

Differences From Artifact [1c6e965299]:

To Artifact [14f63e2483]:


191
192
193
194
195
196
197
198

199
200
201
202
203
204

205
206
207
208
209
210
211
191
192
193
194
195
196
197

198

199
200
201
202

203
204
205
206
207
208
209
210







-
+
-




-
+







}

- (OFArray*)children
{
	return [[children copy] autorelease];
}

- (OFString*)_stringValueWithParentNamespaces: (OFDictionary*)parent_namespaces
- (OFString*)_stringValueWithParent: (OFXMLElement*)parent
		       parentDefaultNamespace: (OFString*)parent_default_ns
{
	OFAutoreleasePool *pool, *pool2;
	char *str_c;
	size_t len, i, j, attrs_count;
	OFString *prefix = nil;
	OFString *prefix, *parent_prefix;
	OFXMLAttribute **attrs_carray;
	OFString *ret, *tmp;
	OFMutableDictionary *all_namespaces;
	OFString *def_ns;

	if (characters != nil)
		return [characters stringByXMLEscaping];
228
229
230
231
232
233
234
235


236
237

238
239
240
241
242

243
244
245
246
247
248
249
250
251
252



253
254
255
256
257
258
259
260
261



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281



282
283
284
285
286
287
288
227
228
229
230
231
232
233

234
235
236

237
238
239
240
241

242
243
244
245
246
247
248
249
250


251
252
253
254
255
256
257
258
259
260
261

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283

284
285
286
287
288
289
290
291
292
293







-
+
+

-
+




-
+








-
-
+
+
+








-
+
+
+



















-
+
+
+







		 */
		str->isa = [OFString class];
		return str;
	}

	pool = [[OFAutoreleasePool alloc] init];
	def_ns = (defaultNamespace != nil
	    ? defaultNamespace : parent_default_ns);
	    ? defaultNamespace
	    : (parent != nil ? parent->defaultNamespace : nil));

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

		all_namespaces = [[parent_namespaces mutableCopy] autorelease];
		all_namespaces = [[parent->namespaces mutableCopy] autorelease];

		while ((key = [key_enum nextObject]) != nil &&
		    (obj = [obj_enum nextObject]) != nil)
			[all_namespaces setObject: obj
					   forKey: key];
	} else
		all_namespaces = namespaces;

	prefix = [all_namespaces objectForKey:
	    (ns != nil ? ns : (OFString*)@"")];
	prefix = [all_namespaces objectForKey: (ns != nil ? ns : @"")];
	parent_prefix = [all_namespaces objectForKey:
		(parent != nil && parent->ns != nil ? parent->ns : @"")];

	i = 0;
	len = [name cStringLength] + 3;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	str_c[i++] = '<';

	if (prefix != nil && ![ns isEqual: def_ns]) {
	if (prefix != nil && ![ns isEqual: def_ns] &&
	    (![ns isEqual: (parent != nil ? parent->ns : nil)] ||
	    parent_prefix != nil)) {
		len += [prefix cStringLength] + 1;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (id e) {
			[self freeMemory: str_c];
			@throw e;
		}

		memcpy(str_c + i, [prefix cString],
		    [prefix cStringLength]);
		i += [prefix cStringLength];
		str_c[i++] = ':';
	}

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

	/* xmlns if necessary */
	if (ns != nil && prefix == nil && ![ns isEqual: def_ns]) {
	if (ns != nil && prefix == nil && ![ns isEqual: def_ns] &&
	     (![ns isEqual: (parent != nil ? parent->ns : nil)] ||
	     parent_prefix != nil)) {
		len += [ns cStringLength] + 9;

		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (id e) {
			[self freeMemory: str_c];
356
357
358
359
360
361
362
363

364
365
366
367
368
369
370
371
361
362
363
364
365
366
367

368

369
370
371
372
373
374
375







-
+
-







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

		for (j = 0; j < children_count; j++)
			append(tmp, @selector(
			    appendCStringWithoutUTF8Checking:),
			    [[children_carray[j]
			    _stringValueWithParentNamespaces: all_namespaces
			        _stringValueWithParent: self] cString]);
			    parentDefaultNamespace: def_ns] cString]);

		len += [tmp cStringLength] + [name cStringLength] + 2;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (id e) {
			[self freeMemory: str_c];
409
410
411
412
413
414
415
416

417
418
419
420
421
422
423
424
413
414
415
416
417
418
419

420

421
422
423
424
425
426
427







-
+
-







		[self freeMemory: str_c];
	}
	return ret;
}

- (OFString*)stringValue
{
	return [self _stringValueWithParentNamespaces: nil
	return [self _stringValueWithParent: nil];
			       parentDefaultNamespace: nil];
}

- (OFString*)description
{
	return [self stringValue];
}