X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=xmlIO.c;h=e628ab094c9313d13be0985deca0ab37e408aba4;hb=01021030a4e2b351e9ce5f5af13aaf1c14ba0648;hp=847cb7edbbda1c5bfc7c2c3b2ad03a5bfe219dcf;hpb=4e8fa1efca3c71ef7e0c515afb175e849a97d416;p=platform%2Fupstream%2Flibxml2.git diff --git a/xmlIO.c b/xmlIO.c index 847cb7e..e628ab0 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -800,6 +800,13 @@ xmlCheckFilename (const char *path) return 1; } +/** + * xmlNop: + * + * No Operation function, does nothing, no input + * + * Returns zero + */ int xmlNop(void) { return(0); @@ -887,7 +894,7 @@ xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) { */ static void * xmlFileOpen_real (const char *filename) { - const char *path = NULL; + const char *path = filename; FILE *fd; if (filename == NULL) @@ -917,11 +924,8 @@ xmlFileOpen_real (const char *filename) { #else path = &filename[5]; #endif - } else - path = filename; + } - if (path == NULL) - return(NULL); if (!xmlCheckFilename(path)) return(NULL); @@ -1159,7 +1163,12 @@ xmlGzfileOpen_real (const char *filename) { gzFile fd; if (!strcmp(filename, "-")) { - fd = gzdopen(dup(0), "rb"); + int duped_fd = dup(fileno(stdin)); + fd = gzdopen(duped_fd, "rb"); + if (fd == Z_NULL && duped_fd >= 0) { + close(duped_fd); /* gzdOpen() does not close on failure */ + } + return((void *) fd); } @@ -1233,7 +1242,12 @@ xmlGzfileOpenW (const char *filename, int compression) { snprintf(mode, sizeof(mode), "wb%d", compression); if (!strcmp(filename, "-")) { - fd = gzdopen(dup(1), mode); + int duped_fd = dup(fileno(stdout)); + fd = gzdopen(duped_fd, "rb"); + if (fd == Z_NULL && duped_fd >= 0) { + close(duped_fd); /* gzdOpen() does not close on failure */ + } + return((void *) fd); } @@ -1355,7 +1369,7 @@ xmlXzfileOpen_real (const char *filename) { xzFile fd; if (!strcmp(filename, "-")) { - fd = __libxml2_xzdopen(dup(0), "rb"); + fd = __libxml2_xzdopen(dup(fileno(stdin)), "rb"); return((void *) fd); } @@ -2669,6 +2683,12 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { #endif } #endif +#ifdef HAVE_LZMA_H + if ((xmlInputCallbackTable[i].opencallback == xmlXzfileOpen) && + (strcmp(URI, "-") != 0)) { + ret->compressed = __libxml2_xzcompressed(context); + } +#endif } else xmlInputCallbackTable[i].closecallback (context); @@ -3325,6 +3345,17 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) { if (res < 0) { return(-1); } + + /* + * try to establish compressed status of input if not done already + */ + if (in->compressed == -1) { +#ifdef HAVE_LZMA_H + if (in->readcallback == xmlXzfileRead) + in->compressed = __libxml2_xzcompressed(in->context); +#endif + } + len = res; if (in->encoder != NULL) { unsigned int use;