ObjFW  Diff

Differences From Artifact [9cf8e5058f]:

To Artifact [47f877a838]:


60
61
62
63
64
65
66
67

68
69
70
71
72
73
74
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74







-
+







		}
	}

	if ((i = of_string_unicode_to_utf8(c, buf)) == 0)
		return nil;

	return [OFString stringWithCString: buf
				 andLength: i];
				    length: i];
}

@implementation OFXMLParser
+ xmlParser
{
	return [[[self alloc] init] autorelease];
}
175
176
177
178
179
180
181
182

183
184
185

186
187
188
189
190
191

192
193
194
195
196
197
198
199
200
201
202
203



204
205
206
207
208
209


210
211
212
213
214
215
216
175
176
177
178
179
180
181

182
183
184

185
186
187
188
189
190

191
192
193
194
195
196
197
198
199
200



201
202
203
204
205
206
207


208
209
210
211
212
213
214
215
216







-
+


-
+





-
+









-
-
-
+
+
+




-
-
+
+







				cache_c = [cache cString];
				cache_len = [cache length];

				if ((tmp = memchr(cache_c, ':',
				    cache_len)) != NULL) {
					prefix = [[OFString alloc]
					    initWithCString: cache_c
						  andLength: tmp - cache_c];
						     length: tmp - cache_c];
					name = [[OFString alloc]
					    initWithCString: tmp + 1
						  andLength: cache_len - (tmp -
						     length: cache_len - (tmp -
							     cache_c) - 1];
				} else {
					prefix = nil;
					name = [[OFString alloc]
					    initWithCString: cache_c
						  andLength: cache_len];
						     length: cache_len];
				}

				[cache setToCString: ""];

				if (buf[i] == '>' || buf[i] == '/') {
					pool = [[OFAutoreleasePool alloc] init];

					[delegate xmlParser: self
					didStartTagWithName: name
						  andPrefix: prefix
					       andNamespace: ns
					      andAttributes: nil];
						     prefix: prefix
						  namespace: ns
						 attributes: nil];

					if (buf[i] == '/')
						[delegate xmlParser: self
						  didEndTagWithName: name
							  andPrefix: prefix
						       andNamespace: ns];
							     prefix: prefix
							  namespace: ns];

					[pool release];

					[name release];
					[prefix release];
					[ns release];

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







-
+


-
+





-
+








-
-
+
+







				cache_c = [cache cString];
				cache_len = [cache length];

				if ((tmp = memchr(cache_c, ':',
				    cache_len)) != NULL) {
					prefix = [[OFString alloc]
					    initWithCString: cache_c
						  andLength: tmp - cache_c];
						     length: tmp - cache_c];
					name = [[OFString alloc]
					    initWithCString: tmp + 1
						  andLength: cache_len - (tmp -
						     length: cache_len - (tmp -
							     cache_c) - 1];
				} else {
					prefix = nil;
					name = [[OFString alloc]
					    initWithCString: cache_c
						  andLength: cache_len];
						     length: cache_len];
				}

				[cache setToCString: ""];

				pool = [[OFAutoreleasePool alloc] init];

				[delegate xmlParser: self
				  didEndTagWithName: name
					  andPrefix: prefix
				       andNamespace: ns];
					     prefix: prefix
					  namespace: ns];

				[pool release];

				[name release];
				[prefix release];
				[ns release];

278
279
280
281
282
283
284
285
286
287



288
289
290
291
292
293


294
295
296
297
298
299
300
278
279
280
281
282
283
284



285
286
287
288
289
290
291


292
293
294
295
296
297
298
299
300







-
-
-
+
+
+




-
-
+
+







		/* Inside a tag, name found */
		case OF_XMLPARSER_IN_TAG:
			if (buf[i] == '>' || buf[i] == '/') {
				pool = [[OFAutoreleasePool alloc] init];

				[delegate xmlParser: self
				didStartTagWithName: name
					  andPrefix: prefix
				       andNamespace: ns
				      andAttributes: attrs];
					     prefix: prefix
					  namespace: ns
					 attributes: attrs];

				if (buf[i] == '/')
					[delegate xmlParser: self
					  didEndTagWithName: name
						  andPrefix: prefix
					       andNamespace: ns];
						     prefix: prefix
						  namespace: ns];

				[pool release];

				[name release];
				[prefix release];
				[ns release];
				[attrs release];
411
412
413
414
415
416
417
418

419
420
421
422
423
424
425
411
412
413
414
415
416
417

418
419
420
421
422
423
424
425







-
+







	last = 0;
	in_entity = NO;
	ret = [OFMutableString string];

	for (i = 0; i < length; i++) {
		if (!in_entity && string[i] == '&') {
			[ret appendCStringWithoutUTF8Checking: string + last
						    andLength: i - last];
						    length: i - last];

			last = i + 1;
			in_entity = YES;
		} else if (in_entity && string[i] == ';') {
			char *entity = string + last;
			size_t len = i - last;

449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
449
450
451
452
453
454
455

456
457
458
459
460
461
462
463







-
+







			} else if (h != nil) {
				OFAutoreleasePool *pool;
				OFString *n, *tmp;

				pool = [[OFAutoreleasePool alloc] init];

				n = [OFString stringWithCString: entity
						      andLength: len];
							 length: len];
				tmp = [h foundUnknownEntityNamed: n];

				if (tmp == nil)
					@throw [OFInvalidEncodingException
					    newWithClass: isa];

				[ret appendString: tmp];
471
472
473
474
475
476
477
478

479
480
481
482
471
472
473
474
475
476
477

478
479
480
481
482







-
+




		}
	}

	if (in_entity)
		@throw [OFInvalidEncodingException newWithClass: isa];

	[ret appendCStringWithoutUTF8Checking: string + last
				    andLength: i - last];
				       length: i - last];

	return ret;
}
@end