[Expat-checkins] CVS: expat/lib xmlparse.c,1.26,1.27
Karl Waclawek
kwaclaw@users.sourceforge.net
Tue Apr 23 06:51:32 2002
Update of /cvsroot/expat/expat/lib
In directory usw-pr-cvs1:/tmp/cvs-serv27194
Modified Files:
xmlparse.c
Log Message:
XML_UNICODE fixes
Index: xmlparse.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** xmlparse.c 19 Apr 2002 20:52:39 -0000 1.26
--- xmlparse.c 23 Apr 2002 13:49:31 -0000 1.27
***************
*** 55,62 ****
#endif
! #ifdef XML_UNICODE_WCHAR_T
! #define XML_T(x) L ## x
! #else
#define XML_T(x) x
#endif
--- 55,73 ----
#endif
! #ifdef XML_UNICODE
!
! # ifdef XML_UNICODE_WCHAR_T
! # define XML_T(x) (const wchar_t)x
! # define XML_L(x) L ## x
! # else
! # define XML_T(x) (const unsigned short)x
! # define XML_L(x) x
! # endif
!
! #else
!
#define XML_T(x) x
+ #define XML_L(x) x
+
#endif
***************
*** 431,435 ****
STRING_POOL m_tempPool;
STRING_POOL m_temp2Pool;
! char *m_groupConnector;
unsigned m_groupSize;
int m_hadExternalDoctype;
--- 442,446 ----
STRING_POOL m_tempPool;
STRING_POOL m_temp2Pool;
! char *m_groupConnector;
unsigned m_groupSize;
int m_hadExternalDoctype;
***************
*** 564,579 ****
XML_Parser parser;
! static
! const XML_Char implicitContext[] = {
! XML_T('x'), XML_T('m'), XML_T('l'), XML_T('='),
! XML_T('h'), XML_T('t'), XML_T('t'), XML_T('p'), XML_T(':'),
! XML_T('/'), XML_T('/'), XML_T('w'), XML_T('w'), XML_T('w'),
! XML_T('.'), XML_T('w'), XML_T('3'),
! XML_T('.'), XML_T('o'), XML_T('r'), XML_T('g'),
! XML_T('/'), XML_T('X'), XML_T('M'), XML_T('L'),
! XML_T('/'), XML_T('1'), XML_T('9'), XML_T('9'), XML_T('8'),
! XML_T('/'), XML_T('n'), XML_T('a'), XML_T('m'), XML_T('e'),
! XML_T('s'), XML_T('p'), XML_T('a'), XML_T('c'), XML_T('e'),
! XML_T('\0')
};
--- 575,583 ----
XML_Parser parser;
! static const XML_Char implicitContext[] = {
! 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/',
! 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/',
! 'X', 'M', 'L', '/', '1', '9', '9', '8', '/',
! 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0'
};
***************
*** 1313,1339 ****
static const XML_LChar *message[] = {
0,
! XML_T("out of memory"),
! XML_T("syntax error"),
! XML_T("no element found"),
! XML_T("not well-formed (invalid token)"),
! XML_T("unclosed token"),
! XML_T("partial character"),
! XML_T("mismatched tag"),
! XML_T("duplicate attribute"),
! XML_T("junk after document element"),
! XML_T("illegal parameter entity reference"),
! XML_T("undefined entity"),
! XML_T("recursive entity reference"),
! XML_T("asynchronous entity"),
! XML_T("reference to invalid character number"),
! XML_T("reference to binary entity"),
! XML_T("reference to external entity in attribute"),
! XML_T("xml processing instruction not at start of external entity"),
! XML_T("unknown encoding"),
! XML_T("encoding specified in XML declaration is incorrect"),
! XML_T("unclosed CDATA section"),
! XML_T("error in processing external entity reference"),
! XML_T("document is not standalone"),
! XML_T("unexpected parser state - please send a bug report")
};
if (code > 0 && code < sizeof(message)/sizeof(message[0]))
--- 1317,1343 ----
static const XML_LChar *message[] = {
0,
! XML_L("out of memory"),
! XML_L("syntax error"),
! XML_L("no element found"),
! XML_L("not well-formed (invalid token)"),
! XML_L("unclosed token"),
! XML_L("partial character"),
! XML_L("mismatched tag"),
! XML_L("duplicate attribute"),
! XML_L("junk after document element"),
! XML_L("illegal parameter entity reference"),
! XML_L("undefined entity"),
! XML_L("recursive entity reference"),
! XML_L("asynchronous entity"),
! XML_L("reference to invalid character number"),
! XML_L("reference to binary entity"),
! XML_L("reference to external entity in attribute"),
! XML_L("xml processing instruction not at start of external entity"),
! XML_L("unknown encoding"),
! XML_L("encoding specified in XML declaration is incorrect"),
! XML_L("unclosed CDATA section"),
! XML_L("error in processing external entity reference"),
! XML_L("document is not standalone"),
! XML_L("unexpected parser state - please send a bug report")
};
if (code > 0 && code < sizeof(message)/sizeof(message[0]))
***************
*** 1353,1357 ****
/* ### I'm assuming cpp is portable in this respect... */
! #define V1(a,b,c) "expat_"#a"."#b"."#c
#define V2(a,b,c) V1(a,b,c)
--- 1357,1361 ----
/* ### I'm assuming cpp is portable in this respect... */
! #define V1(a,b,c) XML_L("expat_")XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c)
#define V2(a,b,c) V1(a,b,c)
***************
*** 1915,1919 ****
const XML_Char **appAtts; /* the attribute list for the application */
int attIndex = 0;
! int prefixLen = 0;
int i;
int n;
--- 1919,1923 ----
const XML_Char **appAtts; /* the attribute list for the application */
int attIndex = 0;
! int prefixLen;
int i;
int n;
***************
*** 2075,2079 ****
return XML_ERROR_NO_MEMORY;
}
! while (*s++ != ':')
;
do {
--- 2079,2083 ----
return XML_ERROR_NO_MEMORY;
}
! while (*s++ != XML_T(':'))
;
do {
***************
*** 2121,2137 ****
}
else
! localPart = NULL;
if (ns && ns_triplets && binding->prefix->name) {
! for (prefixLen = 0; binding->prefix->name[prefixLen++];)
;
- n += prefixLen;
}
- else
- return XML_ERROR_NONE;
tagNamePtr->localPart = localPart;
tagNamePtr->uriLen = binding->uriLen;
for (i = 0; localPart[i++];)
;
! n = i + binding->uriLen;
if (n > binding->uriAlloc) {
TAG *p;
--- 2125,2139 ----
}
else
! return XML_ERROR_NONE;
! prefixLen = 0;
if (ns && ns_triplets && binding->prefix->name) {
! for (prefixLen; binding->prefix->name[prefixLen++];)
;
}
tagNamePtr->localPart = localPart;
tagNamePtr->uriLen = binding->uriLen;
for (i = 0; localPart[i++];)
;
! n = i + binding->uriLen + prefixLen;
if (n > binding->uriAlloc) {
TAG *p;
***************
*** 2435,2443 ****
{
const char *encodingName = 0;
! const char *storedEncName = 0;
const ENCODING *newEncoding = 0;
const char *version = 0;
const char *versionend;
! const char *storedversion = 0;
int standalone = -1;
if (!(ns
--- 2437,2445 ----
{
const char *encodingName = 0;
! const XML_Char *storedEncName = 0;
const ENCODING *newEncoding = 0;
const char *version = 0;
const char *versionend;
! const XML_Char *storedversion = 0;
int standalone = -1;
if (!(ns
***************
*** 2590,2594 ****
--- 2592,2608 ----
static const XML_Char externalSubsetName[] = { '#' , '\0' };
#endif /* XML_DTD */
+ static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A' };
+ static const XML_Char atypeID[] = { 'I', 'D' };
+ static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F' };
+ static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S' };
+ static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y' };
+ static const XML_Char atypeENTITIES[] = { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S' };
+ static const XML_Char atypeNMTOKEN[] = { 'N', 'M', 'T', 'O', 'K', 'E', 'N' };
+ static const XML_Char atypeNMTOKENS[] = { 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S' };
+ static const XML_Char notationPrefix[] = { 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(' };
+ static const XML_Char enumValueSep[] = { '|' };
+ static const XML_Char enumValueStart[] = { '(' };
+
const char **eventPP;
const char **eventEndPP;
***************
*** 2679,2683 ****
case XML_ROLE_DOCTYPE_PUBLIC_ID:
if (startDoctypeDeclHandler) {
! doctypePubid = poolStoreString(&tempPool, enc, s + 1, next - 1);
if (! doctypePubid)
return XML_ERROR_NO_MEMORY;
--- 2693,2697 ----
case XML_ROLE_DOCTYPE_PUBLIC_ID:
if (startDoctypeDeclHandler) {
! doctypePubid = poolStoreString(&tempPool, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar);
if (! doctypePubid)
return XML_ERROR_NO_MEMORY;
***************
*** 2755,2781 ****
case XML_ROLE_ATTRIBUTE_TYPE_CDATA:
declAttributeIsCdata = 1;
! declAttributeType = "CDATA";
break;
case XML_ROLE_ATTRIBUTE_TYPE_ID:
declAttributeIsId = 1;
! declAttributeType = "ID";
break;
case XML_ROLE_ATTRIBUTE_TYPE_IDREF:
! declAttributeType = "IDREF";
break;
case XML_ROLE_ATTRIBUTE_TYPE_IDREFS:
! declAttributeType = "IDREFS";
break;
case XML_ROLE_ATTRIBUTE_TYPE_ENTITY:
! declAttributeType = "ENTITY";
break;
case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES:
! declAttributeType = "ENTITIES";
break;
case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN:
! declAttributeType = "NMTOKEN";
break;
case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS:
! declAttributeType = "NMTOKENS";
break;
--- 2769,2795 ----
case XML_ROLE_ATTRIBUTE_TYPE_CDATA:
declAttributeIsCdata = 1;
! declAttributeType = atypeCDATA;
break;
case XML_ROLE_ATTRIBUTE_TYPE_ID:
declAttributeIsId = 1;
! declAttributeType = atypeID;
break;
case XML_ROLE_ATTRIBUTE_TYPE_IDREF:
! declAttributeType = atypeIDREF;
break;
case XML_ROLE_ATTRIBUTE_TYPE_IDREFS:
! declAttributeType = atypeIDREFS;
break;
case XML_ROLE_ATTRIBUTE_TYPE_ENTITY:
! declAttributeType = atypeENTITY;
break;
case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES:
! declAttributeType = atypeENTITIES;
break;
case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN:
! declAttributeType = atypeNMTOKEN;
break;
case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS:
! declAttributeType = atypeNMTOKENS;
break;
***************
*** 2784,2795 ****
if (attlistDeclHandler)
{
! char *prefix;
if (declAttributeType) {
! prefix = "|";
}
else {
prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE
! ? "NOTATION("
! : "(");
}
if (! poolAppendString(&tempPool, prefix))
--- 2798,2809 ----
if (attlistDeclHandler)
{
! const XML_Char *prefix;
if (declAttributeType) {
! prefix = enumValueSep;
}
else {
prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE
! ? notationPrefix
! : enumValueStart);
}
if (! poolAppendString(&tempPool, prefix))
***************
*** 2808,2816 ****
return XML_ERROR_NO_MEMORY;
if (attlistDeclHandler && declAttributeType) {
! if (*declAttributeType == '('
! || (*declAttributeType == 'N' && declAttributeType[1] == 'O')) {
/* Enumerated or Notation type */
! if (! poolAppendChar(&tempPool, ')')
! || ! poolAppendChar(&tempPool, '\0'))
return XML_ERROR_NO_MEMORY;
declAttributeType = tempPool.start;
--- 2822,2831 ----
return XML_ERROR_NO_MEMORY;
if (attlistDeclHandler && declAttributeType) {
! if (*declAttributeType == XML_T('(')
! || (*declAttributeType == XML_T('N')
! && declAttributeType[1] == XML_T('O'))) {
/* Enumerated or Notation type */
! if (! poolAppendChar(&tempPool, XML_T(')'))
! || ! poolAppendChar(&tempPool, XML_T('\0')))
return XML_ERROR_NO_MEMORY;
declAttributeType = tempPool.start;
***************
*** 2843,2851 ****
return XML_ERROR_NO_MEMORY;
if (attlistDeclHandler && declAttributeType) {
! if (*declAttributeType == '('
! || (*declAttributeType == 'N' && declAttributeType[1] == 'O')) {
/* Enumerated or Notation type */
! if (! poolAppendChar(&tempPool, ')')
! || ! poolAppendChar(&tempPool, '\0'))
return XML_ERROR_NO_MEMORY;
declAttributeType = tempPool.start;
--- 2858,2867 ----
return XML_ERROR_NO_MEMORY;
if (attlistDeclHandler && declAttributeType) {
! if (*declAttributeType == XML_T('(')
! || (*declAttributeType == XML_T('N')
! && declAttributeType[1] == XML_T('O'))) {
/* Enumerated or Notation type */
! if (! poolAppendChar(&tempPool, XML_T(')'))
! || ! poolAppendChar(&tempPool, XML_T('\0')))
return XML_ERROR_NO_MEMORY;
declAttributeType = tempPool.start;
***************
*** 2888,2892 ****
case XML_ROLE_DOCTYPE_SYSTEM_ID:
if (startDoctypeDeclHandler) {
! doctypeSysid = poolStoreString(&tempPool, enc, s + 1, next - 1);
if (! doctypeSysid)
return XML_ERROR_NO_MEMORY;
--- 2904,2910 ----
case XML_ROLE_DOCTYPE_SYSTEM_ID:
if (startDoctypeDeclHandler) {
! doctypeSysid = poolStoreString(&tempPool, enc,
! s + enc->minBytesPerChar,
! next - enc->minBytesPerChar);
if (! doctypeSysid)
return XML_ERROR_NO_MEMORY;
***************
*** 3246,3250 ****
{
ELEMENT_TYPE *el;
! const char *nxt = quant == XML_CQUANT_NONE ? next : next - 1;
int myindex = nextScaffoldPart(parser);
if (myindex < 0)
--- 3264,3268 ----
{
ELEMENT_TYPE *el;
! const char *nxt = quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar;
int myindex = nextScaffoldPart(parser);
if (myindex < 0)
***************
*** 3982,3986 ****
poolDiscard(&tempPool);
}
! else if (*s == '=') {
PREFIX *prefix;
if (poolLength(&tempPool) == 0)
--- 4000,4004 ----
poolDiscard(&tempPool);
}
! else if (*s == XML_T('=')) {
PREFIX *prefix;
if (poolLength(&tempPool) == 0)
***************
*** 4651,4660 ****
XML_Content *dest,
XML_Content **contpos,
! char **strpos)
{
dest->type = dtd.scaffold[src_node].type;
dest->quant = dtd.scaffold[src_node].quant;
if (dest->type == XML_CTYPE_NAME) {
! const char *src;
dest->name = *strpos;
src = dtd.scaffold[src_node].name;
--- 4669,4678 ----
XML_Content *dest,
XML_Content **contpos,
! XML_Char **strpos)
{
dest->type = dtd.scaffold[src_node].type;
dest->quant = dtd.scaffold[src_node].quant;
if (dest->type == XML_CTYPE_NAME) {
! const XML_Char *src;
dest->name = *strpos;
src = dtd.scaffold[src_node].name;
***************
*** 4688,4693 ****
XML_Content *ret;
XML_Content *cpos;
! char * str;
! int allocsize = dtd.scaffCount * sizeof(XML_Content) + dtd.contentStringLen;
ret = MALLOC(allocsize);
--- 4706,4711 ----
XML_Content *ret;
XML_Content *cpos;
! XML_Char * str;
! int allocsize = dtd.scaffCount * sizeof(XML_Content) + (dtd.contentStringLen * sizeof(XML_Char));
ret = MALLOC(allocsize);
***************
*** 4695,4699 ****
return 0;
! str = (char *) (&ret[dtd.scaffCount]);
cpos = &ret[1];
--- 4713,4717 ----
return 0;
! str = (XML_Char *) (&ret[dtd.scaffCount]);
cpos = &ret[1];