--- ray/src/util/wrapBSDF.c 2020/07/21 15:24:42 2.25 +++ ray/src/util/wrapBSDF.c 2022/09/07 18:55:39 2.27 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: wrapBSDF.c,v 2.25 2020/07/21 15:24:42 greg Exp $"; +static const char RCSid[] = "$Id: wrapBSDF.c,v 2.27 2022/09/07 18:55:39 greg Exp $"; #endif /* * Wrap BSDF data in valid WINDOW XML file @@ -27,7 +27,7 @@ const char legal_units[] = "meter|foot|inch|centimeter /* system materials & geometry */ const char *mgf_geometry = NULL; /* comment list */ -#define MAXCOMM 30 +#define MAXCOMM 80 const char *commlist[MAXCOMM]; int ncomm = 0; /* angle bases */ @@ -417,12 +417,12 @@ determine_angle_basis(const char *fn, ezxml_t wtl) return -1; } -/* Filter Klems angle basis, factoring out incident projected solid angle */ +/* Filter Klems angle data, factoring out incident projected solid angle */ static int filter_klems_matrix(FILE *fp) { const char *bn = klems_basis_name[angle_basis]; - int i, j, n = nabases; + int i, j, c, n = nabases; /* get angle basis */ while (n-- > 0) if (!strcasecmp(bn, abase_list[n].name)) @@ -434,8 +434,10 @@ filter_klems_matrix(FILE *fp) const double corr = 1./io_getohm(i, &abase_list[n]); for (j = 0; j < abase_list[n].nangles; j++) { double d; - if (fscanf(fp, "%lf", &d) != 1) + if (fscanf(fp, "%lf ", &d) != 1) return 0; + if ((c = getc(fp)) != ',') + ungetc(c, fp); if (d < -1e-3) { fputs("Negative BSDF data!\n", stderr); return 0; @@ -444,8 +446,8 @@ filter_klems_matrix(FILE *fp) } fputc('\n', stdout); } - while ((i = getc(fp)) != EOF) - if (!isspace(i)) { + while ((c = getc(fp)) != EOF) + if (!isspace(c)) { fputs("Unexpected data past EOF\n", stderr); return 0; } @@ -817,7 +819,7 @@ main(int argc, char *argv[]) argv[0]); return 1; } - if (strchr(argv[++i], '>') != NULL) { + if (strstr(argv[++i], "-->") != NULL) { fprintf(stderr, "%s: illegal character in comment\n", argv[0]); return 1;