const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ state->handler = prolog1;
+ return XML_ROLE_NONE;
+ case XML_TOK_XML_DECL:
+ state->handler = prolog1;
+ return XML_ROLE_XML_DECL;
case XML_TOK_PI:
state->handler = prolog1;
- if (XmlNameMatchesAscii(enc, ptr + 2 * enc->minBytesPerChar, "xml"))
- return XML_ROLE_XML_DECL;
return XML_ROLE_NONE;
case XML_TOK_COMMENT:
state->handler = prolog1;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_PI:
- if (XmlNameMatchesAscii(enc, ptr + 2 * enc->minBytesPerChar, "xml"))
- return syntaxError(state);
case XML_TOK_COMMENT:
case XML_TOK_BOM:
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_PI:
- if (XmlNameMatchesAscii(enc, ptr + 2 * enc->minBytesPerChar, "xml"))
- return syntaxError(state);
case XML_TOK_COMMENT:
return XML_ROLE_NONE;
case XML_TOK_INSTANCE_START:
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = doctype1;
return XML_ROLE_DOCTYPE_NAME;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_OPEN_BRACKET:
state->handler = internalSubset;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = doctype3;
return XML_ROLE_DOCTYPE_PUBLIC_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = doctype4;
return XML_ROLE_DOCTYPE_SYSTEM_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_OPEN_BRACKET:
state->handler = internalSubset;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = prolog2;
return XML_ROLE_DOCTYPE_CLOSE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_DECL_OPEN:
if (XmlNameMatchesAscii(enc,
ptr + 2 * enc->minBytesPerChar,
}
break;
case XML_TOK_PI:
- if (XmlNameMatchesAscii(enc, ptr + 2 * enc->minBytesPerChar, "xml"))
- return syntaxError(state);
case XML_TOK_COMMENT:
case XML_TOK_PARAM_ENTITY_REF:
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_PERCENT:
state->handler = entity1;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = entity7;
return XML_ROLE_PARAM_ENTITY_NAME;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
state->handler = entity4;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = entity4;
return XML_ROLE_ENTITY_PUBLIC_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = entity5;
return XML_ROLE_ENTITY_SYSTEM_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = declClose;
return XML_ROLE_ENTITY_NOTATION_NAME;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
state->handler = entity9;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = entity9;
return XML_ROLE_ENTITY_PUBLIC_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = declClose;
return XML_ROLE_ENTITY_SYSTEM_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = notation1;
return XML_ROLE_NOTATION_NAME;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
state->handler = notation3;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = notation4;
return XML_ROLE_NOTATION_PUBLIC_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = declClose;
return XML_ROLE_NOTATION_SYSTEM_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = declClose;
return XML_ROLE_NOTATION_SYSTEM_ID;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = attlist1;
return XML_ROLE_ATTLIST_ELEMENT_NAME;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
{
static const char *types[] = {
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NMTOKEN:
case XML_TOK_NAME:
state->handler = attlist4;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_CLOSE_PAREN:
state->handler = attlist8;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_OPEN_PAREN:
state->handler = attlist6;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = attlist7;
return XML_ROLE_ATTRIBUTE_NOTATION_VALUE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_CLOSE_PAREN:
state->handler = attlist8;
return XML_ROLE_NONE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_POUND_NAME:
if (XmlNameMatchesAscii(enc,
ptr + enc->minBytesPerChar,
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_LITERAL:
state->handler = attlist1;
return XML_ROLE_FIXED_ATTRIBUTE_VALUE;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = element1;
return XML_ROLE_ELEMENT_NAME;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
if (XmlNameMatchesAscii(enc, ptr, "EMPTY")) {
state->handler = declClose;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_POUND_NAME:
if (XmlNameMatchesAscii(enc,
ptr + enc->minBytesPerChar,
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_CLOSE_PAREN:
case XML_TOK_CLOSE_PAREN_ASTERISK:
state->handler = declClose;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_NAME:
state->handler = element5;
return XML_ROLE_CONTENT_ELEMENT;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_CLOSE_PAREN_ASTERISK:
state->handler = declClose;
return XML_ROLE_GROUP_CLOSE_REP;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_OPEN_PAREN:
state->level += 1;
return XML_ROLE_GROUP_OPEN;
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_CLOSE_PAREN:
state->level -= 1;
if (state->level == 0)
const ENCODING *enc)
{
switch (tok) {
+ case XML_TOK_PROLOG_S:
+ return XML_ROLE_NONE;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
return XML_ROLE_NONE;
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
#define XML_TOK_PI 11 /* processing instruction */
-#define XML_TOK_COMMENT 12
-#define XML_TOK_BOM 13 /* Byte order mark */
+#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
+#define XML_TOK_COMMENT 13
+#define XML_TOK_BOM 14 /* Byte order mark */
/* The following tokens are returned only by XmlPrologTok */
-#define XML_TOK_INSTANCE_START 14
#define XML_TOK_PROLOG_S 15
#define XML_TOK_DECL_OPEN 16 /* <!foo */
#define XML_TOK_DECL_CLOSE 17 /* > */
#define XML_TOK_CLOSE_BRACKET 26
#define XML_TOK_LITERAL 27
#define XML_TOK_PARAM_ENTITY_REF 28
+#define XML_TOK_INSTANCE_START 29
/* The following occur only in element type declarations */
-#define XML_TOK_COMMA 29
#define XML_TOK_NAME_QUESTION 30 /* name? */
#define XML_TOK_NAME_ASTERISK 31 /* name* */
#define XML_TOK_NAME_PLUS 32 /* name+ */
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
-
+#define XML_TOK_COMMA 38
#define XML_N_STATES 2
#define XML_PROLOG_STATE 0
return XML_TOK_PARTIAL;
}
+static
+int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr)
+{
+ int upper = 0;
+ if (end - ptr != MINBPC*3)
+ return 1;
+ switch (BYTE_TO_ASCII(enc, ptr)) {
+ case 'x':
+ break;
+ case 'X':
+ upper = 1;
+ break;
+ default:
+ return 1;
+ }
+ ptr += MINBPC;
+ switch (BYTE_TO_ASCII(enc, ptr)) {
+ case 'm':
+ break;
+ case 'M':
+ upper = 1;
+ break;
+ default:
+ return 1;
+ }
+ ptr += MINBPC;
+ switch (BYTE_TO_ASCII(enc, ptr)) {
+ case 'l':
+ break;
+ case 'L':
+ upper = 1;
+ break;
+ default:
+ return 1;
+ }
+ if (upper)
+ return 0;
+ *tokPtr = XML_TOK_XML_DECL;
+ return 1;
+}
+
/* ptr points to character following "<?" */
static
int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
+ int tok;
+ const char *target = ptr;
if (ptr == end)
return XML_TOK_PARTIAL;
switch (BYTE_TYPE(enc, ptr)) {
switch (BYTE_TYPE(enc, ptr)) {
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_S: case BT_CR: case BT_LF:
+ if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
+ }
ptr += MINBPC;
while (ptr != end) {
switch (BYTE_TYPE(enc, ptr)) {
return XML_TOK_PARTIAL;
if (CHAR_MATCHES(enc, ptr, '>')) {
*nextTokPtr = ptr + MINBPC;
- return XML_TOK_PI;
+ return tok;
}
break;
default:
}
return XML_TOK_PARTIAL;
case BT_QUEST:
+ if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
+ }
ptr += MINBPC;
if (ptr == end)
return XML_TOK_PARTIAL;
if (CHAR_MATCHES(enc, ptr, '>')) {
*nextTokPtr = ptr + MINBPC;
- return XML_TOK_PI;
+ return tok;
}
/* fall through */
default:
return badCharRef;
}
break;
- case XML_TOK_PI:
- if (XmlNameMatchesAscii(enc, s + 2 * enc->minBytesPerChar, "xml")) {
- *badPtr = s;
- return misplacedXmlPi;
- }
- break;
+ case XML_TOK_XML_DECL:
+ *badPtr = s;
+ return misplacedXmlPi;
}
s = next;
if (level == 0) {
for (;;) {
const char *next;
int tok = XmlPrologTok(*enc, s, end, &next);
- if (tok != XML_TOK_PROLOG_S) {
- switch (XmlTokenRole(&state, tok, s, next, *enc)) {
- case XML_ROLE_XML_DECL:
- {
- const char *encodingName = 0;
- const ENCODING *encoding = 0;
- const char *version;
- int standalone = -1;
- if (!XmlParseXmlDecl(0,
- *enc,
- s,
- next,
- nextPtr,
- &version,
- &encodingName,
- &encoding,
- &standalone))
- return syntaxError;
- if (encoding) {
- if (encoding->minBytesPerChar != (*enc)->minBytesPerChar) {
- *nextPtr = encodingName;
- return incorrectEncoding;
- }
- *enc = encoding;
- }
- else if (encodingName) {
- *nextPtr = encodingName;
- return unknownEncoding;
- }
- if (standalone == 1)
- dtd->standalone = 1;
- break;
- }
- case XML_ROLE_DOCTYPE_SYSTEM_ID:
- dtd->containsRef = 1;
- break;
- case XML_ROLE_DOCTYPE_PUBLIC_ID:
- case XML_ROLE_ENTITY_PUBLIC_ID:
- case XML_ROLE_NOTATION_PUBLIC_ID:
- if (!XmlIsPublicId(*enc, s, next, nextPtr))
+ switch (XmlTokenRole(&state, tok, s, next, *enc)) {
+ case XML_ROLE_XML_DECL:
+ {
+ const char *encodingName = 0;
+ const ENCODING *encoding = 0;
+ const char *version;
+ int standalone = -1;
+ if (!XmlParseXmlDecl(0,
+ *enc,
+ s,
+ next,
+ nextPtr,
+ &version,
+ &encodingName,
+ &encoding,
+ &standalone))
return syntaxError;
- break;
- case XML_ROLE_INSTANCE_START:
- *nextPtr = s;
- return wellFormed;
- case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
- case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
- {
- const char *tem = 0;
- enum WfCheckResult result
- = checkAttributeValue(dtd, *enc, s + (*enc)->minBytesPerChar,
- next - (*enc)->minBytesPerChar,
- &tem);
- if (result) {
- if (tem)
- *nextPtr = tem;
- return result;
+ if (encoding) {
+ if (encoding->minBytesPerChar != (*enc)->minBytesPerChar) {
+ *nextPtr = encodingName;
+ return incorrectEncoding;
}
- break;
+ *enc = encoding;
}
- case XML_ROLE_ENTITY_VALUE:
- {
- enum WfCheckResult result
- = storeEntity(dtd,
- *enc,
- entityNamePtr,
- entityNameEnd,
- s,
- next,
- nextPtr);
- if (result != wellFormed)
- return result;
+ else if (encodingName) {
+ *nextPtr = encodingName;
+ return unknownEncoding;
}
+ if (standalone == 1)
+ dtd->standalone = 1;
break;
- case XML_ROLE_ENTITY_SYSTEM_ID:
- if (entityNamePtr) {
- const char *name = poolStoreString(&dtd->pool, *enc, entityNamePtr, entityNameEnd);
- entity = (ENTITY *)lookup(&dtd->generalEntities, name, sizeof(ENTITY));
- if (entity->name != name) {
- poolDiscard(&dtd->pool);
- entity = 0;
- }
- else {
- poolFinish(&dtd->pool);
- entity->systemId = poolStoreString(&dtd->pool, *enc,
- s + (*enc)->minBytesPerChar,
- next - (*enc)->minBytesPerChar);
- poolFinish(&dtd->pool);
- }
+ }
+ case XML_ROLE_DOCTYPE_SYSTEM_ID:
+ dtd->containsRef = 1;
+ break;
+ case XML_ROLE_DOCTYPE_PUBLIC_ID:
+ case XML_ROLE_ENTITY_PUBLIC_ID:
+ case XML_ROLE_NOTATION_PUBLIC_ID:
+ if (!XmlIsPublicId(*enc, s, next, nextPtr))
+ return syntaxError;
+ break;
+ case XML_ROLE_INSTANCE_START:
+ *nextPtr = s;
+ return wellFormed;
+ case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
+ case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
+ {
+ const char *tem = 0;
+ enum WfCheckResult result
+ = checkAttributeValue(dtd, *enc, s + (*enc)->minBytesPerChar,
+ next - (*enc)->minBytesPerChar,
+ &tem);
+ if (result) {
+ if (tem)
+ *nextPtr = tem;
+ return result;
}
break;
- case XML_ROLE_ENTITY_NOTATION_NAME:
- if (entity) {
- entity->notation = poolStoreString(&dtd->pool, *enc, s, next);
+ }
+ case XML_ROLE_ENTITY_VALUE:
+ {
+ enum WfCheckResult result
+ = storeEntity(dtd,
+ *enc,
+ entityNamePtr,
+ entityNameEnd,
+ s,
+ next,
+ nextPtr);
+ if (result != wellFormed)
+ return result;
+ }
+ break;
+ case XML_ROLE_ENTITY_SYSTEM_ID:
+ if (entityNamePtr) {
+ const char *name = poolStoreString(&dtd->pool, *enc, entityNamePtr, entityNameEnd);
+ entity = (ENTITY *)lookup(&dtd->generalEntities, name, sizeof(ENTITY));
+ if (entity->name != name) {
+ poolDiscard(&dtd->pool);
+ entity = 0;
+ }
+ else {
+ poolFinish(&dtd->pool);
+ entity->systemId = poolStoreString(&dtd->pool, *enc,
+ s + (*enc)->minBytesPerChar,
+ next - (*enc)->minBytesPerChar);
poolFinish(&dtd->pool);
}
- break;
- case XML_ROLE_GENERAL_ENTITY_NAME:
- entityNamePtr = s;
- entityNameEnd = next;
- break;
- case XML_ROLE_PARAM_ENTITY_NAME:
- entityNamePtr = 0;
- entityNameEnd = 0;
- break;
- case XML_ROLE_ERROR:
+ }
+ break;
+ case XML_ROLE_ENTITY_NOTATION_NAME:
+ if (entity) {
+ entity->notation = poolStoreString(&dtd->pool, *enc, s, next);
+ poolFinish(&dtd->pool);
+ }
+ break;
+ case XML_ROLE_GENERAL_ENTITY_NAME:
+ entityNamePtr = s;
+ entityNameEnd = next;
+ break;
+ case XML_ROLE_PARAM_ENTITY_NAME:
+ entityNamePtr = 0;
+ entityNameEnd = 0;
+ break;
+ case XML_ROLE_ERROR:
+ *nextPtr = s;
+ switch (tok) {
+ case XML_TOK_COND_SECT_OPEN:
+ return condSect;
+ case XML_TOK_PARAM_ENTITY_REF:
+ return paramEntityRef;
+ case XML_TOK_INVALID:
+ *nextPtr = next;
+ return invalidToken;
+ case XML_TOK_NONE:
+ return noElements;
+ case XML_TOK_PARTIAL:
+ return unclosedToken;
+ case XML_TOK_PARTIAL_CHAR:
+ return partialChar;
+ case XML_TOK_TRAILING_CR:
+ *nextPtr = s + (*enc)->minBytesPerChar;
+ return noElements;
+ case XML_TOK_XML_DECL:
+ return misplacedXmlPi;
+ default:
+ return syntaxError;
+ }
+ case XML_ROLE_GROUP_OPEN:
+ if (state.level >= dtd->groupSize) {
+ if (dtd->groupSize)
+ dtd->groupConnector = realloc(dtd->groupConnector, dtd->groupSize *= 2);
+ else
+ dtd->groupConnector = malloc(dtd->groupSize = 32);
+ if (!dtd->groupConnector)
+ return noMemory;
+ }
+ dtd->groupConnector[state.level] = 0;
+ break;
+ case XML_ROLE_GROUP_SEQUENCE:
+ if (dtd->groupConnector[state.level] == '|') {
*nextPtr = s;
- switch (tok) {
- case XML_TOK_COND_SECT_OPEN:
- return condSect;
- case XML_TOK_PARAM_ENTITY_REF:
- return paramEntityRef;
- case XML_TOK_INVALID:
- *nextPtr = next;
- return invalidToken;
- case XML_TOK_NONE:
- return noElements;
- case XML_TOK_PARTIAL:
- return unclosedToken;
- case XML_TOK_PARTIAL_CHAR:
- return partialChar;
- case XML_TOK_TRAILING_CR:
- *nextPtr = s + (*enc)->minBytesPerChar;
- return noElements;
- case XML_TOK_PI:
- if (XmlNameMatchesAscii(*enc, s + 2 * (*enc)->minBytesPerChar, "xml"))
- return misplacedXmlPi;
- default:
- return syntaxError;
- }
- case XML_ROLE_GROUP_OPEN:
- if (state.level >= dtd->groupSize) {
- if (dtd->groupSize)
- dtd->groupConnector = realloc(dtd->groupConnector, dtd->groupSize *= 2);
- else
- dtd->groupConnector = malloc(dtd->groupSize = 32);
- if (!dtd->groupConnector)
- return noMemory;
- }
- dtd->groupConnector[state.level] = 0;
- break;
- case XML_ROLE_GROUP_SEQUENCE:
- if (dtd->groupConnector[state.level] == '|') {
- *nextPtr = s;
- return syntaxError;
- }
- dtd->groupConnector[state.level] = ',';
- break;
- case XML_ROLE_GROUP_CHOICE:
- if (dtd->groupConnector[state.level] == ',') {
- *nextPtr = s;
- return syntaxError;
- }
- dtd->groupConnector[state.level] = '|';
- break;
- case XML_ROLE_NONE:
- if (tok == XML_TOK_PARAM_ENTITY_REF)
- dtd->containsRef = 1;
- break;
+ return syntaxError;
+ }
+ dtd->groupConnector[state.level] = ',';
+ break;
+ case XML_ROLE_GROUP_CHOICE:
+ if (dtd->groupConnector[state.level] == ',') {
+ *nextPtr = s;
+ return syntaxError;
}
+ dtd->groupConnector[state.level] = '|';
+ break;
+ case XML_ROLE_NONE:
+ if (tok == XML_TOK_PARAM_ENTITY_REF)
+ dtd->containsRef = 1;
+ break;
}
s = next;
}
s = next;
tok = XmlContentTok(*enc, s, end, &next);
}
- if (tok == XML_TOK_PI
- && XmlNameMatchesAscii(*enc, s + 2 * (*enc)->minBytesPerChar, "xml")) {
+ if (tok == XML_TOK_XML_DECL) {
const char *encodingName = 0;
const ENCODING *encoding = 0;
const char *version;