Restarted hacking :-) :
- xmllint.c: Made is so if the file name is "-" is will read form
standard input. Sven Heinicke <sven@zen.org>
- tree.c: fixed a problem when growing buffer
- tree.h: fixed the comment of the node types following andersca
comment
- TODO: updated
Daniel
diff --git a/xmllint.c b/xmllint.c
index 3dd413a..7d6ec87 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -372,7 +372,9 @@
return(fread(buffer, 1, len, f));
}
void myClose(FILE *f) {
+ if (f != stdin) {
fclose(f);
+ }
}
/************************************************************************
@@ -394,7 +396,12 @@
if (push) {
FILE *f;
- f = fopen(filename, "r");
+ /* '-' Usually means stdin -<sven@zen.org> */
+ if ((filename[0] == '-') && (filename[1] == 0)) {
+ f = stdin;
+ } else {
+ f = fopen(filename, "r");
+ }
if (f != NULL) {
int ret;
int res, size = 3;
@@ -424,7 +431,12 @@
int ret;
FILE *f;
- f = fopen(filename, "r");
+ /* '-' Usually means stdin -<sven@zen.org> */
+ if ((filename[0] == '-') && (filename[1] == 0)) {
+ f = stdin;
+ } else {
+ f = fopen(filename, "r");
+ }
if (f != NULL) {
xmlParserCtxtPtr ctxt;
@@ -633,7 +645,8 @@
xmlFreeDoc(doc);
}
-int main(int argc, char **argv) {
+int
+main(int argc, char **argv) {
int i, count;
int files = 0;
@@ -766,7 +779,8 @@
i++;
continue;
}
- if (argv[i][0] != '-') {
+ /* Remember file names. "-" means stding. <sven@zen.org> */
+ if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
if (repeat) {
for (count = 0;count < 100 * repeat;count++)
parseAndPrintFile(argv[i]);