--- ray/src/rt/rv2.c 1991/07/18 16:37:59 1.24 +++ ray/src/rt/rv2.c 1991/10/10 12:08:58 1.28 @@ -1,4 +1,4 @@ -/* Copyright (c) 1987 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -306,6 +306,7 @@ char *str, *dsc; int typ; register union {int i; double d; COLOR C;} *ptr; { + extern char *index(); int i0; double d0, d1, d2; char buf[48]; @@ -339,8 +340,11 @@ register union {int i; double d; COLOR C;} *ptr; sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n'); (*dev->comout)(buf); (*dev->comin)(buf, NULL); + if (buf[0] == '\0' || + index("yY+1tTnN-0fF", buf[0]) == NULL) + break; } - ptr->i = tolower(buf[0]) == 'y'; + ptr->i = index("yY+1tT", buf[0]) != NULL; break; case 'C': /* color */ if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { @@ -468,6 +472,7 @@ register char *s; break; default:; badparam: + *sskip(s) = '\0'; sprintf(errmsg, "%s: unknown variable", s); error(COMMAND, errmsg); break; @@ -537,6 +542,7 @@ char *s; writepict(s) /* write the picture to a file */ char *s; { + extern char VersionID[]; static char buf[128]; char *fname; FILE *fp; @@ -560,6 +566,7 @@ char *s; fputs(progname, fp); fprintview(&ourview, fp); putc('\n', fp); + fprintf(fp, "SOFTWARE= %s\n", VersionID); if (exposure != 1.0) fputexpos(exposure, fp); if (dev->pixaspect != 1.0) @@ -569,14 +576,18 @@ char *s; fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); scanline = (COLR *)malloc(hresolu*sizeof(COLR)); - if (scanline == NULL) - error(SYSTEM, "out of memory in writepict"); + if (scanline == NULL) { + error(COMMAND, "not enough memory!"); + fclose(fp); + unlink(fname); + return; + } for (y = vresolu-1; y >= 0; y--) { getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); if (fwritecolrs(scanline, hresolu, fp) < 0) break; } + free((char *)scanline); if (fclose(fp) < 0) error(COMMAND, "write error"); - free((char *)scanline); }