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.11 by greg, Wed Jun 4 22:34:27 2025 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines