Skip to content

Commit

Permalink
Update fstapi.c to latest from gtkwave 3.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
caryr authored and steveicarus committed Jul 20, 2010
1 parent 30fa8f6 commit 44b08a4
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions vpi/fstapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#define FST_DO_MISALIGNED_OPS
#endif

#if defined(__APPLE__) && defined(__MACH__)
#define FST_MACOSX
#endif


/***********************/
/*** ***/
Expand Down Expand Up @@ -2186,8 +2190,7 @@ if(!xc->fh)
off_t offs_cache = ftello(xc->f);
char *fnam = malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
unsigned char *mem = malloc(FST_GZIO_LEN);
off_t hl;
uint64_t uclen;
off_t hl, uclen;
gzFile zhandle;
int zfd;

Expand Down Expand Up @@ -2223,14 +2226,22 @@ if(!xc->fh)

for(hl = 0; hl < uclen; hl += FST_GZIO_LEN)
{
unsigned len = ((uclen - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - hl);
int gzreadlen = gzread(zhandle, mem, len); /* rc should equal len... */
size_t len = ((uclen - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - hl);
size_t gzreadlen = gzread(zhandle, mem, len); /* rc should equal len... */
size_t fwlen;

if(gzreadlen != len)
{
pass_status = 0;
break;
}
fstFwrite(mem, len, 1, xc->fh);

fwlen = fstFwrite(mem, len, 1, xc->fh);
if(fwlen != 1)
{
pass_status = 0;
break;
}
}
gzclose(zhandle);
free(mem);
Expand Down Expand Up @@ -2625,6 +2636,10 @@ if(sectype == FST_BL_ZWRAPPER)
if(!fcomp) return(0);
}

#if defined(FST_MACOSX)
setvbuf(fcomp, (char *)NULL, _IONBF, 0); /* keeps gzip from acting weird in tandem with fopen */
#endif

#ifdef __MINGW32__
setvbuf(fcomp, (char *)NULL, _IONBF, 0); /* keeps gzip from acting weird in tandem with fopen */
xc->filename_unpacked = hf;
Expand All @@ -2646,13 +2661,20 @@ if(sectype == FST_BL_ZWRAPPER)
for(offpnt = 0; offpnt < uclen; offpnt += FST_GZIO_LEN)
{
size_t this_len = ((uclen - offpnt) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - offpnt);
int gzreadlen = gzread(zhandle, gz_membuf, this_len);
size_t gzreadlen = gzread(zhandle, gz_membuf, this_len);
size_t fwlen;

if(gzreadlen != this_len)
{
gzread_pass_status = 0;
break;
}
fstFwrite(gz_membuf, this_len, 1, fcomp);
fwlen = fstFwrite(gz_membuf, this_len, 1, fcomp);
if(fwlen != 1)
{
gzread_pass_status = 0;
break;
}
}
gzclose(zhandle);
}
Expand Down Expand Up @@ -2888,7 +2910,7 @@ if((!nam)||(!(xc->f=fopen(nam, "rb"))))
char *hf = calloc(1, flen + 6);
int rc;

#ifdef __MINGW32__
#if defined(__MINGW32__) || defined(FST_MACOSX)
setvbuf(xc->f, (char *)NULL, _IONBF, 0); /* keeps gzip from acting weird in tandem with fopen */
#endif

Expand Down

0 comments on commit 44b08a4

Please sign in to comment.