*** xmllint/orig Wed Dec 5 03:35:06 2001 --- xmllint/riscos Mon Dec 17 15:12:38 2001 *************** *** 115,120 **** --- 115,122 ---- static int catalogs = 0; static int nocatalogs = 0; #endif + static const char *output = NULL; + /************************************************************************ * * *************** *** 691,710 **** } } else #endif /* HAVE_SYS_MMAN_H */ ! if (compress) ! xmlSaveFile("-", doc); else if (encoding != NULL) { if ( format ) { ! xmlSaveFormatFileEnc("-", doc, encoding, 1); ! } else { ! xmlSaveFileEnc("-", doc, encoding); } } - else if (format) - xmlSaveFormatFile("-", doc, 1); - else - xmlDocDump(stdout, doc); if ((timing) && (!repeat)) { long msec; gettimeofday(&end, NULL); --- 693,724 ---- } } else #endif /* HAVE_SYS_MMAN_H */ ! if (compress) { ! xmlSaveFile(output ? output : "-", doc); ! } else if (encoding != NULL) { if ( format ) { ! xmlSaveFormatFileEnc(output ? output : "-", doc, encoding, 1); ! } ! else { ! xmlSaveFileEnc(output ? output : "-", doc, encoding); ! } ! } ! else if (format) { ! xmlSaveFormatFile(output ? output : "-", doc, 1); ! } ! else { ! FILE *out; ! if (output == NULL) ! out = stdout; else { ! out = fopen(output,"wb"); } + xmlDocDump(out, doc); + + if (output) + fclose(out); } if ((timing) && (!repeat)) { long msec; gettimeofday(&end, NULL); *************** *** 715,721 **** } #ifdef LIBXML_DEBUG_ENABLED } else { ! xmlDebugDumpDocument(stdout, doc); } #endif } --- 729,744 ---- } #ifdef LIBXML_DEBUG_ENABLED } else { ! FILE *out; ! if (output == NULL) ! out = stdout; ! else { ! out = fopen(output,"wb"); ! } ! xmlDebugDumpDocument(out, doc); ! ! if (output) ! fclose(out); } #endif } *************** *** 834,842 **** --- 857,868 ---- printf("\t--postvalid : do a posteriori validation, i.e after parsing\n"); printf("\t--dtdvalid URL : do a posteriori validation against a given DTD\n"); printf("\t--timing : print some timings\n"); + printf("\t--output file or -o file: save to a given file\n"); printf("\t--repeat : repeat 100 times, for timing or profiling\n"); printf("\t--insert : ad-hoc test for valid insertions\n"); + #ifdef HAVE_ZLIB_H printf("\t--compress : turn on gzip compression of output\n"); + #endif #ifdef LIBXML_DOCB_ENABLED printf("\t--sgml : use the DocBook SGML parser\n"); #endif *************** *** 905,910 **** --- 931,942 ---- else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) noout++; + else if ((!strcmp(argv[i], "-o")) || + (!strcmp(argv[i], "-output")) || + (!strcmp(argv[i], "--output"))) { + i++; + output = argv[i++]; + } else if ((!strcmp(argv[i], "-htmlout")) || (!strcmp(argv[i], "--htmlout"))) htmlout++; *************** *** 971,981 **** --- 1003,1015 ---- (!strcmp(argv[i], "--xinclude"))) xinclude++; #endif + #ifdef HAVE_ZLIB_H else if ((!strcmp(argv[i], "-compress")) || (!strcmp(argv[i], "--compress"))) { compress++; xmlSetCompressMode(9); } + #endif else if ((!strcmp(argv[i], "-nowarning")) || (!strcmp(argv[i], "--nowarning"))) { xmlGetWarningsDefaultValue = 0; *************** *** 1066,1071 **** --- 1100,1110 ---- (!strcmp(argv[i], "--encode"))) { i++; continue; + } else if ((!strcmp(argv[i], "-o")) || + (!strcmp(argv[i], "-output")) || + (!strcmp(argv[i], "--output"))) { + i++; + continue; } if ((!strcmp(argv[i], "-dtdvalid")) || (!strcmp(argv[i], "--dtdvalid"))) {