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

Comparing ray/src/util/rmatrix.c (file contents):
Revision 2.45 by greg, Fri Jan 15 02:46:28 2021 UTC vs.
Revision 2.46 by greg, Tue Jan 19 23:32:00 2021 UTC

# Line 203 | Line 203 | rmx_load_rgbe(RMATRIX *rm, FILE *fp)
203  
204   /* Load matrix from supported file type */
205   RMATRIX *
206 < rmx_load(const char *inspec)
206 > rmx_load(const char *inspec, RMPref rmp)
207   {
208 <        FILE            *fp = stdin;
208 >        FILE            *fp;
209          RMATRIX         dinfo;
210          RMATRIX         *dnew;
211  
212 <        if (!inspec) {                          /* reading from stdin? */
213 <                inspec = "<stdin>";
214 <                SET_FILE_BINARY(stdin);
212 >        if (!inspec || !*inspec)
213 >                return(NULL);
214 >        if (inspec == stdin_name) {             /* reading from stdin? */
215 >                fp = stdin;
216          } else if (inspec[0] == '!') {
217                  if (!(fp = popen(inspec+1, "r")))
218                          return(NULL);
218                SET_FILE_BINARY(fp);
219          } else {
220                  const char      *sp = inspec;   /* check suffix */
221                  while (*sp)
# Line 223 | Line 223 | rmx_load(const char *inspec)
223                  while (sp > inspec && sp[-1] != '.')
224                          --sp;
225                  if (!strcasecmp(sp, "XML")) {   /* assume it's a BSDF */
226 <                        CMATRIX *cm = cm_loadBTDF((char *)inspec);
226 >                        CMATRIX *cm = rmp==RMPtrans ? cm_loadBTDF(inspec) :
227 >                                        cm_loadBRDF(inspec, rmp==RMPreflB) ;
228                          if (!cm)
229                                  return(NULL);
230                          dnew = rmx_from_cmatrix(cm);
# Line 232 | Line 233 | rmx_load(const char *inspec)
233                          return(dnew);
234                  }
235                                                  /* else open it ourselves */
236 <                if (!(fp = fopen(inspec, "rb")))
236 >                if (!(fp = fopen(inspec, "r")))
237                          return(NULL);
238          }
239 +        SET_FILE_BINARY(fp);
240   #ifdef getc_unlocked
241          flockfile(fp);
242   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines