diff options
Diffstat (limited to 'URPM.xs')
-rw-r--r-- | URPM.xs | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -20,7 +20,6 @@ #include <sys/wait.h> #include <fcntl.h> #include <unistd.h> -#include <zlib.h> #include <libintl.h> // fix compiling (error: conflicting types for ‘fflush’): @@ -2845,12 +2844,13 @@ Urpm_parse_synthesis__XS(urpm, filename, ...) if (depslist != NULL) { char buff[65536]; - char *p, *eol; + char *p, *eol, *t; int buff_len; struct s_Package pkg; - gzFile f; + FD_t f = NULL; int start_id = 1 + av_len(depslist); SV *callback = NULL; + rpmCompressedMagic compressed = COMPRESSED_OTHER; if (items > 2) { int i; @@ -2864,12 +2864,25 @@ Urpm_parse_synthesis__XS(urpm, filename, ...) } PUTBACK; - if ((f = gzopen(filename, "rb")) != NULL) { + int rc = rpmFileIsCompressed(filename, &compressed); + + switch (compressed) { + case COMPRESSED_BZIP2: t = "r.bzip2"; break; + case COMPRESSED_LZMA: + case COMPRESSED_XZ: + t = "r.xz"; break; + case COMPRESSED_OTHER: + default: + t = "r.gzip"; break; + } + f = Fopen(filename, "r.fdio"); + + if (!rc && (f = Fdopen(f, t)) != NULL && !Ferror(f)) { memset(&pkg, 0, sizeof(struct s_Package)); buff[sizeof(buff)-1] = 0; p = buff; int ok = 1; - while ((buff_len = gzread(f, p, sizeof(buff)-1-(p-buff))) >= 0 && + while ((buff_len = Fread(p, sizeof(buff)-1-(p-buff), 1, f)) >= 0 && (buff_len += p-buff)) { buff[buff_len] = 0; p = buff; @@ -2888,17 +2901,15 @@ Urpm_parse_synthesis__XS(urpm, filename, ...) ok = 0; break; } - if (gzeof(f)) { - if (!parse_line(depslist, provides, obsoletes, &pkg, p, urpm, callback)) ok = 0; - break; - } else { /* move the remaining non-complete-line at beginning */ memmove(buff, p, buff_len-(p-buff)); /* point to the end of the non-complete-line */ p = &buff[buff_len-(p-buff)]; - } } - if (gzclose(f) != 0) ok = 0; + // EOF: + if (!parse_line(depslist, provides, obsoletes, &pkg, p, urpm, callback)) + ok = 0; + if (Fclose(f) != 0) ok = 0; SPAGAIN; if (ok) { mXPUSHs(newSViv(start_id)); |