--- ray/src/util/radcompare.c 2018/10/19 23:50:32 2.13 +++ ray/src/util/radcompare.c 2018/10/19 23:56:15 2.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: radcompare.c,v 2.13 2018/10/19 23:50:32 greg Exp $"; +static const char RCSid[] = "$Id: radcompare.c,v 2.14 2018/10/19 23:56:15 greg Exp $"; #endif /* * Compare Radiance files for significant differences @@ -75,12 +75,12 @@ LUTAB hdr2 = LU_SINIT(free,free); lin2cnt += (htp == &hdr2)) typedef struct { /* dynamic line buffer */ - char *ptr; + char *str; int len; int siz; } LINEBUF; -#define init_line(bp) ((bp)->ptr = NULL, (bp)->siz = 0) +#define init_line(bp) ((bp)->str = NULL, (bp)->siz = 0) /* 100 MByte limit on line buffer */ #define MAXBUF (100L<<20) @@ -110,14 +110,14 @@ static int read_line(LINEBUF *bp, FILE *fp) { bp->len = 0; - if (!bp->ptr) { - bp->ptr = (char *)malloc(bp->siz = 512); - if (!bp->ptr) + if (!bp->str) { + bp->str = (char *)malloc(bp->siz = 512); + if (!bp->str) goto memerr; } - while (fgets(bp->ptr + bp->len, bp->siz - bp->len, fp)) { - bp->len += strlen(bp->ptr + bp->len); - if (bp->ptr[bp->len-1] == '\n') + while (fgets(bp->str + bp->len, bp->siz - bp->len, fp)) { + bp->len += strlen(bp->str + bp->len); + if (bp->str[bp->len-1] == '\n') break; /* found EOL */ if (bp->len < bp->siz - 4) continue; /* at EOF? */ @@ -125,8 +125,8 @@ read_line(LINEBUF *bp, FILE *fp) break; /* don't go to extremes */ if ((bp->siz += bp->siz/2) > MAXBUF) bp->siz = MAXBUF; - bp->ptr = (char *)realloc(bp->ptr, bp->siz); - if (!bp->ptr) + bp->str = (char *)realloc(bp->str, bp->siz); + if (!bp->str) goto memerr; } return(bp->len); @@ -141,7 +141,7 @@ memerr: static void free_line(LINEBUF *bp) { - if (bp->ptr) free(bp->ptr); + if (bp->str) free(bp->str); init_line(bp); } @@ -504,12 +504,12 @@ compare_text() init_line(&l1buf); init_line(&l2buf); /* compare a line at a time */ while (read_line(&l1buf, f1in)) { lin1cnt++; - if (!*sskip2(l1buf.ptr,0)) + if (!*sskip2(l1buf.str,0)) continue; /* ignore empty lines */ while (read_line(&l2buf, f2in)) { lin2cnt++; - if (*sskip2(l2buf.ptr,0)) + if (*sskip2(l2buf.str,0)) break; /* found other non-empty line */ } if (!l2buf.len) { /* input 2 EOF? */ @@ -521,7 +521,7 @@ compare_text() return(0); } /* compare non-empty lines */ - if (!equiv_string(l1buf.ptr, l2buf.ptr)) { + if (!equiv_string(l1buf.str, l2buf.str)) { if (report != REP_QUIET) { printf("%s: inputs '%s' and '%s' differ at line %d|%d\n", progname, f1name, f2name, @@ -531,9 +531,9 @@ compare_text() (l2buf.len < 256) ) { fputs("------------- Mismatch -------------\n", stdout); printf("%s@%d:\t%s", f1name, - lin1cnt, l1buf.ptr); + lin1cnt, l1buf.str); printf("%s@%d:\t%s", f2name, - lin2cnt, l2buf.ptr); + lin2cnt, l2buf.str); } } free_line(&l1buf); free_line(&l2buf); @@ -542,7 +542,7 @@ compare_text() } free_line(&l1buf); /* check for EOF on input 2 */ while (read_line(&l2buf, f2in)) { - if (!*sskip2(l2buf.ptr,0)) + if (!*sskip2(l2buf.str,0)) continue; if (report != REP_QUIET) { fputs(f1name, stdout);