| ︙ | | | ︙ | |
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
switch (state) {
/* Not in a tag */
case OF_XMLPARSER_OUTSIDE_TAG:
if (buf[i] == '<') {
len = i - last;
if (len > 0)
[cache appendCString: buf + last
withLength: len];
if ([cache cStringLength] > 0) {
OFString *str;
pool = [[OFAutoreleasePool alloc] init];
str = transform_string(cache, self);
[delegate xmlParser: self
|
|
>
|
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
switch (state) {
/* Not in a tag */
case OF_XMLPARSER_OUTSIDE_TAG:
if (buf[i] == '<') {
len = i - last;
if (len > 0)
[cache appendCStringWithoutUTF8Checking:
buf + last
length: len];
if ([cache cStringLength] > 0) {
OFString *str;
pool = [[OFAutoreleasePool alloc] init];
str = transform_string(cache, self);
[delegate xmlParser: self
|
| ︙ | | | ︙ | |
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
if (buf[i] == ' ' || buf[i] == '\n' || buf[i] == '\r' ||
buf[i] == '>' || buf[i] == '/') {
const char *cache_c, *tmp;
size_t cache_len;
len = i - last;
if (len > 0)
[cache appendCString: buf + last
withLength: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL) {
name = [[OFString alloc]
initWithCString: tmp + 1
|
|
>
|
|
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
if (buf[i] == ' ' || buf[i] == '\n' || buf[i] == '\r' ||
buf[i] == '>' || buf[i] == '/') {
const char *cache_c, *tmp;
size_t cache_len;
len = i - last;
if (len > 0)
[cache appendCStringWithoutUTF8Checking:
buf + last
length: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL) {
name = [[OFString alloc]
initWithCString: tmp + 1
|
| ︙ | | | ︙ | |
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
buf[i] == '>') {
const char *cache_c, *tmp;
size_t cache_len;
OFString *ns;
len = i - last;
if (len > 0)
[cache appendCString: buf + last
withLength: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL) {
name = [[OFString alloc]
initWithCString: tmp + 1
|
|
>
|
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
buf[i] == '>') {
const char *cache_c, *tmp;
size_t cache_len;
OFString *ns;
len = i - last;
if (len > 0)
[cache appendCStringWithoutUTF8Checking:
buf + last
length: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL) {
name = [[OFString alloc]
initWithCString: tmp + 1
|
| ︙ | | | ︙ | |
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
case OF_XMLPARSER_IN_ATTR_NAME:
if (buf[i] == '=') {
const char *cache_c, *tmp;
size_t cache_len;
len = i - last;
if (len > 0)
[cache appendCString: buf + last
withLength: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL ) {
attrName = [[OFString alloc]
|
|
>
|
|
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
case OF_XMLPARSER_IN_ATTR_NAME:
if (buf[i] == '=') {
const char *cache_c, *tmp;
size_t cache_len;
len = i - last;
if (len > 0)
[cache appendCStringWithoutUTF8Checking:
buf + last
length: len];
cache_c = [cache cString];
cache_len = [cache cStringLength];
if ((tmp = memchr(cache_c, ':',
cache_len)) != NULL ) {
attrName = [[OFString alloc]
|
| ︙ | | | ︙ | |
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
|
case OF_XMLPARSER_IN_ATTR_VALUE:
if (buf[i] == delim) {
OFString *attr_ns;
OFString *attr_val;
len = i - last;
if (len > 0)
[cache appendCString: buf + last
withLength: len];
pool = [[OFAutoreleasePool alloc] init];
attr_ns = namespace_for_prefix(
(attrPrefix != nil ? attrPrefix : prefix),
namespaces);
attr_val = transform_string(cache, self);
|
|
>
|
|
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
case OF_XMLPARSER_IN_ATTR_VALUE:
if (buf[i] == delim) {
OFString *attr_ns;
OFString *attr_val;
len = i - last;
if (len > 0)
[cache appendCStringWithoutUTF8Checking:
buf + last
length: len];
pool = [[OFAutoreleasePool alloc] init];
attr_ns = namespace_for_prefix(
(attrPrefix != nil ? attrPrefix : prefix),
namespaces);
attr_val = transform_string(cache, self);
|
| ︙ | | | ︙ | |
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
break;
case OF_XMLPARSER_IN_COMMENT_3:
if (buf[i] == '-')
state = OF_XMLPARSER_IN_COMMENT_4;
break;
case OF_XMLPARSER_IN_COMMENT_4:
if (buf[i] == '-') {
size_t cache_len;
[cache appendCString: buf + last
withLength: i - last];
cache_len = [cache length];
pool = [[OFAutoreleasePool alloc] init];
[cache removeCharactersFromIndex: cache_len - 1
toIndex: cache_len];
[cache removeLeadingAndTrailingWhitespaces];
[delegate xmlParser: self
foundComment: cache];
[pool release];
[cache setToCString: ""];
last = i + 1;
state = OF_XMLPARSER_EXPECT_CLOSE;
} else
state = OF_XMLPARSER_IN_COMMENT_3;
break;
}
}
len = size - last;
/* In OF_XMLPARSER_IN_TAG, there can be only spaces */
if (len > 0 && state != OF_XMLPARSER_IN_TAG)
[cache appendCString: buf + last
withLength: len];
}
- (OFString*)foundUnknownEntityNamed: (OFString*)entity
{
return [delegate xmlParser: self
foundUnknownEntityNamed: entity];
}
|
>
|
>
>
|
>
|
|
>
>
<
|
|
|
|
|
|
|
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
break;
case OF_XMLPARSER_IN_COMMENT_3:
if (buf[i] == '-')
state = OF_XMLPARSER_IN_COMMENT_4;
break;
case OF_XMLPARSER_IN_COMMENT_4:
if (buf[i] == '-') {
OFMutableString *comment;
size_t len;
pool = [[OFAutoreleasePool alloc] init];
[cache
appendCStringWithoutUTF8Checking: buf + last
length: i - last];
comment = [[cache mutableCopy] autorelease];
len = [comment length];
[comment removeCharactersFromIndex: len - 1
toIndex: len];
[comment removeLeadingAndTrailingWhitespaces];
[delegate xmlParser: self
foundComment: comment];
[pool release];
[cache setToCString: ""];
last = i + 1;
state = OF_XMLPARSER_EXPECT_CLOSE;
} else
state = OF_XMLPARSER_IN_COMMENT_3;
break;
}
}
len = size - last;
/* In OF_XMLPARSER_IN_TAG, there can be only spaces */
if (len > 0 && state != OF_XMLPARSER_IN_TAG)
[cache appendCStringWithoutUTF8Checking: buf + last
length: len];
}
- (OFString*)foundUnknownEntityNamed: (OFString*)entity
{
return [delegate xmlParser: self
foundUnknownEntityNamed: entity];
}
|
| ︙ | | | ︙ | |