diff -ur libxml2-2.4.20/xmlIO.c libxml2-2.4.20-/xmlIO.c --- libxml2-2.4.20/xmlIO.c Wed Mar 27 04:35:12 2002 +++ libxml2-2.4.20-/xmlIO.c Thu May 23 20:35:12 2002 @@ -465,8 +465,35 @@ if (path == NULL) return(NULL); - if (!xmlCheckFilename(path)) - return(NULL); + + if (!xmlCheckFilename(path)) { + /* If we cannot open `foo.xml', we try `foo.xml.gz'. However we i + * append .gz only if filename doesn't alreay end with .gz. */ + if (strlen(path) < 3 || strcmp(path + strlen(path) - 3, ".gz") != 0) { + char *gz_filename = xmlMalloc(strlen(path) + 4); + + if (gz_filename == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlGzfileOpen: %s\n", + "Failure allocating buffer for filename."); + return NULL; + } + + strcpy(gz_filename, path); + strcat(gz_filename, ".gz"); + + fd = NULL; + + if (xmlCheckFilename(gz_filename)) + fd = gzopen(gz_filename, "rb"); + + xmlFree(gz_filename); + + return((void *) fd); + } else { + return NULL; + } + } fd = gzopen(path, "rb"); return((void *) fd);