]> git.pld-linux.org Git - packages/libxml2.git/blob - libxml2-open.gz.patch
up to 2.12.1
[packages/libxml2.git] / libxml2-open.gz.patch
1 --- libxml2-2.10.0/xmlIO.c.orig 2022-08-18 16:29:32.843322082 +0200
2 +++ libxml2-2.10.0/xmlIO.c      2022-08-18 16:32:12.985787850 +0200
3 @@ -1115,8 +1115,33 @@ xmlGzfileOpen_real (const char *filename
4  
5      if (path == NULL)
6         return(NULL);
7 -    if (!xmlCheckFilename(path))
8 -        return(NULL);
9 +    if (!xmlCheckFilename(path)) {
10 +       /* If we cannot open `foo.xml', we try `foo.xml.gz'. However we i
11 +        * append .gz only if filename doesn't alreay end with .gz. */
12 +       if (strlen(path) < 3 || strcmp(path + strlen(path) - 3, ".gz") != 0) {
13 +           char *gz_filename = xmlMalloc(strlen(path) + 4);
14 +
15 +           if (gz_filename == NULL) {
16 +               xmlGenericError(xmlGenericErrorContext,
17 +                               "xmlGzfileOpen:  %s\n",
18 +                               "Failure allocating buffer for filename.");
19 +               return NULL;
20 +           }
21 +
22 +           strcpy(gz_filename, path);
23 +           strcat(gz_filename, ".gz");
24 +
25 +           fd = NULL;
26 +
27 +           if (xmlCheckFilename(gz_filename))
28 +               fd = gzopen(gz_filename, "rb");
29 +
30 +           xmlFree(gz_filename);
31 +            
32 +           return((void *) fd);
33 +       } else
34 +           return NULL;
35 +    }
36  
37  #if defined(_WIN32)
38      fd = xmlWrapGzOpenUtf8(path, "rb");
This page took 0.028454 seconds and 3 git commands to generate.