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

Comparing ray/src/util/rcode_norm.c (file contents):
Revision 2.6 by greg, Wed Nov 13 18:20:47 2019 UTC vs.
Revision 2.12 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   #include "rtmath.h"
14   #include "normcodec.h"
15  
16 char            *progname;              /* set in main() */
16  
18
17   /* Report usage error and exit */
18   static void
19   usage_exit(int code)
# Line 38 | Line 36 | encode_normals(NORMCODEC *ncp)
36          long    nexpected = (long)ncp->res.xr * ncp->res.yr;
37  
38          if (ncp->inpfmt[0]) {
39 <                if (strstr(ncp->inpfmt, "ascii") != NULL)
39 >                if (!strcmp(ncp->inpfmt, "ascii"))
40                          ncp->format = 'a';
41 <                else if (strstr(ncp->inpfmt, "float") != NULL)
41 >                else if (!strcmp(ncp->inpfmt, "float"))
42                          ncp->format = 'f';
43 <                else if (strstr(ncp->inpfmt, "double") != NULL)
43 >                else if (!strcmp(ncp->inpfmt, "double"))
44                          ncp->format = 'd';
45                  else {
46                          fputs(ncp->inpname, stderr);
# Line 52 | Line 50 | encode_normals(NORMCODEC *ncp)
50                          return 0;
51                  }
52          }
53 +        if (ncp->format == 'a')
54 +                SET_FILE_TEXT(ncp->finp);
55  
56          do {
57                  int     ok = 0;
# Line 189 | Line 189 | pixel_normals(NORMCODEC *ncp, int unbuf)
189                  fputs(": can only handle standard pixel ordering\n", stderr);
190                  return 0;
191          }
192 +
193          while (scanf("%d %d", &x, &y) == 2) {
194  
195                  y = ncp->res.yr-1 - y;
# Line 222 | Line 223 | main(int argc, char *argv[])
223          int             unbuffered = 0;
224          NORMCODEC       nc;
225          int             a;
226 <
227 <        progname = argv[0];
226 >                                        /* set global progname */
227 >        fixargv0(argv[0]);
228          set_nc_defaults(&nc);
229          nc.hdrflags = HF_ALL;
230          for (a = 1; a < argc && argv[a][0] == '-'; a++)
# Line 339 | Line 340 | main(int argc, char *argv[])
340                  fputs(": cannot open for writing\n", stderr);
341                  return 1;
342          }
343 <        SET_FILE_BINARY(nc.finp);
344 <        if (reverse || nc.format != 'a')
344 <                SET_FILE_BINARY(stdout);
343 >        SET_FILE_BINARY(nc.finp);       /* starting assumption */
344 >        SET_FILE_BINARY(stdout);
345   #ifdef getc_unlocked                    /* avoid stupid semaphores */
346          flockfile(nc.finp);
347          flockfile(stdout);
# Line 349 | Line 349 | main(int argc, char *argv[])
349                                          /* read/copy header */
350          if (!process_nc_header(&nc, a, argv))
351                  return 1;
352 +
353 +        if (reverse && nc.format == 'a')
354 +                SET_FILE_TEXT(stdout);
355                                          /* process data */
356          if (!reverse) {
357                  if (!encode_normals(&nc))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines