aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/register.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-09-26 19:35:12 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-09-26 19:35:12 +0200
commit435300f9304a230680bdc054d0f0b3a3205b05f7 (patch)
treebde12444cdd362a83c44e173b2730b752b0de18a /kernel/register.cc
parenta009314597b2d71cb786745c516e53dff4b21a00 (diff)
downloadyosys-435300f9304a230680bdc054d0f0b3a3205b05f7.tar.gz
yosys-435300f9304a230680bdc054d0f0b3a3205b05f7.tar.bz2
yosys-435300f9304a230680bdc054d0f0b3a3205b05f7.zip
Make read/write gzip files on macos works, fixes #1357
Diffstat (limited to 'kernel/register.cc')
-rw-r--r--kernel/register.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/kernel/register.cc b/kernel/register.cc
index 1fd1bad1d..8131fa279 100644
--- a/kernel/register.cc
+++ b/kernel/register.cc
@@ -48,7 +48,7 @@ using zlib to write gzip-compressed data every time the stream is flushed.
*/
class gzip_ostream : public std::ostream {
public:
- gzip_ostream()
+ gzip_ostream() : std::ostream(nullptr)
{
rdbuf(&outbuf);
}
@@ -71,7 +71,7 @@ private:
str("");
return 0;
}
- ~gzip_streambuf()
+ virtual ~gzip_streambuf()
{
sync();
gzclose(gzf);
@@ -498,7 +498,15 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
if (f != NULL) {
// Check for gzip magic
unsigned char magic[3];
- int n = readsome(*ff, reinterpret_cast<char*>(magic), 3);
+ int n = 0;
+ while (n < 3)
+ {
+ int c = ff->get();
+ if (c != EOF) {
+ magic[n] = (unsigned char) c;
+ }
+ n++;
+ }
if (n == 3 && magic[0] == 0x1f && magic[1] == 0x8b) {
#ifdef YOSYS_ENABLE_ZLIB
log("Found gzip magic in file `%s', decompressing using zlib.\n", filename.c_str());