From d2c1656f5ffb955602cec6301f6b4c737e2f896e Mon Sep 17 00:00:00 2001 From: James Clark Date: Fri, 26 Mar 1999 03:53:05 +0000 Subject: [PATCH] Add XML_GetSpecifiedAttributeCount(). --- expat/xmlparse/xmlparse.c | 9 +++++++++ expat/xmlparse/xmlparse.h | 6 ++++++ expat/xmlwf/xmlwf.c | 7 ++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/expat/xmlparse/xmlparse.c b/expat/xmlparse/xmlparse.c index 01081a9a..12b2b6c3 100755 --- a/expat/xmlparse/xmlparse.c +++ b/expat/xmlparse/xmlparse.c @@ -309,6 +309,7 @@ typedef struct { BINDING *inheritedBindings; BINDING *freeBindingList; int attsSize; + int nSpecifiedAtts; ATTRIBUTE *atts; POSITION position; STRING_POOL tempPool; @@ -376,6 +377,7 @@ typedef struct { #define tagStack (((Parser *)parser)->tagStack) #define atts (((Parser *)parser)->atts) #define attsSize (((Parser *)parser)->attsSize) +#define nSpecifiedAtts (((Parser *)parser)->nSpecifiedAtts) #define tempPool (((Parser *)parser)->tempPool) #define temp2Pool (((Parser *)parser)->temp2Pool) #define groupConnector (((Parser *)parser)->groupConnector) @@ -440,6 +442,7 @@ XML_Parser XML_ParserCreate(const XML_Char *encodingName) inheritedBindings = 0; attsSize = INIT_ATTS_SIZE; atts = malloc(attsSize * sizeof(ATTRIBUTE)); + nSpecifiedAtts = 0; dataBuf = malloc(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); groupSize = 0; groupConnector = 0; @@ -635,6 +638,11 @@ const XML_Char *XML_GetBase(XML_Parser parser) return dtd.base; } +int XML_GetSpecifiedAttributeCount(XML_Parser parser) +{ + return nSpecifiedAtts; +} + void XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end) @@ -1541,6 +1549,7 @@ static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc, else attIndex++; } + nSpecifiedAtts = attIndex; if (tagNamePtr) { int j; for (j = 0; j < nDefaultAtts; j++) { diff --git a/expat/xmlparse/xmlparse.h b/expat/xmlparse/xmlparse.h index 2b544b7d..3687a4a5 100755 --- a/expat/xmlparse/xmlparse.h +++ b/expat/xmlparse/xmlparse.h @@ -357,6 +357,12 @@ XML_SetBase(XML_Parser parser, const XML_Char *base); const XML_Char XMLPARSEAPI * XML_GetBase(XML_Parser parser); +/* Returns the number of the attributes passed in last call to the +XML_StartElementHandler that were specified in the start-tag rather +than defaulted. */ + +int XMLPARSEAPI XML_GetSpecifiedAttributeCount(XML_Parser parser); + /* Parses some input. Returns 0 if a fatal error is detected. The last call to XML_Parse must have isFinal true; len may be zero for this call (or any other). */ diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c index 746c5812..f8403a56 100755 --- a/expat/xmlwf/xmlwf.c +++ b/expat/xmlwf/xmlwf.c @@ -257,6 +257,8 @@ static void metaStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts) { FILE *fp = XML_GetUserData(parser); + const XML_Char **specifiedAttsEnd + = atts + 2*XML_GetSpecifiedAttributeCount(parser); ftprintf(fp, T("\n"), fp); + if (atts >= specifiedAttsEnd) + fputs(T("\" defaulted=\"yes\"/>\n"), fp); + else + fputts(T("\"/>\n"), fp); } while (*(atts += 2)); fputts(T("\n"), fp); }