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

Comparing ray/src/px/pcompos.c (file contents):
Revision 2.35 by greg, Tue Feb 2 18:02:32 2016 UTC vs.
Revision 2.42 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *     6/30/87
8   */
9  
10 #include  <stdio.h>
10   #include  <math.h>
12 #include  <time.h>
13 #include  <string.h>
11  
12   #include "copyright.h"
13  
14 + #include  "rtio.h"
15   #include  "platform.h"
18 #include  "paths.h"
16   #include  "rterror.h"
17   #include  "color.h"
18   #include  "resolu.h"
19  
20 + #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */
21 + #undef getc
22 + #define getc    getc_unlocked
23 + #endif
24 +
25   #define  MAXFILE        1024
26  
27   #define  HASMIN         1
# Line 44 | Line 46 | char  StandardInput[] = "<stdin>";
46   char  Command[] = "<Command>";
47   char  Label[] = "<Label>";
48  
47 char  *progname;
48
49   struct {
50          char  *name;                    /* file or command name */
51          FILE  *fp;                      /* stream pointer */
# Line 58 | Line 58 | struct {
58   int  nfile;                     /* number of files */
59  
60   int  echoheader = 1;
61 < char  ourfmt[LPICFMT+1] = PICFMT;
61 > char  ourfmt[MAXFMTLEN] = PICFMT;
62   int  wrongformat = 0;
63 + double  common_expos = 1.;
64  
65 + double  this_expos;
66  
67   static gethfunc headline;
68   static void compos(void);
# Line 75 | Line 77 | headline(                      /* print line preceded by a tab */
77          void    *p
78   )
79   {
80 <        char  fmt[32];
80 >        char  fmt[MAXFMTLEN];
81  
82          if (isheadid(s))
83                  return(0);
84 +        if (isexpos(s))
85 +                this_expos *= exposval(s);
86          if (formatval(fmt, s)) {
87                  if (globmatch(ourfmt, fmt)) {
88                          wrongformat = 0;
# Line 86 | Line 90 | headline(                      /* print line preceded by a tab */
90                  } else
91                          wrongformat = 1;
92          } else if (echoheader) {
93 <                putc('\t', stdout);
93 >                fputc('\t', stdout);
94                  fputs(s, stdout);
95          }
96          return(0);
# Line 105 | Line 109 | main(
109          int  xsgn, ysgn;
110          char  *thislabel;
111          int  an;
112 +
113          SET_DEFAULT_BINARY();
114          SET_FILE_BINARY(stdin);
115          SET_FILE_BINARY(stdout);
111        progname = argv[0];
116  
117 +        fixargv0(argv[0]);              /* sets global progname */
118 +
119          for (an = 1; an < argc && argv[an][0] == '-'; an++)
120                  switch (argv[an][1]) {
121                  case 'h':
# Line 230 | Line 236 | getfile:
236                                                  /* get header */
237                  if (echoheader)
238                          printf("%s:\n", input[nfile].name);
239 +                this_expos = 1;
240                  getheader(input[nfile].fp, headline, NULL);
241 +                if (!nfile)
242 +                        common_expos = this_expos;
243 +                else if (common_expos > 0 &&
244 +                                fabs(this_expos/common_expos - 1.) > 0.02)
245 +                        common_expos = 0;
246                  if (wrongformat) {
247                          fprintf(stderr, "%s: incompatible input format\n",
248                                          input[nfile].name);
# Line 304 | Line 316 | getfile:
316          }
317                                          /* add new header info. */
318          printargs(argc, argv, stdout);
319 +        if (common_expos > 0)           /* print exposure if shared */
320 +                fputexpos(common_expos, stdout);
321          if (strcmp(ourfmt, PICFMT))
322                  fputformat(ourfmt, stdout);     /* print format if known */
323          putchar('\n');

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines