From a2c83c96b51d6ddbddc393d389912e55cc876056 Mon Sep 17 00:00:00 2001 From: James Clark Date: Thu, 13 Nov 1997 11:45:31 +0000 Subject: [PATCH] Do literals properly. Support for conditional sections. --- expat/xmltok/xmltok_impl.c | 75 ++++++++++++++++++++++++++------------ expat/xmlwf/wfcheck.c | 3 ++ 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/expat/xmltok/xmltok_impl.c b/expat/xmltok/xmltok_impl.c index f49553fd..28f82cf4 100755 --- a/expat/xmltok/xmltok_impl.c +++ b/expat/xmltok/xmltok_impl.c @@ -128,9 +128,12 @@ int PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end, if (ptr == end) return XML_TOK_PARTIAL; if (CHAR_MATCHES(enc, ptr, '-')) - return PREFIX(scanComment)(enc, ptr + MINBPC, end, nextTokPtr); - /* FIXME check for or % afterwards */ - for (ptr += MINBPC; ptr != end; ptr += MINBPC) { - if (BYTE_TYPE(enc, ptr) == BT_QUOT) { - *nextTokPtr = ptr + MINBPC; - return XML_TOK_LITERAL; - } - } - return XML_TOK_PARTIAL; - } + return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC, end, nextTokPtr); case BT_APOS: - { - /* FIXME multibyte, plus require S, > or % afterwards */ - for (ptr += MINBPC; ptr != end; ptr += MINBPC) { - if (BYTE_TYPE(enc, ptr) == BT_APOS) { - *nextTokPtr = ptr + MINBPC; - return XML_TOK_LITERAL; - } - } - return XML_TOK_PARTIAL; - } + return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC, end, nextTokPtr); case BT_LT: { ptr += MINBPC; @@ -812,8 +829,18 @@ int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, *nextTokPtr = ptr + MINBPC; return XML_TOK_OPEN_BRACKET; case BT_RSQB: - /* FIXME check for ]]> */ - *nextTokPtr = ptr + MINBPC; + ptr += MINBPC; + if (ptr == end) + return XML_TOK_PARTIAL; + if (CHAR_MATCHES(enc, ptr, ']')) { + if (ptr + MINBPC == end) + return XML_TOK_PARTIAL; + if (CHAR_MATCHES(enc, ptr + MINBPC, '>')) { + *nextTokPtr = ptr + 2*MINBPC; + return XML_TOK_COND_SECT_CLOSE; + } + } + *nextTokPtr = ptr; return XML_TOK_CLOSE_BRACKET; case BT_LPAR: *nextTokPtr = ptr + MINBPC; diff --git a/expat/xmlwf/wfcheck.c b/expat/xmlwf/wfcheck.c index 898be896..78cf4203 100755 --- a/expat/xmlwf/wfcheck.c +++ b/expat/xmlwf/wfcheck.c @@ -177,6 +177,9 @@ int skipProlog(const char **startp, const char *end, case XML_TOK_COMMENT: case XML_TOK_PI: break; + case XML_TOK_COND_SECT_OPEN: + *startp = s; + return XML_TOK_INVALID; default: if (!*doctypeP) { *startp = s;