Update to the final version released as Expat 1.95.6 (maintaining
Martin's integration changes).
This commit is contained in:
parent
d97da80dd5
commit
4faea015f7
|
@ -309,8 +309,8 @@ doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr,
|
||||||
#endif /* XML_DTD */
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
static enum XML_Error
|
static enum XML_Error
|
||||||
storeAtts(XML_Parser parser, const ENCODING *,
|
storeAtts(XML_Parser parser, const ENCODING *, const char *s,
|
||||||
const char *s, TAG_NAME *tagNamePtr, BINDING **bindingsPtr);
|
TAG_NAME *tagNamePtr, BINDING **bindingsPtr);
|
||||||
static enum XML_Error
|
static enum XML_Error
|
||||||
addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
|
||||||
const XML_Char *uri, BINDING **bindingsPtr);
|
const XML_Char *uri, BINDING **bindingsPtr);
|
||||||
|
@ -2097,11 +2097,6 @@ doContent(XML_Parser parser,
|
||||||
}
|
}
|
||||||
tag->name.str = (XML_Char *)tag->buf;
|
tag->name.str = (XML_Char *)tag->buf;
|
||||||
*toPtr = XML_T('\0');
|
*toPtr = XML_T('\0');
|
||||||
if (!startElementHandler && (tok == XML_TOK_START_TAG_NO_ATTS)) {
|
|
||||||
if (defaultHandler)
|
|
||||||
reportDefault(parser, enc, s, next);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
|
result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
@ -2114,13 +2109,6 @@ doContent(XML_Parser parser,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
|
case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
|
||||||
if (!startElementHandler && !endElementHandler) {
|
|
||||||
if (defaultHandler)
|
|
||||||
reportDefault(parser, enc, s, next);
|
|
||||||
if (tagLevel == 0)
|
|
||||||
return epilogProcessor(parser, next, end, nextPtr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
|
case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
|
||||||
{
|
{
|
||||||
|
@ -2134,13 +2122,10 @@ doContent(XML_Parser parser,
|
||||||
if (!name.str)
|
if (!name.str)
|
||||||
return XML_ERROR_NO_MEMORY;
|
return XML_ERROR_NO_MEMORY;
|
||||||
poolFinish(&tempPool);
|
poolFinish(&tempPool);
|
||||||
if (startElementHandler ||
|
result = storeAtts(parser, enc, s, &name, &bindings);
|
||||||
(tok == XML_TOK_EMPTY_ELEMENT_WITH_ATTS)) {
|
if (result)
|
||||||
result = storeAtts(parser, enc, s, &name, &bindings);
|
return result;
|
||||||
if (result)
|
poolFinish(&tempPool);
|
||||||
return result;
|
|
||||||
poolFinish(&tempPool);
|
|
||||||
}
|
|
||||||
if (startElementHandler) {
|
if (startElementHandler) {
|
||||||
startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
|
startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
|
||||||
noElmHandlers = XML_FALSE;
|
noElmHandlers = XML_FALSE;
|
||||||
|
@ -2343,8 +2328,15 @@ doContent(XML_Parser parser,
|
||||||
/* not reached */
|
/* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If tagNamePtr is non-null, build a real list of attributes,
|
/* Precondition: all arguments must be non-NULL;
|
||||||
otherwise just check the attributes for well-formedness.
|
Purpose:
|
||||||
|
- normalize attributes
|
||||||
|
- check attributes for well-formedness
|
||||||
|
- generate namespace aware attribute names (URI, prefix)
|
||||||
|
- build list of attributes for startElementHandler
|
||||||
|
- default attributes
|
||||||
|
- process namespace declarations (check and report them)
|
||||||
|
- generate namespace aware element name (URI, prefix)
|
||||||
*/
|
*/
|
||||||
static enum XML_Error
|
static enum XML_Error
|
||||||
storeAtts(XML_Parser parser, const ENCODING *enc,
|
storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
|
@ -2365,21 +2357,20 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
const XML_Char *localPart;
|
const XML_Char *localPart;
|
||||||
|
|
||||||
/* lookup the element type name */
|
/* lookup the element type name */
|
||||||
if (tagNamePtr) {
|
elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0);
|
||||||
elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0);
|
if (!elementType) {
|
||||||
if (!elementType) {
|
const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str);
|
||||||
const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str);
|
if (!name)
|
||||||
if (!name)
|
return XML_ERROR_NO_MEMORY;
|
||||||
return XML_ERROR_NO_MEMORY;
|
elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name,
|
||||||
elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name,
|
sizeof(ELEMENT_TYPE));
|
||||||
sizeof(ELEMENT_TYPE));
|
if (!elementType)
|
||||||
if (!elementType)
|
return XML_ERROR_NO_MEMORY;
|
||||||
return XML_ERROR_NO_MEMORY;
|
if (ns && !setElementTypePrefix(parser, elementType))
|
||||||
if (ns && !setElementTypePrefix(parser, elementType))
|
return XML_ERROR_NO_MEMORY;
|
||||||
return XML_ERROR_NO_MEMORY;
|
|
||||||
}
|
|
||||||
nDefaultAtts = elementType->nDefaultAtts;
|
|
||||||
}
|
}
|
||||||
|
nDefaultAtts = elementType->nDefaultAtts;
|
||||||
|
|
||||||
/* get the attributes from the tokenizer */
|
/* get the attributes from the tokenizer */
|
||||||
n = XmlGetAttributes(enc, attStr, attsSize, atts);
|
n = XmlGetAttributes(enc, attStr, attsSize, atts);
|
||||||
if (n + nDefaultAtts > attsSize) {
|
if (n + nDefaultAtts > attsSize) {
|
||||||
|
@ -2393,6 +2384,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
if (n > oldAttsSize)
|
if (n > oldAttsSize)
|
||||||
XmlGetAttributes(enc, attStr, n, atts);
|
XmlGetAttributes(enc, attStr, n, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
appAtts = (const XML_Char **)atts;
|
appAtts = (const XML_Char **)atts;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
/* add the name and value to the attribute list */
|
/* add the name and value to the attribute list */
|
||||||
|
@ -2430,14 +2422,10 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
&tempPool);
|
&tempPool);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
if (tagNamePtr) {
|
appAtts[attIndex] = poolStart(&tempPool);
|
||||||
appAtts[attIndex] = poolStart(&tempPool);
|
poolFinish(&tempPool);
|
||||||
poolFinish(&tempPool);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
poolDiscard(&tempPool);
|
|
||||||
}
|
}
|
||||||
else if (tagNamePtr) {
|
else {
|
||||||
/* the value did not need normalizing */
|
/* the value did not need normalizing */
|
||||||
appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr,
|
appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr,
|
||||||
atts[i].valueEnd);
|
atts[i].valueEnd);
|
||||||
|
@ -2446,7 +2434,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
poolFinish(&tempPool);
|
poolFinish(&tempPool);
|
||||||
}
|
}
|
||||||
/* handle prefixed attribute names */
|
/* handle prefixed attribute names */
|
||||||
if (attId->prefix && tagNamePtr) {
|
if (attId->prefix) {
|
||||||
if (attId->xmlns) {
|
if (attId->xmlns) {
|
||||||
/* deal with namespace declarations here */
|
/* deal with namespace declarations here */
|
||||||
enum XML_Error result = addBinding(parser, attId->prefix, attId,
|
enum XML_Error result = addBinding(parser, attId->prefix, attId,
|
||||||
|
@ -2465,45 +2453,46 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
else
|
else
|
||||||
attIndex++;
|
attIndex++;
|
||||||
}
|
}
|
||||||
if (tagNamePtr) {
|
|
||||||
int j;
|
/* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */
|
||||||
nSpecifiedAtts = attIndex;
|
nSpecifiedAtts = attIndex;
|
||||||
if (elementType->idAtt && (elementType->idAtt->name)[-1]) {
|
if (elementType->idAtt && (elementType->idAtt->name)[-1]) {
|
||||||
for (i = 0; i < attIndex; i += 2)
|
for (i = 0; i < attIndex; i += 2)
|
||||||
if (appAtts[i] == elementType->idAtt->name) {
|
if (appAtts[i] == elementType->idAtt->name) {
|
||||||
idAttIndex = i;
|
idAttIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
idAttIndex = -1;
|
idAttIndex = -1;
|
||||||
/* do attribute defaulting */
|
|
||||||
for (j = 0; j < nDefaultAtts; j++) {
|
/* do attribute defaulting */
|
||||||
const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + j;
|
for (i = 0; i < nDefaultAtts; i++) {
|
||||||
if (!(da->id->name)[-1] && da->value) {
|
const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i;
|
||||||
if (da->id->prefix) {
|
if (!(da->id->name)[-1] && da->value) {
|
||||||
if (da->id->xmlns) {
|
if (da->id->prefix) {
|
||||||
enum XML_Error result = addBinding(parser, da->id->prefix, da->id,
|
if (da->id->xmlns) {
|
||||||
da->value, bindingsPtr);
|
enum XML_Error result = addBinding(parser, da->id->prefix, da->id,
|
||||||
if (result)
|
da->value, bindingsPtr);
|
||||||
return result;
|
if (result)
|
||||||
}
|
return result;
|
||||||
else {
|
|
||||||
(da->id->name)[-1] = 2;
|
|
||||||
nPrefixes++;
|
|
||||||
appAtts[attIndex++] = da->id->name;
|
|
||||||
appAtts[attIndex++] = da->value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(da->id->name)[-1] = 1;
|
(da->id->name)[-1] = 2;
|
||||||
|
nPrefixes++;
|
||||||
appAtts[attIndex++] = da->id->name;
|
appAtts[attIndex++] = da->id->name;
|
||||||
appAtts[attIndex++] = da->value;
|
appAtts[attIndex++] = da->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
(da->id->name)[-1] = 1;
|
||||||
|
appAtts[attIndex++] = da->id->name;
|
||||||
|
appAtts[attIndex++] = da->value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
appAtts[attIndex] = 0;
|
|
||||||
}
|
}
|
||||||
|
appAtts[attIndex] = 0;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (nPrefixes) {
|
if (nPrefixes) {
|
||||||
/* expand prefixed attribute names */
|
/* expand prefixed attribute names */
|
||||||
|
@ -2548,10 +2537,9 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
|
||||||
/* clear the flags that say whether attributes were specified */
|
/* clear the flags that say whether attributes were specified */
|
||||||
for (; i < attIndex; i += 2)
|
for (; i < attIndex; i += 2)
|
||||||
((XML_Char *)(appAtts[i]))[-1] = 0;
|
((XML_Char *)(appAtts[i]))[-1] = 0;
|
||||||
if (!tagNamePtr)
|
|
||||||
return XML_ERROR_NONE;
|
|
||||||
for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
|
for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
|
||||||
binding->attId->name[-1] = 0;
|
binding->attId->name[-1] = 0;
|
||||||
|
|
||||||
/* expand the element type name */
|
/* expand the element type name */
|
||||||
if (elementType->prefix) {
|
if (elementType->prefix) {
|
||||||
binding = elementType->prefix->binding;
|
binding = elementType->prefix->binding;
|
||||||
|
|
Loading…
Reference in New Issue