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

Comparing ray/src/util/rcode_ident.c (file contents):
Revision 2.4 by greg, Tue Jul 23 17:23:25 2019 UTC vs.
Revision 2.9 by greg, Fri Jul 26 18:38:39 2019 UTC

# Line 73 | Line 73 | scan_ident(char ident[MAXIDLEN], FILE *fp)
73   static int
74   headline(char *s, void *p)
75   {
76 <        extern const char       FMTSTR[];
77 <
78 <        if (strstr(s, FMTSTR) == s)
76 >        if (isformat(s))
77                  return 0;
78  
79          fputs(s, stdout);
# Line 91 | Line 89 | create_index(const char *fname, int hdrflags, int ndxb
89          char    **idmap;
90          int     idmlen;
91          int     nextID = 0;
92 <        LUTAB   hashtab = LU_SINIT(free,NULL);
92 >        LUTAB   hashtab;
93          RESOLU  rs;
94          long    n;
95          int     ndx;
# Line 134 | Line 132 | create_index(const char *fname, int hdrflags, int ndxb
132                  fputs(": unsupported bits/pixel\n", stderr);
133                  return 0;
134          }
135 +        memset(&hashtab, 0, sizeof(hashtab));
136 +        hashtab.hashf = lu_shash;
137 +        hashtab.keycmp = strcmp;
138 +        hashtab.freek = free;
139          if (!idmap || !lu_init(&hashtab, idmlen))
140                  goto memerr;
141          fputc('\n', stdout);            /* end of info header */
# Line 210 | Line 212 | memerr:
212   }
213  
214  
215 < /* print out table IDs */
215 > /* print out ID table */
216   void
217   print_IDs(IDMAP *idmp)
218   {
# Line 218 | Line 220 | print_IDs(IDMAP *idmp)
220  
221          printf("============ %d IDs ============\n", idmp->nids);
222  
223 <        for (i = 0; i < idmp->nids; i++)
224 <                puts(mapID(idmp, i));
225 <
223 >        for (i = 0; i < idmp->nids; i++) {
224 >                fputs(mapID(idmp, i), stdout);
225 >                putchar(sepc);
226 >        }
227 >        if (sepc != '\n')
228 >                fputc('\n', stdout);
229          puts("============= END =============");
230   }
231  
# Line 230 | Line 235 | int
235   decode_select(const char *fname, int hdrflags)
236   {
237          IDMAP   *idmp = idmap_ropen(fname, hdrflags);
238 <        int     x, y;
238 >        int     i, j;
239  
240          if (!idmp)
241                  return 0;
# Line 244 | Line 249 | decode_select(const char *fname, int hdrflags)
249                  idmap_close(idmp);
250                  return 0;
251          }
252 <        while (scanf("%d %d", &x, &y) == 2) {
253 <                x = idmap_seek(idmp, x, idmp->res.yr-1 - y);
254 <                if (!x) {
252 >        while (scanf("%d %d", &i, &j) == 2) {
253 >                i = idmap_seek(idmp, i, idmp->res.yr-1 - j);
254 >                if (!i) {
255                          fputs(progname, stderr);
256                          fputs(": warning - pixel index is off map\n", stderr);
257                          continue;
258                  }
259 <                if (x > 0)
260 <                        x = idmap_next_i(idmp);
261 <                if (x < 0) {
259 >                if (i > 0)
260 >                        i = idmap_next_i(idmp);
261 >                if (i < 0) {
262                          fputs(fname, stderr);
263                          fputs(": read/seek error in decode_select()\n", stderr);
264                          idmap_close(idmp);
265                          return 0;
266                  }
267                  if (numeric) {
268 <                        printf("%d", x);
268 >                        printf("%d", i);
269                  } else {
270 <                        const char      *id = mapID(idmp, x);
270 >                        const char      *id = mapID(idmp, i);
271                          if (!id) {
272                                  fputs(fname, stderr);
273                                  fputs(": bad ID index in file\n", stderr);
# Line 304 | Line 309 | decode_all(const char *fname, int hdrflags)
309                  print_IDs(idmp);
310  
311          for (n = idmp->res.xr*idmp->res.yr; n-- > 0; ) {
312 <                int     ndx = idmap_next_i(idmp);
312 >                const int       ndx = idmap_next_i(idmp);
313                  if (ndx < 0) {
314                          fputs(fname, stderr);
315                          fputs(": unexpected EOF\n", stderr);
# Line 336 | Line 341 | main(int argc, char *argv[])
341          char    *inpfname = NULL;
342          int     reverse = 0;
343          int     bypixel = 0;
344 <        int     hdrflags = HF_HEADOUT|HF_RESOUT;
344 >        int     hdrflags = HF_HEADOUT|HF_RESOUT|HF_STDERR;
345          int     xres=0, yres=0;
346          int     ndxbytes = 2;
347          int     a;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines