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

Comparing ray/src/util/getinfo.c (file contents):
Revision 2.18 by greg, Sat Jul 6 14:08:07 2019 UTC vs.
Revision 2.20 by greg, Fri Jul 19 17:37:56 2019 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *     1/3/86
8   */
9  
10 < #include  <stdio.h>
11 < #include  <string.h>
12 <
10 > #include  "rtio.h"
11   #include  "platform.h"
12   #include  "rtprocess.h"
13   #include  "resolu.h"
# Line 54 | Line 52 | main(
52          FILE  *fp;
53          int  i;
54  
55 <        if (argc > 1 && !strcmp(argv[1], "-d")) {
55 >        if (argc > 1 && (argv[1][0] == '-') | (argv[1][0] == '+') &&
56 >                        argv[1][1] == 'd') {
57 >                dim = 1 - 2*(argv[1][0] == '-');
58                  argc--; argv++;
59                dim = 1;
59          }
60   #ifdef getc_unlocked                            /* avoid lock/unlock overhead */
61          flockfile(stdin);
# Line 75 | Line 74 | main(
74                                  fputs("No resolution string\n", stderr);
75                                  return 1;
76                          }
77 <                        fputsresolu(&rs, stdout);
77 >                        if (dim > 0)
78 >                                fputsresolu(&rs, stdout);
79                  }
80                  fflush(stdout);
81                  execvp(argv[2], argv+2);
# Line 99 | Line 99 | main(
99                  SET_FILE_BINARY(stdout);
100                  if (getheader(stdin, NULL, NULL) < 0)
101                          return 1;
102 <                if (dim) {                      /* skip resolution string? */
102 >                if (dim < 0) {                  /* skip resolution string? */
103                          RESOLU  rs;
104                          if (!fgetsresolu(&rs, stdin)) {
105                                  fputs("No resolution string\n", stderr);
# Line 114 | Line 114 | main(
114                  if ((fp = fopen(argv[i], "r")) == NULL)
115                          fputs(": cannot open\n", stdout);
116                  else {
117 <                        if (dim) {
117 >                        if (dim < 0) {                  /* dimensions only */
118 >                                if (getheader(fp, NULL, NULL) < 0) {
119 >                                        fputs("bad header\n", stdout);
120 >                                        continue;      
121 >                                }
122                                  fputs(": ", stdout);
123                                  getdim(fp);
124                          } else {
125                                  tabstr(":\n", NULL);
126 <                                getheader(fp, tabstr, NULL);
126 >                                if (getheader(fp, tabstr, NULL) < 0)
127 >                                        return 1;
128                                  fputc('\n', stdout);
129 +                                if (dim > 0) {
130 +                                        fputc('\t', stdout);
131 +                                        getdim(fp);
132 +                                }
133                          }
134                          fclose(fp);
135                  }
136          }
137          if (argc == 1) {
138 <                if (dim) {
138 >                if (dim < 0) {
139 >                        if (getheader(stdin, NULL, NULL) < 0)
140 >                                return 1;      
141                          getdim(stdin);
142                  } else {
143                          if (getheader(stdin, (gethfunc *)fputs, stdout) < 0)
144                                  return 1;
145                          fputc('\n', stdout);
146 +                        if (dim > 0)
147 +                                getdim(stdin);
148                  }
149          }
150          return 0;
# Line 145 | Line 158 | getdim(                                /* get dimensions from file */
158   {
159          int  j;
160          int  c;
161 <                                /* skip header */
149 <        if (getheader(fp, NULL, NULL) < 0) {
150 <                fputs("bad header\n", stdout);
151 <                return;
152 <        }
161 >
162          switch (c = getc(fp)) {
163          case '+':               /* picture */
164          case '-':

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines