mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-15 09:44:36 +00:00
De-tabify; minor code-style consistency changes.
This commit is contained in:
parent
2594a4e358
commit
2c06092697
2 changed files with 19 additions and 16 deletions
|
@ -1,7 +1,8 @@
|
|||
/* This is simple demonstration of how to use expat. This program
|
||||
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. */
|
||||
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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "expat.h"
|
||||
|
@ -38,9 +39,9 @@ main(int argc, char *argv[])
|
|||
done = len < sizeof(buf);
|
||||
if (!XML_Parse(parser, buf, len, done)) {
|
||||
fprintf(stderr,
|
||||
"%s at line %d\n",
|
||||
XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
XML_GetCurrentLineNumber(parser));
|
||||
"%s at line %d\n",
|
||||
XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
XML_GetCurrentLineNumber(parser));
|
||||
return 1;
|
||||
}
|
||||
} while (!done);
|
||||
|
|
|
@ -24,14 +24,15 @@
|
|||
#include <stdio.h>
|
||||
#include <expat.h>
|
||||
|
||||
#define BUFFSIZE 8192
|
||||
#define BUFFSIZE 8192
|
||||
|
||||
char Buff[BUFFSIZE];
|
||||
|
||||
int Depth;
|
||||
|
||||
static void
|
||||
start(void *data, const char *el, const char **attr) {
|
||||
start(void *data, const char *el, const char **attr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < Depth; i++)
|
||||
|
@ -45,15 +46,17 @@ start(void *data, const char *el, const char **attr) {
|
|||
|
||||
printf("\n");
|
||||
Depth++;
|
||||
} /* End of start handler */
|
||||
}
|
||||
|
||||
static void
|
||||
end(void *data, const char *el) {
|
||||
end(void *data, const char *el)
|
||||
{
|
||||
Depth--;
|
||||
} /* End of end handler */
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
XML_Parser p = XML_ParserCreate(NULL);
|
||||
if (! p) {
|
||||
fprintf(stderr, "Couldn't allocate memory for parser\n");
|
||||
|
@ -75,8 +78,8 @@ main(int argc, char *argv[]) {
|
|||
|
||||
if (! XML_Parse(p, Buff, len, done)) {
|
||||
fprintf(stderr, "Parse error at line %d:\n%s\n",
|
||||
XML_GetCurrentLineNumber(p),
|
||||
XML_ErrorString(XML_GetErrorCode(p)));
|
||||
XML_GetCurrentLineNumber(p),
|
||||
XML_ErrorString(XML_GetErrorCode(p)));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -84,5 +87,4 @@ main(int argc, char *argv[]) {
|
|||
break;
|
||||
}
|
||||
return 0;
|
||||
} /* End of main */
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue