text stringlengths 0 357 |
|---|
{ |
/* skip <!DOCTYPE ...> or <!DOCTYPE name [ ... ]> |
**************************************************************/ |
while (*p && *p != '[' && *p != '>' ) p++; /* search for [ or >, whatever comes first */ |
if (*p==0) { |
goto cleanup; /* unclosed doctype */ |
} |
else if (*p=='[') { |
p = strstr(p, "]>"); /* search end of inline doctype */ |
if (p==NULL) { |
goto cleanup; /* unclosed inline doctype */ |
} |
else { |
p += 2; |
} |
} |
else { |
p++; |
} |
} |
else if (*p=='?') |
{ |
/* skip <? ... ?> processing instruction |
**************************************************************/ |
p = strstr(p, "?>"); |
if (p==NULL) { goto cleanup; } /* unclosed processing instruction */ |
p += 2; |
} |
else |
{ |
p += strspn(p, XML_WS); /* skip whitespace between `<` and tagname */ |
if (*p=='/') |
{ |
/* process </tag> end tag |
**************************************************************/ |
p++; |
p += strspn(p, XML_WS); /* skip whitespace between `/` and tagname */ |
char* beg_tag_name = p; |
p += strcspn(p, XML_WS "/>"); /* find character after tagname */ |
if (p != beg_tag_name) |
{ |
bak = *p; |
*p = '\0'; /* null-terminate tag name temporary, eg. a covered `>` may get important downwards */ |
dc_strlower_in_place(beg_tag_name); |
saxparser->endtag_cb(saxparser->userdata, beg_tag_name); |
*p = bak; |
} |
} |
else |
{ |
/* process <tag attr1="val" attr2='val' attr3=val ..> |
**************************************************************/ |
do_free_attr(attr, free_attr); |
char* beg_tag_name = p; |
p += strcspn(p, XML_WS "/>"); /* find character after tagname */ |
if (p != beg_tag_name) |
{ |
char* after_tag_name = p; |
/* scan for attributes */ |
int attr_index = 0; |
while (isspace(*p)) { p++; } /* forward to first attribute name beginning */ |
while (*p && *p!='/' && *p!='>') |
{ |
char *beg_attr_name = p, *beg_attr_value = NULL, *beg_attr_value_new = NULL; |
if ('='==*beg_attr_name) { |
p++; // otherwise eg. `"val"=` causes a deadlock as the second `=` is no exit condition and is not skipped by strcspn() |
continue; |
} |
p += strcspn(p, XML_WS "=/>"); /* get end of attribute name */ |
if (p != beg_attr_name) |
{ |
/* attribute found */ |
char* after_attr_name = p; |
p += strspn(p, XML_WS); /* skip whitespace between attribute name and possible `=` */ |
if (*p=='=') |
{ |
p += strspn(p, XML_WS "="); /* skip spaces and equal signs */ |
char quote = *p; |
if (quote=='"' || quote=='\'') |
{ |
/* quoted attribute value */ |
p++; |
beg_attr_value = p; |
while (*p && *p != quote) { p++; } |
if (*p) { |
*p = '\0'; /* null terminate attribute val */ |
p++; |
} |
beg_attr_value_new = xml_decode(beg_attr_value, ' '); |
} |
else |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.