From 881c589e09ac161562b3cbb9392a6045639e5db7 Mon Sep 17 00:00:00 2001 From: kwaclaw Date: Wed, 28 Dec 2005 18:43:36 +0000 Subject: * Added support for XML_LARGE_SIZE. * Added comment about using with UTF-8 version of Expat only. --- examples/elements.c | 13 ++++++++++++- examples/outline.c | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/elements.c b/examples/elements.c index e81d465..421a1ce 100644 --- a/examples/elements.c +++ b/examples/elements.c @@ -2,11 +2,22 @@ reads an XML document from standard input and writes a line with the name of each element to standard output indenting child elements by one tab stop more than their parent element. + It must be used with Expat compiled for UTF-8 output. */ #include #include "expat.h" +#ifdef XML_LARGE_SIZE +#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 +#define XML_FMT_INT_MOD "I64" +#else +#define XML_FMT_INT_MOD "ll" +#endif +#else +#define XML_FMT_INT_MOD "l" +#endif + static void XMLCALL startElement(void *userData, const char *name, const char **atts) { @@ -45,7 +56,7 @@ main(int argc, char *argv[]) done = len < sizeof(buf); if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { fprintf(stderr, - "%s at line %d\n", + "%s at line %" XML_FMT_INT_MOD "u\n", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); return 1; diff --git a/examples/outline.c b/examples/outline.c index e770819..807ddb8 100644 --- a/examples/outline.c +++ b/examples/outline.c @@ -18,12 +18,23 @@ * * Read an XML document from standard input and print an element * outline on standard output. + * Must be used with Expat compiled for UTF-8 output. */ #include #include +#ifdef XML_LARGE_SIZE +#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 +#define XML_FMT_INT_MOD "I64" +#else +#define XML_FMT_INT_MOD "ll" +#endif +#else +#define XML_FMT_INT_MOD "l" +#endif + #define BUFFSIZE 8192 char Buff[BUFFSIZE]; @@ -83,7 +94,7 @@ main(int argc, char *argv[]) done = feof(stdin); if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) { - fprintf(stderr, "Parse error at line %d:\n%s\n", + fprintf(stderr, "Parse error at line %" XML_FMT_INT_MOD "u:\n%s\n", XML_GetCurrentLineNumber(p), XML_ErrorString(XML_GetErrorCode(p))); exit(-1); -- cgit v1.2.1