From b79859426e7ad57f37fbb56297707e6bc9cbc6fa Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 1 Sep 2016 11:45:18 +0100 Subject: [PATCH 1/2] fclose() the memstream when we are done with it The documentation says The locations pointed to by ptr and sizeloc are used to report, respectively, the current location and the size of the buffer. The locations referred to by these pointers are updated each time the stream is flushed (fflush(3)) and when the stream is closed (fclose(3)). so we need to close it before reading from the pointer. To do this we move the memstream handling into the `if` block where it is needed. --- source/utils.d | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/utils.d b/source/utils.d index e741edec..e75384ea 100644 --- a/source/utils.d +++ b/source/utils.d @@ -411,21 +411,21 @@ string[] getFileContents (const string path, const uint retryCount = 5) @trusted size_t sz = 0; - auto f = open_memstream (&ptr, &sz); - scope (exit) fclose (f); - - auto file = File.wrapFile (f); - if (path.isRemote) { - download (path, file, retryCount); + { + auto f = open_memstream (&ptr, &sz); + scope (exit) fclose (f); + auto file = File.wrapFile (f); + download (path, file, retryCount); + } + + return to!string (ptr.fromStringz).splitLines; } else { if (!std.file.exists (path)) throw new Exception ("No such file '%s'", path); return std.file.readText (path).splitLines; } - - return to!string (ptr.fromStringz).splitLines; } /** From 575f7ea446ba287018552a4c166ff64ff3d4fb73 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 1 Sep 2016 11:46:22 +0100 Subject: [PATCH 2/2] debpkgindex: Be less noisy about translations in debug mode --- source/backends/debian/debpkgindex.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/backends/debian/debpkgindex.d b/source/backends/debian/debpkgindex.d index 393dacb7..45a05cfd 100644 --- a/source/backends/debian/debpkgindex.d +++ b/source/backends/debian/debpkgindex.d @@ -94,6 +94,8 @@ public: { immutable langs = findTranslations (suite, section); + logDebug ("Found translations for: %s", langs.join(", ")); + foreach (const ref lang; langs) { string fname; @@ -117,7 +119,6 @@ public: auto tagf = new TagFile (); tagf.open (fname); - logDebug ("Opened: %s", fname); do { auto pkgname = tagf.readField ("Package"); auto rawDesc = tagf.readField ("Description-%s".format (lang));