diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-08-14 14:12:47 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-08-14 14:12:47 +0000 |
commit | 90493a917101683a1d2895b9f31a166590e8d468 (patch) | |
tree | 8b159bd4719293b7d9cb78ccf9a10602f3744a12 /xmllint.c | |
parent | fe70332f7f29f146a364c73450729a8b3274daee (diff) | |
download | android_external_libxml2-90493a917101683a1d2895b9f31a166590e8d468.tar.gz android_external_libxml2-90493a917101683a1d2895b9f31a166590e8d468.tar.bz2 android_external_libxml2-90493a917101683a1d2895b9f31a166590e8d468.zip |
adding a --format option Daniel
* xmllint.c: adding a --format option
Daniel
Diffstat (limited to 'xmllint.c')
-rw-r--r-- | xmllint.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -92,6 +92,7 @@ static int push = 0; static int memory = 0; #endif static int noblanks = 0; +static int format = 0; static int testIO = 0; static char *encoding = NULL; #ifdef LIBXML_XINCLUDE_ENABLED @@ -630,7 +631,10 @@ static void parseAndPrintFile(char *filename) { if (encoding != NULL) { xmlDocDumpMemoryEnc(doc, &result, &len, encoding); } else { - xmlDocDumpMemory(doc, &result, &len); + if (format) + xmlDocDumpFormatMemory(doc, &result, &len, 1); + else + xmlDocDumpMemory(doc, &result, &len); } if (result == NULL) { fprintf(stderr, "Failed to save\n"); @@ -644,6 +648,8 @@ static void parseAndPrintFile(char *filename) { xmlSaveFile("-", doc); else if (encoding != NULL) xmlSaveFileEnc("-", doc, encoding); + else if (format) + xmlSaveFormatFile("-", doc, 1); else xmlDocDump(stdout, doc); if ((timing) && (!repeat)) { @@ -785,6 +791,7 @@ static void usage(const char *name) { #endif printf("\t--nowarning : do not emit warnings from parser/validator\n"); printf("\t--noblanks : drop (ignorable?) blanks spaces\n"); + printf("\t--format : reformat/reindent the input\n"); printf("\t--testIO : test user I/O support\n"); printf("\t--encode encoding : output in the given encoding\n"); #ifdef LIBXML_CATALOG_ENABLED @@ -945,6 +952,12 @@ main(int argc, char **argv) { (!strcmp(argv[i], "--noblanks"))) { noblanks++; xmlKeepBlanksDefault(0); + } + else if ((!strcmp(argv[i], "-format")) || + (!strcmp(argv[i], "--format"))) { + noblanks++; + format++; + xmlKeepBlanksDefault(0); } else { fprintf(stderr, "Unknown option %s\n", argv[i]); usage(argv[0]); |