summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorkwaclaw <kwaclaw>2005-12-28 18:43:36 +0000
committerkwaclaw <kwaclaw>2005-12-28 18:43:36 +0000
commit881c589e09ac161562b3cbb9392a6045639e5db7 (patch)
tree48af634bb8b983a0ac1794f241c03e318782d133 /examples
parent7c9286962f78c2ae9cdd3740f574cec3a64ec6b8 (diff)
downloadlibexpat-881c589e09ac161562b3cbb9392a6045639e5db7.tar.gz
* Added support for XML_LARGE_SIZE.
* Added comment about using with UTF-8 version of Expat only.
Diffstat (limited to 'examples')
-rw-r--r--examples/elements.c13
-rw-r--r--examples/outline.c13
2 files changed, 24 insertions, 2 deletions
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 <stdio.h>
#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 <stdio.h>
#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
+
#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);