--- ray/src/common/portio.c 2003/07/17 09:21:29 2.8 +++ ray/src/common/portio.c 2005/02/18 16:34:27 2.12 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: portio.c,v 2.8 2003/07/17 09:21:29 schorsch Exp $"; +static const char RCSid[] = "$Id: portio.c,v 2.12 2005/02/18 16:34:27 greg Exp $"; #endif /* * Portable i/o for binary files @@ -13,12 +13,14 @@ static const char RCSid[] = "$Id: portio.c,v 2.8 2003/ #include "rtio.h" -#ifndef frexp -extern double frexp(); +#include + +#ifdef getc_unlocked /* avoid horrendous overhead of flockfile */ +#undef getc +#undef putc +#define getc getc_unlocked +#define putc putc_unlocked #endif -#ifndef ldexp -extern double ldexp(); -#endif void @@ -101,6 +103,10 @@ FILE *fp; double d; l = getint(4, fp); + if (l == 0) { + getc(fp); /* exactly zero -- ignore exponent */ + return(0.0); + } d = (l + (l > 0 ? .5 : -.5)) * (1./0x7fffffff); return(ldexp(d, (int)getint(1, fp))); }