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

Comparing ray/src/common/writewfobj.c (file contents):
Revision 2.1 by greg, Mon Mar 30 18:28:35 2020 UTC vs.
Revision 2.3 by greg, Thu Apr 23 22:35:27 2020 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9   *  Created by Greg Ward on Thu Feb 12 2004.
10   */
11  
12 < #include <stdio.h>
13 < #include <stdlib.h>
14 < #include <string.h>
12 > #include "paths.h"
13   #include "rterror.h"
14   #include "objutil.h"
15  
# Line 222 | Line 220 | writeOBJ(Scene *sc, const char *fspec)
220                  if ((fp = popen(fspec+1, "w")) == NULL) {
221                          sprintf(errmsg, "%s: cannot execute", fspec);
222                          error(SYSTEM, errmsg);
223 <                        return(0);
223 >                        return(-1);
224                  }
225          } else
226   #endif
227          if ((fp = fopen(fspec, "w")) == NULL) {
228                  sprintf(errmsg, "%s: cannot open for writing", fspec);
229                  error(SYSTEM, errmsg);
230 <                return(0);
230 >                return(-1);
231          }
232                                                  /* start off header */
233          fprintf(fp, "# Wavefront .OBJ file created by %s\n#\n", progname);
234          n = toOBJ(sc, fp);                      /* write scene */
235   #if POPEN_SUPPORT
236 <        if (fspec[0] == '!')
237 <                pclose(fp);
238 <        else
236 >        if (fspec[0] == '!') {
237 >                if (pclose(fp)) {
238 >                        sprintf(errmsg, "%s: error writing to command\n", fspec);
239 >                        error(SYSTEM, errmsg);
240 >                        return(-1);
241 >                }
242 >        } else
243   #endif
244 <        fclose(fp);                             /* close it */
244 >        fclose(fp);                             /* close it (already flushed) */
245          return(n);
246   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines