From ad0e1a943b70181c3496e8c923fb6c9b9fc4e612 Mon Sep 17 00:00:00 2001 From: "Fred L. Drake, Jr." Date: Thu, 5 Sep 2002 01:48:26 +0000 Subject: [PATCH] Elaborate the XML_GetFeatureList() API a bit, and add additional info that may be needed by a hughly flexible client. (Or at least used to check that the Expat that it links to matches client expectations.) --- expat/doc/reference.html | 38 +++++++++++++++++++++++++++++++------- expat/lib/expat.h | 7 ++++++- expat/lib/xmlparse.c | 21 ++++++++++++++++----- expat/xmlwf/xmlwf.c | 14 ++++++++------ 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/expat/doc/reference.html b/expat/doc/reference.html index 1d422c7a..fda752f8 100644 --- a/expat/doc/reference.html +++ b/expat/doc/reference.html @@ -1712,12 +1712,17 @@ enum XML_FeatureEnum { XML_FEATURE_END = 0, XML_FEATURE_UNICODE, XML_FEATURE_UNICODE_WCHAR_T, - XML_FEATURE_DTD + XML_FEATURE_DTD, + XML_FEATURE_CONTEXT_BYTES, + XML_FEATURE_MIN_SIZE, + XML_FEATURE_SIZEOF_XML_CHAR, + XML_FEATURE_SIZEOF_XML_LCHAR }; typedef struct { enum XML_FeatureEnum feature; XML_LChar *name; + long int value; } XML_Feature;
@@ -1730,12 +1735,31 @@ check these features to do so at runtime.

The return value is an array of XML_Feature, terminated by a record with a feature of XML_FEATURE_END and name of NULL, -identifying the feature-test macros Expat was compiled with. Since -an application that requires this kind of information needs to -determine the type of character the name points to, -records for the XML_UNICODE and -XML_UNICODE_WCHAR_T features will be located at the -beginning of the list, if they are present at all.

+identifying the feature-test macros Expat was compiled with. Since an +application that requires this kind of information needs to determine +the type of character the name points to, records for the +XML_FEATURE_SIZEOF_XML_CHAR and +XML_FEATURE_SIZEOF_XML_LCHAR will be located at the +beginning of the list, followed by XML_FEATURE_UNICODE +and XML_FEATURE_UNICODE_WCHAR_T, if they are present at +all.

+ +

Some features have an associated value. If there isn't an +associated value, the value field is set to 0. At this +time, the following features have been defined to have values:

+ +
+
XML_FEATURE_SIZEOF_XML_CHAR
+
The number of bytes occupied by one XML_Char + character.
+
XML_FEATURE_SIZEOF_XML_LCHAR
+
The number of bytes occupied by one XML_LChar + character.
+
XML_FEATURE_CONTEXT_BYTES
+
The maximum number of characters of context which can be + reported by XML_GetInputContext.
+

diff --git a/expat/lib/expat.h b/expat/lib/expat.h index 63c08527..d69211ef 100644 --- a/expat/lib/expat.h +++ b/expat/lib/expat.h @@ -875,13 +875,18 @@ enum XML_FeatureEnum { XML_FEATURE_END = 0, XML_FEATURE_UNICODE, XML_FEATURE_UNICODE_WCHAR_T, - XML_FEATURE_DTD + XML_FEATURE_DTD, + XML_FEATURE_CONTEXT_BYTES, + XML_FEATURE_MIN_SIZE, + XML_FEATURE_SIZEOF_XML_CHAR, + XML_FEATURE_SIZEOF_XML_LCHAR /* Additional features must be added to the end of this enum. */ }; typedef struct { enum XML_FeatureEnum feature; XML_LChar *name; + long int value; } XML_Feature; XMLPARSEAPI(const XML_Feature *) diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index db15eae1..0488f41c 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -1607,19 +1607,30 @@ XML_ExpatVersionInfo(void) const XML_Feature * XML_GetFeatureList(void) { - static const XML_Feature features[] = { + static XML_Feature features[] = { + {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)")}, + {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)")}, #ifdef XML_UNICODE - {XML_FEATURE_UNICODE, XML_L("XML_UNICODE")}, + {XML_FEATURE_UNICODE, XML_L("XML_UNICODE")}, #endif #ifdef XML_UNICODE_WCHAR_T - {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T")}, + {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T")}, #endif #ifdef XML_DTD - {XML_FEATURE_DTD, XML_L("XML_DTD")}, + {XML_FEATURE_DTD, XML_L("XML_DTD")}, #endif - {XML_FEATURE_END, NULL} +#ifdef XML_CONTEXT_BYTES + {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), + XML_CONTEXT_BYTES}, +#endif +#ifdef XML_MIN_SIZE + {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE")}, +#endif + {XML_FEATURE_END, NULL} }; + features[0].value = sizeof(XML_Char); + features[1].value = sizeof(XML_LChar); return features; } diff --git a/expat/xmlwf/xmlwf.c b/expat/xmlwf/xmlwf.c index 34149c34..8a8056e5 100755 --- a/expat/xmlwf/xmlwf.c +++ b/expat/xmlwf/xmlwf.c @@ -609,17 +609,19 @@ showVersion(XML_Char *prog) prog = s + 1; ++s; } - ftprintf(stdout, T("%s using %s"), prog, XML_ExpatVersion()); - if (features == NULL || features[0].feature == XML_FEATURE_END) - ftprintf(stdout, T("\n")); - else { + ftprintf(stdout, T("%s using %s\n"), prog, XML_ExpatVersion()); + if (features != NULL && features[0].feature != XML_FEATURE_END) { int i = 1; - ftprintf(stdout, T(" (%s"), features[0].name); + ftprintf(stdout, T("%s"), features[0].name); + if (features[0].value) + ftprintf(stdout, T("=%ld"), features[0].value); while (features[i].feature != XML_FEATURE_END) { ftprintf(stdout, T(", %s"), features[i].name); + if (features[i].value) + ftprintf(stdout, T("=%ld"), features[i].value); ++i; } - ftprintf(stdout, T(")\n")); + ftprintf(stdout, T("\n")); } } -- 2.40.0