adding a --format option Daniel

* xmllint.c: adding a --format option
Daniel
diff --git a/xmllint.c b/xmllint.c
index 6573c3c..abc612a 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -92,6 +92,7 @@
 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 @@
 		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 @@
 		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 @@
 #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 @@
 	         (!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]);