--- ray/src/common/color.c 1991/08/28 08:39:47 1.15 +++ ray/src/common/color.c 1993/02/26 10:08:50 2.5 @@ -15,16 +15,21 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" #define MINELEN 8 /* minimum scanline length for encoding */ +#define MAXELEN 0x7ffe /* maximum scanline length for encoding */ #define MINRUN 4 /* minimum run length */ +#ifndef frexp +extern double frexp(); +#endif + char * tempbuffer(len) /* get a temporary buffer */ unsigned len; { extern char *malloc(), *realloc(); static char *tempbuf = NULL; - static int tempbuflen = 0; + static unsigned tempbuflen = 0; if (len > tempbuflen) { if (tempbuflen > 0) @@ -39,18 +44,17 @@ unsigned len; fwritecolrs(scanline, len, fp) /* write out a colr scanline */ register COLR *scanline; -int len; +unsigned len; register FILE *fp; { register int i, j, beg, cnt; int c2; - if (len < MINELEN) /* too small to encode */ + if (len < MINELEN | len > MAXELEN) /* OOBs, write out flat */ return(fwrite((char *)scanline,sizeof(COLR),len,fp) - len); - if (len > 32767) /* too big! */ - return(-1); - putc(2, fp); /* put magic header */ + /* put magic header */ putc(2, fp); + putc(2, fp); putc(len>>8, fp); putc(len&255, fp); /* put components seperately */ @@ -98,7 +102,7 @@ register FILE *fp; register int i, j; int code; /* determine scanline type */ - if (len < MINELEN) + if (len < MINELEN | len > MAXELEN) return(oldreadcolrs(scanline, len, fp)); if ((i = getc(fp)) == EOF) return(-1); @@ -226,7 +230,6 @@ setcolr(clr, r, g, b) /* assign a short color value * register COLR clr; double r, g, b; { - double frexp(); double d; int e;