Update fstapi.c to latest from gtkwave 3.3.10
(cherry picked from commit 44b08a4630)
This commit is contained in:
parent
39b91f604a
commit
3c2e4a3a7b
38
vpi/fstapi.c
38
vpi/fstapi.c
|
|
@ -38,6 +38,10 @@
|
||||||
#define FST_DO_MISALIGNED_OPS
|
#define FST_DO_MISALIGNED_OPS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
#define FST_MACOSX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***********************/
|
/***********************/
|
||||||
/*** ***/
|
/*** ***/
|
||||||
|
|
@ -2186,8 +2190,7 @@ if(!xc->fh)
|
||||||
off_t offs_cache = ftello(xc->f);
|
off_t offs_cache = ftello(xc->f);
|
||||||
char *fnam = malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
|
char *fnam = malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
|
||||||
unsigned char *mem = malloc(FST_GZIO_LEN);
|
unsigned char *mem = malloc(FST_GZIO_LEN);
|
||||||
off_t hl;
|
off_t hl, uclen;
|
||||||
uint64_t uclen;
|
|
||||||
gzFile zhandle;
|
gzFile zhandle;
|
||||||
int zfd;
|
int zfd;
|
||||||
|
|
||||||
|
|
@ -2223,14 +2226,22 @@ if(!xc->fh)
|
||||||
|
|
||||||
for(hl = 0; hl < uclen; hl += FST_GZIO_LEN)
|
for(hl = 0; hl < uclen; hl += FST_GZIO_LEN)
|
||||||
{
|
{
|
||||||
unsigned len = ((uclen - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - hl);
|
size_t len = ((uclen - hl) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - hl);
|
||||||
int gzreadlen = gzread(zhandle, mem, len); /* rc should equal len... */
|
size_t gzreadlen = gzread(zhandle, mem, len); /* rc should equal len... */
|
||||||
|
size_t fwlen;
|
||||||
|
|
||||||
if(gzreadlen != len)
|
if(gzreadlen != len)
|
||||||
{
|
{
|
||||||
pass_status = 0;
|
pass_status = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fstFwrite(mem, len, 1, xc->fh);
|
|
||||||
|
fwlen = fstFwrite(mem, len, 1, xc->fh);
|
||||||
|
if(fwlen != 1)
|
||||||
|
{
|
||||||
|
pass_status = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gzclose(zhandle);
|
gzclose(zhandle);
|
||||||
free(mem);
|
free(mem);
|
||||||
|
|
@ -2625,6 +2636,10 @@ if(sectype == FST_BL_ZWRAPPER)
|
||||||
if(!fcomp) return(0);
|
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__
|
#ifdef __MINGW32__
|
||||||
setvbuf(fcomp, (char *)NULL, _IONBF, 0); /* keeps gzip from acting weird in tandem with fopen */
|
setvbuf(fcomp, (char *)NULL, _IONBF, 0); /* keeps gzip from acting weird in tandem with fopen */
|
||||||
xc->filename_unpacked = hf;
|
xc->filename_unpacked = hf;
|
||||||
|
|
@ -2646,13 +2661,20 @@ if(sectype == FST_BL_ZWRAPPER)
|
||||||
for(offpnt = 0; offpnt < uclen; offpnt += FST_GZIO_LEN)
|
for(offpnt = 0; offpnt < uclen; offpnt += FST_GZIO_LEN)
|
||||||
{
|
{
|
||||||
size_t this_len = ((uclen - offpnt) > FST_GZIO_LEN) ? FST_GZIO_LEN : (uclen - offpnt);
|
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)
|
if(gzreadlen != this_len)
|
||||||
{
|
{
|
||||||
gzread_pass_status = 0;
|
gzread_pass_status = 0;
|
||||||
break;
|
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);
|
gzclose(zhandle);
|
||||||
}
|
}
|
||||||
|
|
@ -2888,7 +2910,7 @@ if((!nam)||(!(xc->f=fopen(nam, "rb"))))
|
||||||
char *hf = calloc(1, flen + 6);
|
char *hf = calloc(1, flen + 6);
|
||||||
int rc;
|
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 */
|
setvbuf(xc->f, (char *)NULL, _IONBF, 0); /* keeps gzip from acting weird in tandem with fopen */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue