ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ambient.c
(Generate patch)

Comparing ray/src/rt/ambient.c (file contents):
Revision 2.16 by greg, Fri Jan 22 09:51:13 1993 UTC vs.
Revision 2.17 by greg, Tue Jan 26 09:08:20 1993 UTC

# Line 35 | Line 35 | double minarad;                /* minimum ambient radius */
35  
36   static AMBTREE  atrunk;         /* our ambient trunk node */
37  
38 static char  *ambfname = NULL;  /* ambient file name */
38   static FILE  *ambfp = NULL;     /* ambient file pointer */
39   static int  nunflshed = 0;      /* number of unflushed ambient values */
40  
# Line 75 | Line 74 | char  *afile;
74                                                  /* init ambient limits */
75          setambres(ambres);
76                                                  /* open ambient file */
77 <        if ((ambfname = afile) != NULL) {
77 >        if (afile != NULL) {
78                  if ((ambfp = fopen(afile, "r+")) != NULL) {
79                          initambfile(0);
80                          headlen = ftell(ambfp);
# Line 325 | Line 324 | int  creat;
324                  fputformat(AMBFMT, ambfp);
325                  putc('\n', ambfp);
326                  putambmagic(ambfp);
327 <        } else if (checkheader(ambfp, AMBFMT, NULL) < 0 || !hasambmagic(ambfp)) {
328 <                sprintf(errmsg, "bad ambient file \"%s\"", ambfname);
330 <                error(USER, errmsg);
331 <        }
327 >        } else if (checkheader(ambfp, AMBFMT, NULL) < 0 || !hasambmagic(ambfp))
328 >                error(USER, "bad ambient file");
329   }
330  
331  
# Line 346 | Line 343 | AMBVAL *av;
343                          goto writerr;
344          return;
345   writerr:
346 <        sprintf(errmsg, "error writing ambient file \"%s\"", ambfname);
350 <        error(SYSTEM, errmsg);
346 >        error(SYSTEM, "error writing ambient file");
347   }
348  
349  
# Line 426 | Line 422 | ambsync()                      /* synchronize ambient file */
422          if ((flen = lseek(fileno(ambfp), 0L, 2)) < 0)
423                  error(SYSTEM, "cannot seek on ambient file");
424          if (n = flen - lastpos) {               /* file has grown */
425 <                if (ambinp == NULL) {
426 <                        ambinp = fopen(ambfname, "r");
425 >                if (ambinp == NULL) {           /* use duplicate filedes */
426 >                        ambinp = fdopen(dup(fileno(ambfp)), "r");
427                          if (ambinp == NULL)
428 <                                error(SYSTEM, "fopen failed in ambsync");
428 >                                error(SYSTEM, "fdopen failed in ambsync");
429                  }
430                  if (fseek(ambinp, lastpos, 0) < 0)
431                          error(SYSTEM, "fseek failed in ambsync");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines