ObjFW  Diff

Differences From Artifact [aa41ccd975]:

To Artifact [d8c5285da7]:


76
77
78
79
80
81
82

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

	[attr->ns release];
	attr->ns = [attr_ns retain];
}

@implementation OFXMLParser
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)

@synthesize elementStartHandler, elementEndHandler, charactersHandler;
@synthesize CDATAHandler, commentHandler, unknownEntityHandler;
#endif

+ (void)initialize
{
	size_t i;

	const SEL sels[] = {
		@selector(_parseOutsideTagWithBuffer:i:last:),
		@selector(_parseTagOpenedWithBuffer:i:last:),
		@selector(_parseInPrologWithBuffer:i:last:),
		@selector(_parseInTagNameWithBuffer:i:last:),
		@selector(_parseInCloseTagNameWithBuffer:i:last:),
		@selector(_parseInTagWithBuffer:i:last:),
		@selector(_parseInAttributeNameWithBuffer:i:last:),
		@selector(_parseExpectDelimiterWithBuffer:i:last:),
		@selector(_parseInAttributeValueWithBuffer:i:last:),
		@selector(_parseExpectCloseWithBuffer:i:last:),







>
|
|









|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

	[attr->ns release];
	attr->ns = [attr_ns retain];
}

@implementation OFXMLParser
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
@synthesize processingInstructionsHandler, elementStartHandler;
@synthesize elementEndHandler, charactersHandler, CDATAHandler, commentHandler;
@synthesize unknownEntityHandler;
#endif

+ (void)initialize
{
	size_t i;

	const SEL sels[] = {
		@selector(_parseOutsideTagWithBuffer:i:last:),
		@selector(_parseTagOpenedWithBuffer:i:last:),
		@selector(_parseInProcessingInstructionsWithBuffer:i:last:),
		@selector(_parseInTagNameWithBuffer:i:last:),
		@selector(_parseInCloseTagNameWithBuffer:i:last:),
		@selector(_parseInTagWithBuffer:i:last:),
		@selector(_parseInAttributeNameWithBuffer:i:last:),
		@selector(_parseExpectDelimiterWithBuffer:i:last:),
		@selector(_parseInAttributeValueWithBuffer:i:last:),
		@selector(_parseExpectCloseWithBuffer:i:last:),
281
282
283
284
285
286
287
288

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309






310




311


312








313


314
315
316
317
318
319
320
- (void)_parseTagOpenedWithBuffer: (const char*)buf
				i: (size_t*)i
			     last: (size_t*)last
{
	switch (buf[*i]) {
		case '?':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_PROLOG;

			break;
		case '/':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
			break;
		case '!':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
			break;
		default:
			state = OF_XMLPARSER_IN_TAG_NAME;
			(*i)--;
			break;
	}
}

/* Inside prolog */
- (void)_parseInPrologWithBuffer: (const char*)buf
			       i: (size_t*)i
			    last: (size_t*)last
{






	*last = *i + 1;







	if (buf[*i] == '?')








		state = OF_XMLPARSER_EXPECT_CLOSE;


}

/* Inside a tag, no name yet */
- (void)_parseInTagNameWithBuffer: (const char*)buf
				i: (size_t*)i
			     last: (size_t*)last
{







|
>

















|
|
|

>
>
>
>
>
>
|
>
>
>
>

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







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
- (void)_parseTagOpenedWithBuffer: (const char*)buf
				i: (size_t*)i
			     last: (size_t*)last
{
	switch (buf[*i]) {
		case '?':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS;
			level = 0;
			break;
		case '/':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_CLOSE_TAG_NAME;
			break;
		case '!':
			*last = *i + 1;
			state = OF_XMLPARSER_IN_EXCLAMATIONMARK;
			break;
		default:
			state = OF_XMLPARSER_IN_TAG_NAME;
			(*i)--;
			break;
	}
}

/* Inside prolog */
- (void)_parseInProcessingInstructionsWithBuffer: (const char*)buf
					       i: (size_t*)i
					    last: (size_t*)last
{
	if (buf[*i] == '?')
		level = 1;
	else if (level == 1 && buf[*i] == '>') {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFMutableString *pi;
		size_t len;

		[cache appendCStringWithoutUTF8Checking: buf + *last
						 length: *i - *last];
		pi = [[cache mutableCopy] autorelease];
		len = [pi length];

		[pi removeCharactersFromIndex: len - 1
				      toIndex: len];

		[delegate parser: self
		    foundProcessingInstructions: pi];

		[pool release];

		[cache setToCString: ""];

		*last = *i + 1;
		state = OF_XMLPARSER_OUTSIDE_TAG;
	} else
		level = 0;
}

/* Inside a tag, no name yet */
- (void)_parseInTagNameWithBuffer: (const char*)buf
				i: (size_t*)i
			     last: (size_t*)last
{
855
856
857
858
859
860
861





862
863
864
865
866
867
868

	return [delegate parser: self
	foundUnknownEntityNamed: entity];
}
@end

@implementation OFObject (OFXMLParserDelegate)





-    (void)parser: (OFXMLParser*)parser
  didStartElement: (OFString*)name
       withPrefix: (OFString*)prefix
	namespace: (OFString*)ns
       attributes: (OFArray*)attrs
{
}







>
>
>
>
>







879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897

	return [delegate parser: self
	foundUnknownEntityNamed: entity];
}
@end

@implementation OFObject (OFXMLParserDelegate)
-		 (void)parser: (OFXMLParser*)parser
  foundProcessingInstructions: (OFString*)pi
{
}

-    (void)parser: (OFXMLParser*)parser
  didStartElement: (OFString*)name
       withPrefix: (OFString*)prefix
	namespace: (OFString*)ns
       attributes: (OFArray*)attrs
{
}