From 29b5924fea5ba3a7033079292d8129a6d882e364 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 23 May 2011 13:05:28 +0200 Subject: [PATCH] - fix gzdopen() call, it does not like mode "r+" --- examples/pysolv | 2 +- examples/solv.c | 2 +- ext/sat_xfopen.c | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/pysolv b/examples/pysolv index f6ea3bd1..045cf352 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -495,7 +495,7 @@ class repo_susetags(repo_generic): di = self.handle.Dataiterator(solv.SOLVID_META, solv.SUSETAGS_FILE_NAME, None, 0) di.prepend_keyname(solv.SUSETAGS_FILE) for d in di: - filename = d.str + filename = d.str() if not filename: continue if filename[0:9] != "packages.": diff --git a/examples/solv.c b/examples/solv.c index 70461813..75418c07 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -850,7 +850,7 @@ curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsign return 0; } if (uncompress) - return sat_xfopen_fd(".gz", fd, 0); + return sat_xfopen_fd(".gz", fd, "r"); fcntl(fd, F_SETFD, FD_CLOEXEC); return fdopen(fd, "r"); } diff --git a/ext/sat_xfopen.c b/ext/sat_xfopen.c index 07fcfe37..cf943cf7 100644 --- a/ext/sat_xfopen.c +++ b/ext/sat_xfopen.c @@ -80,7 +80,12 @@ sat_xfopen_fd(const char *fn, int fd, const char *mode) if (fl == O_WRONLY) mode = "w"; else if (fl == O_RDWR) - mode = "r+"; + { + if (!suf || strcmp(suf, ".gz") != 0) + mode = "r+"; + else + mode = "r"; + } else mode = "r"; } -- 2.47.2